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 always_except LU-9693 42a 42c
43 always_except LU-6493 42b
44 always_except LU-14541 277
45 always_except LU-9054 312
46 always_except LU-8411 407
49 always_except LU-14181 64e 64f
52 # skip the grant tests for ARM until they are fixed
53 if [[ $(uname -m) = aarch64 ]]; then
54 always_except LU-11671 45
55 always_except LU-14067 400a 400b
58 # skip nfs tests on kernels >= 4.12.0 until they are fixed
59 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
60 always_except LU-12661 817
62 # skip cgroup tests on RHEL8.1 kernels until they are fixed
63 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
64 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
65 always_except LU-13063 411
68 #skip ACL tests on RHEL8 and SLES15 until tests changed to use other users
69 if (( $(egrep -cw "^bin|^daemon" /etc/passwd) < 2 )); then
70 always_except LU-15259 103a 125 154a
74 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 60i 64b 68 71 115 135 136 230d 300o"
76 if [ "$mds1_FSTYPE" = "zfs" ]; then
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
81 if [ "$ost1_FSTYPE" = "zfs" ]; then
82 always_except LU-1941 130a 130b 130c 130d 130e 130f 130g
85 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
87 # Get the SLES distro version
89 # Returns a version string that should only be used in comparing
90 # strings returned by version_code()
93 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
95 # All SuSE Linux versions have one decimal. version_code expects two
96 local sles_version=$version.0
97 version_code $sles_version
100 # Check if we are running on Ubuntu or SLES so we can make decisions on
102 if [ -r /etc/SuSE-release ]; then
103 sles_version=$(sles_version_code)
104 [ $sles_version -lt $(version_code 11.4.0) ] &&
105 always_except LU-4341 170
107 [ $sles_version -lt $(version_code 12.0.0) ] &&
108 always_except LU-3703 234
109 elif [ -r /etc/os-release ]; then
110 if grep -qi ubuntu /etc/os-release; then
111 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
112 -e 's/^VERSION=//p' \
116 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
117 always_except LU-10334 103a
118 always_except LU-10366 410
128 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
129 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
138 check_swap_layouts_support()
140 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
141 skip "Does not support layout lock."
144 check_swap_layout_no_dom()
147 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
148 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
151 check_and_setup_lustre
155 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
157 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
158 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
159 rm -rf $DIR/[Rdfs][0-9]*
161 # $RUNAS_ID may get set incorrectly somewhere else
162 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
163 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
165 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
167 if [ "${ONLY}" = "MOUNT" ] ; then
168 echo "Lustre is up, please go on"
172 echo "preparing for tests involving mounts"
173 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
175 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
176 echo # add a newline after mke2fs.
180 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
181 lctl set_param debug=-1 2> /dev/null || true
184 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
186 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
188 run_test 0a "touch; rm ====================="
191 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
192 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
194 run_test 0b "chmod 0755 $DIR ============================="
197 $LCTL get_param mdc.*.import | grep "state: FULL" ||
198 error "import not FULL"
199 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
202 run_test 0c "check import proc"
204 test_0d() { # LU-3397
205 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
206 skip "proc exports not supported before 2.10.57"
208 local mgs_exp="mgs.MGS.exports"
209 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
211 local exp_client_version
214 local temp_imp=$DIR/$tfile.import
215 local temp_exp=$DIR/$tfile.export
217 # save mgc import file to $temp_imp
218 $LCTL get_param mgc.*.import | tee $temp_imp
219 # Check if client uuid is found in MGS export
220 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
221 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
225 # save mgs export file to $temp_exp
226 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
228 # Compare the value of field "connect_flags"
229 imp_val=$(grep "connect_flags" $temp_imp)
230 exp_val=$(grep "connect_flags" $temp_exp)
231 [ "$exp_val" == "$imp_val" ] ||
232 error "export flags '$exp_val' != import flags '$imp_val'"
234 # Compare client versions. Only compare top-3 fields for compatibility
235 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
236 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
237 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
238 [ "$exp_val" == "$imp_val" ] ||
239 error "exp version '$exp_client_version'($exp_val) != " \
240 "'$(lustre_build_version client)'($imp_val)"
242 run_test 0d "check export proc ============================="
244 test_0e() { # LU-13417
245 (( $MDSCOUNT > 1 )) ||
246 skip "We need at least 2 MDTs for this test"
248 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
249 skip "Need server version at least 2.14.51"
251 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
252 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
254 [ $default_lmv_count -eq 1 ] ||
255 error "$MOUNT default stripe count $default_lmv_count"
257 [ $default_lmv_index -eq -1 ] ||
258 error "$MOUNT default stripe index $default_lmv_index"
260 mkdir $MOUNT/$tdir.1 || error "mkdir $MOUNT/$tdir.1 failed"
261 mkdir $MOUNT/$tdir.2 || error "mkdir $MOUNT/$tdir.2 failed"
263 local mdt_index1=$($LFS getdirstripe -i $MOUNT/$tdir.1)
264 local mdt_index2=$($LFS getdirstripe -i $MOUNT/$tdir.2)
266 [ $mdt_index1 -eq $mdt_index2 ] &&
267 error "directories are on the same MDT $mdt_index1=$mdt_index2"
269 rmdir $MOUNT/$tdir.1 $MOUNT/$tdir.2
271 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
274 test_mkdir $DIR/$tdir
275 test_mkdir $DIR/$tdir/d2
276 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
277 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
280 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
282 run_test 1 "mkdir; remkdir; rmdir"
285 test_mkdir $DIR/$tdir
286 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
287 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
289 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
291 run_test 2 "mkdir; touch; rmdir; check file"
294 test_mkdir $DIR/$tdir
295 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
296 touch $DIR/$tdir/$tfile
297 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
299 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
301 run_test 3 "mkdir; touch; rmdir; check dir"
303 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
305 test_mkdir -i 1 $DIR/$tdir
307 touch $DIR/$tdir/$tfile ||
308 error "Create file under remote directory failed"
311 error "Expect error removing in-use dir $DIR/$tdir"
313 test -d $DIR/$tdir || error "Remote directory disappeared"
315 rm -rf $DIR/$tdir || error "remove remote dir error"
317 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
320 test_mkdir $DIR/$tdir
321 test_mkdir $DIR/$tdir/d2
322 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
323 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
324 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
326 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
329 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
330 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
331 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
332 error "$tfile does not have perm 0666 or UID $UID"
333 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
334 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
335 error "$tfile should be 0666 and owned by UID $UID"
337 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
340 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
343 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
344 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
345 error "$tfile should be owned by UID $RUNAS_ID"
346 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
347 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
348 error "$tfile should be owned by UID $RUNAS_ID"
350 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
353 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
356 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
357 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
358 error "$tfile should be owned by GID $UID"
359 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
360 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
361 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
363 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
366 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
368 test_mkdir $DIR/$tdir
369 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
370 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
371 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
372 test_mkdir $DIR/$tdir/d/subdir
373 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
374 error "$tdir/d/subdir should be GID $RUNAS_GID"
375 if [[ $MDSCOUNT -gt 1 ]]; then
376 # check remote dir sgid inherite
377 $LFS mkdir -i 0 $DIR/$tdir.local ||
378 error "mkdir $tdir.local failed"
379 chmod g+s $DIR/$tdir.local ||
380 error "chmod $tdir.local failed"
381 chgrp $RUNAS_GID $DIR/$tdir.local ||
382 error "chgrp $tdir.local failed"
383 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
384 error "mkdir $tdir.remote failed"
385 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
386 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
387 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
388 error "$tdir.remote should be mode 02755"
391 run_test 6g "verify new dir in sgid dir inherits group"
393 test_6h() { # bug 7331
394 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
396 touch $DIR/$tfile || error "touch failed"
397 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
398 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
399 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
400 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
401 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
403 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
406 test_mkdir $DIR/$tdir
407 $MCREATE $DIR/$tdir/$tfile
408 chmod 0666 $DIR/$tdir/$tfile
409 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
410 error "$tdir/$tfile should be mode 0666"
412 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
415 if [ ! -d $DIR/$tdir ]; then
416 test_mkdir $DIR/$tdir
418 $MCREATE $DIR/$tdir/$tfile
419 echo -n foo > $DIR/$tdir/$tfile
420 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
421 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
423 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
426 test_mkdir $DIR/$tdir
427 touch $DIR/$tdir/$tfile
428 chmod 0666 $DIR/$tdir/$tfile
429 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
430 error "$tfile mode not 0666"
432 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
435 test_mkdir $DIR/$tdir
436 test_mkdir $DIR/$tdir/d2
437 test_mkdir $DIR/$tdir/d2/d3
438 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
440 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
443 test_mkdir $DIR/$tdir
444 test_mkdir $DIR/$tdir/d2
445 touch $DIR/$tdir/d2/$tfile
446 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
447 error "$tdir/d2/$tfile not a file"
449 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
452 test_mkdir $DIR/$tdir
453 test_mkdir $DIR/$tdir/d2
454 chmod 0666 $DIR/$tdir/d2
455 chmod 0705 $DIR/$tdir/d2
456 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
457 error "$tdir/d2 mode not 0705"
459 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
462 test_mkdir $DIR/$tdir
463 touch $DIR/$tdir/$tfile
464 chmod 0666 $DIR/$tdir/$tfile
465 chmod 0654 $DIR/$tdir/$tfile
466 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
467 error "$tdir/d2 mode not 0654"
469 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
472 test_mkdir $DIR/$tdir
473 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
475 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
476 error "$tdir/$tfile size not 0 after truncate"
478 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
481 test_mkdir $DIR/$tdir
482 touch $DIR/$tdir/$tfile
484 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
486 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
489 test_mkdir $DIR/$tdir
490 touch $DIR/$tdir/$tfile
491 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
492 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
493 error "$tdir/${tfile_2} not a file after rename"
494 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
496 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
499 test_mkdir $DIR/$tdir
500 touch $DIR/$tdir/$tfile
501 rm -rf $DIR/$tdir/$tfile
502 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
504 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
507 test_mkdir $DIR/$tdir
508 touch $DIR/$tdir/$tfile
509 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
511 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
512 error "$tdir/l-exist not a symlink"
513 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
514 error "$tdir/l-exist not referencing a file"
515 rm -f $DIR/$tdir/l-exist
516 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
518 run_test 17a "symlinks: create, remove (real)"
521 test_mkdir $DIR/$tdir
522 ln -s no-such-file $DIR/$tdir/l-dangle
524 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
525 error "$tdir/l-dangle not referencing no-such-file"
526 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
527 error "$tdir/l-dangle not referencing non-existent file"
528 rm -f $DIR/$tdir/l-dangle
529 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
531 run_test 17b "symlinks: create, remove (dangling)"
533 test_17c() { # bug 3440 - don't save failed open RPC for replay
534 test_mkdir $DIR/$tdir
535 ln -s foo $DIR/$tdir/$tfile
536 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
538 run_test 17c "symlinks: open dangling (should return error)"
541 test_mkdir $DIR/$tdir
542 ln -s foo $DIR/$tdir/$tfile
543 touch $DIR/$tdir/$tfile || error "creating to new symlink"
545 run_test 17d "symlinks: create dangling"
548 test_mkdir $DIR/$tdir
549 local foo=$DIR/$tdir/$tfile
550 ln -s $foo $foo || error "create symlink failed"
551 ls -l $foo || error "ls -l failed"
552 ls $foo && error "ls not failed" || true
554 run_test 17e "symlinks: create recursive symlink (should return error)"
557 test_mkdir $DIR/$tdir
558 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
559 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
560 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
561 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
562 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
563 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
566 run_test 17f "symlinks: long and very long symlink name"
568 # str_repeat(S, N) generate a string that is string S repeated N times
573 while [ $((n -= 1)) -ge 0 ]; do
579 # Long symlinks and LU-2241
581 test_mkdir $DIR/$tdir
582 local TESTS="59 60 61 4094 4095"
584 # Fix for inode size boundary in 2.1.4
585 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
588 # Patch not applied to 2.2 or 2.3 branches
589 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
590 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
594 local SYMNAME=$(str_repeat 'x' $i)
595 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
596 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
599 run_test 17g "symlinks: really long symlink name and inode boundaries"
601 test_17h() { #bug 17378
602 [ $PARALLEL == "yes" ] && skip "skip parallel run"
603 remote_mds_nodsh && skip "remote MDS with nodsh"
607 test_mkdir $DIR/$tdir
608 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
609 $LFS setstripe -c -1 $DIR/$tdir
610 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
611 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
612 touch $DIR/$tdir/$tfile || true
614 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
616 test_17i() { #bug 20018
617 [ $PARALLEL == "yes" ] && skip "skip parallel run"
618 remote_mds_nodsh && skip "remote MDS with nodsh"
620 local foo=$DIR/$tdir/$tfile
623 test_mkdir -c1 $DIR/$tdir
624 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
625 ln -s $foo $foo || error "create symlink failed"
626 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
627 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
628 ls -l $foo && error "error not detected"
631 run_test 17i "don't panic on short symlink (should return error)"
633 test_17k() { #bug 22301
634 [ $PARALLEL == "yes" ] && skip "skip parallel run"
635 [[ -z "$(which rsync 2>/dev/null)" ]] &&
636 skip "no rsync command"
637 rsync --help | grep -q xattr ||
638 skip_env "$(rsync --version | head -n1) does not support xattrs"
639 test_mkdir $DIR/$tdir
640 test_mkdir $DIR/$tdir.new
641 touch $DIR/$tdir/$tfile
642 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
643 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
644 error "rsync failed with xattrs enabled"
646 run_test 17k "symlinks: rsync with xattrs enabled"
648 test_17l() { # LU-279
649 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
650 skip "no getfattr command"
652 test_mkdir $DIR/$tdir
653 touch $DIR/$tdir/$tfile
654 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
655 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
656 # -h to not follow symlinks. -m '' to list all the xattrs.
657 # grep to remove first line: '# file: $path'.
658 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
660 lgetxattr_size_check $path $xattr ||
661 error "lgetxattr_size_check $path $xattr failed"
665 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
670 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
671 remote_mds_nodsh && skip "remote MDS with nodsh"
672 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
673 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
674 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
676 local short_sym="0123456789"
677 local wdir=$DIR/$tdir
682 # create a long symlink file
683 for ((i = 0; i < 4; ++i)); do
684 long_sym=${long_sym}${long_sym}
687 echo "create 512 short and long symlink files under $wdir"
688 for ((i = 0; i < 256; ++i)); do
689 ln -sf ${long_sym}"a5a5" $wdir/long-$i
690 ln -sf ${short_sym}"a5a5" $wdir/short-$i
696 wait_delete_completed
698 echo "recreate the 512 symlink files with a shorter string"
699 for ((i = 0; i < 512; ++i)); do
700 # rewrite the symlink file with a shorter string
701 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
702 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
705 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
707 echo "stop and checking mds${mds_index}:"
708 # e2fsck should not return error
710 local devname=$(mdsdevname $mds_index)
711 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
714 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
715 error "start mds${mds_index} failed"
716 df $MOUNT > /dev/null 2>&1
718 error "e2fsck detected error for short/long symlink: rc=$rc"
721 run_test 17m "run e2fsck against MDT which contains short/long symlink"
723 check_fs_consistency_17n() {
727 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
728 # so it only check MDT1/MDT2 instead of all of MDTs.
729 for mdt_index in 1 2; do
730 # e2fsck should not return error
732 local devname=$(mdsdevname $mdt_index)
733 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
736 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
737 error "mount mds$mdt_index failed"
738 df $MOUNT > /dev/null 2>&1
744 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
745 [ $PARALLEL == "yes" ] && skip "skip parallel run"
746 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
747 remote_mds_nodsh && skip "remote MDS with nodsh"
748 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
749 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
750 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
754 test_mkdir $DIR/$tdir
755 for ((i=0; i<10; i++)); do
756 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
757 error "create remote dir error $i"
758 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
759 error "create files under remote dir failed $i"
762 check_fs_consistency_17n ||
763 error "e2fsck report error after create files under remote dir"
765 for ((i = 0; i < 10; i++)); do
766 rm -rf $DIR/$tdir/remote_dir_${i} ||
767 error "destroy remote dir error $i"
770 check_fs_consistency_17n ||
771 error "e2fsck report error after unlink files under remote dir"
773 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
774 skip "lustre < 2.4.50 does not support migrate mv"
776 for ((i = 0; i < 10; i++)); do
777 mkdir -p $DIR/$tdir/remote_dir_${i}
778 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
779 error "create files under remote dir failed $i"
780 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
781 error "migrate remote dir error $i"
783 check_fs_consistency_17n || error "e2fsck report error after migration"
785 for ((i = 0; i < 10; i++)); do
786 rm -rf $DIR/$tdir/remote_dir_${i} ||
787 error "destroy remote dir error $i"
790 check_fs_consistency_17n || error "e2fsck report error after unlink"
792 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
795 remote_mds_nodsh && skip "remote MDS with nodsh"
796 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
797 skip "Need MDS version at least 2.3.64"
799 local wdir=$DIR/${tdir}o
805 mdt_index=$($LFS getstripe -m $wdir/$tfile)
806 mdt_index=$((mdt_index + 1))
809 #fail mds will wait the failover finish then set
810 #following fail_loc to avoid interfer the recovery process.
813 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
814 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
815 ls -l $wdir/$tfile && rc=1
816 do_facet mds${mdt_index} lctl set_param fail_loc=0
817 [[ $rc -eq 0 ]] || error "stat file should fail"
819 run_test 17o "stat file with incompat LMA feature"
822 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
823 ls $DIR || error "Failed to ls $DIR: $?"
825 run_test 18 "touch .../f ; ls ... =============================="
831 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
833 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
836 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
838 run_test 19b "ls -l .../f19 (should return error) =============="
841 [ $RUNAS_ID -eq $UID ] &&
842 skip_env "RUNAS_ID = UID = $UID -- skipping"
844 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
846 run_test 19c "$RUNAS touch .../f19 (should return error) =="
849 cat $DIR/f19 && error || true
851 run_test 19d "cat .../f19 (should return error) =============="
860 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
862 run_test 20 "touch .../f ; ls -l ..."
865 test_mkdir $DIR/$tdir
866 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
867 ln -s dangle $DIR/$tdir/link
868 echo foo >> $DIR/$tdir/link
869 cat $DIR/$tdir/dangle
870 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
871 $CHECKSTAT -f -t file $DIR/$tdir/link ||
872 error "$tdir/link not linked to a file"
874 run_test 21 "write to dangling link"
877 local wdir=$DIR/$tdir
879 chown $RUNAS_ID:$RUNAS_GID $wdir
880 (cd $wdir || error "cd $wdir failed";
881 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
883 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
884 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
885 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
886 error "checkstat -u failed"
888 run_test 22 "unpack tar archive as non-root user"
892 test_mkdir $DIR/$tdir
893 local file=$DIR/$tdir/$tfile
895 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
896 openfile -f O_CREAT:O_EXCL $file &&
897 error "$file recreate succeeded" || true
899 run_test 23a "O_CREAT|O_EXCL in subdir"
901 test_23b() { # bug 18988
902 test_mkdir $DIR/$tdir
903 local file=$DIR/$tdir/$tfile
906 echo foo > $file || error "write filed"
907 echo bar >> $file || error "append filed"
908 $CHECKSTAT -s 8 $file || error "wrong size"
911 run_test 23b "O_APPEND check"
913 # LU-9409, size with O_APPEND and tiny writes
915 local file=$DIR/$tfile
918 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
919 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
923 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
924 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
926 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
929 #racing tiny & normal writes
930 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
931 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
933 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
936 #racing tiny & normal writes 2, ugly numbers
937 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
938 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
940 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
943 run_test 23c "O_APPEND size checks for tiny writes"
945 # LU-11069 file offset is correct after appending writes
947 local file=$DIR/$tfile
950 echo CentaurHauls > $file
951 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
952 if ((offset != 26)); then
953 error "wrong offset, expected 26, got '$offset'"
956 run_test 23d "file offset is correct after appending writes"
960 echo '-- same directory rename'
961 test_mkdir $DIR/$tdir
962 touch $DIR/$tdir/$tfile.1
963 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
964 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
966 run_test 24a "rename file to non-existent target"
969 test_mkdir $DIR/$tdir
970 touch $DIR/$tdir/$tfile.{1,2}
971 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
972 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
973 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
975 run_test 24b "rename file to existing target"
978 test_mkdir $DIR/$tdir
979 test_mkdir $DIR/$tdir/d$testnum.1
980 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
981 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
982 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
984 run_test 24c "rename directory to non-existent target"
987 test_mkdir -c1 $DIR/$tdir
988 test_mkdir -c1 $DIR/$tdir/d$testnum.1
989 test_mkdir -c1 $DIR/$tdir/d$testnum.2
990 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
991 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
992 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
994 run_test 24d "rename directory to existing target"
997 echo '-- cross directory renames --'
1001 mv $DIR/R5a/f $DIR/R5b/g
1002 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
1003 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
1005 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
1010 touch $DIR/R6a/f $DIR/R6b/g
1011 mv $DIR/R6a/f $DIR/R6b/g
1012 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
1013 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
1015 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1020 test_mkdir $DIR/R7a/d
1021 mv $DIR/R7a/d $DIR/R7b/e
1022 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1023 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1025 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1028 test_mkdir -c1 $DIR/R8a
1029 test_mkdir -c1 $DIR/R8b
1030 test_mkdir -c1 $DIR/R8a/d
1031 test_mkdir -c1 $DIR/R8b/e
1032 mrename $DIR/R8a/d $DIR/R8b/e
1033 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1034 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1036 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1039 echo "-- rename error cases"
1041 test_mkdir $DIR/R9/a
1043 mrename $DIR/R9/f $DIR/R9/a
1044 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1045 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1046 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1048 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1052 mrename $DIR/R10/f $DIR/R10/g
1053 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1054 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1055 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1057 run_test 24j "source does not exist ============================"
1060 test_mkdir $DIR/R11a
1061 test_mkdir $DIR/R11a/d
1063 mv $DIR/R11a/f $DIR/R11a/d
1064 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1065 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1067 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1069 # bug 2429 - rename foo foo foo creates invalid file
1072 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1074 run_test 24l "Renaming a file to itself ========================"
1078 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1079 # on ext3 this does not remove either the source or target files
1080 # though the "expected" operation would be to remove the source
1081 $CHECKSTAT -t file ${f} || error "${f} missing"
1082 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1084 run_test 24m "Renaming a file to a hard link to itself ========="
1088 # this stats the old file after it was renamed, so it should fail
1090 $CHECKSTAT ${f} || error "${f} missing"
1092 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1093 $CHECKSTAT -a ${f} || error "${f} exists"
1095 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1098 test_mkdir $DIR/$tdir
1099 rename_many -s random -v -n 10 $DIR/$tdir
1101 run_test 24o "rename of files during htree split"
1104 test_mkdir $DIR/R12a
1105 test_mkdir $DIR/R12b
1106 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1107 mrename $DIR/R12a $DIR/R12b
1108 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1109 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1110 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1111 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1113 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1115 cleanup_multiop_pause() {
1117 kill -USR1 $MULTIPID
1121 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1123 test_mkdir $DIR/R13a
1124 test_mkdir $DIR/R13b
1125 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1126 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1129 trap cleanup_multiop_pause EXIT
1130 mrename $DIR/R13a $DIR/R13b
1131 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1132 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1133 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1134 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1135 cleanup_multiop_pause
1136 wait $MULTIPID || error "multiop close failed"
1138 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1140 test_24r() { #bug 3789
1141 test_mkdir $DIR/R14a
1142 test_mkdir $DIR/R14a/b
1143 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1144 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1145 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1147 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1150 test_mkdir $DIR/R15a
1151 test_mkdir $DIR/R15a/b
1152 test_mkdir $DIR/R15a/b/c
1153 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1154 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1155 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1157 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1159 test_mkdir $DIR/R16a
1160 test_mkdir $DIR/R16a/b
1161 test_mkdir $DIR/R16a/b/c
1162 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1163 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1164 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1166 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1168 test_24u() { # bug12192
1169 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1170 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1172 run_test 24u "create stripe file"
1174 simple_cleanup_common() {
1178 [[ -z "$DIR" || -z "$tdir" || ! -d "$DIR/$tdir" ]] && return 0
1180 local start=$SECONDS
1182 [[ -n "$createmany" ]] && unlinkmany $DIR/$tdir/$tfile $createmany
1183 rm -rf $DIR/$tdir || error "cleanup $DIR/$tdir failed"
1185 wait_delete_completed
1186 echo "cleanup time $((SECONDS - start))"
1190 max_pages_per_rpc() {
1191 local mdtname="$(printf "MDT%04x" ${1:-0})"
1192 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1196 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1198 local nrfiles=${COUNT:-100000}
1199 local fname="$DIR/$tdir/$tfile"
1201 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1202 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1204 test_mkdir "$(dirname $fname)"
1205 # assume MDT0000 has the fewest inodes
1206 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1207 local free_inodes=$(($(mdt_free_inodes 0) * ${stripes/#0/1}))
1208 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1210 stack_trap "simple_cleanup_common $nrfiles"
1212 createmany -m "$fname" $nrfiles
1214 cancel_lru_locks mdc
1215 lctl set_param mdc.*.stats clear
1217 # was previously test_24D: LU-6101
1218 # readdir() returns correct number of entries after cursor reload
1219 local num_ls=$(ls $DIR/$tdir | wc -l)
1220 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1221 local num_all=$(ls -a $DIR/$tdir | wc -l)
1222 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1223 [ $num_all -ne $((nrfiles + 2)) ]; then
1224 error "Expected $nrfiles files, got $num_ls " \
1225 "($num_uniq unique $num_all .&..)"
1227 # LU-5 large readdir
1228 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1229 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1230 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1231 # take into account of overhead in lu_dirpage header and end mark in
1232 # each page, plus one in rpc_num calculation.
1233 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1234 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1235 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1236 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1237 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1238 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1239 echo "readpages: $mds_readpage rpc_max: $rpc_max-2/+1"
1240 (( $mds_readpage >= $rpc_max - 2 && $mds_readpage <= $rpc_max + 1)) ||
1241 error "large readdir doesn't take effect: " \
1242 "$mds_readpage should be about $rpc_max"
1244 run_test 24v "list large directory (test hash collision, b=17560)"
1246 test_24w() { # bug21506
1248 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1249 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1250 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1251 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1252 [[ "$SZ1" -eq "$SZ2" ]] ||
1253 error "Error reading at the end of the file $tfile"
1255 run_test 24w "Reading a file larger than 4Gb"
1258 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1259 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1260 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1261 skip "Need MDS version at least 2.7.56"
1264 local remote_dir=$DIR/$tdir/remote_dir
1266 test_mkdir $DIR/$tdir
1267 $LFS mkdir -i $MDTIDX $remote_dir ||
1268 error "create remote directory failed"
1270 test_mkdir $DIR/$tdir/src_dir
1271 touch $DIR/$tdir/src_file
1272 test_mkdir $remote_dir/tgt_dir
1273 touch $remote_dir/tgt_file
1275 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1276 error "rename dir cross MDT failed!"
1278 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1279 error "rename file cross MDT failed!"
1281 touch $DIR/$tdir/ln_file
1282 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1283 error "ln file cross MDT failed"
1285 rm -rf $DIR/$tdir || error "Can not delete directories"
1287 run_test 24x "cross MDT rename/link"
1290 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1291 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1293 local remote_dir=$DIR/$tdir/remote_dir
1296 test_mkdir $DIR/$tdir
1297 $LFS mkdir -i $mdtidx $remote_dir ||
1298 error "create remote directory failed"
1300 test_mkdir $remote_dir/src_dir
1301 touch $remote_dir/src_file
1302 test_mkdir $remote_dir/tgt_dir
1303 touch $remote_dir/tgt_file
1305 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1306 error "rename subdir in the same remote dir failed!"
1308 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1309 error "rename files in the same remote dir failed!"
1311 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1312 error "link files in the same remote dir failed!"
1314 rm -rf $DIR/$tdir || error "Can not delete directories"
1316 run_test 24y "rename/link on the same dir should succeed"
1319 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1320 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1321 skip "Need MDS version at least 2.12.51"
1325 for index in 0 1; do
1326 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1327 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1330 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1332 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1333 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1335 local mdts=$(comma_list $(mdts_nodes))
1337 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1338 stack_trap "do_nodes $mdts $LCTL \
1339 set_param mdt.*.enable_remote_rename=1" EXIT
1341 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1343 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1344 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1346 run_test 24z "cross-MDT rename is done as cp"
1348 test_24A() { # LU-3182
1351 test_mkdir $DIR/$tdir
1352 stack_trap "simple_cleanup_common $NFILES"
1353 createmany -m $DIR/$tdir/$tfile $NFILES
1354 local t=$(ls $DIR/$tdir | wc -l)
1355 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1356 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1358 (( $t == $NFILES && $u == $NFILES && $v == NFILES + 2 )) ||
1359 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1361 run_test 24A "readdir() returns correct number of entries."
1363 test_24B() { # LU-4805
1364 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1368 test_mkdir $DIR/$tdir
1369 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1370 error "create striped dir failed"
1372 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1373 [ $count -eq 2 ] || error "Expected 2, got $count"
1375 touch $DIR/$tdir/striped_dir/a
1377 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1378 [ $count -eq 3 ] || error "Expected 3, got $count"
1380 touch $DIR/$tdir/striped_dir/.f
1382 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1383 [ $count -eq 4 ] || error "Expected 4, got $count"
1385 rm -rf $DIR/$tdir || error "Can not delete directories"
1387 run_test 24B "readdir for striped dir return correct number of entries"
1390 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1396 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1397 error "create striped dir failed"
1399 cd $DIR/$tdir/d0/striped_dir
1401 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1402 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1403 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1405 [ "$d0_ino" = "$parent_ino" ] ||
1406 error ".. wrong, expect $d0_ino, get $parent_ino"
1408 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1409 error "mv striped dir failed"
1411 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1413 [ "$d1_ino" = "$parent_ino" ] ||
1414 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1416 run_test 24C "check .. in striped dir"
1419 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1420 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1423 mkdir $DIR/$tdir/src_dir
1424 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1425 error "create remote source failed"
1427 touch $DIR/$tdir/src_dir/src_child/a
1429 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1430 error "create remote target dir failed"
1432 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1433 error "create remote target child failed"
1435 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1436 error "rename dir cross MDT failed!"
1440 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1441 error "src_child still exists after rename"
1443 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1444 error "missing file(a) after rename"
1446 rm -rf $DIR/$tdir || error "Can not delete directories"
1448 run_test 24E "cross MDT rename/link"
1451 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1454 [ "$SLOW" = "no" ] && repeats=100
1458 echo "$repeats repeats"
1459 for ((i = 0; i < repeats; i++)); do
1460 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1461 touch $DIR/$tdir/test/a || error "touch fails"
1462 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1463 rm -rf $DIR/$tdir/test || error "rmdir fails"
1468 run_test 24F "hash order vs readdir (LU-11330)"
1471 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1476 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1477 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1478 touch $DIR/$tdir-0/f1 || error "touch f1"
1479 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1480 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1481 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1482 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1483 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1485 run_test 24G "migrate symlink in rename"
1488 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1489 [[ $(hostname) != $(facet_active_host mds2) ]] ||
1490 skip "MDT1 should be on another node"
1492 test_mkdir -i 1 -c 1 $DIR/$tdir
1493 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
1494 do_facet mds2 $LCTL set_param fail_loc=0x80001103
1495 touch $DIR/$tdir/$tfile || error "touch failed"
1497 run_test 24H "repeat FLD_QUERY rpc"
1500 echo '== symlink sanity ============================================='
1504 touch $DIR/s25/foo ||
1505 error "File creation in symlinked directory failed"
1507 run_test 25a "create file in symlinked directory ==============="
1510 [ ! -d $DIR/d25 ] && test_25a
1511 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1513 run_test 25b "lookup file in symlinked directory ==============="
1517 test_mkdir $DIR/d26/d26-2
1518 ln -s d26/d26-2 $DIR/s26
1519 touch $DIR/s26/foo || error "File creation failed"
1521 run_test 26a "multiple component symlink ======================="
1524 test_mkdir -p $DIR/$tdir/d26-2
1525 ln -s $tdir/d26-2/foo $DIR/s26-2
1526 touch $DIR/s26-2 || error "File creation failed"
1528 run_test 26b "multiple component symlink at end of lookup ======"
1531 test_mkdir $DIR/d26.2
1532 touch $DIR/d26.2/foo
1533 ln -s d26.2 $DIR/s26.2-1
1534 ln -s s26.2-1 $DIR/s26.2-2
1535 ln -s s26.2-2 $DIR/s26.2-3
1536 chmod 0666 $DIR/s26.2-3/foo
1538 run_test 26c "chain of symlinks"
1540 # recursive symlinks (bug 439)
1542 ln -s d26-3/foo $DIR/d26-3
1544 run_test 26d "create multiple component recursive symlink"
1547 [ ! -h $DIR/d26-3 ] && test_26d
1550 run_test 26e "unlink multiple component recursive symlink"
1552 # recursive symlinks (bug 7022)
1554 test_mkdir $DIR/$tdir
1555 test_mkdir $DIR/$tdir/$tfile
1556 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1557 test_mkdir -p lndir/bar1
1558 test_mkdir $DIR/$tdir/$tfile/$tfile
1559 cd $tfile || error "cd $tfile failed"
1560 ln -s .. dotdot || error "ln dotdot failed"
1561 ln -s dotdot/lndir lndir || error "ln lndir failed"
1562 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1563 output=`ls $tfile/$tfile/lndir/bar1`
1564 [ "$output" = bar1 ] && error "unexpected output"
1565 rm -r $tfile || error "rm $tfile failed"
1566 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1568 run_test 26f "rm -r of a directory which has recursive symlink"
1571 test_mkdir $DIR/$tdir
1572 $LFS getstripe $DIR/$tdir
1573 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1574 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1575 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1577 run_test 27a "one stripe file"
1580 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1582 test_mkdir $DIR/$tdir
1583 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1584 $LFS getstripe -c $DIR/$tdir/$tfile
1585 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1586 error "two-stripe file doesn't have two stripes"
1588 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1590 run_test 27b "create and write to two stripe file"
1592 # 27c family tests specific striping, setstripe -o
1594 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1595 test_mkdir -p $DIR/$tdir
1598 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1599 $LFS getstripe -i $DIR/$tdir/$tfile
1600 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1601 error "stripe not on specified OST"
1603 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1605 run_test 27ca "one stripe on specified OST"
1608 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1609 test_mkdir -p $DIR/$tdir
1611 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1612 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1615 # Strip getstripe output to a space separated list of OSTs
1616 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1617 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1618 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1619 error "stripes not on specified OSTs"
1621 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1623 run_test 27cb "two stripes on specified OSTs"
1626 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1627 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1628 skip "server does not support overstriping"
1630 test_mkdir -p $DIR/$tdir
1632 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1633 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1636 # Strip getstripe output to a space separated list of OSTs
1637 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1638 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1639 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1640 error "stripes not on specified OSTs"
1642 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1644 run_test 27cc "two stripes on the same OST"
1647 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1648 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1649 skip "server does not support overstriping"
1650 test_mkdir -p $DIR/$tdir
1651 local osts="0,1,1,0"
1652 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1653 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1656 # Strip getstripe output to a space separated list of OSTs
1657 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1658 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1659 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1660 error "stripes not on specified OSTs"
1662 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1664 run_test 27cd "four stripes on two OSTs"
1667 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1668 skip_env "too many osts, skipping"
1669 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1670 skip "server does not support overstriping"
1671 # We do one more stripe than we have OSTs
1672 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1673 skip_env "ea_inode feature disabled"
1675 test_mkdir -p $DIR/$tdir
1677 for i in $(seq 0 $OSTCOUNT);
1680 if [ $i -ne $OSTCOUNT ]; then
1684 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1685 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1688 # Strip getstripe output to a space separated list of OSTs
1689 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1690 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1691 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1692 error "stripes not on specified OSTs"
1694 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1696 run_test 27ce "more stripes than OSTs with -o"
1699 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1702 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1703 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1704 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1705 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1706 error "failed to set $osp_proc=0"
1708 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1711 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1712 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1713 error "failed to set $osp_proc=1"
1716 error "should return error due to $osp_proc=0"
1718 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1721 test_mkdir $DIR/$tdir
1722 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1723 error "setstripe failed"
1724 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1725 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1727 run_test 27d "create file with default settings"
1730 # LU-5839 adds check for existed layout before setting it
1731 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1732 skip "Need MDS version at least 2.7.56"
1734 test_mkdir $DIR/$tdir
1735 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1736 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1737 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1739 run_test 27e "setstripe existing file (should return error)"
1742 test_mkdir $DIR/$tdir
1743 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1744 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1745 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1746 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1747 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1748 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1750 run_test 27f "setstripe with bad stripe size (should return error)"
1753 test_mkdir $DIR/$tdir
1754 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1755 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1756 error "$DIR/$tdir/$tfile has object"
1758 run_test 27g "$LFS getstripe with no objects"
1761 test_mkdir $DIR/$tdir
1762 touch $DIR/$tdir/$tfile || error "touch failed"
1763 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1764 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1766 (( rc == 2 )) || error "getstripe did not return ENOENT"
1768 run_test 27ga "$LFS getstripe with missing file (should return error)"
1771 test_mkdir $DIR/$tdir
1772 touch $DIR/$tdir/$tfile || error "touch failed"
1773 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1774 error "missing objects"
1776 run_test 27i "$LFS getstripe with some objects"
1779 test_mkdir $DIR/$tdir
1780 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1781 error "setstripe failed" || true
1783 run_test 27j "setstripe with bad stripe offset (should return error)"
1785 test_27k() { # bug 2844
1786 test_mkdir $DIR/$tdir
1787 local file=$DIR/$tdir/$tfile
1788 local ll_max_blksize=$((4 * 1024 * 1024))
1789 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1790 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1791 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1792 dd if=/dev/zero of=$file bs=4k count=1
1793 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1794 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1796 run_test 27k "limit i_blksize for broken user apps"
1799 mcreate $DIR/$tfile || error "creating file"
1800 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1801 error "setstripe should have failed" || true
1803 run_test 27l "check setstripe permissions (should return error)"
1806 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1808 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1809 skip_env "multiple clients -- skipping"
1811 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1813 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1814 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1816 stack_trap simple_cleanup_common
1817 test_mkdir $DIR/$tdir
1818 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1819 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1820 error "dd should fill OST0"
1822 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1824 [ $i -gt 256 ] && break
1827 touch $DIR/$tdir/$tfile.$i
1828 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1829 awk '{print $1}'| grep -w "0") ] &&
1830 error "OST0 was full but new created file still use it"
1832 touch $DIR/$tdir/$tfile.$i
1833 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1834 awk '{print $1}'| grep -w "0") ] &&
1835 error "OST0 was full but new created file still use it" || true
1837 run_test 27m "create file while OST0 was full"
1839 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1840 # if the OST isn't full anymore.
1842 local ostidx=${1:-""}
1847 local list=$(comma_list $(osts_nodes))
1848 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1850 do_nodes $list lctl set_param fail_loc=0
1851 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1852 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1853 awk '{print $1 * 2;exit;}')
1854 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1856 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1860 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1862 remote_mds_nodsh && skip "remote MDS with nodsh"
1863 remote_ost_nodsh && skip "remote OST with nodsh"
1866 rm -f $DIR/$tdir/$tfile
1867 exhaust_precreations 0 0x80000215
1868 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1869 touch $DIR/$tdir/$tfile || error "touch failed"
1870 $LFS getstripe $DIR/$tdir/$tfile
1873 run_test 27n "create file with some full OSTs"
1876 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1878 remote_mds_nodsh && skip "remote MDS with nodsh"
1879 remote_ost_nodsh && skip "remote OST with nodsh"
1882 rm -f $DIR/$tdir/$tfile
1883 exhaust_all_precreations 0x215
1885 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1890 run_test 27o "create file with all full OSTs (should error)"
1892 function create_and_checktime() {
1897 for ((i=0; i < $loops; i++)); do
1898 local start=$SECONDS
1899 multiop $fname-$i Oc
1900 ((SECONDS-start < TIMEOUT)) ||
1901 error "creation took " $((SECONDS-$start)) && return 1
1906 local mdts=$(comma_list $(mdts_nodes))
1908 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1909 skip "Need MDS version at least 2.13.57"
1911 local f0=$DIR/${tfile}-0
1912 local f1=$DIR/${tfile}-1
1914 wait_delete_completed
1916 # refill precreated objects
1917 $LFS setstripe -i0 -c1 $f0
1919 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1920 # force QoS allocation policy
1921 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1922 stack_trap "do_nodes $mdts $LCTL set_param \
1923 lov.*.qos_threshold_rr=$saved" EXIT
1926 # one OST is unavailable, but still have few objects preallocated
1928 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1929 rm -rf $f1 $DIR/$tdir*" EXIT
1931 for ((i=0; i < 7; i++)); do
1932 mkdir $DIR/$tdir$i || error "can't create dir"
1933 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1934 error "can't set striping"
1936 for ((i=0; i < 7; i++)); do
1937 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1941 run_test 27oo "don't let few threads to reserve too many objects"
1944 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1946 remote_mds_nodsh && skip "remote MDS with nodsh"
1947 remote_ost_nodsh && skip "remote OST with nodsh"
1950 rm -f $DIR/$tdir/$tfile
1951 test_mkdir $DIR/$tdir
1953 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1954 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1955 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1957 exhaust_precreations 0 0x80000215
1958 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1959 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1960 $LFS getstripe $DIR/$tdir/$tfile
1964 run_test 27p "append to a truncated file with some full OSTs"
1967 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1968 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1969 remote_mds_nodsh && skip "remote MDS with nodsh"
1970 remote_ost_nodsh && skip "remote OST with nodsh"
1973 rm -f $DIR/$tdir/$tfile
1975 mkdir_on_mdt0 $DIR/$tdir
1976 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1977 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1978 error "truncate $DIR/$tdir/$tfile failed"
1979 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1981 exhaust_all_precreations 0x215
1983 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1984 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1988 run_test 27q "append to truncated file with all OSTs full (should error)"
1991 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1992 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1993 remote_mds_nodsh && skip "remote MDS with nodsh"
1994 remote_ost_nodsh && skip "remote OST with nodsh"
1997 rm -f $DIR/$tdir/$tfile
1998 exhaust_precreations 0 0x80000215
2000 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2004 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2006 test_27s() { # bug 10725
2007 test_mkdir $DIR/$tdir
2008 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2009 local stripe_count=0
2010 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2011 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2012 error "stripe width >= 2^32 succeeded" || true
2015 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2017 test_27t() { # bug 10864
2022 $WLFS getstripe $tfile
2025 run_test 27t "check that utils parse path correctly"
2027 test_27u() { # bug 4900
2028 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2029 remote_mds_nodsh && skip "remote MDS with nodsh"
2032 local list=$(comma_list $(mdts_nodes))
2034 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2035 do_nodes $list $LCTL set_param fail_loc=0x139
2036 test_mkdir -p $DIR/$tdir
2037 stack_trap "simple_cleanup_common 1000"
2038 createmany -o $DIR/$tdir/$tfile 1000
2039 do_nodes $list $LCTL set_param fail_loc=0
2041 TLOG=$TMP/$tfile.getstripe
2042 $LFS getstripe $DIR/$tdir > $TLOG
2043 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2044 [[ $OBJS -gt 0 ]] &&
2045 error "$OBJS objects created on OST-0. See $TLOG" ||
2048 run_test 27u "skip object creation on OSC w/o objects"
2050 test_27v() { # bug 4900
2051 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2053 remote_mds_nodsh && skip "remote MDS with nodsh"
2054 remote_ost_nodsh && skip "remote OST with nodsh"
2056 exhaust_all_precreations 0x215
2059 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2061 touch $DIR/$tdir/$tfile
2062 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2064 for (( i=1; i < OSTCOUNT; i++ )); do
2065 do_facet ost$i lctl set_param fail_loc=0x705
2067 local START=`date +%s`
2068 createmany -o $DIR/$tdir/$tfile 32
2070 local FINISH=`date +%s`
2071 local TIMEOUT=`lctl get_param -n timeout`
2072 local PROCESS=$((FINISH - START))
2073 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2074 error "$FINISH - $START >= $TIMEOUT / 2"
2075 sleep $((TIMEOUT / 2 - PROCESS))
2078 run_test 27v "skip object creation on slow OST"
2080 test_27w() { # bug 10997
2081 test_mkdir $DIR/$tdir
2082 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2083 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2084 error "stripe size $size != 65536" || true
2085 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2086 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2088 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2091 [[ $OSTCOUNT -lt 2 ]] &&
2092 skip_env "skipping multiple stripe count/offset test"
2094 test_mkdir $DIR/$tdir
2095 for i in $(seq 1 $OSTCOUNT); do
2097 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2098 error "setstripe -c $i -i $offset failed"
2099 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2100 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2101 [ $count -ne $i ] && error "stripe count $count != $i" || true
2102 [ $index -ne $offset ] &&
2103 error "stripe offset $index != $offset" || true
2106 run_test 27wa "check $LFS setstripe -c -i options"
2109 remote_ost_nodsh && skip "remote OST with nodsh"
2110 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2113 OFFSET=$(($OSTCOUNT - 1))
2115 local OST=$(ostname_from_index $OSTIDX)
2117 test_mkdir $DIR/$tdir
2118 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2119 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2121 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2122 for i in $(seq 0 $OFFSET); do
2123 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2124 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2125 error "OST0 was degraded but new created file still use it"
2127 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2129 run_test 27x "create files while OST0 is degraded"
2132 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2133 remote_mds_nodsh && skip "remote MDS with nodsh"
2134 remote_ost_nodsh && skip "remote OST with nodsh"
2135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2137 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2138 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2139 osp.$mdtosc.prealloc_last_id)
2140 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2141 osp.$mdtosc.prealloc_next_id)
2142 local fcount=$((last_id - next_id))
2143 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2144 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2146 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2147 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2148 local OST_DEACTIVE_IDX=-1
2153 for OSC in $MDS_OSCS; do
2154 OST=$(osc_to_ost $OSC)
2155 OSTIDX=$(index_from_ostuuid $OST)
2156 if [ $OST_DEACTIVE_IDX == -1 ]; then
2157 OST_DEACTIVE_IDX=$OSTIDX
2159 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2160 echo $OSC "is Deactivated:"
2161 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2165 OSTIDX=$(index_from_ostuuid $OST)
2166 test_mkdir $DIR/$tdir
2167 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2169 for OSC in $MDS_OSCS; do
2170 OST=$(osc_to_ost $OSC)
2171 OSTIDX=$(index_from_ostuuid $OST)
2172 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2173 echo $OST "is degraded:"
2174 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2175 obdfilter.$OST.degraded=1
2180 createmany -o $DIR/$tdir/$tfile $fcount
2182 for OSC in $MDS_OSCS; do
2183 OST=$(osc_to_ost $OSC)
2184 OSTIDX=$(index_from_ostuuid $OST)
2185 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2186 echo $OST "is recovered from degraded:"
2187 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2188 obdfilter.$OST.degraded=0
2190 do_facet $SINGLEMDS lctl --device %$OSC activate
2194 # all osp devices get activated, hence -1 stripe count restored
2195 local stripe_count=0
2197 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2198 # devices get activated.
2200 $LFS setstripe -c -1 $DIR/$tfile
2201 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2203 [ $stripe_count -ne $OSTCOUNT ] &&
2204 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2207 run_test 27y "create files while OST0 is degraded and the rest inactive"
2213 lmm_count=$($LFS getstripe -c $1)
2214 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2215 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2217 local old_ifs="$IFS"
2219 fid=($($LFS path2fid $1))
2222 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2223 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2225 # compare lmm_seq and lu_fid->f_seq
2226 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2227 # compare lmm_object_id and lu_fid->oid
2228 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2230 # check the trusted.fid attribute of the OST objects of the file
2231 local have_obdidx=false
2233 $LFS getstripe $1 | while read obdidx oid hex seq; do
2234 # skip lines up to and including "obdidx"
2235 [ -z "$obdidx" ] && break
2236 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2237 $have_obdidx || continue
2239 local ost=$((obdidx + 1))
2240 local dev=$(ostdevname $ost)
2243 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2245 seq=$(echo $seq | sed -e "s/^0x//g")
2246 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2247 oid_hex=$(echo $oid)
2249 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2251 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2255 # Don't unmount/remount the OSTs if we don't need to do that.
2256 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2257 # update too, until that use mount/ll_decode_filter_fid/mount.
2258 # Re-enable when debugfs will understand new filter_fid.
2260 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2261 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2262 $dev 2>/dev/null" | grep "parent=")
2264 if [ -z "$ff" ]; then
2266 mount_fstype ost$ost
2267 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2268 $(facet_mntpt ost$ost)/$obj_file)
2269 unmount_fstype ost$ost
2270 start ost$ost $dev $OST_MOUNT_OPTS
2274 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2276 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2278 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2279 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2281 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2282 # stripe_size=1048576 component_id=1 component_start=0 \
2283 # component_end=33554432
2284 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2285 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2286 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2288 if grep -q 'stripe=' <<<$ff; then
2289 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2291 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2292 # into f_ver in this case. See comment on ff_parent.
2293 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2296 # compare lmm_seq and filter_fid->ff_parent.f_seq
2297 [ $ff_pseq = $lmm_seq ] ||
2298 error "FF parent SEQ $ff_pseq != $lmm_seq"
2299 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2300 [ $ff_poid = $lmm_oid ] ||
2301 error "FF parent OID $ff_poid != $lmm_oid"
2302 (($ff_pstripe == $stripe_nr)) ||
2303 error "FF stripe $ff_pstripe != $stripe_nr"
2305 stripe_nr=$((stripe_nr + 1))
2306 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2308 if grep -q 'stripe_count=' <<<$ff; then
2309 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2310 -e 's/ .*//' <<<$ff)
2311 [ $lmm_count = $ff_scnt ] ||
2312 error "FF stripe count $lmm_count != $ff_scnt"
2318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2319 remote_ost_nodsh && skip "remote OST with nodsh"
2321 test_mkdir $DIR/$tdir
2322 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2323 { error "setstripe -c -1 failed"; return 1; }
2324 # We need to send a write to every object to get parent FID info set.
2325 # This _should_ also work for setattr, but does not currently.
2326 # touch $DIR/$tdir/$tfile-1 ||
2327 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2328 { error "dd $tfile-1 failed"; return 2; }
2329 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2330 { error "setstripe -c -1 failed"; return 3; }
2331 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2332 { error "dd $tfile-2 failed"; return 4; }
2334 # make sure write RPCs have been sent to OSTs
2337 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2338 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2340 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2342 test_27A() { # b=19102
2343 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2345 save_layout_restore_at_exit $MOUNT
2346 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2347 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2348 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2349 local default_size=$($LFS getstripe -S $MOUNT)
2350 local default_offset=$($LFS getstripe -i $MOUNT)
2351 local dsize=$(do_facet $SINGLEMDS \
2352 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2353 [ $default_size -eq $dsize ] ||
2354 error "stripe size $default_size != $dsize"
2355 [ $default_offset -eq -1 ] ||
2356 error "stripe offset $default_offset != -1"
2358 run_test 27A "check filesystem-wide default LOV EA values"
2360 test_27B() { # LU-2523
2361 test_mkdir $DIR/$tdir
2362 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2364 # open f1 with O_LOV_DELAY_CREATE
2366 # call setstripe ioctl on open file descriptor for f1
2368 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2372 # open f1 with O_LOV_DELAY_CREATE
2374 # call setstripe ioctl on open file descriptor for f1
2376 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2378 # Allow multiop to fail in imitation of NFS's busted semantics.
2381 run_test 27B "call setstripe on open unlinked file/rename victim"
2383 # 27C family tests full striping and overstriping
2384 test_27Ca() { #LU-2871
2385 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2393 test_mkdir $DIR/$tdir
2395 for i in $(seq 0 $((OSTCOUNT - 1))); do
2396 # set stripe across all OSTs starting from OST$i
2397 $LFS setstripe -i $i -c -1 $tfile$i
2398 # get striping information
2399 ost_idx=($($LFS getstripe $tfile$i |
2400 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2401 echo "OST Index: ${ost_idx[*]}"
2404 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2405 error "${#ost_idx[@]} != $OSTCOUNT"
2407 for index in $(seq 0 $((OSTCOUNT - 1))); do
2409 for j in "${ost_idx[@]}"; do
2410 if [ $index -eq $j ]; then
2416 error "Can not find $index in ${ost_idx[*]}"
2420 run_test 27Ca "check full striping across all OSTs"
2423 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2424 skip "server does not support overstriping"
2425 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2426 skip_env "too many osts, skipping"
2428 test_mkdir -p $DIR/$tdir
2429 local setcount=$(($OSTCOUNT * 2))
2430 [ $setcount -lt 160 ] || large_xattr_enabled ||
2431 skip_env "ea_inode feature disabled"
2433 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2434 error "setstripe failed"
2436 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2437 [ $count -eq $setcount ] ||
2438 error "stripe count $count, should be $setcount"
2440 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2441 error "overstriped should be set in pattern"
2443 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2446 run_test 27Cb "more stripes than OSTs with -C"
2449 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2450 skip "server does not support overstriping"
2451 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2453 test_mkdir -p $DIR/$tdir
2454 local setcount=$(($OSTCOUNT - 1))
2456 [ $setcount -lt 160 ] || large_xattr_enabled ||
2457 skip_env "ea_inode feature disabled"
2459 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2460 error "setstripe failed"
2462 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2463 [ $count -eq $setcount ] ||
2464 error "stripe count $count, should be $setcount"
2466 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2467 error "overstriped should not be set in pattern"
2469 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2472 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2475 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2476 skip "server does not support overstriping"
2477 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2478 large_xattr_enabled || skip_env "ea_inode feature disabled"
2480 test_mkdir -p $DIR/$tdir
2481 local setcount=$LOV_MAX_STRIPE_COUNT
2483 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2484 error "setstripe failed"
2486 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2487 [ $count -eq $setcount ] ||
2488 error "stripe count $count, should be $setcount"
2490 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2491 error "overstriped should be set in pattern"
2493 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2496 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2498 run_test 27Cd "test maximum stripe count"
2501 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2502 skip "server does not support overstriping"
2503 test_mkdir -p $DIR/$tdir
2505 pool_add $TESTNAME || error "Pool creation failed"
2506 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2510 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2511 error "setstripe failed"
2513 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2514 [ $count -eq $setcount ] ||
2515 error "stripe count $count, should be $setcount"
2517 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2518 error "overstriped should be set in pattern"
2520 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2523 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2525 run_test 27Ce "test pool with overstriping"
2528 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2529 skip "server does not support overstriping"
2530 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2531 skip_env "too many osts, skipping"
2533 test_mkdir -p $DIR/$tdir
2535 local setcount=$(($OSTCOUNT * 2))
2536 [ $setcount -lt 160 ] || large_xattr_enabled ||
2537 skip_env "ea_inode feature disabled"
2539 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2540 error "setstripe failed"
2542 echo 1 > $DIR/$tdir/$tfile
2544 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2545 [ $count -eq $setcount ] ||
2546 error "stripe count $count, should be $setcount"
2548 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2549 error "overstriped should be set in pattern"
2551 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2554 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2556 run_test 27Cf "test default inheritance with overstriping"
2559 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2560 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2561 remote_mds_nodsh && skip "remote MDS with nodsh"
2563 local POOL=${POOL:-testpool}
2565 local last_ost=$(($OSTCOUNT - 1))
2567 local ost_list=$(seq $first_ost $ost_step $last_ost)
2568 local ost_range="$first_ost $last_ost $ost_step"
2570 test_mkdir $DIR/$tdir
2571 pool_add $POOL || error "pool_add failed"
2572 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2575 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2577 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2578 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2579 skip27D+=" -s 30,31"
2580 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2581 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2582 skip27D+=" -s 32,33"
2583 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2585 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2586 error "llapi_layout_test failed"
2588 destroy_test_pools || error "destroy test pools failed"
2590 run_test 27D "validate llapi_layout API"
2592 # Verify that default_easize is increased from its initial value after
2593 # accessing a widely striped file.
2595 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2596 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2597 skip "client does not have LU-3338 fix"
2599 # 72 bytes is the minimum space required to store striping
2600 # information for a file striped across one OST:
2601 # (sizeof(struct lov_user_md_v3) +
2602 # sizeof(struct lov_user_ost_data_v1))
2604 $LCTL set_param -n llite.*.default_easize $min_easize ||
2605 error "lctl set_param failed"
2606 local easize=$($LCTL get_param -n llite.*.default_easize)
2608 [ $easize -eq $min_easize ] ||
2609 error "failed to set default_easize"
2611 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2612 error "setstripe failed"
2613 # In order to ensure stat() call actually talks to MDS we need to
2614 # do something drastic to this file to shake off all lock, e.g.
2615 # rename it (kills lookup lock forcing cache cleaning)
2616 mv $DIR/$tfile $DIR/${tfile}-1
2617 ls -l $DIR/${tfile}-1
2620 easize=$($LCTL get_param -n llite.*.default_easize)
2622 [ $easize -gt $min_easize ] ||
2623 error "default_easize not updated"
2625 run_test 27E "check that default extended attribute size properly increases"
2627 test_27F() { # LU-5346/LU-7975
2628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2629 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2630 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2631 skip "Need MDS version at least 2.8.51"
2632 remote_ost_nodsh && skip "remote OST with nodsh"
2634 test_mkdir $DIR/$tdir
2636 $LFS setstripe -c 2 $DIR/$tdir
2638 # stop all OSTs to reproduce situation for LU-7975 ticket
2639 for num in $(seq $OSTCOUNT); do
2643 # open/create f0 with O_LOV_DELAY_CREATE
2644 # truncate f0 to a non-0 size
2646 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2648 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2649 # open/write it again to force delayed layout creation
2650 cat /etc/hosts > $DIR/$tdir/f0 &
2654 for num in $(seq $OSTCOUNT); do
2655 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2656 error "ost$num failed to start"
2659 wait $catpid || error "cat failed"
2661 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2662 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2663 error "wrong stripecount"
2666 run_test 27F "Client resend delayed layout creation with non-zero size"
2668 test_27G() { #LU-10629
2669 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2670 skip "Need MDS version at least 2.11.51"
2671 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2672 remote_mds_nodsh && skip "remote MDS with nodsh"
2673 local POOL=${POOL:-testpool}
2674 local ostrange="0 0 1"
2676 test_mkdir $DIR/$tdir
2677 touch $DIR/$tdir/$tfile.nopool
2678 pool_add $POOL || error "pool_add failed"
2679 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2680 $LFS setstripe -p $POOL $DIR/$tdir
2682 local pool=$($LFS getstripe -p $DIR/$tdir)
2684 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2685 touch $DIR/$tdir/$tfile.default
2686 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2687 $LFS find $DIR/$tdir -type f --pool $POOL
2688 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2689 [[ "$found" == "2" ]] ||
2690 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2692 $LFS setstripe -d $DIR/$tdir
2694 pool=$($LFS getstripe -p -d $DIR/$tdir)
2696 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2698 run_test 27G "Clear OST pool from stripe"
2701 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2702 skip "Need MDS version newer than 2.11.54"
2703 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2704 test_mkdir $DIR/$tdir
2705 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2706 touch $DIR/$tdir/$tfile
2707 $LFS getstripe -c $DIR/$tdir/$tfile
2708 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2709 error "two-stripe file doesn't have two stripes"
2711 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2712 $LFS getstripe -y $DIR/$tdir/$tfile
2713 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2714 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2715 error "expected l_ost_idx: [02]$ not matched"
2717 # make sure ost list has been cleared
2718 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2719 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2720 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2722 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2724 run_test 27H "Set specific OSTs stripe"
2727 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2728 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2729 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2730 skip "Need MDS version newer than 2.12.52"
2731 local pool=$TESTNAME
2732 local ostrange="1 1 1"
2734 save_layout_restore_at_exit $MOUNT
2735 $LFS setstripe -c 2 -i 0 $MOUNT
2736 pool_add $pool || error "pool_add failed"
2737 pool_add_targets $pool $ostrange ||
2738 error "pool_add_targets failed"
2739 test_mkdir $DIR/$tdir
2740 $LFS setstripe -p $pool $DIR/$tdir
2741 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2742 $LFS getstripe $DIR/$tdir/$tfile
2744 run_test 27I "check that root dir striping does not break parent dir one"
2747 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2748 skip "Need MDS version newer than 2.12.51"
2750 test_mkdir $DIR/$tdir
2751 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2752 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2754 # create foreign file (raw way)
2755 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2756 error "creating $tfile w/ hex flags w/o --foreign should fail"
2758 ! $LFS setstripe --foreign --flags foo \
2759 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2760 error "creating $tfile with '--flags foo' should fail"
2762 ! $LFS setstripe --foreign --flags 0xffffffff \
2763 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2764 error "creating $tfile w/ 0xffffffff flags should fail"
2766 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2767 -t 1 -F 0xda08 || error "create_foreign_file failed"
2769 # verify foreign file (raw way)
2770 parse_foreign_file -f $DIR/$tdir/$tfile |
2771 grep "lov_foreign_magic: 0x0BD70BD0" ||
2772 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2773 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2774 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2775 parse_foreign_file -f $DIR/$tdir/$tfile |
2776 grep "lov_foreign_size: 73" ||
2777 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2778 parse_foreign_file -f $DIR/$tdir/$tfile |
2779 grep "lov_foreign_type: 1" ||
2780 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2781 parse_foreign_file -f $DIR/$tdir/$tfile |
2782 grep "lov_foreign_flags: 0x0000DA08" ||
2783 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2784 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2785 grep "lov_foreign_value: 0x" |
2786 sed -e 's/lov_foreign_value: 0x//')
2787 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2788 [[ $lov = ${lov2// /} ]] ||
2789 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2791 # create foreign file (lfs + API)
2792 $LFS setstripe --foreign=none --flags 0xda08 \
2793 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2794 error "$DIR/$tdir/${tfile}2: create failed"
2796 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2797 grep "lfm_magic:.*0x0BD70BD0" ||
2798 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2799 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2800 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2801 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2802 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2803 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2804 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2805 grep "lfm_flags:.*0x0000DA08" ||
2806 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2807 $LFS getstripe $DIR/$tdir/${tfile}2 |
2808 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2809 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2811 # modify striping should fail
2812 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2813 error "$DIR/$tdir/$tfile: setstripe should fail"
2814 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2815 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2818 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2819 cat $DIR/$tdir/${tfile}2 &&
2820 error "$DIR/$tdir/${tfile}2: read should fail"
2821 cat /etc/passwd > $DIR/$tdir/$tfile &&
2822 error "$DIR/$tdir/$tfile: write should fail"
2823 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2824 error "$DIR/$tdir/${tfile}2: write should fail"
2827 chmod 222 $DIR/$tdir/$tfile ||
2828 error "$DIR/$tdir/$tfile: chmod failed"
2829 chmod 222 $DIR/$tdir/${tfile}2 ||
2830 error "$DIR/$tdir/${tfile}2: chmod failed"
2833 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2834 error "$DIR/$tdir/$tfile: chown failed"
2835 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2836 error "$DIR/$tdir/${tfile}2: chown failed"
2838 # rename should work
2839 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2840 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2841 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2842 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2844 #remove foreign file
2845 rm $DIR/$tdir/${tfile}.new ||
2846 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2847 rm $DIR/$tdir/${tfile}2.new ||
2848 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2850 run_test 27J "basic ops on file with foreign LOV"
2853 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2854 skip "Need MDS version newer than 2.12.49"
2856 test_mkdir $DIR/$tdir
2857 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2858 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2860 # create foreign dir (raw way)
2861 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2862 error "creating $tdir w/ hex flags w/o --foreign should fail"
2864 ! $LFS setdirstripe --foreign --flags foo \
2865 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2866 error "creating $tdir with '--flags foo' should fail"
2868 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2869 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2870 error "creating $tdir w/ 0xffffffff flags should fail"
2872 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2873 error "create_foreign_dir FAILED"
2875 # verify foreign dir (raw way)
2876 parse_foreign_dir -d $DIR/$tdir/$tdir |
2877 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2878 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2879 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2880 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2881 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2882 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2883 parse_foreign_dir -d $DIR/$tdir/$tdir |
2884 grep "lmv_foreign_flags: 55813$" ||
2885 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2886 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2887 grep "lmv_foreign_value: 0x" |
2888 sed 's/lmv_foreign_value: 0x//')
2889 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2891 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2893 # create foreign dir (lfs + API)
2894 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2895 $DIR/$tdir/${tdir}2 ||
2896 error "$DIR/$tdir/${tdir}2: create failed"
2898 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2899 grep "lfm_magic:.*0x0CD50CD0" ||
2900 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2901 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2902 # - sizeof(lfm_type) - sizeof(lfm_flags)
2903 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2904 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2905 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2906 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2907 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2908 grep "lfm_flags:.*0x0000DA05" ||
2909 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2910 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2911 grep "lfm_value.*${uuid1}@${uuid2}" ||
2912 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2914 # file create in dir should fail
2915 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
2916 touch $DIR/$tdir/${tdir}2/$tfile &&
2917 error "$DIR/${tdir}2: file create should fail"
2920 chmod 777 $DIR/$tdir/$tdir ||
2921 error "$DIR/$tdir: chmod failed"
2922 chmod 777 $DIR/$tdir/${tdir}2 ||
2923 error "$DIR/${tdir}2: chmod failed"
2926 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2927 error "$DIR/$tdir: chown failed"
2928 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2929 error "$DIR/${tdir}2: chown failed"
2931 # rename should work
2932 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2933 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2934 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2935 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2938 rmdir $DIR/$tdir/${tdir}.new ||
2939 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2940 rmdir $DIR/$tdir/${tdir}2.new ||
2941 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2943 run_test 27K "basic ops on dir with foreign LMV"
2946 remote_mds_nodsh && skip "remote MDS with nodsh"
2948 local POOL=${POOL:-$TESTNAME}
2950 pool_add $POOL || error "pool_add failed"
2952 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2953 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2954 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2956 run_test 27L "lfs pool_list gives correct pool name"
2959 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2960 skip "Need MDS version >= than 2.12.57"
2961 remote_mds_nodsh && skip "remote MDS with nodsh"
2962 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2964 test_mkdir $DIR/$tdir
2966 # Set default striping on directory
2970 # if we run against a 2.12 server which lacks overstring support
2971 # then the connect_flag will not report overstriping, even if client
2973 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
2974 stripe_opt="-C $setcount"
2975 elif (( $OSTCOUNT >= $setcount )); then
2976 stripe_opt="-c $setcount"
2978 skip "server does not support overstriping"
2980 $LFS setstripe $stripe_opt $DIR/$tdir
2982 echo 1 > $DIR/$tdir/${tfile}.1
2983 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2984 [ $count -eq $setcount ] ||
2985 error "(1) stripe count $count, should be $setcount"
2987 # Capture existing append_stripe_count setting for restore
2988 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2989 local mdts=$(comma_list $(mdts_nodes))
2990 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2992 local appendcount=$orig_count
2993 echo 1 >> $DIR/$tdir/${tfile}.2_append
2994 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2995 [ $count -eq $appendcount ] ||
2996 error "(2)stripe count $count, should be $appendcount for append"
2998 # Disable O_APPEND striping, verify it works
2999 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3001 # Should now get the default striping, which is 4
3003 echo 1 >> $DIR/$tdir/${tfile}.3_append
3004 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3005 [ $count -eq $setcount ] ||
3006 error "(3) stripe count $count, should be $setcount"
3008 # Try changing the stripe count for append files
3009 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3011 # Append striping is now 2 (directory default is still 4)
3013 echo 1 >> $DIR/$tdir/${tfile}.4_append
3014 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3015 [ $count -eq $appendcount ] ||
3016 error "(4) stripe count $count, should be $appendcount for append"
3018 # Test append stripe count of -1
3019 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3020 appendcount=$OSTCOUNT
3021 echo 1 >> $DIR/$tdir/${tfile}.5
3022 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3023 [ $count -eq $appendcount ] ||
3024 error "(5) stripe count $count, should be $appendcount for append"
3026 # Set append striping back to default of 1
3027 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3029 # Try a new default striping, PFL + DOM
3030 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3032 # Create normal DOM file, DOM returns stripe count == 0
3034 touch $DIR/$tdir/${tfile}.6
3035 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3036 [ $count -eq $setcount ] ||
3037 error "(6) stripe count $count, should be $setcount"
3041 echo 1 >> $DIR/$tdir/${tfile}.7_append
3042 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3043 [ $count -eq $appendcount ] ||
3044 error "(7) stripe count $count, should be $appendcount for append"
3046 # Clean up DOM layout
3047 $LFS setstripe -d $DIR/$tdir
3049 save_layout_restore_at_exit $MOUNT
3050 # Now test that append striping works when layout is from root
3051 $LFS setstripe -c 2 $MOUNT
3052 # Make a special directory for this
3053 mkdir $DIR/${tdir}/${tdir}.2
3055 # Verify for normal file
3057 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3058 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3059 [ $count -eq $setcount ] ||
3060 error "(8) stripe count $count, should be $setcount"
3063 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3064 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3065 [ $count -eq $appendcount ] ||
3066 error "(9) stripe count $count, should be $appendcount for append"
3068 # Now test O_APPEND striping with pools
3069 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3070 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
3073 pool_add $TESTNAME || error "pool creation failed"
3074 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3076 echo 1 >> $DIR/$tdir/${tfile}.10_append
3078 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3079 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3081 # Check that count is still correct
3083 echo 1 >> $DIR/$tdir/${tfile}.11_append
3084 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3085 [ $count -eq $appendcount ] ||
3086 error "(11) stripe count $count, should be $appendcount for append"
3088 # Disable O_APPEND stripe count, verify pool works separately
3089 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3091 echo 1 >> $DIR/$tdir/${tfile}.12_append
3093 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3094 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3096 # Remove pool setting, verify it's not applied
3097 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3099 echo 1 >> $DIR/$tdir/${tfile}.13_append
3101 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3102 [ "$pool" = "" ] || error "(13) pool found: $pool"
3104 run_test 27M "test O_APPEND striping"
3107 combined_mgs_mds && skip "needs separate MGS/MDT"
3109 pool_add $TESTNAME || error "pool_add failed"
3110 do_facet mgs "$LCTL pool_list $FSNAME" |
3111 grep -Fx "${FSNAME}.${TESTNAME}" ||
3112 error "lctl pool_list on MGS failed"
3114 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3116 clean_foreign_symlink() {
3118 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3119 for i in $DIR/$tdir/* ; do
3120 $LFS unlink_foreign $i || true
3125 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3126 skip "Need MDS version newer than 2.12.51"
3128 test_mkdir $DIR/$tdir
3129 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3130 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3132 trap clean_foreign_symlink EXIT
3134 # enable foreign_symlink behaviour
3135 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3137 # foreign symlink LOV format is a partial path by default
3139 # create foreign file (lfs + API)
3140 $LFS setstripe --foreign=symlink --flags 0xda05 \
3141 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3142 error "$DIR/$tdir/${tfile}: create failed"
3144 $LFS getstripe -v $DIR/$tdir/${tfile} |
3145 grep "lfm_magic:.*0x0BD70BD0" ||
3146 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3147 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3148 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3149 $LFS getstripe -v $DIR/$tdir/${tfile} |
3150 grep "lfm_flags:.*0x0000DA05" ||
3151 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3152 $LFS getstripe $DIR/$tdir/${tfile} |
3153 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3154 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3156 # modify striping should fail
3157 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3158 error "$DIR/$tdir/$tfile: setstripe should fail"
3160 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3161 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3162 cat /etc/passwd > $DIR/$tdir/$tfile &&
3163 error "$DIR/$tdir/$tfile: write should fail"
3165 # rename should succeed
3166 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3167 error "$DIR/$tdir/$tfile: rename has failed"
3169 #remove foreign_symlink file should fail
3170 rm $DIR/$tdir/${tfile}.new &&
3171 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3174 mkdir /tmp/${uuid1} ||
3175 error "/tmp/${uuid1}: mkdir has failed"
3176 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3177 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3178 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3179 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3180 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3181 #read should succeed now
3182 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3183 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3184 #write should succeed now
3185 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3186 error "$DIR/$tdir/${tfile}.new: write should succeed"
3187 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3188 error "$DIR/$tdir/${tfile}.new: diff has failed"
3189 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3190 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3192 #check that getstripe still works
3193 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3194 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3196 # chmod should still succeed
3197 chmod 644 $DIR/$tdir/${tfile}.new ||
3198 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3200 # chown should still succeed
3201 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3202 error "$DIR/$tdir/${tfile}.new: chown has failed"
3204 # rename should still succeed
3205 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3206 error "$DIR/$tdir/${tfile}.new: rename has failed"
3208 #remove foreign_symlink file should still fail
3209 rm $DIR/$tdir/${tfile} &&
3210 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3212 #use special ioctl() to unlink foreign_symlink file
3213 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3214 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3217 run_test 27O "basic ops on foreign file of symlink type"
3220 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3221 skip "Need MDS version newer than 2.12.49"
3223 test_mkdir $DIR/$tdir
3224 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3225 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3227 trap clean_foreign_symlink EXIT
3229 # enable foreign_symlink behaviour
3230 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3232 # foreign symlink LMV format is a partial path by default
3234 # create foreign dir (lfs + API)
3235 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3236 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3237 error "$DIR/$tdir/${tdir}: create failed"
3239 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3240 grep "lfm_magic:.*0x0CD50CD0" ||
3241 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3242 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3243 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3244 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3245 grep "lfm_flags:.*0x0000DA05" ||
3246 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3247 $LFS getdirstripe $DIR/$tdir/${tdir} |
3248 grep "lfm_value.*${uuid1}/${uuid2}" ||
3249 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3251 # file create in dir should fail
3252 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3253 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
3255 # rename should succeed
3256 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3257 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3259 #remove foreign_symlink dir should fail
3260 rmdir $DIR/$tdir/${tdir}.new &&
3261 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3264 mkdir -p /tmp/${uuid1}/${uuid2} ||
3265 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3266 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3267 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3268 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3269 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3270 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3271 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3272 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3274 #check that getstripe fails now that foreign_symlink enabled
3275 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3276 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3278 # file create in dir should work now
3279 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3280 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3281 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3282 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3283 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3284 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3286 # chmod should still succeed
3287 chmod 755 $DIR/$tdir/${tdir}.new ||
3288 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3290 # chown should still succeed
3291 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3292 error "$DIR/$tdir/${tdir}.new: chown has failed"
3294 # rename should still succeed
3295 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3296 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3298 #remove foreign_symlink dir should still fail
3299 rmdir $DIR/$tdir/${tdir} &&
3300 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3302 #use special ioctl() to unlink foreign_symlink file
3303 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3304 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3306 #created file should still exist
3307 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3308 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3309 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3310 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3312 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3315 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3316 stack_trap "rm -f $TMP/$tfile*"
3318 test_mkdir $DIR/$tdir-1
3319 test_mkdir $DIR/$tdir-2
3321 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3322 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3324 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3325 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3327 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3328 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3330 # Create some bad symlinks and ensure that we don't loop
3331 # forever or something. These should return ELOOP (40) and
3332 # ENOENT (2) but I don't want to test for that because there's
3333 # always some weirdo architecture that needs to ruin
3334 # everything by defining these error numbers differently.
3336 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3337 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3339 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3340 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3344 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3347 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
3348 skip "need MDS 2.14.55 or later"
3349 (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
3351 local testdir="$DIR/$tdir"
3352 test_mkdir -p $testdir
3353 stack_trap "rm -rf $testdir"
3354 $LFS setstripe -c -1 $testdir || error "setstripe failed"
3356 local f1="$testdir/f1"
3357 touch $f1 || error "failed to touch $f1"
3358 local count=$($LFS getstripe -c $f1)
3359 (( $count == $OSTCOUNT )) || error "wrong stripe count"
3361 do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
3362 (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
3364 local maxcount=$(($OSTCOUNT - 1))
3365 local mdts=$(comma_list $(mdts_nodes))
3366 do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
3367 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
3369 local f2="$testdir/f2"
3370 touch $f2 || error "failed to touch $f2"
3371 local count=$($LFS getstripe -c $f2)
3372 (( $count == $maxcount )) || error "wrong stripe count"
3374 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
3377 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
3378 skip "Need MDS version at least 2.14.54"
3379 [[ "$(facet_host mds1)" != "$(facet_host ost1)" ]] ||
3380 skip "needs different host for mdt1 ost1"
3382 local count=$(precreated_ost_obj_count 0 0)
3384 echo "precreate count $count"
3385 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
3386 $LFS setstripe -i 0 -c 1 $DIR/$tdir || error "setstripe $tdir failed"
3387 #define OBD_FAIL_OSP_GET_LAST_FID 0x2109
3388 do_facet mds1 $LCTL set_param fail_loc=0x2109
3389 #define OBD_FAIL_OST_GET_LAST_FID 0x252
3390 do_facet ost1 $LCTL set_param fail_loc=0x252
3391 createmany -o $DIR/$tdir/f $count &
3393 echo "precreate count $(precreated_ost_obj_count 0 0)"
3394 do_facet mds1 $LCTL set_param fail_loc=0
3395 do_facet ost1 $LCTL set_param fail_loc=0
3396 wait $pid || error "createmany failed"
3397 echo "precreate count $(precreated_ost_obj_count 0 0)"
3399 run_test 27S "don't deactivate OSP on network issue"
3402 [ $(facet_host client) == $(facet_host ost1) ] &&
3403 skip "need ost1 and client on different nodes"
3405 #define OBD_FAIL_OSC_NO_GRANT 0x411
3406 $LCTL set_param fail_loc=0x20000411 fail_val=1
3407 #define OBD_FAIL_OST_ENOSPC 0x215
3408 do_facet ost1 "$LCTL set_param fail_loc=0x80000215"
3409 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3410 $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c ||
3411 error "multiop failed"
3413 run_test 27T "no eio on close on partial write due to enosp"
3415 # createtest also checks that device nodes are created and
3416 # then visible correctly (#2091)
3417 test_28() { # bug 2091
3419 $CREATETEST $DIR/d28/ct || error "createtest failed"
3421 run_test 28 "create/mknod/mkdir with bad file types ============"
3424 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3426 [ $MDS1_VERSION -ge $(version_code 2.14.51) ] && {
3428 stack_trap "restore_opencache"
3431 sync; sleep 1; sync # flush out any dirty pages from previous tests
3438 declare -i LOCKCOUNTORIG=0
3439 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3440 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3442 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3444 declare -i LOCKUNUSEDCOUNTORIG=0
3445 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3446 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3453 declare -i LOCKCOUNTCURRENT=0
3454 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3455 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3458 declare -i LOCKUNUSEDCOUNTCURRENT=0
3459 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3460 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3463 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3464 $LCTL set_param -n ldlm.dump_namespaces ""
3465 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3466 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3467 log "dumped log to $TMP/test_29.dk (bug 5793)"
3470 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3471 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3472 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3473 log "dumped log to $TMP/test_29.dk (bug 5793)"
3477 run_test 29 "IT_GETATTR regression ============================"
3479 test_30a() { # was test_30
3480 cp $(which ls) $DIR || cp /bin/ls $DIR
3481 $DIR/ls / || error "Can't execute binary from lustre"
3484 run_test 30a "execute binary from Lustre (execve) =============="
3487 cp `which ls` $DIR || cp /bin/ls $DIR
3489 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3492 run_test 30b "execute binary from Lustre as non-root ==========="
3494 test_30c() { # b=22376
3495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3497 cp $(which ls) $DIR || cp /bin/ls $DIR
3499 cancel_lru_locks mdc
3500 cancel_lru_locks osc
3501 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3504 run_test 30c "execute binary from Lustre without read perms ===="
3507 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3509 for i in {1..10}; do
3510 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3513 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3514 wait $PID || error "executing dd from Lustre failed"
3520 run_test 30d "execute binary from Lustre while clear locks"
3523 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3524 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3526 run_test 31a "open-unlink file =================================="
3529 touch $DIR/f31 || error "touch $DIR/f31 failed"
3530 ln $DIR/f31 $DIR/f31b || error "ln failed"
3531 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3532 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3534 run_test 31b "unlink file with multiple links while open ======="
3537 touch $DIR/f31 || error "touch $DIR/f31 failed"
3538 ln $DIR/f31 $DIR/f31c || error "ln failed"
3539 multiop_bg_pause $DIR/f31 O_uc ||
3540 error "multiop_bg_pause for $DIR/f31 failed"
3542 $MULTIOP $DIR/f31c Ouc
3543 kill -USR1 $MULTIPID
3546 run_test 31c "open-unlink file with multiple links ============="
3549 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3550 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3552 run_test 31d "remove of open directory ========================="
3554 test_31e() { # bug 2904
3555 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3557 run_test 31e "remove of open non-empty directory ==============="
3559 test_31f() { # bug 4554
3560 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3563 test_mkdir $DIR/d31f
3564 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3565 cp /etc/hosts $DIR/d31f
3567 $LFS getstripe $DIR/d31f/hosts
3568 multiop_bg_pause $DIR/d31f D_c || return 1
3571 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3572 test_mkdir $DIR/d31f
3573 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3574 cp /etc/hosts $DIR/d31f
3576 $LFS getstripe $DIR/d31f/hosts
3577 multiop_bg_pause $DIR/d31f D_c || return 1
3580 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3581 wait $MULTIPID || error "first opendir $MULTIPID failed"
3585 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3586 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3589 run_test 31f "remove of open directory with open-unlink file ==="
3592 echo "-- cross directory link --"
3593 test_mkdir -c1 $DIR/${tdir}ga
3594 test_mkdir -c1 $DIR/${tdir}gb
3595 touch $DIR/${tdir}ga/f
3596 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3597 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3598 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3599 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3600 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3602 run_test 31g "cross directory link==============="
3605 echo "-- cross directory link --"
3606 test_mkdir -c1 $DIR/${tdir}
3607 test_mkdir -c1 $DIR/${tdir}/dir
3608 touch $DIR/${tdir}/f
3609 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3610 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3611 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3612 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3613 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3615 run_test 31h "cross directory link under child==============="
3618 echo "-- cross directory link --"
3619 test_mkdir -c1 $DIR/$tdir
3620 test_mkdir -c1 $DIR/$tdir/dir
3621 touch $DIR/$tdir/dir/f
3622 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3623 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3624 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3625 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3626 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3628 run_test 31i "cross directory link under parent==============="
3631 test_mkdir -c1 -p $DIR/$tdir
3632 test_mkdir -c1 -p $DIR/$tdir/dir1
3633 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3634 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3635 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3636 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3639 run_test 31j "link for directory==============="
3642 test_mkdir -c1 -p $DIR/$tdir
3644 touch $DIR/$tdir/exist
3645 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3646 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3647 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3648 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3649 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3650 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3651 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3654 run_test 31k "link to file: the same, non-existing, dir==============="
3660 touch $DIR/d31m2/exist
3661 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3662 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3663 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3664 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3665 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3666 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3669 run_test 31m "link to file: the same, non-existing, dir==============="
3672 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3673 nlink=$(stat --format=%h $DIR/$tfile)
3674 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3676 local cmd="exec $fd<$DIR/$tfile"
3679 trap "eval $cmd" EXIT
3680 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3681 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3682 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3683 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3684 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3687 run_test 31n "check link count of unlinked file"
3690 local tempfile=$(mktemp $1_XXXXXX)
3691 mlink $tempfile $1 2> /dev/null &&
3692 echo "$BASHPID: link $tempfile to $1 succeeded"
3696 test_31o() { # LU-2901
3697 test_mkdir $DIR/$tdir
3698 for LOOP in $(seq 100); do
3699 rm -f $DIR/$tdir/$tfile*
3700 for THREAD in $(seq 8); do
3701 link_one $DIR/$tdir/$tfile.$LOOP &
3704 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3705 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3706 error "$LINKS duplicate links to $tfile.$LOOP" &&
3710 run_test 31o "duplicate hard links with same filename"
3713 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3715 test_mkdir $DIR/$tdir
3716 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3717 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3719 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3720 error "open unlink test1 failed"
3721 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3722 error "open unlink test2 failed"
3724 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3725 error "test1 still exists"
3726 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3727 error "test2 still exists"
3729 run_test 31p "remove of open striped directory"
3732 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3734 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3735 index=$($LFS getdirstripe -i $DIR/$tdir)
3736 [ $index -eq 3 ] || error "first stripe index $index != 3"
3737 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3738 [ $index -eq 1 ] || error "second stripe index $index != 1"
3740 # when "-c <stripe_count>" is set, the number of MDTs specified after
3741 # "-i" should equal to the stripe count
3742 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3744 run_test 31q "create striped directory on specific MDTs"
3748 touch $DIR/$tfile.target
3749 touch $DIR/$tfile.source
3751 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3752 $LCTL set_param fail_loc=0x1419 fail_val=3
3753 cat $DIR/$tfile.target &
3756 # Guarantee open is waiting before we get here
3758 mv $DIR/$tfile.source $DIR/$tfile.target
3762 if [[ $RC -ne 0 ]]; then
3763 error "open with cat failed, rc=$RC"
3766 run_test 31r "open-rename(replace) race"
3768 cleanup_test32_mount() {
3771 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3772 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3773 losetup -d $loopdev || true
3779 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3781 echo "== more mountpoints and symlinks ================="
3782 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3783 trap cleanup_test32_mount EXIT
3784 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3785 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3786 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3787 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3788 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3789 cleanup_test32_mount
3791 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3796 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3797 trap cleanup_test32_mount EXIT
3798 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3799 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3800 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3801 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3802 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3803 cleanup_test32_mount
3805 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3808 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3810 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3811 trap cleanup_test32_mount EXIT
3812 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3813 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3814 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3815 test_mkdir -p $DIR/$tdir/d2/test_dir
3816 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3817 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3818 cleanup_test32_mount
3820 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3823 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3825 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3826 trap cleanup_test32_mount EXIT
3827 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3828 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3829 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3830 test_mkdir -p $DIR/$tdir/d2/test_dir
3831 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3832 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3833 cleanup_test32_mount
3835 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3839 test_mkdir -p $DIR/$tdir/tmp
3840 local tmp_dir=$DIR/$tdir/tmp
3841 ln -s $DIR/$tdir $tmp_dir/symlink11
3842 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3843 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3844 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3846 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3850 test_mkdir -p $DIR/$tdir/tmp
3851 local tmp_dir=$DIR/$tdir/tmp
3852 ln -s $DIR/$tdir $tmp_dir/symlink11
3853 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3854 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3855 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3857 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3860 local tmp_dir=$DIR/$tdir/tmp
3861 test_mkdir -p $tmp_dir
3862 test_mkdir $DIR/${tdir}2
3863 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3864 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3865 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3866 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3867 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3868 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3870 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3873 rm -fr $DIR/$tdir $DIR/${tdir}2
3874 tmp_dir=$DIR/$tdir/tmp
3875 test_mkdir -p $tmp_dir
3876 test_mkdir $DIR/${tdir}2
3877 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3878 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3879 ls $tmp_dir/symlink12 || error "listing symlink12"
3880 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3882 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3885 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3887 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3888 trap cleanup_test32_mount EXIT
3889 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3890 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3891 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3892 touch $DIR/$tdir/test_file
3893 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3894 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3895 cleanup_test32_mount
3897 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3900 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3902 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3903 trap cleanup_test32_mount EXIT
3904 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3905 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3906 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3907 touch $DIR/$tdir/test_file
3908 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3909 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3910 cleanup_test32_mount
3912 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3915 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3918 trap cleanup_test32_mount EXIT
3919 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3920 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3921 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3922 test_mkdir -p $DIR/$tdir/d2
3923 touch $DIR/$tdir/d2/test_file || error "touch failed"
3924 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3925 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3926 cleanup_test32_mount
3928 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3931 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3934 trap cleanup_test32_mount EXIT
3935 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3936 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3937 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3938 test_mkdir -p $DIR/$tdir/d2
3939 touch $DIR/$tdir/d2/test_file || error "touch failed"
3940 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3941 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3942 cleanup_test32_mount
3944 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3948 test_mkdir -p $DIR/d32m/tmp
3949 TMP_DIR=$DIR/d32m/tmp
3950 ln -s $DIR $TMP_DIR/symlink11
3951 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3952 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3953 error "symlink11 not a link"
3954 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3955 error "symlink01 not a link"
3957 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3961 test_mkdir -p $DIR/d32n/tmp
3962 TMP_DIR=$DIR/d32n/tmp
3963 ln -s $DIR $TMP_DIR/symlink11
3964 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3965 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3966 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3968 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3972 test_mkdir -p $DIR/d32o/tmp
3973 TMP_DIR=$DIR/d32o/tmp
3974 ln -s $DIR/$tfile $TMP_DIR/symlink12
3975 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3976 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3977 error "symlink12 not a link"
3978 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3979 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3980 error "$DIR/d32o/tmp/symlink12 not file type"
3981 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3982 error "$DIR/d32o/symlink02 not file type"
3984 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3994 test_mkdir -p $DIR/d32p/tmp
3996 TMP_DIR=$DIR/d32p/tmp
3998 ln -s $DIR/$tfile $TMP_DIR/symlink12
4000 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4002 cat $DIR/d32p/tmp/symlink12 ||
4003 error "Can't open $DIR/d32p/tmp/symlink12"
4005 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
4008 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
4011 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4013 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4014 trap cleanup_test32_mount EXIT
4015 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4016 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4017 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4018 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4019 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
4020 cleanup_test32_mount
4022 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4025 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4027 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4028 trap cleanup_test32_mount EXIT
4029 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4030 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4031 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4032 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4033 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4034 cleanup_test32_mount
4036 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4041 chmod 444 $DIR/$tfile
4042 chown $RUNAS_ID $DIR/$tfile
4044 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4047 run_test 33aa "write file with mode 444 (should return error)"
4051 test_mkdir $DIR/$tdir
4052 chown $RUNAS_ID $DIR/$tdir
4053 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4054 error "$RUNAS create $tdir/$tfile failed"
4055 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4056 error "open RDWR" || true
4058 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4062 test_mkdir $DIR/$tdir
4063 chown $RUNAS_ID $DIR/$tdir
4064 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4066 run_test 33b "test open file with malformed flags (No panic)"
4069 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4070 remote_ost_nodsh && skip "remote OST with nodsh"
4078 test_mkdir $DIR/$tdir
4079 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4082 for ostnum in $(seq $OSTCOUNT); do
4083 # test-framework's OST numbering is one-based, while Lustre's
4085 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4086 # check if at least some write_bytes stats are counted
4087 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4088 obdfilter.$ostname.stats |
4089 awk '/^write_bytes/ {print $7}' )
4090 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4091 if (( ${write_bytes:-0} > 0 )); then
4097 $all_zeros || return 0
4100 echo foo > $DIR/$tdir/bar
4104 # Total up write_bytes after writing. We'd better find non-zeros.
4105 for ostnum in $(seq $OSTCOUNT); do
4106 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4107 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4108 obdfilter/$ostname/stats |
4109 awk '/^write_bytes/ {print $7}' )
4110 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4111 if (( ${write_bytes:-0} > 0 )); then
4118 for ostnum in $(seq $OSTCOUNT); do
4119 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4120 echo "Check write_bytes is in obdfilter.*.stats:"
4121 do_facet ost$ostnum lctl get_param -n \
4122 obdfilter.$ostname.stats
4124 error "OST not keeping write_bytes stats (b=22312)"
4127 run_test 33c "test write_bytes stats"
4130 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4134 local remote_dir=$DIR/$tdir/remote_dir
4136 test_mkdir $DIR/$tdir
4137 $LFS mkdir -i $MDTIDX $remote_dir ||
4138 error "create remote directory failed"
4140 touch $remote_dir/$tfile
4141 chmod 444 $remote_dir/$tfile
4142 chown $RUNAS_ID $remote_dir/$tfile
4144 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4146 chown $RUNAS_ID $remote_dir
4147 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4148 error "create" || true
4149 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4150 error "open RDWR" || true
4151 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4153 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4156 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4160 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4161 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4162 mkdir $DIR/$tdir/local_dir
4164 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4165 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4166 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4168 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4169 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4171 rmdir $DIR/$tdir/* || error "rmdir failed"
4174 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4175 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4176 mkdir $DIR/$tdir/local_dir
4178 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4179 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4180 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4182 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4183 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4185 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4188 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4189 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4190 mkdir $DIR/$tdir/local_dir
4192 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4193 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4194 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4196 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4197 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4199 run_test 33e "mkdir and striped directory should have same mode"
4203 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4207 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4208 remote_mds_nodsh && skip "remote MDS with nodsh"
4211 chmod go+rwx $DIR/$tdir
4212 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4213 trap cleanup_33f EXIT
4215 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4216 error "cannot create striped directory"
4218 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4219 error "cannot create files in striped directory"
4221 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4222 error "cannot remove files in striped directory"
4224 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4225 error "cannot remove striped directory"
4229 run_test 33f "nonroot user can create, access, and remove a striped directory"
4232 mkdir -p $DIR/$tdir/dir2
4234 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4236 [[ $err =~ "exists" ]] || error "Not exists error"
4238 run_test 33g "nonroot user create already existing root created file"
4241 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4242 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
4243 skip "Need MDS version at least 2.13.50"
4245 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir ||
4246 error "mkdir $tdir failed"
4247 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4249 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4252 for fname in $DIR/$tdir/$tfile.bak \
4253 $DIR/$tdir/$tfile.SAV \
4254 $DIR/$tdir/$tfile.orig \
4255 $DIR/$tdir/$tfile~; do
4256 touch $fname || error "touch $fname failed"
4257 index2=$($LFS getstripe -m $fname)
4258 [ $index -eq $index2 ] ||
4259 error "$fname MDT index mismatch $index != $index2"
4263 for i in {1..250}; do
4264 for fname in $(mktemp -u $DIR/$tdir/.$tfile.XXXXXX) \
4265 $(mktemp $DIR/$tdir/$tfile.XXXXXXXX); do
4266 touch $fname || error "touch $fname failed"
4267 index2=$($LFS getstripe -m $fname)
4268 if [[ $index != $index2 ]]; then
4269 failed=$((failed + 1))
4270 echo "$fname MDT index mismatch $index != $index2"
4274 echo "$failed MDT index mismatches"
4275 (( failed < 20 )) || error "MDT index mismatch $failed times"
4278 run_test 33h "temp file is located on the same MDT as target"
4282 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4284 local FNAME=$(str_repeat 'f' 250)
4286 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4287 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4292 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4294 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4296 lctl --device %$MDC deactivate
4297 stack_trap "lctl --device %$MDC activate"
4298 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4299 total=$(\ls -l $DIR/$tdir | wc -l)
4300 # "ls -l" will list total in the first line
4301 total=$((total - 1))
4302 (( total + count == 1000 )) ||
4303 error "ls list $total files, $count files on MDT1"
4305 run_test 33i "striped directory can be accessed when one MDT is down"
4307 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4310 $MCREATE $DIR/f34 || error "mcreate failed"
4311 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4312 error "getstripe failed"
4313 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4314 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4315 error "getstripe failed"
4316 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4317 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4319 run_test 34a "truncate file that has not been opened ==========="
4322 [ ! -f $DIR/f34 ] && test_34a
4323 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4324 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4325 $OPENFILE -f O_RDONLY $DIR/f34
4326 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4327 error "getstripe failed"
4328 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4329 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4331 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4334 [ ! -f $DIR/f34 ] && test_34a
4335 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4336 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4337 $OPENFILE -f O_RDWR $DIR/f34
4338 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4339 error "$LFS getstripe failed"
4340 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4341 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4343 run_test 34c "O_RDWR opening file-with-size works =============="
4346 [ ! -f $DIR/f34 ] && test_34a
4347 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4349 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4350 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4353 run_test 34d "write to sparse file ============================="
4357 $MCREATE $DIR/f34e || error "mcreate failed"
4358 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4359 $CHECKSTAT -s 1000 $DIR/f34e ||
4360 error "Size of $DIR/f34e not equal to 1000 bytes"
4361 $OPENFILE -f O_RDWR $DIR/f34e
4362 $CHECKSTAT -s 1000 $DIR/f34e ||
4363 error "Size of $DIR/f34e not equal to 1000 bytes"
4365 run_test 34e "create objects, some with size and some without =="
4367 test_34f() { # bug 6242, 6243
4368 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4372 $MCREATE $DIR/f34f || error "mcreate failed"
4373 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4374 dd if=$DIR/f34f of=$TMP/f34f
4375 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4376 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4377 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4378 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4379 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4381 run_test 34f "read from a file with no objects until EOF ======="
4384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4386 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4388 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4389 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4390 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4391 cancel_lru_locks osc
4392 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4393 error "wrong size after lock cancel"
4395 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4396 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4397 error "expanding truncate failed"
4398 cancel_lru_locks osc
4399 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4400 error "wrong expanded size after lock cancel"
4402 run_test 34g "truncate long file ==============================="
4405 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4410 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4411 sync # Flush the cache so that multiop below does not block on cache
4412 # flush when getting the group lock
4413 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4416 # Since just timed wait is not good enough, let's do a sync write
4417 # that way we are sure enough time for a roundtrip + processing
4418 # passed + 2 seconds of extra margin.
4419 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4423 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4424 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4428 local nsz=`stat -c %s $DIR/$tfile`
4429 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4431 run_test 34h "ftruncate file under grouplock should not block"
4434 cp /bin/sh $DIR/f35a
4436 chown $RUNAS_ID $DIR/f35a
4437 $RUNAS $DIR/f35a && error || true
4440 run_test 35a "exec file with mode 444 (should return and not leak)"
4444 utime $DIR/f36 || error "utime failed for MDS"
4446 run_test 36a "MDS utime check (mknod, utime)"
4450 utime $DIR/f36 || error "utime failed for OST"
4452 run_test 36b "OST utime check (open, utime)"
4457 chown $RUNAS_ID $DIR/d36
4458 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4460 run_test 36c "non-root MDS utime check (mknod, utime)"
4463 [ ! -d $DIR/d36 ] && test_36c
4464 echo "" > $DIR/d36/f36
4465 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4467 run_test 36d "non-root OST utime check (open, utime)"
4470 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4472 test_mkdir $DIR/$tdir
4473 touch $DIR/$tdir/$tfile
4474 $RUNAS utime $DIR/$tdir/$tfile &&
4475 error "utime worked, expected failure" || true
4477 run_test 36e "utime on non-owned file (should return error)"
4481 local LANG_SAVE=$LANG
4482 local LC_LANG_SAVE=$LC_LANG
4483 export LANG=C LC_LANG=C # for date language
4485 DATESTR="Dec 20 2000"
4486 test_mkdir $DIR/$tdir
4487 lctl set_param fail_loc=$fl
4489 cp /etc/hosts $DIR/$tdir/$tfile
4490 sync & # write RPC generated with "current" inode timestamp, but delayed
4492 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4493 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4494 cancel_lru_locks $OSC
4495 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4497 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4498 echo "BEFORE: $LS_BEFORE" && \
4499 echo "AFTER : $LS_AFTER" && \
4500 echo "WANT : $DATESTR" && \
4501 error "$DIR/$tdir/$tfile timestamps changed" || true
4503 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4507 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4509 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4510 subr_36fh "0x80000214"
4512 run_test 36f "utime on file racing with OST BRW write =========="
4515 remote_ost_nodsh && skip "remote OST with nodsh"
4516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4517 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4518 skip "Need MDS version at least 2.12.51"
4523 local tgt="obdfilter"
4525 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4527 test_mkdir $DIR/$tdir
4528 fmd_max_age=$(do_facet $facet \
4529 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4532 echo "FMD max age: ${fmd_max_age}s"
4533 touch $DIR/$tdir/$tfile
4534 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4535 gawk '{cnt=cnt+$1} END{print cnt}')
4536 echo "FMD before: $fmd"
4538 error "FMD wasn't create by touch"
4539 sleep $((fmd_max_age + 12))
4540 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4541 gawk '{cnt=cnt+$1} END{print cnt}')
4542 echo "FMD after: $fmd"
4544 error "FMD wasn't expired by ping"
4546 run_test 36g "FMD cache expiry ====================="
4549 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4551 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4552 subr_36fh "0x80000227"
4554 run_test 36h "utime on file racing with OST BRW write =========="
4557 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4559 test_mkdir $DIR/$tdir
4560 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4562 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4563 local new_mtime=$((mtime + 200))
4565 #change Modify time of striped dir
4566 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4567 error "change mtime failed"
4569 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4571 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4573 run_test 36i "change mtime on striped directory"
4575 # test_37 - duplicate with tests 32q 32r
4578 local file=$DIR/$tfile
4580 openfile -f O_DIRECTORY $file
4583 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4584 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4586 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4588 test_39a() { # was test_39
4590 touch $DIR/${tfile}2
4591 # ls -l $DIR/$tfile $DIR/${tfile}2
4592 # ls -lu $DIR/$tfile $DIR/${tfile}2
4593 # ls -lc $DIR/$tfile $DIR/${tfile}2
4595 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4596 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4598 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4600 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4602 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4603 error "O_TRUNC didn't change timestamps"
4606 run_test 39a "mtime changed on create"
4609 test_mkdir -c1 $DIR/$tdir
4610 cp -p /etc/passwd $DIR/$tdir/fopen
4611 cp -p /etc/passwd $DIR/$tdir/flink
4612 cp -p /etc/passwd $DIR/$tdir/funlink
4613 cp -p /etc/passwd $DIR/$tdir/frename
4614 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4617 echo "aaaaaa" >> $DIR/$tdir/fopen
4618 echo "aaaaaa" >> $DIR/$tdir/flink
4619 echo "aaaaaa" >> $DIR/$tdir/funlink
4620 echo "aaaaaa" >> $DIR/$tdir/frename
4622 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4623 local link_new=`stat -c %Y $DIR/$tdir/flink`
4624 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4625 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4627 cat $DIR/$tdir/fopen > /dev/null
4628 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4629 rm -f $DIR/$tdir/funlink2
4630 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4632 for (( i=0; i < 2; i++ )) ; do
4633 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4634 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4635 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4636 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4638 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4639 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4640 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4641 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4643 cancel_lru_locks $OSC
4644 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4647 run_test 39b "mtime change on open, link, unlink, rename ======"
4649 # this should be set to past
4650 TEST_39_MTIME=`date -d "1 year ago" +%s`
4656 local mtime0=`stat -c %Y $DIR1/$tfile`
4658 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4659 local mtime1=`stat -c %Y $DIR1/$tfile`
4660 [ "$mtime1" = $TEST_39_MTIME ] || \
4661 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4664 echo hello >> $DIR1/$tfile
4666 local mtime2=`stat -c %Y $DIR1/$tfile`
4667 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4668 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4670 mv $DIR1/$tfile $DIR1/$tfile-1
4672 for (( i=0; i < 2; i++ )) ; do
4673 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4674 [ "$mtime2" = "$mtime3" ] || \
4675 error "mtime ($mtime2) changed (to $mtime3) on rename"
4677 cancel_lru_locks $OSC
4678 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4681 run_test 39c "mtime change on rename ==========================="
4685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4688 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4690 for (( i=0; i < 2; i++ )) ; do
4691 local mtime=`stat -c %Y $DIR1/$tfile`
4692 [ $mtime = $TEST_39_MTIME ] || \
4693 error "mtime($mtime) is not set to $TEST_39_MTIME"
4695 cancel_lru_locks $OSC
4696 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4699 run_test 39d "create, utime, stat =============================="
4703 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4706 local mtime1=`stat -c %Y $DIR1/$tfile`
4708 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4710 for (( i=0; i < 2; i++ )) ; do
4711 local mtime2=`stat -c %Y $DIR1/$tfile`
4712 [ $mtime2 = $TEST_39_MTIME ] || \
4713 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4715 cancel_lru_locks $OSC
4716 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4719 run_test 39e "create, stat, utime, stat ========================"
4723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4726 mtime1=`stat -c %Y $DIR1/$tfile`
4729 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4731 for (( i=0; i < 2; i++ )) ; do
4732 local mtime2=`stat -c %Y $DIR1/$tfile`
4733 [ $mtime2 = $TEST_39_MTIME ] || \
4734 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4736 cancel_lru_locks $OSC
4737 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4740 run_test 39f "create, stat, sleep, utime, stat ================="
4744 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4746 echo hello >> $DIR1/$tfile
4747 local mtime1=`stat -c %Y $DIR1/$tfile`
4750 chmod o+r $DIR1/$tfile
4752 for (( i=0; i < 2; i++ )) ; do
4753 local mtime2=`stat -c %Y $DIR1/$tfile`
4754 [ "$mtime1" = "$mtime2" ] || \
4755 error "lost mtime: $mtime2, should be $mtime1"
4757 cancel_lru_locks $OSC
4758 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4761 run_test 39g "write, chmod, stat ==============================="
4765 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4771 echo hello >> $DIR1/$tfile
4772 local mtime1=`stat -c %Y $DIR1/$tfile`
4774 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4776 if [ "$d1" != "$d2" ]; then
4777 echo "write and touch not within one second"
4779 for (( i=0; i < 2; i++ )) ; do
4780 local mtime2=`stat -c %Y $DIR1/$tfile`
4781 [ "$mtime2" = $TEST_39_MTIME ] || \
4782 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4784 cancel_lru_locks $OSC
4785 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4789 run_test 39h "write, utime within one second, stat ============="
4792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4797 echo hello >> $DIR1/$tfile
4798 local mtime1=`stat -c %Y $DIR1/$tfile`
4800 mv $DIR1/$tfile $DIR1/$tfile-1
4802 for (( i=0; i < 2; i++ )) ; do
4803 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4805 [ "$mtime1" = "$mtime2" ] || \
4806 error "lost mtime: $mtime2, should be $mtime1"
4808 cancel_lru_locks $OSC
4809 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4812 run_test 39i "write, rename, stat =============================="
4815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4817 start_full_debug_logging
4821 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4822 lctl set_param fail_loc=0x80000412
4823 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4824 error "multiop failed"
4826 local mtime1=`stat -c %Y $DIR1/$tfile`
4828 mv $DIR1/$tfile $DIR1/$tfile-1
4830 kill -USR1 $multipid
4831 wait $multipid || error "multiop close failed"
4833 for (( i=0; i < 2; i++ )) ; do
4834 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4835 [ "$mtime1" = "$mtime2" ] ||
4836 error "mtime is lost on close: $mtime2, " \
4840 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4842 lctl set_param fail_loc=0
4843 stop_full_debug_logging
4845 run_test 39j "write, rename, close, stat ======================="
4848 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4853 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4855 local mtime1=`stat -c %Y $DIR1/$tfile`
4857 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4859 kill -USR1 $multipid
4860 wait $multipid || error "multiop close failed"
4862 for (( i=0; i < 2; i++ )) ; do
4863 local mtime2=`stat -c %Y $DIR1/$tfile`
4865 [ "$mtime2" = $TEST_39_MTIME ] || \
4866 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4869 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4872 run_test 39k "write, utime, close, stat ========================"
4874 # this should be set to future
4875 TEST_39_ATIME=`date -d "1 year" +%s`
4878 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4879 remote_mds_nodsh && skip "remote MDS with nodsh"
4881 local atime_diff=$(do_facet $SINGLEMDS \
4882 lctl get_param -n mdd.*MDT0000*.atime_diff)
4884 mkdir_on_mdt0 $DIR/$tdir
4886 # test setting directory atime to future
4887 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4888 local atime=$(stat -c %X $DIR/$tdir)
4889 [ "$atime" = $TEST_39_ATIME ] ||
4890 error "atime is not set to future: $atime, $TEST_39_ATIME"
4892 # test setting directory atime from future to now
4893 local now=$(date +%s)
4894 touch -a -d @$now $DIR/$tdir
4896 atime=$(stat -c %X $DIR/$tdir)
4897 [ "$atime" -eq "$now" ] ||
4898 error "atime is not updated from future: $atime, $now"
4900 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4903 # test setting directory atime when now > dir atime + atime_diff
4904 local d1=$(date +%s)
4906 local d2=$(date +%s)
4907 cancel_lru_locks mdc
4908 atime=$(stat -c %X $DIR/$tdir)
4909 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4910 error "atime is not updated : $atime, should be $d2"
4912 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4915 # test not setting directory atime when now < dir atime + atime_diff
4917 cancel_lru_locks mdc
4918 atime=$(stat -c %X $DIR/$tdir)
4919 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4920 error "atime is updated to $atime, should remain $d1<atime<$d2"
4922 do_facet $SINGLEMDS \
4923 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4925 run_test 39l "directory atime update ==========================="
4928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4932 local far_past_mtime=$(date -d "May 29 1953" +%s)
4933 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4935 touch -m -d @$far_past_mtime $DIR1/$tfile
4936 touch -a -d @$far_past_atime $DIR1/$tfile
4938 for (( i=0; i < 2; i++ )) ; do
4939 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4940 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4941 error "atime or mtime set incorrectly"
4943 cancel_lru_locks $OSC
4944 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4947 run_test 39m "test atime and mtime before 1970"
4949 test_39n() { # LU-3832
4950 remote_mds_nodsh && skip "remote MDS with nodsh"
4952 local atime_diff=$(do_facet $SINGLEMDS \
4953 lctl get_param -n mdd.*MDT0000*.atime_diff)
4958 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4961 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4962 atime0=$(stat -c %X $DIR/$tfile)
4965 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4966 atime1=$(stat -c %X $DIR/$tfile)
4969 cancel_lru_locks mdc
4970 cancel_lru_locks osc
4971 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4972 atime2=$(stat -c %X $DIR/$tfile)
4974 do_facet $SINGLEMDS \
4975 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4977 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4978 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4980 run_test 39n "check that O_NOATIME is honored"
4983 TESTDIR=$DIR/$tdir/$tfile
4984 [ -e $TESTDIR ] && rm -rf $TESTDIR
4991 links2=$(stat -c %h .)
4992 [ $(($links1 + 2)) != $links2 ] &&
4993 error "wrong links count $(($links1 + 2)) != $links2"
4995 links3=$(stat -c %h .)
4996 [ $(($links1 + 1)) != $links3 ] &&
4997 error "wrong links count $links1 != $links3"
5000 run_test 39o "directory cached attributes updated after create"
5003 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5006 TESTDIR=$DIR/$tdir/$tdir
5007 [ -e $TESTDIR ] && rm -rf $TESTDIR
5008 test_mkdir -p $TESTDIR
5012 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5013 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5015 links2=$(stat -c %h .)
5016 [ $(($links1 + 2)) != $links2 ] &&
5017 error "wrong links count $(($links1 + 2)) != $links2"
5019 links3=$(stat -c %h .)
5020 [ $(($links1 + 1)) != $links3 ] &&
5021 error "wrong links count $links1 != $links3"
5024 run_test 39p "remote directory cached attributes updated after create ========"
5027 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5028 skip "no atime update on old OST"
5029 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5030 skip_env "ldiskfs only test"
5034 saved_adiff=$(do_facet ost1 \
5035 lctl get_param -n obdfilter.*OST0000.atime_diff)
5036 stack_trap "do_facet ost1 \
5037 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5039 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5041 $LFS setstripe -i 0 $DIR/$tfile
5042 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5043 error "can't write initial file"
5044 cancel_lru_locks osc
5046 # exceed atime_diff and access file
5048 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5049 error "can't udpate atime"
5051 local atime_cli=$(stat -c %X $DIR/$tfile)
5052 echo "client atime: $atime_cli"
5053 # allow atime update to be written to device
5054 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5057 local ostdev=$(ostdevname 1)
5058 local fid=($(lfs getstripe -y $DIR/$tfile |
5059 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
5060 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
5061 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5063 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5064 local atime_ost=$(do_facet ost1 "$cmd" |&
5065 awk -F'[: ]' '/atime:/ { print $4 }')
5066 (( atime_cli == atime_ost )) ||
5067 error "atime on client $atime_cli != ost $atime_ost"
5069 run_test 39r "lazy atime update on OST"
5071 test_39q() { # LU-8041
5072 local testdir=$DIR/$tdir
5074 multiop_bg_pause $testdir D_c || error "multiop failed"
5076 cancel_lru_locks mdc
5077 kill -USR1 $multipid
5078 local atime=$(stat -c %X $testdir)
5079 [ "$atime" -ne 0 ] || error "atime is zero"
5081 run_test 39q "close won't zero out atime"
5084 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5085 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5086 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5087 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5088 error "$tfile is not 4096 bytes in size"
5090 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5094 small_write $DIR/f41 18
5096 run_test 41 "test small file write + fstat ====================="
5098 count_ost_writes() {
5099 lctl get_param -n ${OSC}.*.stats |
5100 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5101 END { printf("%0.0f", writes) }'
5108 BG_DIRTY_RATIO_SAVE=10
5109 MAX_BG_DIRTY_RATIO=25
5113 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5114 # dirty_ratio, dirty_background_ratio
5115 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5116 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5117 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5118 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5120 # if file not here, we are a 2.4 kernel
5121 kill -CONT `pidof kupdated`
5126 # setup the trap first, so someone cannot exit the test at the
5127 # exact wrong time and mess up a machine
5128 trap start_writeback EXIT
5129 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5130 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5131 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5132 sysctl -w vm.dirty_writeback_centisecs=0
5133 sysctl -w vm.dirty_writeback_centisecs=0
5134 # save and increase /proc/sys/vm/dirty_ratio
5135 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5136 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5137 # save and increase /proc/sys/vm/dirty_background_ratio
5138 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5139 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5141 # if file not here, we are a 2.4 kernel
5142 kill -STOP `pidof kupdated`
5146 # ensure that all stripes have some grant before we test client-side cache
5148 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5149 dd if=/dev/zero of=$i bs=4k count=1
5154 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5155 # file truncation, and file removal.
5157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5160 cancel_lru_locks $OSC
5162 sync; sleep 1; sync # just to be safe
5163 BEFOREWRITES=`count_ost_writes`
5164 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5165 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5166 AFTERWRITES=`count_ost_writes`
5167 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5168 error "$BEFOREWRITES < $AFTERWRITES"
5171 run_test 42a "ensure that we don't flush on close"
5174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5177 cancel_lru_locks $OSC
5180 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5181 BEFOREWRITES=$(count_ost_writes)
5182 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5183 AFTERWRITES=$(count_ost_writes)
5184 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5185 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5187 BEFOREWRITES=$(count_ost_writes)
5188 sync || error "sync: $?"
5189 AFTERWRITES=$(count_ost_writes)
5190 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5191 error "$BEFOREWRITES < $AFTERWRITES on sync"
5193 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5197 run_test 42b "test destroy of file with cached dirty data ======"
5199 # if these tests just want to test the effect of truncation,
5200 # they have to be very careful. consider:
5201 # - the first open gets a {0,EOF}PR lock
5202 # - the first write conflicts and gets a {0, count-1}PW
5203 # - the rest of the writes are under {count,EOF}PW
5204 # - the open for truncate tries to match a {0,EOF}PR
5205 # for the filesize and cancels the PWs.
5206 # any number of fixes (don't get {0,EOF} on open, match
5207 # composite locks, do smarter file size management) fix
5208 # this, but for now we want these tests to verify that
5209 # the cancellation with truncate intent works, so we
5210 # start the file with a full-file pw lock to match against
5211 # until the truncate.
5216 cancel_lru_locks $OSC
5218 # prime the file with 0,EOF PW to match
5222 # now the real test..
5223 dd if=/dev/zero of=$file bs=1024 count=100
5224 BEFOREWRITES=`count_ost_writes`
5225 $TRUNCATE $file $offset
5226 cancel_lru_locks $OSC
5227 AFTERWRITES=`count_ost_writes`
5232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5235 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5236 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5239 run_test 42c "test partial truncate of file with cached dirty data"
5242 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5245 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5246 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5249 run_test 42d "test complete truncate of file with cached dirty data"
5251 test_42e() { # bug22074
5252 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5254 local TDIR=$DIR/${tdir}e
5255 local pages=16 # hardcoded 16 pages, don't change it.
5256 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5257 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5261 test_mkdir $DIR/${tdir}e
5262 $LFS setstripe -c 1 $TDIR
5263 createmany -o $TDIR/f $files
5265 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5267 # we assume that with $OSTCOUNT files, at least one of them will
5268 # be allocated on OST0.
5269 warmup_files=$((OSTCOUNT * max_dirty_mb))
5270 createmany -o $TDIR/w $warmup_files
5272 # write a large amount of data into one file and sync, to get good
5273 # avail_grant number from OST.
5274 for ((i=0; i<$warmup_files; i++)); do
5275 idx=$($LFS getstripe -i $TDIR/w$i)
5276 [ $idx -ne 0 ] && continue
5277 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5280 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5282 $LCTL get_param $proc_osc0/cur_dirty_bytes
5283 $LCTL get_param $proc_osc0/cur_grant_bytes
5285 # create as much dirty pages as we can while not to trigger the actual
5286 # RPCs directly. but depends on the env, VFS may trigger flush during this
5287 # period, hopefully we are good.
5288 for ((i=0; i<$warmup_files; i++)); do
5289 idx=$($LFS getstripe -i $TDIR/w$i)
5290 [ $idx -ne 0 ] && continue
5291 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5293 $LCTL get_param $proc_osc0/cur_dirty_bytes
5294 $LCTL get_param $proc_osc0/cur_grant_bytes
5296 # perform the real test
5297 $LCTL set_param $proc_osc0/rpc_stats 0
5298 for ((;i<$files; i++)); do
5299 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5300 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5303 $LCTL get_param $proc_osc0/rpc_stats
5306 local have_ppr=false
5307 $LCTL get_param $proc_osc0/rpc_stats |
5308 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5309 # skip lines until we are at the RPC histogram data
5310 [ "$PPR" == "pages" ] && have_ppr=true && continue
5311 $have_ppr || continue
5313 # we only want the percent stat for < 16 pages
5314 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5316 percent=$((percent + WPCT))
5317 if [[ $percent -gt 15 ]]; then
5318 error "less than 16-pages write RPCs" \
5325 run_test 42e "verify sub-RPC writes are not done synchronously"
5327 test_43A() { # was test_43
5328 test_mkdir $DIR/$tdir
5329 cp -p /bin/ls $DIR/$tdir/$tfile
5330 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5332 # give multiop a chance to open
5335 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5337 # Wait for multiop to exit
5340 run_test 43A "execution of file opened for write should return -ETXTBSY"
5343 test_mkdir $DIR/$tdir
5344 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5345 $DIR/$tdir/sleep 60 &
5347 # Make sure exec of $tdir/sleep wins race with truncate
5349 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5352 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5355 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5357 test_mkdir $DIR/$tdir
5358 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5359 $DIR/$tdir/sleep 60 &
5361 # Make sure exec of $tdir/sleep wins race with truncate
5363 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5366 run_test 43b "truncate of file being executed should return -ETXTBSY"
5369 local testdir="$DIR/$tdir"
5372 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5373 ( cd $testdir && md5sum -c )
5375 run_test 43c "md5sum of copy into lustre"
5377 test_44A() { # was test_44
5378 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5380 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5381 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5383 run_test 44A "zero length read from a sparse stripe"
5386 local nstripe=$($LFS getstripe -c -d $DIR)
5387 [ -z "$nstripe" ] && skip "can't get stripe info"
5388 [[ $nstripe -gt $OSTCOUNT ]] &&
5389 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5391 local stride=$($LFS getstripe -S -d $DIR)
5392 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5393 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5396 OFFSETS="0 $((stride/2)) $((stride-1))"
5397 for offset in $OFFSETS; do
5398 for i in $(seq 0 $((nstripe-1))); do
5399 local GLOBALOFFSETS=""
5401 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5402 local myfn=$DIR/d44a-$size
5403 echo "--------writing $myfn at $size"
5404 ll_sparseness_write $myfn $size ||
5405 error "ll_sparseness_write"
5406 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5407 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5408 error "ll_sparseness_verify $GLOBALOFFSETS"
5410 for j in $(seq 0 $((nstripe-1))); do
5412 size=$((((j + $nstripe )*$stride + $offset)))
5413 ll_sparseness_write $myfn $size ||
5414 error "ll_sparseness_write"
5415 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5417 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5418 error "ll_sparseness_verify $GLOBALOFFSETS"
5423 run_test 44a "test sparse pwrite ==============================="
5427 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5433 before=`dirty_osc_total`
5434 echo executing "\"$*\""
5436 after=`dirty_osc_total`
5437 echo before $before, after $after
5440 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5443 # Obtain grants from OST if it supports it
5444 echo blah > ${f}_grant
5447 do_dirty_record "echo blah > $f"
5448 [[ $before -eq $after ]] && error "write wasn't cached"
5449 do_dirty_record "> $f"
5450 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5451 do_dirty_record "echo blah > $f"
5452 [[ $before -eq $after ]] && error "write wasn't cached"
5453 do_dirty_record "sync"
5454 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5455 do_dirty_record "echo blah > $f"
5456 [[ $before -eq $after ]] && error "write wasn't cached"
5457 do_dirty_record "cancel_lru_locks osc"
5458 [[ $before -gt $after ]] ||
5459 error "lock cancellation didn't lower dirty count"
5462 run_test 45 "osc io page accounting ============================"
5464 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5465 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5466 # objects offset and an assert hit when an rpc was built with 1023's mapped
5467 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5469 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5474 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5476 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5477 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5481 run_test 46 "dirtying a previously written page ================"
5483 # test_47 is removed "Device nodes check" is moved to test_28
5485 test_48a() { # bug 2399
5486 [ "$mds1_FSTYPE" = "zfs" ] &&
5487 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5488 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5490 test_mkdir $DIR/$tdir
5492 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5493 test_mkdir $DIR/$tdir
5494 touch foo || error "'touch foo' failed after recreating cwd"
5496 touch .foo || error "'touch .foo' failed after recreating cwd"
5498 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5499 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5500 cd . || error "'cd .' failed after recreating cwd"
5501 mkdir . && error "'mkdir .' worked after recreating cwd"
5502 rmdir . && error "'rmdir .' worked after recreating cwd"
5503 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5504 cd .. || error "'cd ..' failed after recreating cwd"
5506 run_test 48a "Access renamed working dir (should return errors)="
5508 test_48b() { # bug 2399
5510 test_mkdir $DIR/$tdir
5512 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5513 touch foo && error "'touch foo' worked after removing cwd"
5514 mkdir foo && error "'mkdir foo' worked after removing cwd"
5515 touch .foo && error "'touch .foo' worked after removing cwd"
5516 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5517 ls . > /dev/null && error "'ls .' worked after removing cwd"
5518 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5519 mkdir . && error "'mkdir .' worked after removing cwd"
5520 rmdir . && error "'rmdir .' worked after removing cwd"
5521 ln -s . foo && error "'ln -s .' worked after removing cwd"
5522 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5524 run_test 48b "Access removed working dir (should return errors)="
5526 test_48c() { # bug 2350
5527 #lctl set_param debug=-1
5530 test_mkdir -p $DIR/$tdir/dir
5532 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5533 $TRACE touch foo && error "touch foo worked after removing cwd"
5534 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5535 touch .foo && error "touch .foo worked after removing cwd"
5536 mkdir .foo && error "mkdir .foo worked after removing cwd"
5537 $TRACE ls . && error "'ls .' worked after removing cwd"
5538 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5539 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5540 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5541 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5542 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5544 run_test 48c "Access removed working subdir (should return errors)"
5546 test_48d() { # bug 2350
5547 #lctl set_param debug=-1
5550 test_mkdir -p $DIR/$tdir/dir
5552 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5553 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5554 $TRACE touch foo && error "'touch foo' worked after removing parent"
5555 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5556 touch .foo && error "'touch .foo' worked after removing parent"
5557 mkdir .foo && error "mkdir .foo worked after removing parent"
5558 $TRACE ls . && error "'ls .' worked after removing parent"
5559 $TRACE ls .. && error "'ls ..' worked after removing parent"
5560 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5561 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5562 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5565 run_test 48d "Access removed parent subdir (should return errors)"
5567 test_48e() { # bug 4134
5568 #lctl set_param debug=-1
5571 test_mkdir -p $DIR/$tdir/dir
5573 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5574 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5575 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5576 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5577 # On a buggy kernel addition of "touch foo" after cd .. will
5578 # produce kernel oops in lookup_hash_it
5579 touch ../foo && error "'cd ..' worked after recreate parent"
5581 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5583 run_test 48e "Access to recreated parent subdir (should return errors)"
5586 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5587 skip "need MDS >= 2.13.55"
5588 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5589 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5590 skip "needs different host for mdt1 mdt2"
5591 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5593 $LFS mkdir -i0 $DIR/$tdir
5594 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5596 for d in sub1 sub2 sub3; do
5597 #define OBD_FAIL_OSD_REF_DEL 0x19c
5598 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5599 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5602 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5604 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5606 test_49() { # LU-1030
5607 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5608 remote_ost_nodsh && skip "remote OST with nodsh"
5610 # get ost1 size - $FSNAME-OST0000
5611 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5613 # write 800M at maximum
5614 [[ $ost1_size -lt 2 ]] && ost1_size=2
5615 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5617 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5618 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5621 # change max_pages_per_rpc while writing the file
5622 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5623 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5624 # loop until dd process exits
5625 while ps ax -opid | grep -wq $dd_pid; do
5626 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5627 sleep $((RANDOM % 5 + 1))
5629 # restore original max_pages_per_rpc
5630 $LCTL set_param $osc1_mppc=$orig_mppc
5631 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5633 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5637 test_mkdir $DIR/$tdir
5639 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5641 run_test 50 "special situations: /proc symlinks ==============="
5643 test_51a() { # was test_51
5644 # bug 1516 - create an empty entry right after ".." then split dir
5645 test_mkdir -c1 $DIR/$tdir
5646 touch $DIR/$tdir/foo
5647 $MCREATE $DIR/$tdir/bar
5649 createmany -m $DIR/$tdir/longfile 201
5651 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5652 $MCREATE $DIR/$tdir/longfile$FNUM
5657 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5659 run_test 51a "special situations: split htree with empty entry =="
5661 cleanup_print_lfs_df () {
5668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5670 local dir=$DIR/$tdir
5671 local nrdirs=$((65536 + 100))
5673 # cleanup the directory
5676 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5680 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5681 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5682 [[ $numfree -lt $nrdirs ]] &&
5683 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5685 # need to check free space for the directories as well
5686 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5687 numfree=$(( blkfree / $(fs_inode_ksize) ))
5688 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5690 trap cleanup_print_lfs_df EXIT
5693 createmany -d $dir/d $nrdirs || {
5694 unlinkmany $dir/d $nrdirs
5695 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5699 nrdirs=$(ls -U $dir | wc -l)
5701 # unlink all but 100 subdirectories, then check it still works
5703 local delete=$((nrdirs - left))
5708 # for ldiskfs the nlink count should be 1, but this is OSD specific
5709 # and so this is listed for informational purposes only
5710 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5711 unlinkmany -d $dir/d $delete ||
5712 error "unlink of first $delete subdirs failed"
5714 echo "nlink between: $(stat -c %h $dir)"
5715 local found=$(ls -U $dir | wc -l)
5716 [ $found -ne $left ] &&
5717 error "can't find subdirs: found only $found, expected $left"
5719 unlinkmany -d $dir/d $delete $left ||
5720 error "unlink of second $left subdirs failed"
5721 # regardless of whether the backing filesystem tracks nlink accurately
5722 # or not, the nlink count shouldn't be more than "." and ".." here
5723 local after=$(stat -c %h $dir)
5724 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5725 echo "nlink after: $after"
5727 cleanup_print_lfs_df
5729 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5733 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5736 test_mkdir $DIR/$tdir
5737 $LFS setstripe -c $OSTCOUNT $DIR/$tdir
5739 qos_old=$(do_facet mds1 \
5740 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
5741 do_nodes $(comma_list $(mdts_nodes)) \
5742 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
5743 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
5744 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
5746 createmany -o $DIR/$tdir/t- 1000
5747 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5748 for ((n = 0; n < $OSTCOUNT; n++)); do
5749 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
5750 END { printf("%0.0f", objs) }' $TMP/$tfile)
5751 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5752 '($1 == '$n') { objs += 1 } \
5753 END { printf("%0.0f", objs) }')
5754 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
5756 unlinkmany $DIR/$tdir/t- 1000
5759 for ((n = 0; n < $OSTCOUNT; n++)); do
5760 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
5761 { $LFS df && $LFS df -i &&
5762 error "OST $n has fewer objects vs. OST $nlast" \
5763 " (${objs[$n]} < ${objs[$nlast]}"; }
5764 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
5765 { $LFS df && $LFS df -i &&
5766 error "OST $n has fewer objects vs. OST $nlast" \
5767 " (${objs[$n]} < ${objs[$nlast]}"; }
5769 (( ${objs0[$n]} > ${objs0[$nlast]} * 4 / 5 )) ||
5770 { $LFS df && $LFS df -i &&
5771 error "OST $n has fewer #0 objects vs. OST $nlast" \
5772 " (${objs0[$n]} < ${objs0[$nlast]}"; }
5773 (( ${objs0[$n]} < ${objs0[$nlast]} * 5 / 4 )) ||
5774 { $LFS df && $LFS df -i &&
5775 error "OST $n has fewer #0 objects vs. OST $nlast" \
5776 " (${objs0[$n]} < ${objs0[$nlast]}"; }
5780 run_test 51d "check object distribution"
5783 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5784 skip_env "ldiskfs only test"
5787 test_mkdir -c1 $DIR/$tdir
5788 test_mkdir -c1 $DIR/$tdir/d0
5790 touch $DIR/$tdir/d0/foo
5791 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5792 error "file exceed 65000 nlink limit!"
5793 unlinkmany $DIR/$tdir/d0/f- 65001
5796 run_test 51e "check file nlink limit"
5799 test_mkdir $DIR/$tdir
5802 local ulimit_old=$(ulimit -n)
5803 local spare=20 # number of spare fd's for scripts/libraries, etc.
5804 local mdt=$($LFS getstripe -m $DIR/$tdir)
5805 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5807 echo "MDT$mdt numfree=$numfree, max=$max"
5808 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5809 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5810 while ! ulimit -n $((numfree + spare)); do
5811 numfree=$((numfree * 3 / 4))
5813 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5815 echo "left ulimit at $ulimit_old"
5818 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5819 unlinkmany $DIR/$tdir/f $numfree
5820 error "create+open $numfree files in $DIR/$tdir failed"
5822 ulimit -n $ulimit_old
5824 # if createmany exits at 120s there will be fewer than $numfree files
5825 unlinkmany $DIR/$tdir/f $numfree || true
5827 run_test 51f "check many open files limit"
5830 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5831 test_mkdir $DIR/$tdir
5832 touch $DIR/$tdir/foo
5833 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5834 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5835 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5836 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5837 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5839 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5840 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5841 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5843 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5844 cp -r $DIR/$tdir $TMP/
5845 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5847 run_test 52a "append-only flag test (should return errors)"
5850 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5851 test_mkdir $DIR/$tdir
5852 touch $DIR/$tdir/foo
5853 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5854 cat test > $DIR/$tdir/foo && error "cat test worked"
5855 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5856 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5857 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5859 echo foo >> $DIR/$tdir/foo && error "echo worked"
5860 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5861 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5862 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5863 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5865 chattr -i $DIR/$tdir/foo || error "chattr failed"
5867 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5869 run_test 52b "immutable flag test (should return errors) ======="
5872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5873 remote_mds_nodsh && skip "remote MDS with nodsh"
5874 remote_ost_nodsh && skip "remote OST with nodsh"
5887 local support_last_seq=true
5889 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5890 support_last_seq=false
5893 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5895 for value in $(do_facet $SINGLEMDS \
5896 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5897 param=$(echo ${value[0]} | cut -d "=" -f1)
5898 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5900 if $support_last_seq; then
5901 param_seq=$(echo $param |
5902 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5903 mds_last_seq=$(do_facet $SINGLEMDS \
5904 $LCTL get_param -n $param_seq)
5906 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5908 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5909 node=$(facet_active_host ost$((ostnum+1)))
5910 param="obdfilter.$ostname.last_id"
5911 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5912 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5913 ost_last_id=$ost_last
5915 if $support_last_seq; then
5916 ost_last_id=$(echo $ost_last |
5917 awk -F':' '{print $2}' |
5919 ost_last_seq=$(echo $ost_last |
5920 awk -F':' '{print $1}')
5921 [[ $ost_last_seq = $mds_last_seq ]] || continue
5924 if [[ $ost_last_id != $mds_last ]]; then
5925 error "$ost_last_id != $mds_last"
5932 $found || error "can not match last_seq/last_id for $mdtosc"
5935 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5938 perl -MSocket -e ';' || skip "no Socket perl module installed"
5940 $SOCKETSERVER $DIR/socket ||
5941 error "$SOCKETSERVER $DIR/socket failed: $?"
5942 $SOCKETCLIENT $DIR/socket ||
5943 error "$SOCKETCLIENT $DIR/socket failed: $?"
5944 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5946 run_test 54a "unix domain socket test =========================="
5952 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5954 run_test 54b "char device works in lustre ======================"
5957 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5958 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5959 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5961 for i in $(seq 3 7); do
5962 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5971 loopdev="$DIR/loop54c"
5974 $UMOUNT $DIR/$tdir || rc=$?
5975 losetup -d $loopdev || true
5976 losetup -d $LOOPDEV || true
5977 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5982 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5984 loopdev="$DIR/loop54c"
5987 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5988 trap cleanup_54c EXIT
5989 mknod $loopdev b 7 $LOOPNUM
5990 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5991 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5992 losetup $loopdev $DIR/$tfile ||
5993 error "can't set up $loopdev for $DIR/$tfile"
5994 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5995 test_mkdir $DIR/$tdir
5996 mount -t ext2 $loopdev $DIR/$tdir ||
5997 error "error mounting $loopdev on $DIR/$tdir"
5998 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6001 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6005 run_test 54c "block device works in lustre ====================="
6008 local pipe="$DIR/$tfile.pipe"
6009 local string="aaaaaa"
6012 echo -n "$string" > $pipe &
6013 local result=$(cat $pipe)
6014 [[ "$result" == "$string" ]] || error "$result != $string"
6016 run_test 54d "fifo device works in lustre ======================"
6021 cp -aL /dev/console $f
6022 echo $string > $f || error "echo $string to $f failed"
6024 run_test 54e "console/tty device works in lustre ======================"
6029 local dir=$DIR/$tdir
6032 test_mkdir -p $dir/dir
6033 for i in $(seq $numfiles); do
6035 touch $dir/dir/file$i
6038 local numcomp=$($LFS getstripe --component-count $dir)
6040 [[ $numcomp == 0 ]] && numcomp=1
6042 # test lfs getstripe with --recursive
6043 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6045 [[ $filenum -eq $((numfiles * 2)) ]] ||
6046 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6047 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6048 [[ $filenum -eq $numfiles ]] ||
6049 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6050 echo "$LFS getstripe showed obdidx or l_ost_idx"
6052 # test lfs getstripe with file instead of dir
6053 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6054 [[ $filenum -eq 1 ]] ||
6055 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6056 echo "$LFS getstripe file1 passed"
6058 #test lfs getstripe with --verbose
6059 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6060 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6061 error "$LFS getstripe --verbose $dir: "\
6062 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6063 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6064 error "$LFS getstripe $dir: showed lmm_magic"
6066 #test lfs getstripe with -v prints lmm_fid
6067 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6068 local countfids=$((numdirs + numfiles * numcomp))
6069 [[ $filenum -eq $countfids ]] ||
6070 error "$LFS getstripe -v $dir: "\
6071 "got $filenum want $countfids lmm_fid"
6072 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6073 error "$LFS getstripe $dir: showed lmm_fid by default"
6074 echo "$LFS getstripe --verbose passed"
6076 #check for FID information
6077 local fid1=$($LFS getstripe --fid $dir/file1)
6078 local fid2=$($LFS getstripe --verbose $dir/file1 |
6079 awk '/lmm_fid: / { print $2; exit; }')
6080 local fid3=$($LFS path2fid $dir/file1)
6082 [ "$fid1" != "$fid2" ] &&
6083 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6084 [ "$fid1" != "$fid3" ] &&
6085 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6086 echo "$LFS getstripe --fid passed"
6088 #test lfs getstripe with --obd
6089 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6090 error "$LFS getstripe --obd wrong_uuid: should return error"
6092 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6095 local obduuid=$(ostuuid_from_index $ostidx)
6096 local found=$($LFS getstripe -r --obd $obduuid $dir |
6097 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6099 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6100 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6102 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6105 [[ $found -eq $filenum ]] ||
6106 error "$LFS getstripe --obd: found $found expect $filenum"
6107 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6108 sed '/^[ ]*'${ostidx}'[ ]/d' |
6109 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6110 error "$LFS getstripe --obd: should not show file on other obd"
6111 echo "$LFS getstripe --obd passed"
6113 run_test 56a "check $LFS getstripe"
6116 local dir=$DIR/$tdir
6120 for i in $(seq $numdirs); do
6121 test_mkdir $dir/dir$i
6124 # test lfs getdirstripe default mode is non-recursion, which is
6125 # different from lfs getstripe
6126 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6128 [[ $dircnt -eq 1 ]] ||
6129 error "$LFS getdirstripe: found $dircnt, not 1"
6130 dircnt=$($LFS getdirstripe --recursive $dir |
6131 grep -c lmv_stripe_count)
6132 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6133 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6135 run_test 56b "check $LFS getdirstripe"
6138 remote_ost_nodsh && skip "remote OST with nodsh"
6141 local ost_name=$(ostname_from_index $ost_idx)
6142 local old_status=$(ost_dev_status $ost_idx)
6143 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6145 [[ -z "$old_status" ]] ||
6146 skip_env "OST $ost_name is in $old_status status"
6148 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6149 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6150 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6151 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6152 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6153 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6156 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6157 error "$LFS df -v showing inactive devices"
6160 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6162 [[ "$new_status" =~ "D" ]] ||
6163 error "$ost_name status is '$new_status', missing 'D'"
6164 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6165 [[ "$new_status" =~ "N" ]] ||
6166 error "$ost_name status is '$new_status', missing 'N'"
6168 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6169 [[ "$new_status" =~ "f" ]] ||
6170 error "$ost_name status is '$new_status', missing 'f'"
6173 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6174 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6175 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6176 [[ -z "$p" ]] && restore_lustre_params < $p || true
6179 new_status=$(ost_dev_status $ost_idx)
6180 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6181 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6182 # can't check 'f' as devices may actually be on flash
6184 run_test 56c "check 'lfs df' showing device status"
6187 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6188 local osts=$($LFS df -v $MOUNT | grep -c OST)
6192 (( mdts == MDSCOUNT )) ||
6193 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6194 (( osts == OSTCOUNT )) ||
6195 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6197 run_test 56d "'lfs df -v' prints only configured devices"
6200 err_enoent=2 # No such file or directory
6201 err_eopnotsupp=95 # Operation not supported
6203 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6204 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6206 # Check for handling of path not exists
6207 output=$($LFS df $enoent_mnt 2>&1)
6210 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6211 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6212 error "expect failure $err_enoent, not $ret"
6214 # Check for handling of non-Lustre FS
6215 output=$($LFS df $notsup_mnt)
6218 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6219 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6220 error "expect success $err_eopnotsupp, not $ret"
6222 # Check for multiple LustreFS argument
6223 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6226 [[ $output -eq 3 && $ret -eq 0 ]] ||
6227 error "expect success 3, not $output, rc = $ret"
6229 # Check for correct non-Lustre FS handling among multiple
6231 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6232 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6235 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6236 error "expect success 2, not $output, rc = $ret"
6238 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6243 local local_tdir="$1"
6244 local local_numfiles="$2"
6245 local local_numdirs="$3"
6246 local dir_params="$4"
6247 local dir_stripe_params="$5"
6249 if [ ! -d "$local_tdir" ] ; then
6250 test_mkdir -p $dir_stripe_params $local_tdir
6251 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6252 for i in $(seq $local_numfiles) ; do
6253 touch $local_tdir/file$i
6255 for i in $(seq $local_numdirs) ; do
6256 test_mkdir $dir_stripe_params $local_tdir/dir$i
6257 for j in $(seq $local_numfiles) ; do
6258 touch $local_tdir/dir$i/file$j
6264 setup_56_special() {
6266 local local_numfiles=$2
6267 local local_numdirs=$3
6269 setup_56 $local_tdir $local_numfiles $local_numdirs
6271 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6272 for i in $(seq $local_numfiles) ; do
6273 mknod $local_tdir/loop${i}b b 7 $i
6274 mknod $local_tdir/null${i}c c 1 3
6275 ln -s $local_tdir/file1 $local_tdir/link${i}
6277 for i in $(seq $local_numdirs) ; do
6278 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6279 mknod $local_tdir/dir$i/null${i}c c 1 3
6280 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6286 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6287 local expected=$(($NUMDIRS + 2))
6289 setup_56 $dir $NUMFILES $NUMDIRS
6291 # test lfs find with -name
6292 for i in $(seq $NUMFILES) ; do
6293 local nums=$($LFS find -name "*$i" $dir | wc -l)
6295 [ $nums -eq $expected ] ||
6296 error "lfs find -name '*$i' $dir wrong: "\
6297 "found $nums, expected $expected"
6300 run_test 56g "check lfs find -name"
6303 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6304 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6306 setup_56 $dir $NUMFILES $NUMDIRS
6308 # test lfs find with ! -name
6309 for i in $(seq $NUMFILES) ; do
6310 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6312 [ $nums -eq $expected ] ||
6313 error "lfs find ! -name '*$i' $dir wrong: "\
6314 "found $nums, expected $expected"
6317 run_test 56h "check lfs find ! -name"
6320 local dir=$DIR/$tdir
6324 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6327 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6329 run_test 56i "check 'lfs find -ost UUID' skips directories"
6332 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6334 setup_56_special $dir $NUMFILES $NUMDIRS
6336 local expected=$((NUMDIRS + 1))
6337 local cmd="$LFS find -type d $dir"
6338 local nums=$($cmd | wc -l)
6340 [ $nums -eq $expected ] ||
6341 error "'$cmd' wrong: found $nums, expected $expected"
6343 run_test 56j "check lfs find -type d"
6346 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6348 setup_56_special $dir $NUMFILES $NUMDIRS
6350 local expected=$(((NUMDIRS + 1) * NUMFILES))
6351 local cmd="$LFS find -type f $dir"
6352 local nums=$($cmd | wc -l)
6354 [ $nums -eq $expected ] ||
6355 error "'$cmd' wrong: found $nums, expected $expected"
6357 run_test 56k "check lfs find -type f"
6360 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6362 setup_56_special $dir $NUMFILES $NUMDIRS
6364 local expected=$((NUMDIRS + NUMFILES))
6365 local cmd="$LFS find -type b $dir"
6366 local nums=$($cmd | wc -l)
6368 [ $nums -eq $expected ] ||
6369 error "'$cmd' wrong: found $nums, expected $expected"
6371 run_test 56l "check lfs find -type b"
6374 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6376 setup_56_special $dir $NUMFILES $NUMDIRS
6378 local expected=$((NUMDIRS + NUMFILES))
6379 local cmd="$LFS find -type c $dir"
6380 local nums=$($cmd | wc -l)
6381 [ $nums -eq $expected ] ||
6382 error "'$cmd' wrong: found $nums, expected $expected"
6384 run_test 56m "check lfs find -type c"
6387 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6388 setup_56_special $dir $NUMFILES $NUMDIRS
6390 local expected=$((NUMDIRS + NUMFILES))
6391 local cmd="$LFS find -type l $dir"
6392 local nums=$($cmd | wc -l)
6394 [ $nums -eq $expected ] ||
6395 error "'$cmd' wrong: found $nums, expected $expected"
6397 run_test 56n "check lfs find -type l"
6400 local dir=$DIR/$tdir
6402 setup_56 $dir $NUMFILES $NUMDIRS
6403 utime $dir/file1 > /dev/null || error "utime (1)"
6404 utime $dir/file2 > /dev/null || error "utime (2)"
6405 utime $dir/dir1 > /dev/null || error "utime (3)"
6406 utime $dir/dir2 > /dev/null || error "utime (4)"
6407 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6408 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6411 local nums=$($LFS find -mtime +0 $dir | wc -l)
6413 [ $nums -eq $expected ] ||
6414 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6417 cmd="$LFS find -mtime 0 $dir"
6418 nums=$($cmd | wc -l)
6419 [ $nums -eq $expected ] ||
6420 error "'$cmd' wrong: found $nums, expected $expected"
6422 run_test 56o "check lfs find -mtime for old files"
6425 local dir=$DIR/$tdir
6429 # just to make sure there is something that won't be found
6431 touch $dir/$tfile.now
6433 for age in year week day hour min; do
6434 count=$((count + 1))
6436 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6437 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6438 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6440 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6441 local nums=$($cmd | wc -l)
6442 [ $nums -eq $expected ] ||
6443 error "'$cmd' wrong: found $nums, expected $expected"
6445 cmd="$LFS find $dir -atime $count${age:0:1}"
6446 nums=$($cmd | wc -l)
6447 [ $nums -eq $expected ] ||
6448 error "'$cmd' wrong: found $nums, expected $expected"
6452 cmd="$LFS find $dir -ctime +1s -type f"
6453 nums=$($cmd | wc -l)
6454 (( $nums == $count * 2 + 1)) ||
6455 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6457 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6459 test_newerXY_base() {
6462 local dir=$DIR/$tdir
6466 if [ $y == "t" ]; then
6467 if [ $x == "b" ]; then
6468 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6470 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6473 ref=$DIR/$tfile.newer.$x$y
6474 touch $ref || error "touch $ref failed"
6477 echo "before = $ref"
6479 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6481 if [ $y == "t" ]; then
6482 if [ $x == "b" ]; then
6483 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6485 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6488 negref=$DIR/$tfile.negnewer.$x$y
6489 touch $negref || error "touch $negref failed"
6492 echo "after = $negref"
6493 local cmd="$LFS find $dir -newer$x$y $ref"
6494 local nums=$(eval $cmd | wc -l)
6495 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6497 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6498 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6500 cmd="$LFS find $dir ! -newer$x$y $negref"
6501 nums=$(eval $cmd | wc -l)
6502 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6503 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6505 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6506 nums=$(eval $cmd | wc -l)
6507 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6508 error "'$cmd' wrong: found $nums between, expected $expected"; }
6514 test_newerXY_base "a" "a"
6515 test_newerXY_base "a" "m"
6516 test_newerXY_base "a" "c"
6517 test_newerXY_base "m" "a"
6518 test_newerXY_base "m" "m"
6519 test_newerXY_base "m" "c"
6520 test_newerXY_base "c" "a"
6521 test_newerXY_base "c" "m"
6522 test_newerXY_base "c" "c"
6524 [[ -n "$sles_version" ]] &&
6525 echo "skip timestamp tests on SLES, LU-13665" && return 0
6527 test_newerXY_base "a" "t"
6528 test_newerXY_base "m" "t"
6529 test_newerXY_base "c" "t"
6531 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6532 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6533 ! btime_supported && echo "btime unsupported" && return 0
6535 test_newerXY_base "b" "b"
6536 test_newerXY_base "b" "t"
6538 run_test 56oc "check lfs find -newerXY work"
6541 local dir=$DIR/$tdir
6546 $LFS find $dir -btime -1d -type f
6553 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6554 ! btime_supported && skip "btime unsupported on MDS"
6556 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6557 ! btime_supported && skip "btime unsupported on clients"
6559 local dir=$DIR/$tdir
6560 local ref=$DIR/$tfile.ref
6561 local negref=$DIR/$tfile.negref
6563 mkdir $dir || error "mkdir $dir failed"
6564 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6565 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6566 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6567 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6568 touch $ref || error "touch $ref failed"
6569 # sleep 3 seconds at least
6572 local before=$(do_facet mds1 date +%s)
6573 local skew=$(($(date +%s) - before + 1))
6575 if (( skew < 0 && skew > -5 )); then
6576 sleep $((0 - skew + 1))
6580 # Set the dir stripe params to limit files all on MDT0,
6581 # otherwise we need to calc the max clock skew between
6582 # the client and MDTs.
6583 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6585 touch $negref || error "touch $negref failed"
6587 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6588 local nums=$($cmd | wc -l)
6589 local expected=$(((NUMFILES + 1) * NUMDIRS))
6591 [ $nums -eq $expected ] ||
6592 error "'$cmd' wrong: found $nums, expected $expected"
6594 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6595 nums=$($cmd | wc -l)
6596 expected=$((NUMFILES + 1))
6597 [ $nums -eq $expected ] ||
6598 error "'$cmd' wrong: found $nums, expected $expected"
6600 [ $skew -lt 0 ] && return
6602 local after=$(do_facet mds1 date +%s)
6603 local age=$((after - before + 1 + skew))
6605 cmd="$LFS find $dir -btime -${age}s -type f"
6606 nums=$($cmd | wc -l)
6607 expected=$(((NUMFILES + 1) * NUMDIRS))
6609 echo "Clock skew between client and server: $skew, age:$age"
6610 [ $nums -eq $expected ] ||
6611 error "'$cmd' wrong: found $nums, expected $expected"
6613 expected=$(($NUMDIRS + 1))
6614 cmd="$LFS find $dir -btime -${age}s -type d"
6615 nums=$($cmd | wc -l)
6616 [ $nums -eq $expected ] ||
6617 error "'$cmd' wrong: found $nums, expected $expected"
6618 rm -f $ref $negref || error "Failed to remove $ref $negref"
6620 run_test 56od "check lfs find -btime with units"
6623 [ $RUNAS_ID -eq $UID ] &&
6624 skip_env "RUNAS_ID = UID = $UID -- skipping"
6626 local dir=$DIR/$tdir
6628 setup_56 $dir $NUMFILES $NUMDIRS
6629 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6631 local expected=$NUMFILES
6632 local cmd="$LFS find -uid $RUNAS_ID $dir"
6633 local nums=$($cmd | wc -l)
6635 [ $nums -eq $expected ] ||
6636 error "'$cmd' wrong: found $nums, expected $expected"
6638 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6639 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6640 nums=$($cmd | wc -l)
6641 [ $nums -eq $expected ] ||
6642 error "'$cmd' wrong: found $nums, expected $expected"
6644 run_test 56p "check lfs find -uid and ! -uid"
6647 [ $RUNAS_ID -eq $UID ] &&
6648 skip_env "RUNAS_ID = UID = $UID -- skipping"
6650 local dir=$DIR/$tdir
6652 setup_56 $dir $NUMFILES $NUMDIRS
6653 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6655 local expected=$NUMFILES
6656 local cmd="$LFS find -gid $RUNAS_GID $dir"
6657 local nums=$($cmd | wc -l)
6659 [ $nums -eq $expected ] ||
6660 error "'$cmd' wrong: found $nums, expected $expected"
6662 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6663 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6664 nums=$($cmd | wc -l)
6665 [ $nums -eq $expected ] ||
6666 error "'$cmd' wrong: found $nums, expected $expected"
6668 run_test 56q "check lfs find -gid and ! -gid"
6671 local dir=$DIR/$tdir
6673 setup_56 $dir $NUMFILES $NUMDIRS
6676 local cmd="$LFS find -size 0 -type f -lazy $dir"
6677 local nums=$($cmd | wc -l)
6679 [ $nums -eq $expected ] ||
6680 error "'$cmd' wrong: found $nums, expected $expected"
6681 cmd="$LFS find -size 0 -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 0 -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 0 -type f $dir"
6692 nums=$($cmd | wc -l)
6693 [ $nums -eq $expected ] ||
6694 error "'$cmd' wrong: found $nums, expected $expected"
6696 echo "test" > $dir/$tfile
6697 echo "test2" > $dir/$tfile.2 && sync
6699 cmd="$LFS find -size 5 -type f -lazy $dir"
6700 nums=$($cmd | wc -l)
6701 [ $nums -eq $expected ] ||
6702 error "'$cmd' wrong: found $nums, expected $expected"
6703 cmd="$LFS find -size 5 -type f $dir"
6704 nums=$($cmd | wc -l)
6705 [ $nums -eq $expected ] ||
6706 error "'$cmd' wrong: found $nums, expected $expected"
6709 cmd="$LFS find -size +5 -type f -lazy $dir"
6710 nums=$($cmd | wc -l)
6711 [ $nums -eq $expected ] ||
6712 error "'$cmd' wrong: found $nums, expected $expected"
6713 cmd="$LFS find -size +5 -type f $dir"
6714 nums=$($cmd | wc -l)
6715 [ $nums -eq $expected ] ||
6716 error "'$cmd' wrong: found $nums, expected $expected"
6719 cmd="$LFS find -size +0 -type f -lazy $dir"
6720 nums=$($cmd | wc -l)
6721 [ $nums -eq $expected ] ||
6722 error "'$cmd' wrong: found $nums, expected $expected"
6723 cmd="$LFS find -size +0 -type f $dir"
6724 nums=$($cmd | wc -l)
6725 [ $nums -eq $expected ] ||
6726 error "'$cmd' wrong: found $nums, expected $expected"
6729 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6730 nums=$($cmd | wc -l)
6731 [ $nums -eq $expected ] ||
6732 error "'$cmd' wrong: found $nums, expected $expected"
6733 cmd="$LFS find ! -size -5 -type f $dir"
6734 nums=$($cmd | wc -l)
6735 [ $nums -eq $expected ] ||
6736 error "'$cmd' wrong: found $nums, expected $expected"
6739 cmd="$LFS find -size -5 -type f -lazy $dir"
6740 nums=$($cmd | wc -l)
6741 [ $nums -eq $expected ] ||
6742 error "'$cmd' wrong: found $nums, expected $expected"
6743 cmd="$LFS find -size -5 -type f $dir"
6744 nums=$($cmd | wc -l)
6745 [ $nums -eq $expected ] ||
6746 error "'$cmd' wrong: found $nums, expected $expected"
6748 run_test 56r "check lfs find -size works"
6755 cancel_lru_locks $OSC
6757 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6758 local nums=$($cmd | wc -l)
6760 [ $nums -eq $expected ] ||
6761 error "'$cmd' wrong: found $nums, expected $expected"
6763 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6765 if (( rpcs_before + glimpses != rpcs_after )); then
6766 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6767 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6769 if [[ $glimpses == 0 ]]; then
6770 error "'$cmd' should not send glimpse RPCs to OST"
6772 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6778 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6779 skip "MDS < 2.12.58 doesn't return LSOM data"
6780 local dir=$DIR/$tdir
6781 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
6783 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
6785 # statahead_agl may cause extra glimpse which confuses results. LU-13017
6786 $LCTL set_param -n llite.*.statahead_agl=0
6787 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
6789 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6790 # open and close all files to ensure LSOM is updated
6791 cancel_lru_locks $OSC
6792 find $dir -type f | xargs cat > /dev/null
6794 # expect_found glimpse_rpcs command_to_run
6795 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6796 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6797 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6798 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6800 echo "test" > $dir/$tfile
6801 echo "test2" > $dir/$tfile.2 && sync
6802 cancel_lru_locks $OSC
6803 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6805 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6806 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6807 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6808 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6810 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6811 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6812 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6813 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6814 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6815 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6817 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6820 local dir=$DIR/$tdir
6821 local tmp=$TMP/$tfile.log
6824 test_mkdir -p $dir || error "failed to mkdir $dir"
6825 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6826 error "failed to setstripe $dir/$tfile"
6827 mdt_idx=$($LFS getdirstripe -i $dir)
6828 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6830 stack_trap "rm -f $tmp" EXIT
6831 $LFS find --size +100K --ost 0 $dir |& tee $tmp
6832 ! grep -q obd_uuid $tmp ||
6833 error "failed to find --size +100K --ost 0 $dir"
6834 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
6835 ! grep -q obd_uuid $tmp ||
6836 error "failed to find --size +100K --mdt $mdt_idx $dir"
6838 run_test 56rb "check lfs find --size --ost/--mdt works"
6841 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
6842 local dir=$DIR/$tdir
6845 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
6846 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
6847 (( $MDSCOUNT > 2 )) &&
6848 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
6849 mkdir $dir/$tdir-{1..10}
6850 touch $dir/$tfile-{1..10}
6852 found=$($LFS find $dir --mdt-count 2 | wc -l)
6854 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
6856 found=$($LFS find $dir -T +1 | wc -l)
6857 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
6858 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
6860 found=$($LFS find $dir --mdt-hash all_char | wc -l)
6862 (( $found == $expect )) || error "found $found all_char, expect $expect"
6864 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
6865 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
6866 (( $found == $expect )) || error "found $found all_char, expect $expect"
6868 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
6870 test_56s() { # LU-611 #LU-9369
6871 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6873 local dir=$DIR/$tdir
6874 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6876 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6877 for i in $(seq $NUMDIRS); do
6878 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6881 local expected=$NUMDIRS
6882 local cmd="$LFS find -c $OSTCOUNT $dir"
6883 local nums=$($cmd | wc -l)
6885 [ $nums -eq $expected ] || {
6886 $LFS getstripe -R $dir
6887 error "'$cmd' wrong: found $nums, expected $expected"
6890 expected=$((NUMDIRS + onestripe))
6891 cmd="$LFS find -stripe-count +0 -type f $dir"
6892 nums=$($cmd | wc -l)
6893 [ $nums -eq $expected ] || {
6894 $LFS getstripe -R $dir
6895 error "'$cmd' wrong: found $nums, expected $expected"
6899 cmd="$LFS find -stripe-count 1 -type f $dir"
6900 nums=$($cmd | wc -l)
6901 [ $nums -eq $expected ] || {
6902 $LFS getstripe -R $dir
6903 error "'$cmd' wrong: found $nums, expected $expected"
6906 cmd="$LFS find -stripe-count -2 -type f $dir"
6907 nums=$($cmd | wc -l)
6908 [ $nums -eq $expected ] || {
6909 $LFS getstripe -R $dir
6910 error "'$cmd' wrong: found $nums, expected $expected"
6914 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6915 nums=$($cmd | wc -l)
6916 [ $nums -eq $expected ] || {
6917 $LFS getstripe -R $dir
6918 error "'$cmd' wrong: found $nums, expected $expected"
6921 run_test 56s "check lfs find -stripe-count works"
6923 test_56t() { # LU-611 #LU-9369
6924 local dir=$DIR/$tdir
6926 setup_56 $dir 0 $NUMDIRS
6927 for i in $(seq $NUMDIRS); do
6928 $LFS setstripe -S 8M $dir/dir$i/$tfile
6931 local expected=$NUMDIRS
6932 local cmd="$LFS find -S 8M $dir"
6933 local nums=$($cmd | wc -l)
6935 [ $nums -eq $expected ] || {
6936 $LFS getstripe -R $dir
6937 error "'$cmd' wrong: found $nums, expected $expected"
6941 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6943 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6945 expected=$(((NUMDIRS + 1) * NUMFILES))
6946 cmd="$LFS find -stripe-size 512k -type f $dir"
6947 nums=$($cmd | wc -l)
6948 [ $nums -eq $expected ] ||
6949 error "'$cmd' wrong: found $nums, expected $expected"
6951 cmd="$LFS find -stripe-size +320k -type f $dir"
6952 nums=$($cmd | wc -l)
6953 [ $nums -eq $expected ] ||
6954 error "'$cmd' wrong: found $nums, expected $expected"
6956 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6957 cmd="$LFS find -stripe-size +200k -type f $dir"
6958 nums=$($cmd | wc -l)
6959 [ $nums -eq $expected ] ||
6960 error "'$cmd' wrong: found $nums, expected $expected"
6962 cmd="$LFS find -stripe-size -640k -type f $dir"
6963 nums=$($cmd | wc -l)
6964 [ $nums -eq $expected ] ||
6965 error "'$cmd' wrong: found $nums, expected $expected"
6968 cmd="$LFS find -stripe-size 256k -type f $dir"
6969 nums=$($cmd | wc -l)
6970 [ $nums -eq $expected ] ||
6971 error "'$cmd' wrong: found $nums, expected $expected"
6973 cmd="$LFS find -stripe-size -320k -type f $dir"
6974 nums=$($cmd | wc -l)
6975 [ $nums -eq $expected ] ||
6976 error "'$cmd' wrong: found $nums, expected $expected"
6979 cmd="$LFS find -stripe-size 1024k -type f $dir"
6980 nums=$($cmd | wc -l)
6981 [ $nums -eq $expected ] ||
6982 error "'$cmd' wrong: found $nums, expected $expected"
6984 run_test 56t "check lfs find -stripe-size works"
6986 test_56u() { # LU-611
6987 local dir=$DIR/$tdir
6989 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6991 if [[ $OSTCOUNT -gt 1 ]]; then
6992 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6998 local expected=$(((NUMDIRS + 1) * NUMFILES))
6999 local cmd="$LFS find -stripe-index 0 -type f $dir"
7000 local nums=$($cmd | wc -l)
7002 [ $nums -eq $expected ] ||
7003 error "'$cmd' wrong: found $nums, expected $expected"
7006 cmd="$LFS find -stripe-index 1 -type f $dir"
7007 nums=$($cmd | wc -l)
7008 [ $nums -eq $expected ] ||
7009 error "'$cmd' wrong: found $nums, expected $expected"
7011 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7012 nums=$($cmd | wc -l)
7013 [ $nums -eq $expected ] ||
7014 error "'$cmd' wrong: found $nums, expected $expected"
7017 # This should produce an error and not return any files
7018 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7019 nums=$($cmd 2>/dev/null | wc -l)
7020 [ $nums -eq $expected ] ||
7021 error "'$cmd' wrong: found $nums, expected $expected"
7023 if [[ $OSTCOUNT -gt 1 ]]; then
7024 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7025 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7026 nums=$($cmd | wc -l)
7027 [ $nums -eq $expected ] ||
7028 error "'$cmd' wrong: found $nums, expected $expected"
7031 run_test 56u "check lfs find -stripe-index works"
7035 local dir=$DIR/$tdir
7037 setup_56 $dir $NUMFILES $NUMDIRS
7039 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7040 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7042 for file in $($LFS find -m $UUID $dir); do
7043 file_midx=$($LFS getstripe -m $file)
7044 [ $file_midx -eq $mdt_idx ] ||
7045 error "lfs find -m $UUID != getstripe -m $file_midx"
7048 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7051 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7054 local dir=$DIR/$tdir
7056 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7058 local stripe_size=$($LFS getstripe -S -d $dir) ||
7059 error "$LFS getstripe -S -d $dir failed"
7060 stripe_size=${stripe_size%% *}
7062 local file_size=$((stripe_size * OSTCOUNT))
7063 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7064 local required_space=$((file_num * file_size))
7065 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7067 [[ $free_space -le $((required_space / 1024)) ]] &&
7068 skip_env "need $required_space, have $free_space kbytes"
7071 local dd_count=$((file_size / dd_bs))
7073 # write data into the files
7078 for i in $(seq $NUMFILES); do
7080 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7081 error "write data into $file failed"
7083 for i in $(seq $NUMDIRS); do
7084 for j in $(seq $NUMFILES); do
7085 file=$dir/dir$i/file$j
7086 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7087 error "write data into $file failed"
7091 # $LFS_MIGRATE will fail if hard link migration is unsupported
7092 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
7093 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7094 error "creating links to $dir/dir1/file1 failed"
7099 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
7102 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7105 eval $cmd || error "$cmd failed"
7107 check_stripe_count $dir/file1 $expected
7109 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
7111 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7112 # OST 1 if it is on OST 0. This file is small enough to
7113 # be on only one stripe.
7114 file=$dir/migr_1_ost
7115 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7116 error "write data into $file failed"
7117 local obdidx=$($LFS getstripe -i $file)
7118 local oldmd5=$(md5sum $file)
7121 [[ $obdidx -eq 0 ]] && newobdidx=1
7122 cmd="$LFS migrate -i $newobdidx $file"
7124 eval $cmd || error "$cmd failed"
7126 local realobdix=$($LFS getstripe -i $file)
7127 local newmd5=$(md5sum $file)
7129 [[ $newobdidx -ne $realobdix ]] &&
7130 error "new OST is different (was=$obdidx, "\
7131 "wanted=$newobdidx, got=$realobdix)"
7132 [[ "$oldmd5" != "$newmd5" ]] &&
7133 error "md5sum differ: $oldmd5, $newmd5"
7137 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7139 eval $cmd || error "$cmd failed"
7141 for j in $(seq $NUMFILES); do
7142 check_stripe_count $dir/dir1/file$j $expected
7145 # lfs_migrate works with lfs find
7146 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7147 $LFS_MIGRATE -y -c $expected"
7149 eval $cmd || error "$cmd failed"
7151 for i in $(seq 2 $NUMFILES); do
7152 check_stripe_count $dir/file$i $expected
7154 for i in $(seq 2 $NUMDIRS); do
7155 for j in $(seq $NUMFILES); do
7156 check_stripe_count $dir/dir$i/file$j $expected
7160 run_test 56w "check lfs_migrate -c stripe_count works"
7163 local file1=$DIR/$tdir/file1
7164 local create_pool=false
7165 local initial_pool=$($LFS getstripe -p $DIR)
7169 echo -n "Creating test dir..."
7170 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7173 echo -n "Creating test file..."
7174 touch $file1 || error "cannot create file"
7177 echo -n "Detecting existing pools..."
7178 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7180 if [ ${#pool_list[@]} -gt 0 ]; then
7181 echo "${pool_list[@]}"
7182 for thispool in "${pool_list[@]}"; do
7183 if [[ -z "$initial_pool" ||
7184 "$initial_pool" != "$thispool" ]]; then
7186 echo "Using existing pool '$pool'"
7191 echo "none detected."
7193 if [ -z "$pool" ]; then
7194 pool=${POOL:-testpool}
7195 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7196 echo -n "Creating pool '$pool'..."
7198 pool_add $pool &> /dev/null ||
7199 error "pool_add failed"
7202 echo -n "Adding target to pool..."
7203 pool_add_targets $pool 0 0 1 &> /dev/null ||
7204 error "pool_add_targets failed"
7208 echo -n "Setting pool using -p option..."
7209 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7210 error "migrate failed rc = $?"
7213 echo -n "Verifying test file is in pool after migrating..."
7214 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7215 error "file was not migrated to pool $pool"
7218 echo -n "Removing test file from pool '$pool'..."
7219 # "lfs migrate $file" won't remove the file from the pool
7220 # until some striping information is changed.
7221 $LFS migrate -c 1 $file1 &> /dev/null ||
7222 error "cannot remove from pool"
7223 [ "$($LFS getstripe -p $file1)" ] &&
7224 error "pool still set"
7227 echo -n "Setting pool using --pool option..."
7228 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7229 error "migrate failed rc = $?"
7234 if $create_pool; then
7235 destroy_test_pools 2> /dev/null ||
7236 error "destroy test pools failed"
7239 run_test 56wb "check lfs_migrate pool support"
7242 local file1="$DIR/$tdir/file1"
7249 echo -n "Creating test dir..."
7250 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7251 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7252 error "cannot set stripe by '-S 1M -c 1'"
7255 echo -n "Setting initial stripe for test file..."
7256 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7257 error "cannot set stripe"
7258 cur_ssize=$($LFS getstripe -S "$file1")
7259 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
7262 # File currently set to -S 512K -c 1
7264 # Ensure -c and -S options are rejected when -R is set
7265 echo -n "Verifying incompatible options are detected..."
7266 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
7267 error "incompatible -c and -R options not detected"
7268 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
7269 error "incompatible -S and -R options not detected"
7272 # Ensure unrecognized options are passed through to 'lfs migrate'
7273 echo -n "Verifying -S option is passed through to lfs migrate..."
7274 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
7275 error "migration failed"
7276 cur_ssize=$($LFS getstripe -S "$file1")
7277 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
7280 # File currently set to -S 1M -c 1
7282 # Ensure long options are supported
7283 echo -n "Verifying long options supported..."
7284 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
7285 error "long option without argument not supported"
7286 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
7287 error "long option with argument not supported"
7288 cur_ssize=$($LFS getstripe -S "$file1")
7289 [ $cur_ssize -eq 524288 ] ||
7290 error "migrate --stripe-size $cur_ssize != 524288"
7293 # File currently set to -S 512K -c 1
7295 if [ "$OSTCOUNT" -gt 1 ]; then
7296 echo -n "Verifying explicit stripe count can be set..."
7297 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
7298 error "migrate failed"
7299 cur_scount=$($LFS getstripe -c "$file1")
7300 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
7304 # File currently set to -S 512K -c 1 or -S 512K -c 2
7306 # Ensure parent striping is used if -R is set, and no stripe
7307 # count or size is specified
7308 echo -n "Setting stripe for parent directory..."
7309 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7310 error "cannot set stripe '-S 2M -c 1'"
7313 echo -n "Verifying restripe option uses parent stripe settings..."
7314 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7315 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7316 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
7317 error "migrate failed"
7318 cur_ssize=$($LFS getstripe -S "$file1")
7319 [ $cur_ssize -eq $parent_ssize ] ||
7320 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7321 cur_scount=$($LFS getstripe -c "$file1")
7322 [ $cur_scount -eq $parent_scount ] ||
7323 error "migrate -R stripe_count $cur_scount != $parent_scount"
7326 # File currently set to -S 1M -c 1
7328 # Ensure striping is preserved if -R is not set, and no stripe
7329 # count or size is specified
7330 echo -n "Verifying striping size preserved when not specified..."
7331 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7332 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7333 error "cannot set stripe on parent directory"
7334 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7335 error "migrate failed"
7336 cur_ssize=$($LFS getstripe -S "$file1")
7337 [ $cur_ssize -eq $orig_ssize ] ||
7338 error "migrate by default $cur_ssize != $orig_ssize"
7341 # Ensure file name properly detected when final option has no argument
7342 echo -n "Verifying file name properly detected..."
7343 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7344 error "file name interpreted as option argument"
7350 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7353 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7355 local file1=$DIR/$tdir/file1
7357 echo -n "Creating test dir..."
7358 test_mkdir $DIR/$tdir || error "cannot create dir"
7361 echo -n "Creating test file..."
7365 # Ensure 'lfs migrate' will fail by using a non-existent option,
7366 # and make sure rsync is not called to recover
7367 echo -n "Make sure --no-rsync option works..."
7368 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7369 grep -q 'refusing to fall back to rsync' ||
7370 error "rsync was called with --no-rsync set"
7373 # Ensure rsync is called without trying 'lfs migrate' first
7374 echo -n "Make sure --rsync option works..."
7375 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7376 grep -q 'falling back to rsync' &&
7377 error "lfs migrate was called with --rsync set"
7380 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
7381 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
7382 grep -q 'at the same time' ||
7383 error "--rsync and --no-rsync accepted concurrently"
7389 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7395 test_mkdir $td || error "cannot create $td"
7396 touch $tf || error "cannot touch $tf"
7398 echo -n "Make sure --non-direct|-D works..."
7399 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7400 grep -q "lfs migrate --non-direct" ||
7401 error "--non-direct option cannot work correctly"
7402 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7403 grep -q "lfs migrate -D" ||
7404 error "-D option cannot work correctly"
7407 run_test 56we "check lfs_migrate --non-direct|-D support"
7410 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7411 check_swap_layouts_support
7413 local dir=$DIR/$tdir
7414 local ref1=/etc/passwd
7415 local file1=$dir/file1
7417 test_mkdir $dir || error "creating dir $dir"
7418 $LFS setstripe -c 2 $file1
7420 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7421 stripe=$($LFS getstripe -c $file1)
7422 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7423 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7428 run_test 56x "lfs migration support"
7431 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7432 check_swap_layouts_support
7434 local dir=$DIR/$tdir/$testnum
7438 local ref1=/etc/passwd
7439 local file1=$dir/file1
7441 $LFS setstripe -c 2 $file1
7443 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7445 local stripe=$($LFS getstripe -c $file1)
7447 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7448 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7453 run_test 56xa "lfs migration --block support"
7455 check_migrate_links() {
7457 local file1="$dir/file1"
7461 local total_count=$(($begin + $count - 1))
7462 local symlink_count=10
7465 if [ ! -f "$file1" ]; then
7466 echo -n "creating initial file..."
7467 $LFS setstripe -c 1 -S "512k" "$file1" ||
7468 error "cannot setstripe initial file"
7471 echo -n "creating symlinks..."
7472 for s in $(seq 1 $symlink_count); do
7473 ln -s "$file1" "$dir/slink$s" ||
7474 error "cannot create symlinks"
7478 echo -n "creating nonlinked files..."
7479 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7480 error "cannot create nonlinked files"
7485 if [ ! -f "$dir/file$total_count" ]; then
7486 echo -n "creating hard links $begin:$total_count..."
7487 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7488 /dev/null || error "cannot create hard links"
7492 echo -n "checking number of hard links listed in xattrs..."
7493 local fid=$($LFS getstripe -F "$file1")
7494 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7497 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7498 skip "hard link list has unexpected size, skipping test"
7500 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7501 error "link names should exceed xattrs size"
7504 echo -n "migrating files..."
7505 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
7507 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7510 # make sure all links have been properly migrated
7511 echo -n "verifying files..."
7512 fid=$($LFS getstripe -F "$file1") ||
7513 error "cannot get fid for file $file1"
7514 for i in $(seq 2 $total_count); do
7515 local fid2=$($LFS getstripe -F $dir/file$i)
7517 [ "$fid2" == "$fid" ] ||
7518 error "migrated hard link has mismatched FID"
7521 # make sure hard links were properly detected, and migration was
7522 # performed only once for the entire link set; nonlinked files should
7524 local actual=$(grep -c 'done' <<< "$migrate_out")
7525 local expected=$(($uniq_count + 1))
7527 [ "$actual" -eq "$expected" ] ||
7528 error "hard links individually migrated ($actual != $expected)"
7530 # make sure the correct number of hard links are present
7531 local hardlinks=$(stat -c '%h' "$file1")
7533 [ $hardlinks -eq $total_count ] ||
7534 error "num hard links $hardlinks != $total_count"
7541 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7542 skip "Need MDS version at least 2.10.55"
7544 local dir="$DIR/$tdir"
7546 test_mkdir "$dir" || error "cannot create dir $dir"
7548 echo "testing lfs migrate mode when all links fit within xattrs"
7549 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
7551 echo "testing rsync mode when all links fit within xattrs"
7552 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
7554 echo "testing lfs migrate mode when all links do not fit within xattrs"
7555 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
7557 echo "testing rsync mode when all links do not fit within xattrs"
7558 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
7560 chown -R $RUNAS_ID $dir
7561 echo "testing non-root lfs migrate mode when not all links are in xattr"
7562 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
7567 run_test 56xb "lfs migration hard link support"
7570 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7572 local dir="$DIR/$tdir"
7574 test_mkdir "$dir" || error "cannot create dir $dir"
7576 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7577 echo -n "Setting initial stripe for 20MB test file..."
7578 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7579 error "cannot setstripe 20MB file"
7581 echo -n "Sizing 20MB test file..."
7582 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7584 echo -n "Verifying small file autostripe count is 1..."
7585 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7586 error "cannot migrate 20MB file"
7587 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7588 error "cannot get stripe for $dir/20mb"
7589 [ $stripe_count -eq 1 ] ||
7590 error "unexpected stripe count $stripe_count for 20MB file"
7594 # Test 2: File is small enough to fit within the available space on
7595 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7596 # have at least an additional 1KB for each desired stripe for test 3
7597 echo -n "Setting stripe for 1GB test file..."
7598 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7600 echo -n "Sizing 1GB test file..."
7601 # File size is 1GB + 3KB
7602 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7605 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7606 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7607 if (( avail > 524288 * OSTCOUNT )); then
7608 echo -n "Migrating 1GB file..."
7609 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7610 error "cannot migrate 1GB file"
7612 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7613 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7614 error "cannot getstripe for 1GB file"
7615 [ $stripe_count -eq 2 ] ||
7616 error "unexpected stripe count $stripe_count != 2"
7620 # Test 3: File is too large to fit within the available space on
7621 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7622 if [ $OSTCOUNT -ge 3 ]; then
7623 # The required available space is calculated as
7624 # file size (1GB + 3KB) / OST count (3).
7625 local kb_per_ost=349526
7627 echo -n "Migrating 1GB file with limit..."
7628 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7629 error "cannot migrate 1GB file with limit"
7632 stripe_count=$($LFS getstripe -c "$dir/1gb")
7633 echo -n "Verifying 1GB autostripe count with limited space..."
7634 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7635 error "unexpected stripe count $stripe_count (min 3)"
7642 run_test 56xc "lfs migration autostripe"
7645 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7647 local dir=$DIR/$tdir
7648 local f_mgrt=$dir/$tfile.mgrt
7649 local f_yaml=$dir/$tfile.yaml
7650 local f_copy=$dir/$tfile.copy
7651 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7652 local layout_copy="-c 2 -S 2M -i 1"
7653 local yamlfile=$dir/yamlfile
7654 local layout_before;
7657 test_mkdir "$dir" || error "cannot create dir $dir"
7658 $LFS setstripe $layout_yaml $f_yaml ||
7659 error "cannot setstripe $f_yaml with layout $layout_yaml"
7660 $LFS getstripe --yaml $f_yaml > $yamlfile
7661 $LFS setstripe $layout_copy $f_copy ||
7662 error "cannot setstripe $f_copy with layout $layout_copy"
7664 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7666 # 1. test option --yaml
7667 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7668 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7669 layout_before=$(get_layout_param $f_yaml)
7670 layout_after=$(get_layout_param $f_mgrt)
7671 [ "$layout_after" == "$layout_before" ] ||
7672 error "lfs_migrate --yaml: $layout_after != $layout_before"
7674 # 2. test option --copy
7675 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7676 error "cannot migrate $f_mgrt with --copy $f_copy"
7677 layout_before=$(get_layout_param $f_copy)
7678 layout_after=$(get_layout_param $f_mgrt)
7679 [ "$layout_after" == "$layout_before" ] ||
7680 error "lfs_migrate --copy: $layout_after != $layout_before"
7682 run_test 56xd "check lfs_migrate --yaml and --copy support"
7685 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7687 local dir=$DIR/$tdir
7688 local f_comp=$dir/$tfile
7689 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7690 local layout_before=""
7691 local layout_after=""
7693 test_mkdir "$dir" || error "cannot create dir $dir"
7694 $LFS setstripe $layout $f_comp ||
7695 error "cannot setstripe $f_comp with layout $layout"
7696 layout_before=$(get_layout_param $f_comp)
7697 dd if=/dev/zero of=$f_comp bs=1M count=4
7699 # 1. migrate a comp layout file by lfs_migrate
7700 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7701 layout_after=$(get_layout_param $f_comp)
7702 [ "$layout_before" == "$layout_after" ] ||
7703 error "lfs_migrate: $layout_before != $layout_after"
7705 # 2. migrate a comp layout file by lfs migrate
7706 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7707 layout_after=$(get_layout_param $f_comp)
7708 [ "$layout_before" == "$layout_after" ] ||
7709 error "lfs migrate: $layout_before != $layout_after"
7711 run_test 56xe "migrate a composite layout file"
7714 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7716 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7717 skip "Need server version at least 2.13.53"
7719 local dir=$DIR/$tdir
7720 local f_comp=$dir/$tfile
7721 local layout="-E 1M -c1 -E -1 -c2"
7725 test_mkdir "$dir" || error "cannot create dir $dir"
7726 $LFS setstripe $layout $f_comp ||
7727 error "cannot setstripe $f_comp with layout $layout"
7728 fid_before=$($LFS getstripe --fid $f_comp)
7729 dd if=/dev/zero of=$f_comp bs=1M count=4
7731 # 1. migrate a comp layout file to a comp layout
7732 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7733 fid_after=$($LFS getstripe --fid $f_comp)
7734 [ "$fid_before" == "$fid_after" ] ||
7735 error "comp-to-comp migrate: $fid_before != $fid_after"
7737 # 2. migrate a comp layout file to a plain layout
7738 $LFS migrate -c2 $f_comp ||
7739 error "cannot migrate $f_comp by lfs migrate"
7740 fid_after=$($LFS getstripe --fid $f_comp)
7741 [ "$fid_before" == "$fid_after" ] ||
7742 error "comp-to-plain migrate: $fid_before != $fid_after"
7744 # 3. migrate a plain layout file to a comp layout
7745 $LFS migrate $layout $f_comp ||
7746 error "cannot migrate $f_comp by lfs migrate"
7747 fid_after=$($LFS getstripe --fid $f_comp)
7748 [ "$fid_before" == "$fid_after" ] ||
7749 error "plain-to-comp migrate: $fid_before != $fid_after"
7751 run_test 56xf "FID is not lost during migration of a composite layout file"
7753 check_file_ost_range() {
7760 file_range=($($LFS getstripe -y "$file" |
7761 awk '/l_ost_idx:/ { print $NF }'))
7763 if [[ "${#file_range[@]}" = 0 ]]; then
7764 echo "No osts found for $file"
7768 for idx in "${file_range[@]}"; do
7769 [[ " $range " =~ " $idx " ]] ||
7777 local stripe_opt="$1"
7780 local pool_ostidx="$(seq $* | tr '\n' ' ')"
7782 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
7783 error "Fail to migrate $tfile on $pool"
7784 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
7785 error "$tfile is not in pool $pool"
7786 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
7787 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
7791 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7792 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
7793 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
7794 skip "Need MDS version newer than 2.14.52"
7796 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
7797 local -a pool_ranges=("0 0" "1 1" "0 1")
7800 for i in "${!pool_names[@]}"; do
7801 pool_add ${pool_names[$i]} ||
7802 error "pool_add failed (pool: ${pool_names[$i]})"
7803 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
7804 error "pool_add_targets failed (pool: ${pool_names[$i]})"
7807 # init the file to migrate
7808 $LFS setstripe -c1 -i1 $DIR/$tfile ||
7809 error "Unable to create $tfile on OST1"
7810 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
7811 error "Unable to write on $tfile"
7813 echo "1. migrate $tfile on pool ${pool_names[0]}"
7814 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
7816 echo "2. migrate $tfile on pool ${pool_names[2]}"
7817 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
7819 echo "3. migrate $tfile on pool ${pool_names[1]}"
7820 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
7822 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
7823 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
7827 destroy_test_pools ||
7828 error "pool_destroy failed"
7830 run_test 56xg "lfs migrate pool support"
7833 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
7834 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
7837 local dir=$DIR/$tdir
7841 test_mkdir -p $dir || error "creating dir $dir"
7842 touch $f1 || error "creating std file $f1"
7843 $MULTIOP $f2 H2c || error "creating released file $f2"
7845 # a directory can be raid0, so ask only for files
7846 res=$($LFS find $dir -L raid0 -type f | wc -l)
7847 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
7849 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
7850 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
7852 # only files can be released, so no need to force file search
7853 res=$($LFS find $dir -L released)
7854 [[ $res == $f2 ]] || error "search released: found $res != $f2"
7856 res=$($LFS find $dir -type f \! -L released)
7857 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
7859 run_test 56y "lfs find -L raid0|released"
7861 test_56z() { # LU-4824
7862 # This checks to make sure 'lfs find' continues after errors
7863 # There are two classes of errors that should be caught:
7864 # - If multiple paths are provided, all should be searched even if one
7866 # - If errors are encountered during the search, it should not terminate
7868 local dir=$DIR/$tdir
7872 for i in d{0..9}; do
7874 touch $dir/$i/$tfile
7876 $LFS find $DIR/non_existent_dir $dir &&
7877 error "$LFS find did not return an error"
7878 # Make a directory unsearchable. This should NOT be the last entry in
7879 # directory order. Arbitrarily pick the 6th entry
7880 chmod 700 $($LFS find $dir -type d | sed '6!d')
7882 $RUNAS $LFS find $DIR/non_existent $dir
7883 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
7885 # The user should be able to see 10 directories and 9 files
7886 (( count == 19 )) ||
7887 error "$LFS find found $count != 19 entries after error"
7889 run_test 56z "lfs find should continue after an error"
7891 test_56aa() { # LU-5937
7892 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
7894 local dir=$DIR/$tdir
7897 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
7899 createmany -o $dir/striped_dir/${tfile}- 1024
7900 local dirs=$($LFS find --size +8k $dir/)
7902 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
7904 run_test 56aa "lfs find --size under striped dir"
7906 test_56ab() { # LU-10705
7907 test_mkdir $DIR/$tdir
7908 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
7909 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
7910 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
7911 # Flush writes to ensure valid blocks. Need to be more thorough for
7912 # ZFS, since blocks are not allocated/returned to client immediately.
7914 wait_zfs_commit ost1 2
7915 cancel_lru_locks osc
7918 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
7920 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
7922 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
7923 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
7925 rm -f $DIR/$tdir/$tfile.[123]
7927 run_test 56ab "lfs find --blocks"
7931 local dir="$DIR/$tdir"
7932 local perms=(001 002 003 004 005 006 007
7933 010 020 030 040 050 060 070
7934 100 200 300 400 500 600 700
7935 111 222 333 444 555 666 777)
7936 local perm_minus=(8 8 4 8 4 4 2
7940 local perm_slash=(8 8 12 8 12 12 14
7943 16 16 24 16 24 24 28)
7946 for perm in ${perms[*]}; do
7947 touch "$dir/$tfile.$perm"
7948 chmod $perm "$dir/$tfile.$perm"
7951 for ((i = 0; i < ${#perms[*]}; i++)); do
7952 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
7954 error "lfs find -perm ${perms[i]}:"\
7957 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
7958 (( $num == ${perm_minus[i]} )) ||
7959 error "lfs find -perm -${perms[i]}:"\
7960 "$num != ${perm_minus[i]}"
7962 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
7963 (( $num == ${perm_slash[i]} )) ||
7964 error "lfs find -perm /${perms[i]}:"\
7965 "$num != ${perm_slash[i]}"
7968 run_test 56aca "check lfs find -perm with octal representation"
7971 local dir=$DIR/$tdir
7972 # p is the permission of write and execute for user, group and other
7973 # without the umask. It is used to test +wx.
7974 local p=$(printf "%o" "$((0333 & ~$(umask)))")
7975 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
7976 local symbolic=(+t a+t u+t g+t o+t
7982 o=r,ug+o,u+w u=r,a+u,u+w
7983 g=r,ugo=g,u+w u+x,+X +X
7984 u+x,u+X u+X u+x,g+X o+r,+X
7988 for perm in ${perms[*]}; do
7989 touch "$dir/$tfile.$perm"
7990 chmod $perm "$dir/$tfile.$perm"
7993 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
7994 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
7997 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8000 run_test 56acb "check lfs find -perm with symbolic representation"
8003 local dir=$DIR/$tdir
8004 local tests="17777 787 789 abcd
8005 ug=uu ug=a ug=gu uo=ou urw
8009 for err in $tests; do
8010 if $LFS find $dir -perm $err 2>/dev/null; then
8011 error "lfs find -perm $err: parsing should have failed"
8015 run_test 56acc "check parsing error for lfs find -perm"
8018 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8019 skip "Need MDS version at least 2.10.50"
8021 # Create composite files with one component
8022 local dir=$DIR/$tdir
8024 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8025 # Create composite files with three components
8026 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8027 # Create non-composite files
8028 createmany -o $dir/${tfile}- 10
8030 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8032 [[ $nfiles == 10 ]] ||
8033 error "lfs find -E 1M found $nfiles != 10 files"
8035 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8036 [[ $nfiles == 25 ]] ||
8037 error "lfs find ! -E 1M found $nfiles != 25 files"
8039 # All files have a component that starts at 0
8040 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8041 [[ $nfiles == 35 ]] ||
8042 error "lfs find --component-start 0 - $nfiles != 35 files"
8044 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8045 [[ $nfiles == 15 ]] ||
8046 error "lfs find --component-start 2M - $nfiles != 15 files"
8048 # All files created here have a componenet that does not starts at 2M
8049 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8050 [[ $nfiles == 35 ]] ||
8051 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8053 # Find files with a specified number of components
8054 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8055 [[ $nfiles == 15 ]] ||
8056 error "lfs find --component-count 3 - $nfiles != 15 files"
8058 # Remember non-composite files have a component count of zero
8059 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8060 [[ $nfiles == 10 ]] ||
8061 error "lfs find --component-count 0 - $nfiles != 10 files"
8063 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8064 [[ $nfiles == 20 ]] ||
8065 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8067 # All files have a flag called "init"
8068 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8069 [[ $nfiles == 35 ]] ||
8070 error "lfs find --component-flags init - $nfiles != 35 files"
8072 # Multi-component files will have a component not initialized
8073 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8074 [[ $nfiles == 15 ]] ||
8075 error "lfs find !--component-flags init - $nfiles != 15 files"
8080 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8083 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8084 skip "Need MDS version at least 2.10.57"
8094 # create mirrored directories and mirrored files
8095 mkdir $td || error "mkdir $td failed"
8096 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8097 createmany -o $tf- 10 || error "create $tf- failed"
8099 for i in $(seq 2); do
8101 mkdir $dir || error "mkdir $dir failed"
8102 $LFS mirror create -N$((3 + i)) $dir ||
8103 error "create mirrored dir $dir failed"
8104 createmany -o $dir/$tfile- 10 ||
8105 error "create $dir/$tfile- failed"
8108 # change the states of some mirrored files
8110 for i in $(seq 2); do
8112 for j in $(seq 4 9); do
8113 echo foo > $dir/$tfile-$j
8117 # find mirrored files with specific mirror count
8118 cmd="$LFS find --mirror-count 3 --type f $td"
8119 nfiles=$($cmd | wc -l)
8120 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8122 cmd="$LFS find ! --mirror-count 3 --type f $td"
8123 nfiles=$($cmd | wc -l)
8124 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8126 cmd="$LFS find --mirror-count +2 --type f $td"
8127 nfiles=$($cmd | wc -l)
8128 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8130 cmd="$LFS find --mirror-count -6 --type f $td"
8131 nfiles=$($cmd | wc -l)
8132 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8134 # find mirrored files with specific file state
8135 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8136 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8138 cmd="$LFS find --mirror-state=ro --type f $td"
8139 nfiles=$($cmd | wc -l)
8140 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8142 cmd="$LFS find ! --mirror-state=ro --type f $td"
8143 nfiles=$($cmd | wc -l)
8144 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8146 cmd="$LFS find --mirror-state=wp --type f $td"
8147 nfiles=$($cmd | wc -l)
8148 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8150 cmd="$LFS find ! --mirror-state=sp --type f $td"
8151 nfiles=$($cmd | wc -l)
8152 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8154 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8156 test_56da() { # LU-14179
8157 local path=$DIR/$tdir
8162 local longdir=$(str_repeat 'a' 255)
8164 for i in {1..15}; do
8171 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8176 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8179 touch $(str_repeat 'f' 255)
8181 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8182 error "lfs find reported an error"
8186 run_test 56da "test lfs find with long paths"
8188 test_56ea() { #LU-10378
8189 local path=$DIR/$tdir
8190 local pool=$TESTNAME
8193 pool_add $pool || error "pool_add $pool failed"
8194 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8195 error "adding targets to $pool failed"
8197 # Set default pool on directory before creating file
8198 mkdir $path || error "mkdir $path failed"
8199 $LFS setstripe -p $pool $path ||
8200 error "set OST pool on $pool failed"
8201 touch $path/$tfile || error "touch $path/$tfile failed"
8203 # Compare basic file attributes from -printf and stat
8204 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G")
8205 local attr_stat=$(stat -c "%X %Y %Z %u %g" $path/$tfile)
8207 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8208 error "Attrs from lfs find and stat don't match"
8210 # Compare Lustre attributes from lfs find and lfs getstripe
8211 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8212 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8213 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8214 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8215 local fpool=$($LFS getstripe --pool $path/$tfile)
8216 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8218 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8219 error "Attrs from lfs find and lfs getstripe don't match"
8221 # Verify behavior for unknown escape/format sequences
8222 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8224 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8225 error "Escape/format codes don't match"
8227 run_test 56ea "test lfs find -printf option"
8230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8231 # note test will not do anything if MDS is not local
8232 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8233 skip_env "ldiskfs only test"
8235 remote_mds_nodsh && skip "remote MDS with nodsh"
8237 local MNTDEV="osd*.*MDT*.mntdev"
8238 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8239 [ -z "$DEV" ] && error "can't access $MNTDEV"
8240 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8241 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8242 error "can't access $DEV"
8243 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
8244 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8248 run_test 57a "verify MDS filesystem created with large inodes =="
8251 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8252 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8253 skip_env "ldiskfs only test"
8255 remote_mds_nodsh && skip "remote MDS with nodsh"
8257 local dir=$DIR/$tdir
8260 local fileN=$dir/f$filecount
8262 rm -rf $dir || error "removing $dir"
8264 local mdtidx=$($LFS getstripe -m $dir)
8265 local mdtname=MDT$(printf %04x $mdtidx)
8266 local facet=mds$((mdtidx + 1))
8268 echo "mcreating $filecount files"
8269 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8271 # verify that files do not have EAs yet
8272 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8273 error "$file1 has an EA"
8274 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8275 error "$fileN has an EA"
8279 df $dir #make sure we get new statfs data
8280 local mdsfree=$(do_facet $facet \
8281 lctl get_param -n osd*.*$mdtname.kbytesfree)
8282 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8285 echo "opening files to create objects/EAs"
8286 for file in $(seq -f $dir/f%g 1 $filecount); do
8287 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8288 error "opening $file"
8291 # verify that files have EAs now
8292 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8293 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8295 sleep 1 #make sure we get new statfs data
8297 local mdsfree2=$(do_facet $facet \
8298 lctl get_param -n osd*.*$mdtname.kbytesfree)
8299 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8301 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8302 if [ "$mdsfree" != "$mdsfree2" ]; then
8303 error "MDC before $mdcfree != after $mdcfree2"
8305 echo "MDC before $mdcfree != after $mdcfree2"
8306 echo "unable to confirm if MDS has large inodes"
8311 run_test 57b "default LOV EAs are stored inside large inodes ==="
8314 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8315 [ -z "$(which wiretest 2>/dev/null)" ] &&
8316 skip_env "could not find wiretest"
8320 run_test 58 "verify cross-platform wire constants =============="
8323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8325 echo "touch 130 files"
8326 createmany -o $DIR/f59- 130
8328 unlinkmany $DIR/f59- 130
8330 # wait for commitment of removal
8331 wait_delete_completed
8333 run_test 59 "verify cancellation of llog records async ========="
8335 TEST60_HEAD="test_60 run $RANDOM"
8337 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8338 remote_mgs_nodsh && skip "remote MGS with nodsh"
8339 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8340 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8341 skip_env "missing subtest run-llog.sh"
8343 log "$TEST60_HEAD - from kernel mode"
8344 do_facet mgs "$LCTL dk > /dev/null"
8345 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8346 do_facet mgs $LCTL dk > $TMP/$tfile
8348 # LU-6388: test llog_reader
8349 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8350 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8351 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8352 skip_env "missing llog_reader"
8353 local fstype=$(facet_fstype mgs)
8354 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8355 skip_env "Only for ldiskfs or zfs type mgs"
8357 local mntpt=$(facet_mntpt mgs)
8358 local mgsdev=$(mgsdevname 1)
8370 #get fid and record list
8371 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8373 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8375 #remount mgs as ldiskfs or zfs type
8376 stop mgs || error "stop mgs failed"
8377 mount_fstype mgs || error "remount mgs failed"
8378 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8381 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8382 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8387 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8389 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8391 echo "obj_file is $obj_file"
8392 do_facet mgs $llog_reader $obj_file
8394 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8395 awk '{ print $3 }' | sed -e "s/^type=//g")
8396 if [ $rec_type != $rec ]; then
8397 echo "FAILED test_60a wrong record type $rec_type," \
8403 #check obj path if record type is LLOG_LOGID_MAGIC
8404 if [ "$rec" == "1064553b" ]; then
8405 path=$(do_facet mgs $llog_reader $obj_file |
8406 grep "path=" | awk '{ print $NF }' |
8407 sed -e "s/^path=//g")
8408 if [ $obj_file != $mntpt/$path ]; then
8409 echo "FAILED test_60a wrong obj path" \
8410 "$montpt/$path, should be $obj_file"
8417 #restart mgs before "error", otherwise it will block the next test
8418 stop mgs || error "stop mgs failed"
8419 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8420 $pass || error "test failed, see FAILED test_60a messages for specifics"
8422 run_test 60a "llog_test run from kernel module and test llog_reader"
8424 test_60b() { # bug 6411
8425 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8428 LLOG_COUNT=$(do_facet mgs dmesg |
8429 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8430 /llog_[a-z]*.c:[0-9]/ {
8442 [[ $LLOG_COUNT -gt 120 ]] &&
8443 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8445 run_test 60b "limit repeated messages from CERROR/CWARN"
8448 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8450 echo "create 5000 files"
8451 createmany -o $DIR/f60c- 5000
8452 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8453 lctl set_param fail_loc=0x80000137
8454 unlinkmany $DIR/f60c- 5000
8455 lctl set_param fail_loc=0
8457 run_test 60c "unlink file when mds full"
8460 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8462 SAVEPRINTK=$(lctl get_param -n printk)
8463 # verify "lctl mark" is even working"
8464 MESSAGE="test message ID $RANDOM $$"
8465 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8466 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8468 lctl set_param printk=0 || error "set lnet.printk failed"
8469 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8470 MESSAGE="new test message ID $RANDOM $$"
8471 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8472 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8473 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8475 lctl set_param -n printk="$SAVEPRINTK"
8477 run_test 60d "test printk console message masking"
8480 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8481 remote_mds_nodsh && skip "remote MDS with nodsh"
8484 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8485 do_facet mds1 lctl set_param fail_loc=0x15b
8488 run_test 60e "no space while new llog is being created"
8491 local old_path=$($LCTL get_param -n debug_path)
8493 stack_trap "$LCTL set_param debug_path=$old_path"
8494 stack_trap "rm -f $TMP/$tfile*"
8495 rm -f $TMP/$tfile* 2> /dev/null
8496 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8497 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8498 test_mkdir $DIR/$tdir
8499 # retry in case the open is cached and not released
8500 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8501 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8505 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8507 run_test 60f "change debug_path works"
8513 test_mkdir -c $MDSCOUNT $DIR/$tdir
8518 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8519 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8521 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8522 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8523 index=$((index + 1))
8529 for i in {0..100}; do
8530 # define OBD_FAIL_OSD_TXN_START 0x19a
8531 local index=$((i % MDSCOUNT + 1))
8533 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8540 for i in $(seq $MDSCOUNT); do
8541 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8544 mkdir $DIR/$tdir/new || error "mkdir failed"
8545 rmdir $DIR/$tdir/new || error "rmdir failed"
8547 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8549 for i in $(seq $MDSCOUNT); do
8550 wait_update_facet mds$i "$LCTL get_param -n \
8551 mdd.$(facet_svc mds$i).lfsck_namespace |
8552 awk '/^status/ { print \\\$2 }'" "completed"
8556 rm -rf $DIR/$tdir || error "rmdir failed"
8558 run_test 60g "transaction abort won't cause MDT hung"
8561 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8562 skip "Need MDS version at least 2.12.52"
8563 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8567 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8568 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8569 for fail_loc in 0x80000188 0x80000189; do
8570 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8571 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8572 error "mkdir $dir-$fail_loc failed"
8573 for i in {0..10}; do
8574 # create may fail on missing stripe
8575 echo $i > $DIR/$tdir-$fail_loc/$i
8577 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8578 error "getdirstripe $tdir-$fail_loc failed"
8579 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8580 error "migrate $tdir-$fail_loc failed"
8581 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8582 error "getdirstripe $tdir-$fail_loc failed"
8583 pushd $DIR/$tdir-$fail_loc
8585 echo $f | cmp $f - || error "$f data mismatch"
8588 rm -rf $DIR/$tdir-$fail_loc
8591 run_test 60h "striped directory with missing stripes can be accessed"
8593 function t60i_load() {
8595 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
8596 $LCTL set_param fail_loc=0x131c fail_val=1
8597 for ((i=0; i<5000; i++)); do
8598 touch $DIR/$tdir/f$i
8603 changelog_register || error "changelog_register failed"
8604 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
8605 changelog_users $SINGLEMDS | grep -q $cl_user ||
8606 error "User $cl_user not found in changelog_users"
8607 changelog_chmask "ALL"
8610 for((i=0; i<100; i++)); do
8611 changelog_dump >/dev/null ||
8612 error "can't read changelog"
8616 changelog_deregister || error "changelog_deregister failed"
8617 $LCTL set_param fail_loc=0
8619 run_test 60i "llog: new record vs reader race"
8622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8625 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
8626 cancel_lru_locks osc
8627 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
8630 run_test 61a "mmap() writes don't make sync hang ================"
8633 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
8635 run_test 61b "mmap() of unstriped file is successful"
8637 # bug 2330 - insufficient obd_match error checking causes LBUG
8639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8643 cancel_lru_locks osc
8644 lctl set_param fail_loc=0x405
8645 cat $f && error "cat succeeded, expect -EIO"
8646 lctl set_param fail_loc=0
8648 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
8649 # match every page all of the time.
8650 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
8652 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
8653 # Though this test is irrelevant anymore, it helped to reveal some
8654 # other grant bugs (LU-4482), let's keep it.
8655 test_63a() { # was test_63
8656 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8658 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
8660 for i in `seq 10` ; do
8661 dd if=/dev/zero of=$DIR/f63 bs=8k &
8667 rm -f $DIR/f63 || true
8669 run_test 63a "Verify oig_wait interruption does not crash ======="
8671 # bug 2248 - async write errors didn't return to application on sync
8672 # bug 3677 - async write errors left page locked
8674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8677 lctl set_param debug=-1
8679 # ensure we have a grant to do async writes
8680 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
8683 sync # sync lest earlier test intercept the fail_loc
8685 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8686 lctl set_param fail_loc=0x80000406
8687 $MULTIOP $DIR/$tfile Owy && \
8688 error "sync didn't return ENOMEM"
8689 sync; sleep 2; sync # do a real sync this time to flush page
8690 lctl get_param -n llite.*.dump_page_cache | grep locked && \
8691 error "locked page left in cache after async error" || true
8694 run_test 63b "async write errors should be returned to fsync ==="
8697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8700 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
8702 run_test 64a "verify filter grant calculations (in kernel) ====="
8705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8707 bash oos.sh $MOUNT || error "oos.sh failed: $?"
8709 run_test 64b "check out-of-space detection on client"
8712 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
8714 run_test 64c "verify grant shrink"
8720 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
8723 # this does exactly what osc_request.c:osc_announce_cached() does in
8724 # order to calculate max amount of grants to ask from server
8728 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
8729 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
8731 ((rpc_in_flight++));
8732 nrpages=$((nrpages * rpc_in_flight))
8734 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
8736 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
8738 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
8739 local undirty=$((nrpages * PAGE_SIZE))
8741 local max_extent_pages
8742 max_extent_pages=$(import_param $tgt grant_max_extent_size)
8743 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
8744 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
8745 local grant_extent_tax
8746 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8748 undirty=$((undirty + nrextents * grant_extent_tax))
8753 # this is size of unit for grant allocation. It should be equal to
8754 # what tgt_grant.c:tgt_grant_chunk() calculates
8758 local grant_extent_tax
8760 max_brw_size=$(import_param $tgt max_brw_size)
8762 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8764 echo $(((max_brw_size + grant_extent_tax) * 2))
8768 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
8769 skip "OST < 2.10.55 doesn't limit grants enough"
8771 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
8773 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
8774 skip "no grant_param connect flag"
8776 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8778 $LCTL set_param -n -n debug="$OLDDEBUG" || true
8779 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8782 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
8783 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
8785 $LFS setstripe $DIR/$tfile -i 0 -c 1
8786 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
8789 while kill -0 $ddpid; do
8790 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8792 if [[ $cur_grant -gt $max_cur_granted ]]; then
8794 error "cur_grant $cur_grant > $max_cur_granted"
8800 run_test 64d "check grant limit exceed"
8806 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8808 ((cur_grants == expected)) ||
8809 error "$msg: grants mismatch: $cur_grants, expected $expected"
8813 echo $((($1 + $2 - 1) & ~($2 - 1)))
8817 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8818 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
8819 skip "Need OSS version at least 2.11.56"
8821 # Remount client to reset grant
8822 remount_client $MOUNT || error "failed to remount client"
8823 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8825 local init_grants=$(import_param $osc_tgt initial_grant)
8827 check_grants $osc_tgt $init_grants "init grants"
8829 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8830 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8831 local gbs=$(import_param $osc_tgt grant_block_size)
8833 # write random number of bytes from max_brw_size / 4 to max_brw_size
8834 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
8835 # align for direct io
8836 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
8837 # round to grant consumption unit
8838 local wb_round_up=$(round_up_p2 $write_bytes gbs)
8840 local grants=$((wb_round_up + extent_tax))
8842 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8844 # define OBD_FAIL_TGT_NO_GRANT 0x725
8845 # make the server not grant more back
8846 do_facet ost1 $LCTL set_param fail_loc=0x725
8847 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
8849 do_facet ost1 $LCTL set_param fail_loc=0
8851 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
8853 rm -f $DIR/$tfile || error "rm failed"
8855 # Remount client to reset grant
8856 remount_client $MOUNT || error "failed to remount client"
8857 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8859 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8861 # define OBD_FAIL_TGT_NO_GRANT 0x725
8862 # make the server not grant more back
8863 do_facet ost1 $LCTL set_param fail_loc=0x725
8864 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
8865 do_facet ost1 $LCTL set_param fail_loc=0
8867 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
8869 run_test 64e "check grant consumption (no grant allocation)"
8872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8874 # Remount client to reset grant
8875 remount_client $MOUNT || error "failed to remount client"
8876 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8878 local init_grants=$(import_param $osc_tgt initial_grant)
8879 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8880 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8881 local gbs=$(import_param $osc_tgt grant_block_size)
8882 local chunk=$(grant_chunk $osc_tgt)
8884 # write random number of bytes from max_brw_size / 4 to max_brw_size
8885 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
8886 # align for direct io
8887 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
8888 # round to grant consumption unit
8889 local wb_round_up=$(round_up_p2 $write_bytes gbs)
8891 local grants=$((wb_round_up + extent_tax))
8893 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8894 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
8895 error "error writing to $DIR/$tfile"
8897 check_grants $osc_tgt $((init_grants - grants + chunk)) \
8898 "direct io with grant allocation"
8900 rm -f $DIR/$tfile || error "rm failed"
8902 # Remount client to reset grant
8903 remount_client $MOUNT || error "failed to remount client"
8904 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8906 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
8908 local cmd="oO_WRONLY:w${write_bytes}_yc"
8910 $MULTIOP $DIR/$tfile $cmd &
8914 check_grants $osc_tgt $((init_grants - grants)) \
8915 "buffered io, not write rpc"
8917 kill -USR1 $MULTIPID
8920 check_grants $osc_tgt $((init_grants - grants + chunk)) \
8921 "buffered io, one RPC"
8923 run_test 64f "check grant consumption (with grant allocation)"
8926 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
8927 skip "Need MDS version at least 2.14.56"
8929 local mdts=$(comma_list $(mdts_nodes))
8931 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
8933 stack_trap "$LCTL set_param $old"
8935 # generate dirty pages and increase dirty granted on MDT
8936 stack_trap "rm -f $DIR/$tfile-*"
8937 for (( i = 0; i < 10; i++)); do
8938 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
8939 error "can't set stripe"
8940 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
8942 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
8943 $LFS getstripe $DIR/$tfile-$i
8944 error "not DoM file"
8951 # wait until grant shrink reset grant dirty on MDTs
8952 for ((i = 0; i < 120; i++)); do
8953 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
8954 awk '{sum=sum+$1} END {print sum}')
8955 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
8956 echo "$grant_dirty grants, $vm_dirty pages"
8957 (( grant_dirty + vm_dirty == 0 )) && break
8958 (( i == 3 )) && sync &&
8959 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
8963 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
8964 awk '{sum=sum+$1} END {print sum}')
8965 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
8967 run_test 64g "grant shrink on MDT"
8970 local instance=$($LFS getname -i $DIR)
8971 local osc_tgt="$FSNAME-OST0000-osc-$instance"
8972 local num_exps=$(do_facet ost1 \
8973 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
8974 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8975 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
8976 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8978 # 10MiB is for file to be written, max_brw_size * 16 *
8979 # num_exps is space reserve so that tgt_grant_shrink() decided
8981 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
8982 (( avail * 1024 < expect )) &&
8983 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
8985 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
8986 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
8987 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
8988 $LCTL set_param osc.*OST0000*.grant_shrink=1
8989 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
8991 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8992 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
8994 # drop cache so that coming read would do rpc
8995 cancel_lru_locks osc
8997 # shrink interval is set to 10, pause for 7 seconds so that
8998 # grant thread did not wake up yet but coming read entered
8999 # shrink mode for rpc (osc_should_shrink_grant())
9002 declare -a cur_grant_bytes
9003 declare -a tot_granted
9004 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9005 tot_granted[0]=$(do_facet ost1 \
9006 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9008 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9010 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9011 tot_granted[1]=$(do_facet ost1 \
9012 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9014 # grant change should be equal on both sides
9015 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9016 tot_granted[0] - tot_granted[1])) ||
9017 error "grant change mismatch, " \
9018 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9019 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9021 run_test 64h "grant shrink on read"
9024 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
9025 skip "need OST at least 2.14.55 to avoid grant shrink on replay"
9027 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9028 remote_ost_nodsh && skip "remote OSTs with nodsh"
9030 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9032 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9034 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9035 local instance=$($LFS getname -i $DIR)
9037 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9038 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9040 # shrink grants and simulate rpc loss
9041 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9042 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9043 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9047 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9049 local testid=$(echo $TESTNAME | tr '_' ' ')
9051 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9052 grep "GRANT, real grant" &&
9053 error "client has more grants then it owns" || true
9055 run_test 64i "shrink on reconnect"
9057 # bug 1414 - set/get directories' stripe info
9059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9061 test_mkdir $DIR/$tdir
9063 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9065 run_test 65a "directory with no stripe info"
9068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9070 test_mkdir $DIR/$tdir
9071 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9073 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9076 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9078 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9082 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9084 test_mkdir $DIR/$tdir
9085 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9087 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9088 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9090 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9092 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9095 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9097 test_mkdir $DIR/$tdir
9098 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9099 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9101 if [[ $STRIPECOUNT -le 0 ]]; then
9103 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9104 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9105 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9107 sc=$(($STRIPECOUNT - 1))
9109 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9110 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9111 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9112 error "lverify failed"
9114 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9117 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9119 test_mkdir $DIR/$tdir
9121 $LFS setstripe $DIR/$tdir || error "setstripe"
9122 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9123 error "no stripe info failed"
9125 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9127 run_test 65e "directory setstripe defaults"
9130 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9132 test_mkdir $DIR/${tdir}f
9133 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9134 error "setstripe succeeded" || true
9136 run_test 65f "dir setstripe permission (should return error) ==="
9139 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9141 test_mkdir $DIR/$tdir
9142 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9144 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9145 error "setstripe -S failed"
9146 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9147 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9148 error "delete default stripe failed"
9150 run_test 65g "directory setstripe -d"
9153 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9155 test_mkdir $DIR/$tdir
9156 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9158 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9159 error "setstripe -S failed"
9160 test_mkdir $DIR/$tdir/dd1
9161 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9162 error "stripe info inherit failed"
9164 run_test 65h "directory stripe info inherit ===================="
9167 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9169 save_layout_restore_at_exit $MOUNT
9171 # bug6367: set non-default striping on root directory
9172 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
9174 # bug12836: getstripe on -1 default directory striping
9175 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
9177 # bug12836: getstripe -v on -1 default directory striping
9178 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
9180 # bug12836: new find on -1 default directory striping
9181 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
9183 run_test 65i "various tests to set root directory striping"
9185 test_65j() { # bug6367
9186 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9190 # if we aren't already remounting for each test, do so for this test
9191 if [ "$I_MOUNTED" = "yes" ]; then
9192 cleanup || error "failed to unmount"
9196 save_layout_restore_at_exit $MOUNT
9198 $LFS setstripe -d $MOUNT || error "setstripe failed"
9200 run_test 65j "set default striping on root directory (bug 6367)="
9204 wait_delete_completed
9205 do_facet $SINGLEMDS "lctl set_param -n \
9206 osp.$ost*MDT0000.max_create_count=$max_count"
9207 do_facet $SINGLEMDS "lctl set_param -n \
9208 osp.$ost*MDT0000.create_count=$count"
9209 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9210 echo $INACTIVE_OSC "is Activate"
9212 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9215 test_65k() { # bug11679
9216 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9217 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9218 remote_mds_nodsh && skip "remote MDS with nodsh"
9220 local disable_precreate=true
9221 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
9222 disable_precreate=false
9224 echo "Check OST status: "
9225 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
9226 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
9228 for OSC in $MDS_OSCS; do
9229 echo $OSC "is active"
9230 do_facet $SINGLEMDS lctl --device %$OSC activate
9233 for INACTIVE_OSC in $MDS_OSCS; do
9234 local ost=$(osc_to_ost $INACTIVE_OSC)
9235 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
9236 lov.*md*.target_obd |
9237 awk -F: /$ost/'{ print $1 }' | head -n 1)
9240 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
9241 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
9243 echo "Deactivate: " $INACTIVE_OSC
9244 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
9246 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
9247 osp.$ost*MDT0000.create_count")
9248 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
9249 osp.$ost*MDT0000.max_create_count")
9250 $disable_precreate &&
9251 do_facet $SINGLEMDS "lctl set_param -n \
9252 osp.$ost*MDT0000.max_create_count=0"
9254 for idx in $(seq 0 $((OSTCOUNT - 1))); do
9255 [ -f $DIR/$tdir/$idx ] && continue
9256 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
9257 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
9259 error "setstripe $idx should succeed"; }
9260 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
9262 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
9265 do_facet $SINGLEMDS "lctl set_param -n \
9266 osp.$ost*MDT0000.max_create_count=$max_count"
9267 do_facet $SINGLEMDS "lctl set_param -n \
9268 osp.$ost*MDT0000.create_count=$count"
9269 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9270 echo $INACTIVE_OSC "is Activate"
9272 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9275 run_test 65k "validate manual striping works properly with deactivated OSCs"
9277 test_65l() { # bug 12836
9278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9280 test_mkdir -p $DIR/$tdir/test_dir
9281 $LFS setstripe -c -1 $DIR/$tdir/test_dir
9282 $LFS find -mtime -1 $DIR/$tdir >/dev/null
9284 run_test 65l "lfs find on -1 stripe dir ========================"
9287 local layout=$(save_layout $MOUNT)
9288 $RUNAS $LFS setstripe -c 2 $MOUNT && {
9289 restore_layout $MOUNT $layout
9290 error "setstripe should fail by non-root users"
9294 run_test 65m "normal user can't set filesystem default stripe"
9297 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
9298 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
9299 skip "Need MDS version at least 2.12.50"
9300 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9302 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
9303 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
9304 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
9306 save_layout_restore_at_exit $MOUNT
9308 # new subdirectory under root directory should not inherit
9309 # the default layout from root
9310 local dir1=$MOUNT/$tdir-1
9311 mkdir $dir1 || error "mkdir $dir1 failed"
9312 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
9313 error "$dir1 shouldn't have LOV EA"
9315 # delete the default layout on root directory
9316 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
9318 local dir2=$MOUNT/$tdir-2
9319 mkdir $dir2 || error "mkdir $dir2 failed"
9320 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
9321 error "$dir2 shouldn't have LOV EA"
9323 # set a new striping pattern on root directory
9324 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9325 local new_def_stripe_size=$((def_stripe_size * 2))
9326 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
9327 error "set stripe size on $MOUNT failed"
9329 # new file created in $dir2 should inherit the new stripe size from
9330 # the filesystem default
9331 local file2=$dir2/$tfile-2
9332 touch $file2 || error "touch $file2 failed"
9334 local file2_stripe_size=$($LFS getstripe -S $file2)
9335 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
9337 echo "file2_stripe_size: '$file2_stripe_size'"
9338 echo "new_def_stripe_size: '$new_def_stripe_size'"
9339 error "$file2 didn't inherit stripe size $new_def_stripe_size"
9342 local dir3=$MOUNT/$tdir-3
9343 mkdir $dir3 || error "mkdir $dir3 failed"
9344 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
9345 # the root layout, which is the actual default layout that will be used
9346 # when new files are created in $dir3.
9347 local dir3_layout=$(get_layout_param $dir3)
9348 local root_dir_layout=$(get_layout_param $MOUNT)
9349 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
9351 echo "dir3_layout: '$dir3_layout'"
9352 echo "root_dir_layout: '$root_dir_layout'"
9353 error "$dir3 should show the default layout from $MOUNT"
9356 # set OST pool on root directory
9357 local pool=$TESTNAME
9358 pool_add $pool || error "add $pool failed"
9359 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9360 error "add targets to $pool failed"
9362 $LFS setstripe -p $pool $MOUNT ||
9363 error "set OST pool on $MOUNT failed"
9365 # new file created in $dir3 should inherit the pool from
9366 # the filesystem default
9367 local file3=$dir3/$tfile-3
9368 touch $file3 || error "touch $file3 failed"
9370 local file3_pool=$($LFS getstripe -p $file3)
9371 [[ "$file3_pool" = "$pool" ]] ||
9372 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
9374 local dir4=$MOUNT/$tdir-4
9375 mkdir $dir4 || error "mkdir $dir4 failed"
9376 local dir4_layout=$(get_layout_param $dir4)
9377 root_dir_layout=$(get_layout_param $MOUNT)
9378 echo "$LFS getstripe -d $dir4"
9379 $LFS getstripe -d $dir4
9380 echo "$LFS getstripe -d $MOUNT"
9381 $LFS getstripe -d $MOUNT
9382 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
9384 echo "dir4_layout: '$dir4_layout'"
9385 echo "root_dir_layout: '$root_dir_layout'"
9386 error "$dir4 should show the default layout from $MOUNT"
9389 # new file created in $dir4 should inherit the pool from
9390 # the filesystem default
9391 local file4=$dir4/$tfile-4
9392 touch $file4 || error "touch $file4 failed"
9394 local file4_pool=$($LFS getstripe -p $file4)
9395 [[ "$file4_pool" = "$pool" ]] ||
9396 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9398 # new subdirectory under non-root directory should inherit
9399 # the default layout from its parent directory
9400 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9401 error "set directory layout on $dir4 failed"
9403 local dir5=$dir4/$tdir-5
9404 mkdir $dir5 || error "mkdir $dir5 failed"
9406 dir4_layout=$(get_layout_param $dir4)
9407 local dir5_layout=$(get_layout_param $dir5)
9408 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9410 echo "dir4_layout: '$dir4_layout'"
9411 echo "dir5_layout: '$dir5_layout'"
9412 error "$dir5 should inherit the default layout from $dir4"
9415 # though subdir under ROOT doesn't inherit default layout, but
9416 # its sub dir/file should be created with default layout.
9417 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9418 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9419 skip "Need MDS version at least 2.12.59"
9421 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9422 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9423 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9425 if [ $default_lmv_hash == "none" ]; then
9426 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9428 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9429 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9432 $LFS setdirstripe -D -c 2 $MOUNT ||
9433 error "setdirstripe -D -c 2 failed"
9434 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9435 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9436 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9438 # $dir4 layout includes pool
9439 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
9440 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9441 error "pool lost on setstripe"
9442 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
9443 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9444 error "pool lost on compound layout setstripe"
9446 run_test 65n "don't inherit default layout from root for new subdirectories"
9448 # bug 2543 - update blocks count on client
9450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9453 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
9454 sync; sync_all_data; sync; sync_all_data
9455 cancel_lru_locks osc
9456 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
9457 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
9459 run_test 66 "update inode blocks count on client ==============="
9462 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
9466 swapon -s | awk '($1 == "'$1'") { print $4 }'
9469 # bug5265, obdfilter oa2dentry return -ENOENT
9470 # #define OBD_FAIL_SRV_ENOENT 0x217
9472 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9473 remote_ost_nodsh && skip "remote OST with nodsh"
9476 $LFS setstripe -c 1 -i 0 $f
9478 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
9480 do_facet ost1 lctl set_param fail_loc=0x217
9481 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
9482 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
9484 do_facet ost1 lctl set_param fail_loc=0
9485 $DIRECTIO write $f 0 2 || error "write error"
9487 cancel_lru_locks osc
9488 $DIRECTIO read $f 0 1 || error "read error"
9490 do_facet ost1 lctl set_param fail_loc=0x217
9491 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
9493 do_facet ost1 lctl set_param fail_loc=0
9496 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
9499 test_mkdir $DIR/$tdir
9500 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
9501 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
9503 run_test 71 "Running dbench on lustre (don't segment fault) ===="
9505 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
9506 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9507 [ "$RUNAS_ID" = "$UID" ] &&
9508 skip_env "RUNAS_ID = UID = $UID -- skipping"
9509 # Check that testing environment is properly set up. Skip if not
9510 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
9511 skip_env "User $RUNAS_ID does not exist - skipping"
9514 chmod 777 $DIR/$tfile
9515 chmod ug+s $DIR/$tfile
9516 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
9517 error "$RUNAS dd $DIR/$tfile failed"
9518 # See if we are still setuid/sgid
9519 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9520 error "S/gid is not dropped on write"
9521 # Now test that MDS is updated too
9522 cancel_lru_locks mdc
9523 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9524 error "S/gid is not dropped on MDS"
9527 run_test 72a "Test that remove suid works properly (bug5695) ===="
9529 test_72b() { # bug 24226 -- keep mode setting when size is not changing
9532 [ "$RUNAS_ID" = "$UID" ] &&
9533 skip_env "RUNAS_ID = UID = $UID -- skipping"
9534 [ "$RUNAS_ID" -eq 0 ] &&
9535 skip_env "RUNAS_ID = 0 -- skipping"
9536 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9537 # Check that testing environment is properly set up. Skip if not
9538 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
9539 skip_env "User $RUNAS_ID does not exist - skipping"
9541 touch $DIR/${tfile}-f{g,u}
9542 test_mkdir $DIR/${tfile}-dg
9543 test_mkdir $DIR/${tfile}-du
9544 chmod 770 $DIR/${tfile}-{f,d}{g,u}
9545 chmod g+s $DIR/${tfile}-{f,d}g
9546 chmod u+s $DIR/${tfile}-{f,d}u
9547 for perm in 777 2777 4777; do
9548 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
9549 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
9550 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
9551 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
9555 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
9557 # bug 3462 - multiple simultaneous MDC requests
9559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9561 test_mkdir $DIR/d73-1
9562 test_mkdir $DIR/d73-2
9563 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
9566 lctl set_param fail_loc=0x80000129
9567 $MULTIOP $DIR/d73-1/f73-2 Oc &
9569 lctl set_param fail_loc=0
9571 $MULTIOP $DIR/d73-2/f73-3 Oc &
9575 wait $pid1 || return 1
9579 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
9580 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
9581 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
9585 run_test 73 "multiple MDC requests (should not deadlock)"
9587 test_74a() { # bug 6149, 6184
9588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9591 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9593 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9594 # will spin in a tight reconnection loop
9595 $LCTL set_param fail_loc=0x8000030e
9596 # get any lock that won't be difficult - lookup works.
9598 $LCTL set_param fail_loc=0
9602 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
9604 test_74b() { # bug 13310
9605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9607 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9609 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9610 # will spin in a tight reconnection loop
9611 $LCTL set_param fail_loc=0x8000030e
9612 # get a "difficult" lock
9614 $LCTL set_param fail_loc=0
9618 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
9621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9623 #define OBD_FAIL_LDLM_NEW_LOCK
9624 $LCTL set_param fail_loc=0x319
9625 touch $DIR/$tfile && error "touch successful"
9626 $LCTL set_param fail_loc=0
9629 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
9631 slab_lic=/sys/kernel/slab/lustre_inode_cache
9633 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
9634 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
9635 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
9638 test_76a() { # Now for b=20433, added originally in b=1443
9639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9641 cancel_lru_locks osc
9642 # there may be some slab objects cached per core
9643 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
9644 local before=$(num_objects)
9645 local count=$((512 * cpus))
9646 [ "$SLOW" = "no" ] && count=$((128 * cpus))
9647 local margin=$((count / 10))
9648 if [[ -f $slab_lic/aliases ]]; then
9649 local aliases=$(cat $slab_lic/aliases)
9650 (( aliases > 0 )) && margin=$((margin * aliases))
9653 echo "before slab objects: $before"
9654 for i in $(seq $count); do
9658 cancel_lru_locks osc
9659 local after=$(num_objects)
9660 echo "created: $count, after slab objects: $after"
9661 # shared slab counts are not very accurate, allow significant margin
9662 # the main goal is that the cache growth is not permanently > $count
9663 while (( after > before + margin )); do
9665 after=$(num_objects)
9667 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9668 if (( wait > 60 )); then
9669 error "inode slab grew from $before+$margin to $after"
9673 run_test 76a "confirm clients recycle inodes properly ===="
9676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9677 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
9680 local before=$(num_objects)
9682 for i in $(seq $count); do
9687 local after=$(num_objects)
9690 while (( after > before )); do
9692 after=$(num_objects)
9694 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9695 if (( wait > 60 )); then
9696 error "inode slab grew from $before to $after"
9700 echo "slab objects before: $before, after: $after"
9702 run_test 76b "confirm clients recycle directory inodes properly ===="
9707 # Note: in sptlrpc modes which enable its own bulk checksum, the
9708 # original crc32_le bulk checksum will be automatically disabled,
9709 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
9710 # will be checked by sptlrpc code against sptlrpc bulk checksum.
9711 # In this case set_checksums() will not be no-op, because sptlrpc
9712 # bulk checksum will be enabled all through the test.
9714 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
9715 lctl set_param -n osc.*.checksums $1
9719 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9720 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
9721 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9722 tr -d [] | head -n1)}
9725 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
9727 log "set checksum type to $1, rc = $rc"
9731 get_osc_checksum_type()
9733 # arugment 1: OST name, like OST0000
9735 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
9736 sed 's/.*\[\(.*\)\].*/\1/g')
9738 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
9742 F77_TMP=$TMP/f77-temp
9745 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
9746 error "error writing to $F77_TMP"
9749 test_77a() { # bug 10889
9750 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9751 $GSS && skip_env "could not run with gss"
9753 [ ! -f $F77_TMP ] && setup_f77
9755 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
9759 run_test 77a "normal checksum read/write operation"
9761 test_77b() { # bug 10889
9762 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9763 $GSS && skip_env "could not run with gss"
9765 [ ! -f $F77_TMP ] && setup_f77
9766 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9767 $LCTL set_param fail_loc=0x80000409
9770 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9771 error "dd error: $?"
9772 $LCTL set_param fail_loc=0
9774 for algo in $CKSUM_TYPES; do
9775 cancel_lru_locks osc
9776 set_checksum_type $algo
9777 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9778 $LCTL set_param fail_loc=0x80000408
9779 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
9780 $LCTL set_param fail_loc=0
9783 set_checksum_type $ORIG_CSUM_TYPE
9786 run_test 77b "checksum error on client write, read"
9791 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
9793 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
9794 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
9795 $check_ost && [ -n "$ost_file_prefix" ] &&
9796 do_facet ost1 rm -f ${ost_file_prefix}\*
9800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9801 $GSS && skip_env "could not run with gss"
9802 remote_ost_nodsh && skip "remote OST with nodsh"
9805 local osc_file_prefix
9807 local check_ost=false
9808 local ost_file_prefix
9814 # ensure corruption will occur on first OSS/OST
9815 $LFS setstripe -i 0 $DIR/$tfile
9817 [ ! -f $F77_TMP ] && setup_f77
9818 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9819 error "dd write error: $?"
9820 fid=$($LFS path2fid $DIR/$tfile)
9822 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
9825 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
9826 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
9828 echo "OSS do not support bulk pages dump upon error"
9831 osc_file_prefix=$($LCTL get_param -n debug_path)
9832 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
9834 trap cleanup_77c EXIT
9837 # enable bulk pages dump upon error on Client
9838 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
9839 # enable bulk pages dump upon error on OSS
9841 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
9843 # flush Client cache to allow next read to reach OSS
9844 cancel_lru_locks osc
9846 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9847 $LCTL set_param fail_loc=0x80000408
9848 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
9849 $LCTL set_param fail_loc=0
9853 # check cksum dump on Client
9854 osc_file=$(ls ${osc_file_prefix}*)
9855 [ -n "$osc_file" ] || error "no checksum dump file on Client"
9856 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
9857 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
9858 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
9859 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
9861 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
9862 [[ "$orig_cksum" == "$dump_cksum" ]] ||
9863 error "dump content does not match on Client"
9865 $check_ost || skip "No need to check cksum dump on OSS"
9867 # check cksum dump on OSS
9868 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
9869 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
9870 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
9871 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
9872 [[ "$orig_cksum" == "$dump_cksum" ]] ||
9873 error "dump content does not match on OSS"
9877 run_test 77c "checksum error on client read with debug"
9879 test_77d() { # bug 10889
9880 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9881 $GSS && skip_env "could not run with gss"
9883 stack_trap "rm -f $DIR/$tfile"
9884 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9885 $LCTL set_param fail_loc=0x80000409
9887 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
9888 error "direct write: rc=$?"
9889 $LCTL set_param fail_loc=0
9892 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9893 $LCTL set_param fail_loc=0x80000408
9895 cancel_lru_locks osc
9896 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
9897 error "direct read: rc=$?"
9898 $LCTL set_param fail_loc=0
9901 run_test 77d "checksum error on OST direct write, read"
9903 test_77f() { # bug 10889
9904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9905 $GSS && skip_env "could not run with gss"
9908 stack_trap "rm -f $DIR/$tfile"
9909 for algo in $CKSUM_TYPES; do
9910 cancel_lru_locks osc
9911 set_checksum_type $algo
9912 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9913 $LCTL set_param fail_loc=0x409
9914 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
9915 error "direct write succeeded"
9916 $LCTL set_param fail_loc=0
9918 set_checksum_type $ORIG_CSUM_TYPE
9921 run_test 77f "repeat checksum error on write (expect error)"
9923 test_77g() { # bug 10889
9924 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9925 $GSS && skip_env "could not run with gss"
9926 remote_ost_nodsh && skip "remote OST with nodsh"
9928 [ ! -f $F77_TMP ] && setup_f77
9930 local file=$DIR/$tfile
9931 stack_trap "rm -f $file" EXIT
9933 $LFS setstripe -c 1 -i 0 $file
9934 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
9935 do_facet ost1 lctl set_param fail_loc=0x8000021a
9937 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
9938 error "write error: rc=$?"
9939 do_facet ost1 lctl set_param fail_loc=0
9942 cancel_lru_locks osc
9943 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
9944 do_facet ost1 lctl set_param fail_loc=0x8000021b
9946 cmp $F77_TMP $file || error "file compare failed"
9947 do_facet ost1 lctl set_param fail_loc=0
9950 run_test 77g "checksum error on OST write, read"
9952 test_77k() { # LU-10906
9953 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9954 $GSS && skip_env "could not run with gss"
9956 local cksum_param="osc.$FSNAME*.checksums"
9957 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
9961 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
9962 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
9963 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
9966 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
9967 error "failed to set checksum=$i on MGS"
9968 wait_update $HOSTNAME "$get_checksum" $i
9970 echo "remount client, checksum should be $i"
9971 remount_client $MOUNT || error "failed to remount client"
9972 checksum=$(eval $get_checksum)
9973 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
9975 # remove persistent param to avoid races with checksum mountopt below
9976 do_facet mgs $LCTL set_param -P -d $cksum_param ||
9977 error "failed to delete checksum on MGS"
9979 for opt in "checksum" "nochecksum"; do
9980 #remount with mount option
9981 echo "remount client with option $opt, checksum should be $i"
9982 umount_client $MOUNT || error "failed to umount client"
9983 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
9984 error "failed to mount client with option '$opt'"
9985 checksum=$(eval $get_checksum)
9986 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
9990 remount_client $MOUNT || error "failed to remount client"
9992 run_test 77k "enable/disable checksum correctly"
9995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9996 $GSS && skip_env "could not run with gss"
9999 stack_trap "set_checksums $ORIG_CSUM" EXIT
10000 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10002 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10004 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10005 for algo in $CKSUM_TYPES; do
10006 set_checksum_type $algo || error "fail to set checksum type $algo"
10007 osc_algo=$(get_osc_checksum_type OST0000)
10008 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10010 # no locks, no reqs to let the connection idle
10011 cancel_lru_locks osc
10012 lru_resize_disable osc
10013 wait_osc_import_state client ost1 IDLE
10015 # ensure ost1 is connected
10016 stat $DIR/$tfile >/dev/null || error "can't stat"
10017 wait_osc_import_state client ost1 FULL
10019 osc_algo=$(get_osc_checksum_type OST0000)
10020 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10024 run_test 77l "preferred checksum type is remembered after reconnected"
10026 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10031 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10032 skip "Need at least version 2.14.52"
10033 local param=checksum_speed
10035 $LCTL get_param $param || error "reading $param failed"
10037 csum_speeds=$($LCTL get_param -n $param)
10039 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10040 error "known checksum types are missing"
10042 run_test 77m "Verify checksum_speed is correctly read"
10044 check_filefrag_77n() {
10049 while read extidx a b start end rest; do
10050 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10051 nr_ext=$(( $nr_ext + 1 ))
10052 starts+=( ${start%..} )
10055 done < <( filefrag -sv $1 )
10057 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10062 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10065 $TRUNCATE $DIR/$tfile 0
10066 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10067 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10068 check_filefrag_77n $DIR/$tfile ||
10069 skip "$tfile blocks not contiguous around hole"
10072 stack_trap "set_checksums $ORIG_CSUM" EXIT
10073 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10074 stack_trap "rm -f $DIR/$tfile"
10076 for algo in $CKSUM_TYPES; do
10077 if [[ "$algo" =~ ^t10 ]]; then
10078 set_checksum_type $algo ||
10079 error "fail to set checksum type $algo"
10080 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
10081 error "fail to read $tfile with $algo"
10087 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
10090 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
10091 skip "Need MDS version at least 2.14.55"
10092 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
10093 skip "Need OST version at least 2.14.55"
10094 local ofd=obdfilter
10097 # print OST checksum_type
10098 echo "$ofd.$FSNAME-*.checksum_type:"
10099 do_nodes $(comma_list $(osts_nodes)) \
10100 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
10102 # print MDT checksum_type
10103 echo "$mdt.$FSNAME-*.checksum_type:"
10104 do_nodes $(comma_list $(mdts_nodes)) \
10105 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
10107 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
10108 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
10110 (( $o_count == $OSTCOUNT )) ||
10111 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
10113 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
10114 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
10116 (( $m_count == $MDSCOUNT )) ||
10117 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
10119 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
10121 cleanup_test_78() {
10126 test_78() { # bug 10901
10127 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10128 remote_ost || skip_env "local OST"
10131 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
10132 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
10133 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
10134 echo "MemTotal: $MEMTOTAL"
10136 # reserve 256MB of memory for the kernel and other running processes,
10137 # and then take 1/2 of the remaining memory for the read/write buffers.
10138 if [ $MEMTOTAL -gt 512 ] ;then
10139 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
10141 # for those poor memory-starved high-end clusters...
10142 MEMTOTAL=$((MEMTOTAL / 2))
10144 echo "Mem to use for directio: $MEMTOTAL"
10146 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
10147 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
10148 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
10149 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
10151 echo "Smallest OST: $SMALLESTOST"
10152 [[ $SMALLESTOST -lt 10240 ]] &&
10153 skip "too small OSTSIZE, useless to run large O_DIRECT test"
10155 trap cleanup_test_78 EXIT
10157 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
10158 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
10160 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
10161 echo "File size: $F78SIZE"
10162 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
10163 for i in $(seq 1 $NSEQ); do
10164 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
10165 echo directIO rdwr round $i of $NSEQ
10166 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
10171 run_test 78 "handle large O_DIRECT writes correctly ============"
10173 test_79() { # bug 12743
10174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10176 wait_delete_completed
10178 BKTOTAL=$(calc_osc_kbytes kbytestotal)
10179 BKFREE=$(calc_osc_kbytes kbytesfree)
10180 BKAVAIL=$(calc_osc_kbytes kbytesavail)
10182 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
10183 DFTOTAL=`echo $STRING | cut -d, -f1`
10184 DFUSED=`echo $STRING | cut -d, -f2`
10185 DFAVAIL=`echo $STRING | cut -d, -f3`
10186 DFFREE=$(($DFTOTAL - $DFUSED))
10188 ALLOWANCE=$((64 * $OSTCOUNT))
10190 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
10191 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
10192 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
10194 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
10195 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
10196 error "df free($DFFREE) mismatch OST free($BKFREE)"
10198 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
10199 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
10200 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
10203 run_test 79 "df report consistency check ======================="
10205 test_80() { # bug 10718
10206 remote_ost_nodsh && skip "remote OST with nodsh"
10207 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10209 # relax strong synchronous semantics for slow backends like ZFS
10210 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
10211 local soc="obdfilter.*.sync_lock_cancel"
10212 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10214 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
10215 if [ -z "$save" ]; then
10216 soc="obdfilter.*.sync_on_lock_cancel"
10217 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10220 if [ "$save" != "never" ]; then
10221 local hosts=$(comma_list $(osts_nodes))
10223 do_nodes $hosts $LCTL set_param $soc=never
10224 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
10228 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
10229 sync; sleep 1; sync
10230 local before=$(date +%s)
10231 cancel_lru_locks osc
10232 local after=$(date +%s)
10233 local diff=$((after - before))
10234 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
10238 run_test 80 "Page eviction is equally fast at high offsets too"
10240 test_81a() { # LU-456
10241 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10242 remote_ost_nodsh && skip "remote OST with nodsh"
10244 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10245 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
10246 do_facet ost1 lctl set_param fail_loc=0x80000228
10248 # write should trigger a retry and success
10249 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10250 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10252 if [ $RC -ne 0 ] ; then
10253 error "write should success, but failed for $RC"
10256 run_test 81a "OST should retry write when get -ENOSPC ==============="
10258 test_81b() { # LU-456
10259 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10260 remote_ost_nodsh && skip "remote OST with nodsh"
10262 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10263 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
10264 do_facet ost1 lctl set_param fail_loc=0x228
10266 # write should retry several times and return -ENOSPC finally
10267 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10268 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10271 if [ $RC -ne $ENOSPC ] ; then
10272 error "dd should fail for -ENOSPC, but succeed."
10275 run_test 81b "OST should return -ENOSPC when retry still fails ======="
10278 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
10280 test_mkdir $DIR/$tdir.cvsroot
10281 chown $RUNAS_ID $DIR/$tdir.cvsroot
10284 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
10287 # some versions of cvs import exit(1) when asked to import links or
10288 # files they can't read. ignore those files.
10289 local toignore=$(find . -type l -printf '-I %f\n' -o \
10290 ! -perm /4 -printf '-I %f\n')
10291 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
10292 $tdir.reposname vtag rtag
10295 test_mkdir $DIR/$tdir.reposname
10296 chown $RUNAS_ID $DIR/$tdir.reposname
10297 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
10299 cd $DIR/$tdir.reposname
10301 $RUNAS cvs add -m 'addmsg' foo99
10303 $RUNAS cvs commit -m 'nomsg' foo99
10304 rm -fr $DIR/$tdir.cvsroot
10306 run_test 99 "cvs strange file/directory operations"
10309 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10310 [[ "$NETTYPE" =~ tcp ]] ||
10311 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
10312 remote_ost_nodsh && skip "remote OST with nodsh"
10313 remote_mds_nodsh && skip "remote MDS with nodsh"
10315 skip "useless for local single node setup"
10317 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
10318 [ "$PROT" != "tcp" ] && continue
10319 RPORT=$(echo $REMOTE | cut -d: -f2)
10320 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
10323 LPORT=`echo $LOCAL | cut -d: -f2`
10324 if [ $LPORT -ge 1024 ]; then
10325 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
10327 error_exit "local: $LPORT > 1024, remote: $RPORT"
10330 [ "$rc" = 0 ] || error_exit "privileged port not found" )
10332 run_test 100 "check local port using privileged port ==========="
10334 function get_named_value()
10338 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
10341 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
10342 awk '/^max_cached_mb/ { print $2 }')
10345 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
10350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10355 local cache_limit=32
10357 $LCTL set_param -n osc.*-osc*.rpc_stats=0
10358 trap cleanup_101a EXIT
10359 $LCTL set_param -n llite.*.read_ahead_stats=0
10360 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
10363 # randomly read 10000 of 64K chunks from file 3x 32MB in size
10365 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
10366 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
10369 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
10370 get_named_value 'read.but.discarded'); do
10371 discard=$(($discard + $s))
10375 $LCTL get_param osc.*-osc*.rpc_stats
10376 $LCTL get_param llite.*.read_ahead_stats
10378 # Discard is generally zero, but sometimes a few random reads line up
10379 # and trigger larger readahead, which is wasted & leads to discards.
10380 if [[ $(($discard)) -gt $nreads ]]; then
10381 error "too many ($discard) discarded pages"
10383 rm -f $DIR/$tfile || true
10385 run_test 101a "check read-ahead for random reads"
10387 setup_test101bc() {
10388 test_mkdir $DIR/$tdir
10390 local FILE_LENGTH=$2
10393 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
10395 local list=$(comma_list $(osts_nodes))
10396 set_osd_param $list '' read_cache_enable 0
10397 set_osd_param $list '' writethrough_cache_enable 0
10399 trap cleanup_test101bc EXIT
10400 # prepare the read-ahead file
10401 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
10403 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
10404 count=$FILE_SIZE_MB 2> /dev/null
10408 cleanup_test101bc() {
10413 local list=$(comma_list $(osts_nodes))
10414 set_osd_param $list '' read_cache_enable 1
10415 set_osd_param $list '' writethrough_cache_enable 1
10419 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
10424 local stripe_size=$2
10425 local stride_length=$((stripe_size / read_size))
10426 local stride_width=$((stride_length * OSTCOUNT))
10427 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
10428 (stride_width - stride_length) ))
10429 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
10430 get_named_value 'read.but.discarded' | calc_total)
10432 if [[ $discard -gt $discard_limit ]]; then
10433 $LCTL get_param llite.*.read_ahead_stats
10434 error "($discard) discarded pages with size (${read_size})"
10436 echo "Read-ahead success for size ${read_size}"
10441 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10442 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10444 local STRIPE_SIZE=1048576
10445 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
10447 if [ $SLOW == "yes" ]; then
10448 local FILE_LENGTH=$((STRIDE_SIZE * 64))
10450 local FILE_LENGTH=$((STRIDE_SIZE * 8))
10453 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
10455 # prepare the read-ahead file
10456 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10457 cancel_lru_locks osc
10458 for BIDX in 2 4 8 16 32 64 128 256
10460 local BSIZE=$((BIDX*4096))
10461 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
10462 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
10463 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
10464 $LCTL set_param -n llite.*.read_ahead_stats=0
10465 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
10466 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
10467 cancel_lru_locks osc
10468 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
10473 run_test 101b "check stride-io mode read-ahead ================="
10476 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10478 local STRIPE_SIZE=1048576
10479 local FILE_LENGTH=$((STRIPE_SIZE*100))
10482 local osc_rpc_stats
10484 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10486 cancel_lru_locks osc
10487 $LCTL set_param osc.*.rpc_stats=0
10488 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
10489 $LCTL get_param osc.*.rpc_stats
10490 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
10491 local stats=$($LCTL get_param -n $osc_rpc_stats)
10492 local lines=$(echo "$stats" | awk 'END {print NR;}')
10495 if [ $lines -le 20 ]; then
10496 echo "continue debug"
10499 for size in 1 2 4 8; do
10500 local rpc=$(echo "$stats" |
10501 awk '($1 == "'$size':") {print $2; exit; }')
10502 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
10503 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
10505 echo "$osc_rpc_stats check passed!"
10510 run_test 101c "check stripe_size aligned read-ahead"
10513 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10515 local file=$DIR/$tfile
10516 local sz_MB=${FILESIZE_101d:-80}
10517 local ra_MB=${READAHEAD_MB:-40}
10519 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
10520 [ $free_MB -lt $sz_MB ] &&
10521 skip "Need free space ${sz_MB}M, have ${free_MB}M"
10523 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
10524 $LFS setstripe -c -1 $file || error "setstripe failed"
10526 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
10527 echo Cancel LRU locks on lustre client to flush the client cache
10528 cancel_lru_locks osc
10530 echo Disable read-ahead
10531 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10532 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10533 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
10534 $LCTL get_param -n llite.*.max_read_ahead_mb
10536 echo "Reading the test file $file with read-ahead disabled"
10537 local sz_KB=$((sz_MB * 1024 / 4))
10538 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
10539 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
10540 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10541 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10543 echo "Cancel LRU locks on lustre client to flush the client cache"
10544 cancel_lru_locks osc
10545 echo Enable read-ahead with ${ra_MB}MB
10546 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
10548 echo "Reading the test file $file with read-ahead enabled"
10549 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10550 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10552 echo "read-ahead disabled time read $raOFF"
10553 echo "read-ahead enabled time read $raON"
10556 wait_delete_completed
10558 # use awk for this check instead of bash because it handles decimals
10559 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
10560 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
10562 run_test 101d "file read with and without read-ahead enabled"
10565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10567 local file=$DIR/$tfile
10568 local size_KB=500 #KB
10572 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
10573 local need_KB=$((count * size_KB))
10574 [[ $free_KB -le $need_KB ]] &&
10575 skip_env "Need free space $need_KB, have $free_KB"
10577 echo "Creating $count ${size_KB}K test files"
10578 for ((i = 0; i < $count; i++)); do
10579 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
10582 echo "Cancel LRU locks on lustre client to flush the client cache"
10583 cancel_lru_locks $OSC
10585 echo "Reset readahead stats"
10586 $LCTL set_param -n llite.*.read_ahead_stats=0
10588 for ((i = 0; i < $count; i++)); do
10589 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
10592 $LCTL get_param llite.*.max_cached_mb
10593 $LCTL get_param llite.*.read_ahead_stats
10594 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10595 get_named_value 'misses' | calc_total)
10597 for ((i = 0; i < $count; i++)); do
10598 rm -rf $file.$i 2>/dev/null
10601 #10000 means 20% reads are missing in readahead
10602 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
10604 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
10607 which iozone || skip_env "no iozone installed"
10609 local old_debug=$($LCTL get_param debug)
10610 old_debug=${old_debug#*=}
10611 $LCTL set_param debug="reada mmap"
10613 # create a test file
10614 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
10616 echo Cancel LRU locks on lustre client to flush the client cache
10617 cancel_lru_locks osc
10619 echo Reset readahead stats
10620 $LCTL set_param -n llite.*.read_ahead_stats=0
10622 echo mmap read the file with small block size
10623 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
10626 echo checking missing pages
10627 $LCTL get_param llite.*.read_ahead_stats
10628 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10629 get_named_value 'misses' | calc_total)
10631 $LCTL set_param debug="$old_debug"
10632 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
10635 run_test 101f "check mmap read performance"
10637 test_101g_brw_size_test() {
10639 local pages=$((mb * 1048576 / PAGE_SIZE))
10640 local file=$DIR/$tfile
10642 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
10643 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
10644 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
10645 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
10649 stack_trap "rm -f $file" EXIT
10650 $LCTL set_param -n osc.*.rpc_stats=0
10652 # 10 RPCs should be enough for the test
10654 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
10655 { error "dd write ${mb} MB blocks failed"; return 3; }
10656 cancel_lru_locks osc
10657 dd of=/dev/null if=$file bs=${mb}M count=$count ||
10658 { error "dd write ${mb} MB blocks failed"; return 4; }
10660 # calculate number of full-sized read and write RPCs
10661 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
10662 sed -n '/pages per rpc/,/^$/p' |
10663 awk '/'$pages':/ { reads += $2; writes += $6 }; \
10664 END { print reads,writes }'))
10665 # allow one extra full-sized read RPC for async readahead
10666 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
10667 { error "${rpcs[0]} != $count read RPCs"; return 5; }
10668 [[ ${rpcs[1]} == $count ]] ||
10669 { error "${rpcs[1]} != $count write RPCs"; return 6; }
10673 remote_ost_nodsh && skip "remote OST with nodsh"
10676 local osts=$(get_facets OST)
10677 local list=$(comma_list $(osts_nodes))
10678 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10679 local brw_size="obdfilter.*.brw_size"
10681 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10683 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
10685 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
10686 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
10687 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
10688 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
10689 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
10690 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
10692 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
10695 if [[ $orig_mb -lt 16 ]]; then
10696 save_lustre_params $osts "$brw_size" > $p
10697 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
10698 error "set 16MB RPC size failed"
10700 echo "remount client to enable new RPC size"
10701 remount_client $MOUNT || error "remount_client failed"
10704 test_101g_brw_size_test 16 || error "16MB RPC test failed"
10705 # should be able to set brw_size=12, but no rpc_stats for that
10706 test_101g_brw_size_test 8 || error "8MB RPC test failed"
10709 test_101g_brw_size_test 4 || error "4MB RPC test failed"
10711 if [[ $orig_mb -lt 16 ]]; then
10712 restore_lustre_params < $p
10713 remount_client $MOUNT || error "remount_client restore failed"
10716 rm -f $p $DIR/$tfile
10718 run_test 101g "Big bulk(4/16 MiB) readahead"
10721 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10723 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
10724 error "dd 70M file failed"
10725 echo Cancel LRU locks on lustre client to flush the client cache
10726 cancel_lru_locks osc
10728 echo "Reset readahead stats"
10729 $LCTL set_param -n llite.*.read_ahead_stats 0
10731 echo "Read 10M of data but cross 64M bundary"
10732 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
10733 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10734 get_named_value 'misses' | calc_total)
10735 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
10736 rm -f $p $DIR/$tfile
10738 run_test 101h "Readahead should cover current read window"
10741 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
10742 error "dd 10M file failed"
10744 local max_per_file_mb=$($LCTL get_param -n \
10745 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
10746 cancel_lru_locks osc
10747 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
10748 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
10749 error "set max_read_ahead_per_file_mb to 1 failed"
10751 echo "Reset readahead stats"
10752 $LCTL set_param llite.*.read_ahead_stats=0
10754 dd if=$DIR/$tfile of=/dev/null bs=2M
10756 $LCTL get_param llite.*.read_ahead_stats
10757 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10758 awk '/misses/ { print $2 }')
10759 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
10762 run_test 101i "allow current readahead to exceed reservation"
10765 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
10766 error "setstripe $DIR/$tfile failed"
10767 local file_size=$((1048576 * 16))
10768 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10769 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
10771 echo Disable read-ahead
10772 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10774 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
10775 for blk in $PAGE_SIZE 1048576 $file_size; do
10776 cancel_lru_locks osc
10777 echo "Reset readahead stats"
10778 $LCTL set_param -n llite.*.read_ahead_stats=0
10779 local count=$(($file_size / $blk))
10780 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
10781 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10782 get_named_value 'failed.to.fast.read' | calc_total)
10783 $LCTL get_param -n llite.*.read_ahead_stats
10784 [ $miss -eq $count ] || error "expected $count got $miss"
10787 rm -f $p $DIR/$tfile
10789 run_test 101j "A complete read block should be submitted when no RA"
10792 test_mkdir $DIR/$tdir
10793 chown $RUNAS_ID $DIR/$tdir
10796 STRIPE_COUNT=$OSTCOUNT
10797 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
10799 trap cleanup_test102 EXIT
10801 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
10803 for num in 1 2 3 4; do
10804 for count in $(seq 1 $STRIPE_COUNT); do
10805 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
10806 local size=`expr $STRIPE_SIZE \* $num`
10807 local file=file"$num-$idx-$count"
10808 $1 $LFS setstripe -S $size -i $idx -c $count $file
10814 $1 tar cf $TMP/f102.tar $tdir --xattrs
10817 cleanup_test102() {
10819 rm -f $TMP/f102.tar
10820 rm -rf $DIR/d0.sanity/d102
10824 [ "$UID" != 0 ] && skip "must run as root"
10825 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
10826 skip_env "must have user_xattr"
10828 [ -z "$(which setfattr 2>/dev/null)" ] &&
10829 skip_env "could not find setfattr"
10831 local testfile=$DIR/$tfile
10834 echo "set/get xattr..."
10835 setfattr -n trusted.name1 -v value1 $testfile ||
10836 error "setfattr -n trusted.name1=value1 $testfile failed"
10837 getfattr -n trusted.name1 $testfile 2> /dev/null |
10838 grep "trusted.name1=.value1" ||
10839 error "$testfile missing trusted.name1=value1"
10841 setfattr -n user.author1 -v author1 $testfile ||
10842 error "setfattr -n user.author1=author1 $testfile failed"
10843 getfattr -n user.author1 $testfile 2> /dev/null |
10844 grep "user.author1=.author1" ||
10845 error "$testfile missing trusted.author1=author1"
10847 echo "listxattr..."
10848 setfattr -n trusted.name2 -v value2 $testfile ||
10849 error "$testfile unable to set trusted.name2"
10850 setfattr -n trusted.name3 -v value3 $testfile ||
10851 error "$testfile unable to set trusted.name3"
10852 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
10853 grep "trusted.name" | wc -l) -eq 3 ] ||
10854 error "$testfile missing 3 trusted.name xattrs"
10856 setfattr -n user.author2 -v author2 $testfile ||
10857 error "$testfile unable to set user.author2"
10858 setfattr -n user.author3 -v author3 $testfile ||
10859 error "$testfile unable to set user.author3"
10860 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
10861 grep "user.author" | wc -l) -eq 3 ] ||
10862 error "$testfile missing 3 user.author xattrs"
10864 echo "remove xattr..."
10865 setfattr -x trusted.name1 $testfile ||
10866 error "$testfile error deleting trusted.name1"
10867 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
10868 error "$testfile did not delete trusted.name1 xattr"
10870 setfattr -x user.author1 $testfile ||
10871 error "$testfile error deleting user.author1"
10872 echo "set lustre special xattr ..."
10873 $LFS setstripe -c1 $testfile
10874 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
10875 awk -F "=" '/trusted.lov/ { print $2 }' )
10876 setfattr -n "trusted.lov" -v $lovea $testfile ||
10877 error "$testfile doesn't ignore setting trusted.lov again"
10878 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
10879 error "$testfile allow setting invalid trusted.lov"
10882 run_test 102a "user xattr test =================================="
10884 check_102b_layout() {
10886 local testfile=$DIR/$tfile
10888 echo "test layout '$layout'"
10889 $LFS setstripe $layout $testfile || error "setstripe failed"
10890 $LFS getstripe -y $testfile
10892 echo "get/set/list trusted.lov xattr ..." # b=10930
10893 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
10894 [[ "$value" =~ "trusted.lov" ]] ||
10895 error "can't get trusted.lov from $testfile"
10896 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
10897 error "getstripe failed"
10899 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
10901 value=$(cut -d= -f2 <<<$value)
10902 # LU-13168: truncated xattr should fail if short lov_user_md header
10903 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
10904 lens="${#value}" || lens="$(seq 4 2 ${#value})"
10905 for len in $lens; do
10906 echo "setfattr $len $testfile.2"
10907 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
10908 [ $len -lt 66 ] && error "short xattr len=$len worked"
10910 local stripe_size=$($LFS getstripe -S $testfile.2)
10911 local stripe_count=$($LFS getstripe -c $testfile.2)
10912 [[ $stripe_size -eq 65536 ]] ||
10913 error "stripe size $stripe_size != 65536"
10914 [[ $stripe_count -eq $stripe_count_orig ]] ||
10915 error "stripe count $stripe_count != $stripe_count_orig"
10916 rm $testfile $testfile.2
10920 [ -z "$(which setfattr 2>/dev/null)" ] &&
10921 skip_env "could not find setfattr"
10922 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10924 # check plain layout
10925 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
10927 # and also check composite layout
10928 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
10931 run_test 102b "getfattr/setfattr for trusted.lov EAs"
10934 [ -z "$(which setfattr 2>/dev/null)" ] &&
10935 skip_env "could not find setfattr"
10936 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10938 # b10930: get/set/list lustre.lov xattr
10939 echo "get/set/list lustre.lov xattr ..."
10940 test_mkdir $DIR/$tdir
10941 chown $RUNAS_ID $DIR/$tdir
10942 local testfile=$DIR/$tdir/$tfile
10943 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
10944 error "setstripe failed"
10945 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
10946 error "getstripe failed"
10947 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
10948 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
10950 local testfile2=${testfile}2
10951 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
10952 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
10954 $RUNAS $MCREATE $testfile2
10955 $RUNAS setfattr -n lustre.lov -v $value $testfile2
10956 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
10957 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
10958 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
10959 [ $stripe_count -eq $STRIPECOUNT ] ||
10960 error "stripe count $stripe_count != $STRIPECOUNT"
10962 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
10964 compare_stripe_info1() {
10965 local stripe_index_all_zero=true
10967 for num in 1 2 3 4; do
10968 for count in $(seq 1 $STRIPE_COUNT); do
10969 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
10970 local size=$((STRIPE_SIZE * num))
10971 local file=file"$num-$offset-$count"
10972 stripe_size=$($LFS getstripe -S $PWD/$file)
10973 [[ $stripe_size -ne $size ]] &&
10974 error "$file: size $stripe_size != $size"
10975 stripe_count=$($LFS getstripe -c $PWD/$file)
10976 # allow fewer stripes to be created, ORI-601
10977 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
10978 error "$file: count $stripe_count != $count"
10979 stripe_index=$($LFS getstripe -i $PWD/$file)
10980 [[ $stripe_index -ne 0 ]] &&
10981 stripe_index_all_zero=false
10985 $stripe_index_all_zero &&
10986 error "all files are being extracted starting from OST index 0"
10990 have_xattrs_include() {
10991 tar --help | grep -q xattrs-include &&
10992 echo --xattrs-include="lustre.*"
10996 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10997 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10999 XINC=$(have_xattrs_include)
11001 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11002 cd $DIR/$tdir/$tdir
11003 compare_stripe_info1
11005 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11008 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11009 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11011 XINC=$(have_xattrs_include)
11013 test_mkdir $DIR/$tdir.restore
11015 tar cf - --xattrs $tdir | tar xf - \
11016 -C $DIR/$tdir.restore --xattrs $XINC
11017 cd $DIR/$tdir.restore/$tdir
11018 compare_stripe_info1
11020 run_test 102f "tar copy files, not keep osts"
11023 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11024 skip "must have user_xattr"
11025 [ -z "$(which setfattr 2>/dev/null)" ] &&
11026 skip_env "could not find setfattr"
11027 [ -z "$(which getfattr 2>/dev/null)" ] &&
11028 skip_env "could not find getfattr"
11030 local xsize=${1:-1024} # in bytes
11031 local file=$DIR/$tfile
11032 local value="$(generate_string $xsize)"
11033 local xbig=trusted.big
11037 log "save $xbig on $file"
11038 if [ -z "$toobig" ]
11040 setfattr -n $xbig -v $value $file ||
11041 error "saving $xbig on $file failed"
11043 setfattr -n $xbig -v $value $file &&
11044 error "saving $xbig on $file succeeded"
11048 local orig=$(get_xattr_value $xbig $file)
11049 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
11051 local xsml=trusted.sml
11052 log "save $xsml on $file"
11053 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
11055 local new=$(get_xattr_value $xbig $file)
11056 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
11058 log "grow $xsml on $file"
11059 setfattr -n $xsml -v "$value" $file ||
11060 error "growing $xsml on $file failed"
11062 new=$(get_xattr_value $xbig $file)
11063 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
11064 log "$xbig still valid after growing $xsml"
11069 test_102h() { # bug 15777
11072 run_test 102h "grow xattr from inside inode to external block"
11075 large_xattr_enabled || skip_env "ea_inode feature disabled"
11077 echo "setting xattr of max xattr size: $(max_xattr_size)"
11078 grow_xattr $(max_xattr_size)
11080 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
11081 echo "This should fail:"
11082 grow_xattr $(($(max_xattr_size) + 10)) 1
11084 run_test 102ha "grow xattr from inside inode to external inode"
11086 test_102i() { # bug 17038
11087 [ -z "$(which getfattr 2>/dev/null)" ] &&
11088 skip "could not find getfattr"
11091 ln -s $DIR/$tfile $DIR/${tfile}link
11092 getfattr -n trusted.lov $DIR/$tfile ||
11093 error "lgetxattr on $DIR/$tfile failed"
11094 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
11095 grep -i "no such attr" ||
11096 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
11097 rm -f $DIR/$tfile $DIR/${tfile}link
11099 run_test 102i "lgetxattr test on symbolic link ============"
11102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11103 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11105 XINC=$(have_xattrs_include)
11106 setup_test102 "$RUNAS"
11107 chown $RUNAS_ID $DIR/$tdir
11108 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11109 cd $DIR/$tdir/$tdir
11110 compare_stripe_info1 "$RUNAS"
11112 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
11115 [ -z "$(which setfattr 2>/dev/null)" ] &&
11116 skip "could not find setfattr"
11119 # b22187 just check that does not crash for regular file.
11120 setfattr -n trusted.lov $DIR/$tfile
11121 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
11122 local test_kdir=$DIR/$tdir
11123 test_mkdir $test_kdir
11124 local default_size=$($LFS getstripe -S $test_kdir)
11125 local default_count=$($LFS getstripe -c $test_kdir)
11126 local default_offset=$($LFS getstripe -i $test_kdir)
11127 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
11128 error 'dir setstripe failed'
11129 setfattr -n trusted.lov $test_kdir
11130 local stripe_size=$($LFS getstripe -S $test_kdir)
11131 local stripe_count=$($LFS getstripe -c $test_kdir)
11132 local stripe_offset=$($LFS getstripe -i $test_kdir)
11133 [ $stripe_size -eq $default_size ] ||
11134 error "stripe size $stripe_size != $default_size"
11135 [ $stripe_count -eq $default_count ] ||
11136 error "stripe count $stripe_count != $default_count"
11137 [ $stripe_offset -eq $default_offset ] ||
11138 error "stripe offset $stripe_offset != $default_offset"
11139 rm -rf $DIR/$tfile $test_kdir
11141 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
11144 [ -z "$(which getfattr 2>/dev/null)" ] &&
11145 skip "could not find getfattr"
11147 # LU-532 trusted. xattr is invisible to non-root
11148 local testfile=$DIR/$tfile
11152 echo "listxattr as user..."
11153 chown $RUNAS_ID $testfile
11154 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
11155 grep -q "trusted" &&
11156 error "$testfile trusted xattrs are user visible"
11160 run_test 102l "listxattr size test =================================="
11162 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
11163 local path=$DIR/$tfile
11166 listxattr_size_check $path || error "listattr_size_check $path failed"
11168 run_test 102m "Ensure listxattr fails on small bufffer ========"
11172 getxattr() { # getxattr path name
11173 # Return the base64 encoding of the value of xattr name on path.
11177 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
11179 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11181 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11183 getfattr --absolute-names --encoding=base64 --name=$name $path |
11184 awk -F= -v name=$name '$1 == name {
11185 print substr($0, index($0, "=") + 1);
11189 test_102n() { # LU-4101 mdt: protect internal xattrs
11190 [ -z "$(which setfattr 2>/dev/null)" ] &&
11191 skip "could not find setfattr"
11192 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
11194 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
11197 local file0=$DIR/$tfile.0
11198 local file1=$DIR/$tfile.1
11199 local xattr0=$TMP/$tfile.0
11200 local xattr1=$TMP/$tfile.1
11201 local namelist="lov lma lmv link fid version som hsm"
11205 rm -rf $file0 $file1 $xattr0 $xattr1
11206 touch $file0 $file1
11208 # Get 'before' xattrs of $file1.
11209 getfattr --absolute-names --dump --match=- $file1 > $xattr0
11211 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
11212 namelist+=" lfsck_namespace"
11213 for name in $namelist; do
11214 # Try to copy xattr from $file0 to $file1.
11215 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11217 setfattr --name=trusted.$name --value="$value" $file1 ||
11218 error "setxattr 'trusted.$name' failed"
11220 # Try to set a garbage xattr.
11221 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11223 if [[ x$name == "xlov" ]]; then
11224 setfattr --name=trusted.lov --value="$value" $file1 &&
11225 error "setxattr invalid 'trusted.lov' success"
11227 setfattr --name=trusted.$name --value="$value" $file1 ||
11228 error "setxattr invalid 'trusted.$name' failed"
11231 # Try to remove the xattr from $file1. We don't care if this
11232 # appears to succeed or fail, we just don't want there to be
11233 # any changes or crashes.
11234 setfattr --remove=$trusted.$name $file1 2> /dev/null
11237 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
11240 # Try to copy xattr from $file0 to $file1.
11241 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11243 setfattr --name=trusted.$name --value="$value" $file1 ||
11244 error "setxattr 'trusted.$name' failed"
11246 # Try to set a garbage xattr.
11247 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11249 setfattr --name=trusted.$name --value="$value" $file1 ||
11250 error "setxattr 'trusted.$name' failed"
11252 # Try to remove the xattr from $file1. We don't care if this
11253 # appears to succeed or fail, we just don't want there to be
11254 # any changes or crashes.
11255 setfattr --remove=$trusted.$name $file1 2> /dev/null
11258 # Get 'after' xattrs of file1.
11259 getfattr --absolute-names --dump --match=- $file1 > $xattr1
11261 if ! diff $xattr0 $xattr1; then
11262 error "before and after xattrs of '$file1' differ"
11265 rm -rf $file0 $file1 $xattr0 $xattr1
11269 run_test 102n "silently ignore setxattr on internal trusted xattrs"
11271 test_102p() { # LU-4703 setxattr did not check ownership
11272 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
11273 skip "MDS needs to be at least 2.5.56"
11275 local testfile=$DIR/$tfile
11279 echo "setfacl as user..."
11280 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
11281 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
11283 echo "setfattr as user..."
11284 setfacl -m "u:$RUNAS_ID:---" $testfile
11285 $RUNAS setfattr -x system.posix_acl_access $testfile
11286 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
11288 run_test 102p "check setxattr(2) correctly fails without permission"
11291 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
11292 skip "MDS needs to be at least 2.6.92"
11294 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
11296 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
11299 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
11300 skip "MDS needs to be at least 2.6.93"
11302 touch $DIR/$tfile || error "touch"
11303 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
11304 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
11305 rm $DIR/$tfile || error "rm"
11308 mkdir -p $DIR/$tdir || error "mkdir"
11309 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11310 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11311 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11312 error "$testfile error deleting user.author1"
11313 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11314 grep "user.$(basename $tdir)" &&
11315 error "$tdir did not delete user.$(basename $tdir)"
11316 rmdir $DIR/$tdir || error "rmdir"
11319 test_mkdir $DIR/$tdir
11320 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11321 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11322 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11323 error "$testfile error deleting user.author1"
11324 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11325 grep "user.$(basename $tdir)" &&
11326 error "$tdir did not delete user.$(basename $tdir)"
11327 rmdir $DIR/$tdir || error "rm striped dir"
11329 run_test 102r "set EAs with empty values"
11332 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11333 skip "MDS needs to be at least 2.11.52"
11335 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11337 save_lustre_params client "llite.*.xattr_cache" > $save
11339 for cache in 0 1; do
11340 lctl set_param llite.*.xattr_cache=$cache
11343 touch $DIR/$tfile || error "touch"
11344 for prefix in lustre security system trusted user; do
11345 # Note getxattr() may fail with 'Operation not
11346 # supported' or 'No such attribute' depending
11347 # on prefix and cache.
11348 getfattr -n $prefix.n102s $DIR/$tfile &&
11349 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
11353 restore_lustre_params < $save
11355 run_test 102s "getting nonexistent xattrs should fail"
11358 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11359 skip "MDS needs to be at least 2.11.52"
11361 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11363 save_lustre_params client "llite.*.xattr_cache" > $save
11365 for cache in 0 1; do
11366 lctl set_param llite.*.xattr_cache=$cache
11368 for buf_size in 0 256; do
11370 touch $DIR/$tfile || error "touch"
11371 setfattr -n user.multiop $DIR/$tfile
11372 $MULTIOP $DIR/$tfile oa$buf_size ||
11373 error "cannot get zero length xattr value (buf_size = $buf_size)"
11377 restore_lustre_params < $save
11379 run_test 102t "zero length xattr values handled correctly"
11383 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
11388 [ "$UID" != 0 ] && skip "must run as root"
11389 $GSS && skip_env "could not run under gss"
11390 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
11391 skip_env "must have acl enabled"
11392 [ -z "$(which setfacl 2>/dev/null)" ] &&
11393 skip_env "could not find setfacl"
11394 remote_mds_nodsh && skip "remote MDS with nodsh"
11396 gpasswd -a daemon bin # LU-5641
11397 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
11399 declare -a identity_old
11401 for num in $(seq $MDSCOUNT); do
11402 switch_identity $num true || identity_old[$num]=$?
11405 SAVE_UMASK=$(umask)
11407 mkdir -p $DIR/$tdir
11410 echo "performing cp ..."
11411 run_acl_subtest cp || error "run_acl_subtest cp failed"
11412 echo "performing getfacl-noacl..."
11413 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
11414 echo "performing misc..."
11415 run_acl_subtest misc || error "misc test failed"
11416 echo "performing permissions..."
11417 run_acl_subtest permissions || error "permissions failed"
11418 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
11419 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
11420 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
11421 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
11423 echo "performing permissions xattr..."
11424 run_acl_subtest permissions_xattr ||
11425 error "permissions_xattr failed"
11427 echo "performing setfacl..."
11428 run_acl_subtest setfacl || error "setfacl test failed"
11430 # inheritance test got from HP
11431 echo "performing inheritance..."
11432 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
11433 chmod +x make-tree || error "chmod +x failed"
11434 run_acl_subtest inheritance || error "inheritance test failed"
11437 echo "LU-974 ignore umask when acl is enabled..."
11438 run_acl_subtest 974 || error "LU-974 umask test failed"
11439 if [ $MDSCOUNT -ge 2 ]; then
11440 run_acl_subtest 974_remote ||
11441 error "LU-974 umask test failed under remote dir"
11444 echo "LU-2561 newly created file is same size as directory..."
11445 if [ "$mds1_FSTYPE" != "zfs" ]; then
11446 run_acl_subtest 2561 || error "LU-2561 test failed"
11448 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
11451 run_acl_subtest 4924 || error "LU-4924 test failed"
11456 for num in $(seq $MDSCOUNT); do
11457 if [ "${identity_old[$num]}" = 1 ]; then
11458 switch_identity $num false || identity_old[$num]=$?
11462 run_test 103a "acl test"
11468 for U in {0..511}; do
11470 local O=$(printf "%04o" $U)
11472 umask $(printf "%04o" $((511 ^ $O)))
11473 $LFS setstripe -c 1 $DIR/$tfile.s$O
11474 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
11476 (( $S == ($O & 0666) )) ||
11477 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
11479 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
11480 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
11481 (( $S == ($O & 0666) )) ||
11482 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
11484 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
11485 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
11486 (( $S == ($O & 0666) )) ||
11487 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
11488 rm -f $DIR/$tfile.[smp]$0
11492 # limit the concurrently running threads to 64. LU-11878
11493 local idx=$((U % 64))
11494 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
11499 run_test 103b "umask lfs setstripe"
11502 mkdir -p $DIR/$tdir
11503 cp -rp $DIR/$tdir $DIR/$tdir.bak
11505 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
11506 error "$DIR/$tdir shouldn't contain default ACL"
11507 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
11508 error "$DIR/$tdir.bak shouldn't contain default ACL"
11511 run_test 103c "'cp -rp' won't set empty acl"
11516 local saved_debug=$($LCTL get_param -n debug)
11518 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
11519 skip "MDS needs to be at least 2.14.52"
11521 large_xattr_enabled || skip_env "ea_inode feature disabled"
11523 mkdir -p $DIR/$tdir
11524 # add big LOV EA to cause reply buffer overflow earlier
11525 $LFS setstripe -C 1000 $DIR/$tdir
11526 lctl set_param mdc.*-mdc*.stats=clear
11528 $LCTL set_param debug=0
11529 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
11530 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
11532 # add a large number of default ACLs (expect 8000+ for 2.13+)
11533 for U in {2..7000}; do
11534 setfacl -d -m user:$U:rwx $DIR/$tdir ||
11535 error "Able to add just $U default ACLs"
11537 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
11538 echo "$numacl default ACLs created"
11540 stat $DIR/$tdir || error "Cannot stat directory"
11541 # check file creation
11542 touch $DIR/$tdir/$tfile ||
11543 error "failed to create $tfile with $numacl default ACLs"
11544 stat $DIR/$tdir/$tfile || error "Cannot stat file"
11545 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11546 echo "$fileacl ACLs were inherited"
11547 (( $fileacl == $numacl )) ||
11548 error "Not all default ACLs were inherited: $numacl != $fileacl"
11549 # check that new ACLs creation adds new ACLs to inherited ACLs
11550 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
11551 error "Cannot set new ACL"
11552 numacl=$((numacl + 1))
11553 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11554 (( $fileacl == $numacl )) ||
11555 error "failed to add new ACL: $fileacl != $numacl as expected"
11556 # adds more ACLs to a file to reach their maximum at 8000+
11558 for U in {20000..25000}; do
11559 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
11560 numacl=$((numacl + 1))
11562 echo "Added $numacl more ACLs to the file"
11563 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11564 echo "Total $fileacl ACLs in file"
11565 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
11566 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
11567 rmdir $DIR/$tdir || error "Cannot remove directory"
11569 run_test 103e "inheritance of big amount of default ACLs"
11572 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
11573 skip "MDS needs to be at least 2.14.51"
11575 large_xattr_enabled || skip_env "ea_inode feature disabled"
11577 # enable changelog to consume more internal MDD buffers
11580 mkdir -p $DIR/$tdir
11582 $LFS setstripe -C 1000 $DIR/$tdir
11583 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
11584 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
11585 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
11586 rmdir $DIR/$tdir || error "Cannot remove directory"
11588 run_test 103f "changelog doesn't interfere with default ACLs buffers"
11591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11594 lfs df || error "lfs df failed"
11595 lfs df -ih || error "lfs df -ih failed"
11596 lfs df -h $DIR || error "lfs df -h $DIR failed"
11597 lfs df -i $DIR || error "lfs df -i $DIR failed"
11598 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
11599 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
11601 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
11602 lctl --device %$OSC deactivate
11603 lfs df || error "lfs df with deactivated OSC failed"
11604 lctl --device %$OSC activate
11605 # wait the osc back to normal
11606 wait_osc_import_ready client ost
11608 lfs df || error "lfs df with reactivated OSC failed"
11611 run_test 104a "lfs df [-ih] [path] test ========================="
11614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11615 [ $RUNAS_ID -eq $UID ] &&
11616 skip_env "RUNAS_ID = UID = $UID -- skipping"
11618 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
11619 grep "Permission denied" | wc -l)))
11620 if [ $denied_cnt -ne 0 ]; then
11621 error "lfs check servers test failed"
11624 run_test 104b "$RUNAS lfs check servers test ===================="
11627 # Verify $1 is within range of $2.
11628 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
11629 # $1 is <= 2% of $2. Else Fail.
11632 # Strip all units (M, G, T)
11633 actual=$(echo $1 | tr -d A-Z)
11634 expect=$(echo $2 | tr -d A-Z)
11636 expect_lo=$(($expect * 98 / 100)) # 2% below
11637 expect_hi=$(($expect * 102 / 100)) # 2% above
11639 # permit 2% drift above and below
11640 (( $actual >= $expect_lo && $actual <= $expect_hi ))
11644 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11645 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
11647 local ost_param="osd-zfs.$FSNAME-OST0000."
11648 local mdt_param="osd-zfs.$FSNAME-MDT0000."
11649 local ofacets=$(get_facets OST)
11650 local mfacets=$(get_facets MDS)
11651 local saved_ost_blocks=
11652 local saved_mdt_blocks=
11654 echo "Before recordsize change"
11655 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
11656 df=($(df -h | grep "/mnt/lustre"$))
11659 echo "lfs output : ${lfs_df[*]}"
11660 echo "df output : ${df[*]}"
11662 for facet in ${ofacets//,/ }; do
11663 if [ -z $saved_ost_blocks ]; then
11664 saved_ost_blocks=$(do_facet $facet \
11665 lctl get_param -n $ost_param.blocksize)
11666 echo "OST Blocksize: $saved_ost_blocks"
11668 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11669 do_facet $facet zfs set recordsize=32768 $ost
11672 # BS too small. Sufficient for functional testing.
11673 for facet in ${mfacets//,/ }; do
11674 if [ -z $saved_mdt_blocks ]; then
11675 saved_mdt_blocks=$(do_facet $facet \
11676 lctl get_param -n $mdt_param.blocksize)
11677 echo "MDT Blocksize: $saved_mdt_blocks"
11679 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11680 do_facet $facet zfs set recordsize=32768 $mdt
11683 # Give new values chance to reflect change
11686 echo "After recordsize change"
11687 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
11688 df_after=($(df -h | grep "/mnt/lustre"$))
11691 echo "lfs output : ${lfs_df_after[*]}"
11692 echo "df output : ${df_after[*]}"
11695 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
11696 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
11697 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
11698 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
11699 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
11700 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
11703 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
11704 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
11705 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
11706 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
11707 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
11708 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
11710 # Restore MDT recordize back to original
11711 for facet in ${mfacets//,/ }; do
11712 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11713 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
11716 # Restore OST recordize back to original
11717 for facet in ${ofacets//,/ }; do
11718 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11719 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
11724 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
11727 # doesn't work on 2.4 kernels
11729 if $(flock_is_enabled); then
11730 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
11732 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
11736 run_test 105a "flock when mounted without -o flock test ========"
11740 if $(flock_is_enabled); then
11741 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
11743 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
11747 run_test 105b "fcntl when mounted without -o flock test ========"
11751 if $(flock_is_enabled); then
11752 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
11754 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
11758 run_test 105c "lockf when mounted without -o flock test"
11760 test_105d() { # bug 15924
11761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11763 test_mkdir $DIR/$tdir
11764 flock_is_enabled || skip_env "mount w/o flock enabled"
11765 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
11766 $LCTL set_param fail_loc=0x80000315
11767 flocks_test 2 $DIR/$tdir
11769 run_test 105d "flock race (should not freeze) ========"
11771 test_105e() { # bug 22660 && 22040
11772 flock_is_enabled || skip_env "mount w/o flock enabled"
11775 flocks_test 3 $DIR/$tfile
11777 run_test 105e "Two conflicting flocks from same process"
11779 test_106() { #bug 10921
11780 test_mkdir $DIR/$tdir
11781 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
11782 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
11784 run_test 106 "attempt exec of dir followed by chown of that dir"
11787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11795 local save_pattern=$(sysctl -n kernel.core_pattern)
11796 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
11797 sysctl -w kernel.core_pattern=$file
11798 sysctl -w kernel.core_uses_pid=0
11800 ulimit -c unlimited
11806 kill -s 11 $SLEEPPID
11808 if [ -e $file ]; then
11809 size=`stat -c%s $file`
11810 [ $size -eq 0 ] && error "Fail to create core file $file"
11812 error "Fail to create core file $file"
11815 sysctl -w kernel.core_pattern=$save_pattern
11816 sysctl -w kernel.core_uses_pid=$save_uses_pid
11819 run_test 107 "Coredump on SIG"
11822 test_mkdir $DIR/$tdir
11823 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
11824 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
11825 error "mkdir with 256 char should fail, but did not"
11826 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
11827 error "create with 255 char failed"
11828 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
11829 error "create with 256 char should fail, but did not"
11834 run_test 110 "filename length checking"
11837 # Purpose: To verify dynamic thread (OSS) creation.
11840 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11841 remote_ost_nodsh && skip "remote OST with nodsh"
11843 # Lustre does not stop service threads once they are started.
11844 # Reset number of running threads to default.
11849 local save_params="$TMP/sanity-$TESTNAME.parameters"
11851 # Get ll_ost_io count before I/O
11852 OSTIO_pre=$(do_facet ost1 \
11853 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
11854 # Exit if lustre is not running (ll_ost_io not running).
11855 [ -z "$OSTIO_pre" ] && error "no OSS threads"
11857 echo "Starting with $OSTIO_pre threads"
11858 local thread_max=$((OSTIO_pre * 2))
11859 local rpc_in_flight=$((thread_max * 2))
11860 # this is limited to OSC_MAX_RIF_MAX (256)
11861 [ $rpc_in_flight -gt 256 ] && rpc_in_flight=256
11862 thread_max=$((rpc_in_flight / 2))
11863 [ $thread_max -le $OSTIO_pre ] && skip "Too many ost_io threads" &&
11866 # Number of I/O Process proposed to be started.
11868 local facets=$(get_facets OST)
11870 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
11871 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
11873 # Set in_flight to $rpc_in_flight
11874 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
11875 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
11876 nfiles=${rpc_in_flight}
11877 # Set ost thread_max to $thread_max
11878 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
11880 # 5 Minutes should be sufficient for max number of OSS
11881 # threads(thread_max) to be created.
11885 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
11886 test_mkdir $DIR/$tdir
11887 for i in $(seq $nfiles); do
11888 local file=$DIR/$tdir/${tfile}-$i
11889 $LFS setstripe -c -1 -i 0 $file
11890 ($WTL $file $timeout)&
11893 # I/O Started - Wait for thread_started to reach thread_max or report
11894 # error if thread_started is more than thread_max.
11895 echo "Waiting for thread_started to reach thread_max"
11896 local thread_started=0
11897 local end_time=$((SECONDS + timeout))
11899 while [ $SECONDS -le $end_time ] ; do
11901 # Get ost i/o thread_started count.
11902 thread_started=$(do_facet ost1 \
11904 ost.OSS.ost_io.threads_started | cut -d= -f2")
11905 # Break out if thread_started is equal/greater than thread_max
11906 if [[ $thread_started -ge $thread_max ]]; then
11907 echo ll_ost_io thread_started $thread_started, \
11908 equal/greater than thread_max $thread_max
11914 # Cleanup - We have the numbers, Kill i/o jobs if running.
11915 jobcount=($(jobs -p))
11916 for i in $(seq 0 $((${#jobcount[@]}-1)))
11918 kill -9 ${jobcount[$i]}
11919 if [ $? -ne 0 ] ; then
11921 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
11925 # Cleanup files left by WTL binary.
11926 for i in $(seq $nfiles); do
11927 local file=$DIR/$tdir/${tfile}-$i
11929 if [ $? -ne 0 ] ; then
11930 echo "Warning: Failed to delete file $file"
11934 restore_lustre_params <$save_params
11935 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
11937 # Error out if no new thread has started or Thread started is greater
11939 if [[ $thread_started -le $OSTIO_pre ||
11940 $thread_started -gt $thread_max ]]; then
11941 error "ll_ost_io: thread_started $thread_started" \
11942 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
11943 "No new thread started or thread started greater " \
11947 run_test 115 "verify dynamic thread creation===================="
11949 test_116a() { # was previously test_116()
11950 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11951 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11952 remote_mds_nodsh && skip "remote MDS with nodsh"
11954 echo -n "Free space priority "
11955 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
11960 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
11961 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
11962 stack_trap simple_cleanup_common
11964 # Check if we need to generate uneven OSTs
11965 test_mkdir -p $DIR/$tdir/OST${MINI}
11966 local FILL=$((MINV / 4))
11967 local DIFF=$((MAXV - MINV))
11968 local DIFF2=$((DIFF * 100 / MINV))
11970 local threshold=$(do_facet $SINGLEMDS \
11971 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
11972 threshold=${threshold%%%}
11973 echo -n "Check for uneven OSTs: "
11974 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
11976 if [[ $DIFF2 -gt $threshold ]]; then
11978 echo "Don't need to fill OST$MINI"
11980 # generate uneven OSTs. Write 2% over the QOS threshold value
11982 DIFF=$((threshold - DIFF2 + 2))
11983 DIFF2=$((MINV * DIFF / 100))
11984 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
11985 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
11986 error "setstripe failed"
11987 DIFF=$((DIFF2 / 2048))
11989 while [ $i -lt $DIFF ]; do
11991 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
11992 bs=2M count=1 2>/dev/null
12001 DIFF=$((MAXV - MINV))
12002 DIFF2=$((DIFF * 100 / MINV))
12003 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12004 if [ $DIFF2 -gt $threshold ]; then
12007 skip "QOS imbalance criteria not met"
12015 # now fill using QOS
12016 $LFS setstripe -c 1 $DIR/$tdir
12017 FILL=$((FILL / 200))
12018 if [ $FILL -gt 600 ]; then
12021 echo "writing $FILL files to QOS-assigned OSTs"
12023 while [ $i -lt $FILL ]; do
12025 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12026 count=1 2>/dev/null
12029 echo "wrote $i 200k files"
12033 echo "Note: free space may not be updated, so measurements might be off"
12035 DIFF2=$((MAXV - MINV))
12036 echo "free space delta: orig $DIFF final $DIFF2"
12037 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
12038 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
12039 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
12040 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
12041 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
12042 if [[ $DIFF -gt 0 ]]; then
12043 FILL=$((DIFF2 * 100 / DIFF - 100))
12044 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
12047 # Figure out which files were written where
12048 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12049 awk '/'$MINI1': / {print $2; exit}')
12051 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12052 echo "$MINC files created on smaller OST $MINI1"
12053 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12054 awk '/'$MAXI1': / {print $2; exit}')
12056 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12057 echo "$MAXC files created on larger OST $MAXI1"
12058 if [[ $MINC -gt 0 ]]; then
12059 FILL=$((MAXC * 100 / MINC - 100))
12060 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
12062 [[ $MAXC -gt $MINC ]] ||
12063 error_ignore LU-9 "stripe QOS didn't balance free space"
12065 run_test 116a "stripe QOS: free space balance ==================="
12067 test_116b() { # LU-2093
12068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12069 remote_mds_nodsh && skip "remote MDS with nodsh"
12071 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
12072 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
12073 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
12074 [ -z "$old_rr" ] && skip "no QOS"
12075 do_facet $SINGLEMDS lctl set_param \
12076 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
12077 mkdir -p $DIR/$tdir
12078 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
12079 createmany -o $DIR/$tdir/f- 20 || error "can't create"
12080 do_facet $SINGLEMDS lctl set_param fail_loc=0
12082 do_facet $SINGLEMDS lctl set_param \
12083 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
12085 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
12087 test_117() # bug 10891
12089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12091 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
12092 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
12093 lctl set_param fail_loc=0x21e
12094 > $DIR/$tfile || error "truncate failed"
12095 lctl set_param fail_loc=0
12096 echo "Truncate succeeded."
12099 run_test 117 "verify osd extend =========="
12101 NO_SLOW_RESENDCOUNT=4
12102 export OLD_RESENDCOUNT=""
12103 set_resend_count () {
12104 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
12105 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
12106 lctl set_param -n $PROC_RESENDCOUNT $1
12107 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
12110 # for reduce test_118* time (b=14842)
12111 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12113 # Reset async IO behavior after error case
12115 FILE=$DIR/reset_async
12117 # Ensure all OSCs are cleared
12118 $LFS setstripe -c -1 $FILE
12119 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
12124 test_118a() #bug 11710
12126 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12130 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12131 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12132 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12134 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12135 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12140 run_test 118a "verify O_SYNC works =========="
12144 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12145 remote_ost_nodsh && skip "remote OST with nodsh"
12149 #define OBD_FAIL_SRV_ENOENT 0x217
12150 set_nodes_failloc "$(osts_nodes)" 0x217
12151 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12153 set_nodes_failloc "$(osts_nodes)" 0
12154 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12155 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12158 if [[ $RC -eq 0 ]]; then
12159 error "Must return error due to dropped pages, rc=$RC"
12163 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12164 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12168 echo "Dirty pages not leaked on ENOENT"
12170 # Due to the above error the OSC will issue all RPCs syncronously
12171 # until a subsequent RPC completes successfully without error.
12172 $MULTIOP $DIR/$tfile Ow4096yc
12177 run_test 118b "Reclaim dirty pages on fatal error =========="
12181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12183 # for 118c, restore the original resend count, LU-1940
12184 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
12185 set_resend_count $OLD_RESENDCOUNT
12186 remote_ost_nodsh && skip "remote OST with nodsh"
12190 #define OBD_FAIL_OST_EROFS 0x216
12191 set_nodes_failloc "$(osts_nodes)" 0x216
12193 # multiop should block due to fsync until pages are written
12194 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12198 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12199 error "Multiop failed to block on fsync, pid=$MULTIPID"
12202 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12204 if [[ $WRITEBACK -eq 0 ]]; then
12205 error "No page in writeback, writeback=$WRITEBACK"
12208 set_nodes_failloc "$(osts_nodes)" 0
12211 if [[ $RC -ne 0 ]]; then
12212 error "Multiop fsync failed, rc=$RC"
12215 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12216 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12218 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12219 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12223 echo "Dirty pages flushed via fsync on EROFS"
12226 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
12228 # continue to use small resend count to reduce test_118* time (b=14842)
12229 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12234 remote_ost_nodsh && skip "remote OST with nodsh"
12238 #define OBD_FAIL_OST_BRW_PAUSE_BULK
12239 set_nodes_failloc "$(osts_nodes)" 0x214
12240 # multiop should block due to fsync until pages are written
12241 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12245 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12246 error "Multiop failed to block on fsync, pid=$MULTIPID"
12249 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12251 if [[ $WRITEBACK -eq 0 ]]; then
12252 error "No page in writeback, writeback=$WRITEBACK"
12255 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
12256 set_nodes_failloc "$(osts_nodes)" 0
12258 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12259 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12261 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12262 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12266 echo "Dirty pages gaurenteed flushed via fsync"
12269 run_test 118d "Fsync validation inject a delay of the bulk =========="
12272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12276 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
12277 lctl set_param fail_loc=0x8000040a
12279 # Should simulate EINVAL error which is fatal
12280 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12282 if [[ $RC -eq 0 ]]; then
12283 error "Must return error due to dropped pages, rc=$RC"
12286 lctl set_param fail_loc=0x0
12288 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12289 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12290 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12292 if [[ $LOCKED -ne 0 ]]; then
12293 error "Locked pages remain in cache, locked=$LOCKED"
12296 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12297 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12301 echo "No pages locked after fsync"
12306 run_test 118f "Simulate unrecoverable OSC side error =========="
12309 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12313 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
12314 lctl set_param fail_loc=0x406
12316 # simulate local -ENOMEM
12317 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12320 lctl set_param fail_loc=0
12321 if [[ $RC -eq 0 ]]; then
12322 error "Must return error due to dropped pages, rc=$RC"
12325 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12326 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12327 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12329 if [[ $LOCKED -ne 0 ]]; then
12330 error "Locked pages remain in cache, locked=$LOCKED"
12333 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12334 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12338 echo "No pages locked after fsync"
12343 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
12346 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12347 remote_ost_nodsh && skip "remote OST with nodsh"
12351 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12352 set_nodes_failloc "$(osts_nodes)" 0x20e
12353 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12354 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12357 set_nodes_failloc "$(osts_nodes)" 0
12358 if [[ $RC -eq 0 ]]; then
12359 error "Must return error due to dropped pages, rc=$RC"
12362 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12363 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12364 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12366 if [[ $LOCKED -ne 0 ]]; then
12367 error "Locked pages remain in cache, locked=$LOCKED"
12370 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12371 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12375 echo "No pages locked after fsync"
12379 run_test 118h "Verify timeout in handling recoverables errors =========="
12381 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12385 remote_ost_nodsh && skip "remote OST with nodsh"
12389 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12390 set_nodes_failloc "$(osts_nodes)" 0x20e
12392 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12393 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12396 set_nodes_failloc "$(osts_nodes)" 0
12400 if [[ $RC -ne 0 ]]; then
12401 error "got error, but should be not, rc=$RC"
12404 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12405 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12406 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12407 if [[ $LOCKED -ne 0 ]]; then
12408 error "Locked pages remain in cache, locked=$LOCKED"
12411 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12412 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12416 echo "No pages locked after fsync"
12420 run_test 118i "Fix error before timeout in recoverable error =========="
12422 [ "$SLOW" = "no" ] && set_resend_count 4
12425 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12426 remote_ost_nodsh && skip "remote OST with nodsh"
12430 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
12431 set_nodes_failloc "$(osts_nodes)" 0x220
12433 # return -EIO from OST
12434 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12436 set_nodes_failloc "$(osts_nodes)" 0x0
12437 if [[ $RC -eq 0 ]]; then
12438 error "Must return error due to dropped pages, rc=$RC"
12441 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12442 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12443 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12444 if [[ $LOCKED -ne 0 ]]; then
12445 error "Locked pages remain in cache, locked=$LOCKED"
12448 # in recoverable error on OST we want resend and stay until it finished
12449 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12450 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12454 echo "No pages locked after fsync"
12458 run_test 118j "Simulate unrecoverable OST side error =========="
12462 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12463 remote_ost_nodsh && skip "remote OSTs with nodsh"
12465 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12466 set_nodes_failloc "$(osts_nodes)" 0x20e
12467 test_mkdir $DIR/$tdir
12469 for ((i=0;i<10;i++)); do
12470 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
12471 error "dd to $DIR/$tdir/$tfile-$i failed" )&
12478 set_nodes_failloc "$(osts_nodes)" 0
12481 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
12483 test_118l() # LU-646
12485 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12487 test_mkdir $DIR/$tdir
12488 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
12491 run_test 118l "fsync dir"
12493 test_118m() # LU-3066
12495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12497 test_mkdir $DIR/$tdir
12498 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
12501 run_test 118m "fdatasync dir ========="
12503 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12510 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12511 remote_ost_nodsh && skip "remote OSTs with nodsh"
12513 # Sleep to avoid a cached response.
12514 #define OBD_STATFS_CACHE_SECONDS 1
12517 # Inject a 10 second delay in the OST_STATFS handler.
12518 #define OBD_FAIL_OST_STATFS_DELAY 0x242
12519 set_nodes_failloc "$(osts_nodes)" 0x242
12522 stat --file-system $MOUNT > /dev/null
12525 set_nodes_failloc "$(osts_nodes)" 0
12527 if ((end - begin > 20)); then
12528 error "statfs took $((end - begin)) seconds, expected 10"
12531 run_test 118n "statfs() sends OST_STATFS requests in parallel"
12533 test_119a() # bug 11737
12535 BSIZE=$((512 * 1024))
12536 directio write $DIR/$tfile 0 1 $BSIZE
12537 # We ask to read two blocks, which is more than a file size.
12538 # directio will indicate an error when requested and actual
12539 # sizes aren't equeal (a normal situation in this case) and
12540 # print actual read amount.
12541 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
12542 if [ "$NOB" != "$BSIZE" ]; then
12543 error "read $NOB bytes instead of $BSIZE"
12547 run_test 119a "Short directIO read must return actual read amount"
12549 test_119b() # bug 11737
12551 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12553 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
12554 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
12556 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
12557 error "direct read failed"
12560 run_test 119b "Sparse directIO read must return actual read amount"
12562 test_119c() # bug 13099
12565 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
12566 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
12569 run_test 119c "Testing for direct read hitting hole"
12571 test_119d() # bug 15950
12573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12575 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
12576 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
12578 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
12579 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
12580 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
12581 lctl set_param fail_loc=0x40d
12582 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
12585 cat $DIR/$tfile > /dev/null &
12586 lctl set_param fail_loc=0
12589 log "the DIO writes have completed, now wait for the reads (should not block very long)"
12591 [ -n "`ps h -p $pid_reads -o comm`" ] && \
12592 error "the read rpcs have not completed in 2s"
12594 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
12596 run_test 119d "The DIO path should try to send a new rpc once one is completed"
12599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12600 remote_mds_nodsh && skip "remote MDS with nodsh"
12601 test_mkdir -i0 -c1 $DIR/$tdir
12602 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12603 skip_env "no early lock cancel on server"
12605 lru_resize_disable mdc
12606 lru_resize_disable osc
12607 cancel_lru_locks mdc
12608 # asynchronous object destroy at MDT could cause bl ast to client
12609 cancel_lru_locks osc
12611 stat $DIR/$tdir > /dev/null
12612 can1=$(do_facet mds1 \
12613 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12614 awk '/ldlm_cancel/ {print $2}')
12615 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12616 awk '/ldlm_bl_callback/ {print $2}')
12617 test_mkdir -i0 -c1 $DIR/$tdir/d1
12618 can2=$(do_facet mds1 \
12619 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12620 awk '/ldlm_cancel/ {print $2}')
12621 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12622 awk '/ldlm_bl_callback/ {print $2}')
12623 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12624 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12625 lru_resize_enable mdc
12626 lru_resize_enable osc
12628 run_test 120a "Early Lock Cancel: mkdir test"
12631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12632 remote_mds_nodsh && skip "remote MDS with nodsh"
12633 test_mkdir $DIR/$tdir
12634 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12635 skip_env "no early lock cancel on server"
12637 lru_resize_disable mdc
12638 lru_resize_disable osc
12639 cancel_lru_locks mdc
12640 stat $DIR/$tdir > /dev/null
12641 can1=$(do_facet $SINGLEMDS \
12642 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12643 awk '/ldlm_cancel/ {print $2}')
12644 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12645 awk '/ldlm_bl_callback/ {print $2}')
12646 touch $DIR/$tdir/f1
12647 can2=$(do_facet $SINGLEMDS \
12648 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12649 awk '/ldlm_cancel/ {print $2}')
12650 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12651 awk '/ldlm_bl_callback/ {print $2}')
12652 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12653 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12654 lru_resize_enable mdc
12655 lru_resize_enable osc
12657 run_test 120b "Early Lock Cancel: create test"
12660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12661 remote_mds_nodsh && skip "remote MDS with nodsh"
12662 test_mkdir -i0 -c1 $DIR/$tdir
12663 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12664 skip "no early lock cancel on server"
12666 lru_resize_disable mdc
12667 lru_resize_disable osc
12668 test_mkdir -i0 -c1 $DIR/$tdir/d1
12669 test_mkdir -i0 -c1 $DIR/$tdir/d2
12670 touch $DIR/$tdir/d1/f1
12671 cancel_lru_locks mdc
12672 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
12673 can1=$(do_facet mds1 \
12674 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12675 awk '/ldlm_cancel/ {print $2}')
12676 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12677 awk '/ldlm_bl_callback/ {print $2}')
12678 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12679 can2=$(do_facet mds1 \
12680 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12681 awk '/ldlm_cancel/ {print $2}')
12682 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12683 awk '/ldlm_bl_callback/ {print $2}')
12684 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12685 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12686 lru_resize_enable mdc
12687 lru_resize_enable osc
12689 run_test 120c "Early Lock Cancel: link test"
12692 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12693 remote_mds_nodsh && skip "remote MDS with nodsh"
12694 test_mkdir -i0 -c1 $DIR/$tdir
12695 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12696 skip_env "no early lock cancel on server"
12698 lru_resize_disable mdc
12699 lru_resize_disable osc
12701 cancel_lru_locks mdc
12702 stat $DIR/$tdir > /dev/null
12703 can1=$(do_facet mds1 \
12704 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12705 awk '/ldlm_cancel/ {print $2}')
12706 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12707 awk '/ldlm_bl_callback/ {print $2}')
12708 chmod a+x $DIR/$tdir
12709 can2=$(do_facet mds1 \
12710 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12711 awk '/ldlm_cancel/ {print $2}')
12712 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12713 awk '/ldlm_bl_callback/ {print $2}')
12714 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12715 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12716 lru_resize_enable mdc
12717 lru_resize_enable osc
12719 run_test 120d "Early Lock Cancel: setattr test"
12722 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12723 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12724 skip_env "no early lock cancel on server"
12725 remote_mds_nodsh && skip "remote MDS with nodsh"
12727 local dlmtrace_set=false
12729 test_mkdir -i0 -c1 $DIR/$tdir
12730 lru_resize_disable mdc
12731 lru_resize_disable osc
12732 ! $LCTL get_param debug | grep -q dlmtrace &&
12733 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
12734 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
12735 cancel_lru_locks mdc
12736 cancel_lru_locks osc
12737 dd if=$DIR/$tdir/f1 of=/dev/null
12738 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
12739 # XXX client can not do early lock cancel of OST lock
12740 # during unlink (LU-4206), so cancel osc lock now.
12742 cancel_lru_locks osc
12743 can1=$(do_facet mds1 \
12744 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12745 awk '/ldlm_cancel/ {print $2}')
12746 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12747 awk '/ldlm_bl_callback/ {print $2}')
12748 unlink $DIR/$tdir/f1
12750 can2=$(do_facet mds1 \
12751 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12752 awk '/ldlm_cancel/ {print $2}')
12753 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12754 awk '/ldlm_bl_callback/ {print $2}')
12755 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
12756 $LCTL dk $TMP/cancel.debug.txt
12757 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
12758 $LCTL dk $TMP/blocking.debug.txt
12759 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
12760 lru_resize_enable mdc
12761 lru_resize_enable osc
12763 run_test 120e "Early Lock Cancel: unlink test"
12766 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12767 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12768 skip_env "no early lock cancel on server"
12769 remote_mds_nodsh && skip "remote MDS with nodsh"
12771 test_mkdir -i0 -c1 $DIR/$tdir
12772 lru_resize_disable mdc
12773 lru_resize_disable osc
12774 test_mkdir -i0 -c1 $DIR/$tdir/d1
12775 test_mkdir -i0 -c1 $DIR/$tdir/d2
12776 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
12777 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
12778 cancel_lru_locks mdc
12779 cancel_lru_locks osc
12780 dd if=$DIR/$tdir/d1/f1 of=/dev/null
12781 dd if=$DIR/$tdir/d2/f2 of=/dev/null
12782 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
12783 # XXX client can not do early lock cancel of OST lock
12784 # during rename (LU-4206), so cancel osc lock now.
12786 cancel_lru_locks osc
12787 can1=$(do_facet mds1 \
12788 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12789 awk '/ldlm_cancel/ {print $2}')
12790 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12791 awk '/ldlm_bl_callback/ {print $2}')
12792 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12794 can2=$(do_facet mds1 \
12795 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12796 awk '/ldlm_cancel/ {print $2}')
12797 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12798 awk '/ldlm_bl_callback/ {print $2}')
12799 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12800 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12801 lru_resize_enable mdc
12802 lru_resize_enable osc
12804 run_test 120f "Early Lock Cancel: rename test"
12807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12808 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12809 skip_env "no early lock cancel on server"
12810 remote_mds_nodsh && skip "remote MDS with nodsh"
12812 lru_resize_disable mdc
12813 lru_resize_disable osc
12815 echo create $count files
12816 test_mkdir $DIR/$tdir
12817 cancel_lru_locks mdc
12818 cancel_lru_locks osc
12821 can0=$(do_facet $SINGLEMDS \
12822 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12823 awk '/ldlm_cancel/ {print $2}')
12824 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12825 awk '/ldlm_bl_callback/ {print $2}')
12826 createmany -o $DIR/$tdir/f $count
12828 can1=$(do_facet $SINGLEMDS \
12829 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12830 awk '/ldlm_cancel/ {print $2}')
12831 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12832 awk '/ldlm_bl_callback/ {print $2}')
12834 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
12835 echo rm $count files
12838 can2=$(do_facet $SINGLEMDS \
12839 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12840 awk '/ldlm_cancel/ {print $2}')
12841 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12842 awk '/ldlm_bl_callback/ {print $2}')
12844 echo total: $count removes in $((t2-t1))
12845 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
12847 # wait for commitment of removal
12848 lru_resize_enable mdc
12849 lru_resize_enable osc
12851 run_test 120g "Early Lock Cancel: performance test"
12853 test_121() { #bug #10589
12854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12857 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
12858 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
12859 lctl set_param fail_loc=0x310
12860 cancel_lru_locks osc > /dev/null
12861 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
12862 lctl set_param fail_loc=0
12863 [[ $reads -eq $writes ]] ||
12864 error "read $reads blocks, must be $writes blocks"
12866 run_test 121 "read cancel race ========="
12868 test_123a_base() { # was test 123, statahead(bug 11401)
12872 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
12873 log "testing UP system. Performance may be lower than expected."
12878 test_mkdir $DIR/$tdir
12879 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
12880 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
12882 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
12883 createmany -o $DIR/$tdir/$tfile $j $((i - j))
12885 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
12886 lctl set_param -n llite.*.statahead_max 0
12887 lctl get_param llite.*.statahead_max
12888 cancel_lru_locks mdc
12889 cancel_lru_locks osc
12891 time $lsx $DIR/$tdir | wc -l
12893 delta=$((etime - stime))
12894 log "$lsx $i files without statahead: $delta sec"
12895 lctl set_param llite.*.statahead_max=$max
12897 swrong=$(lctl get_param -n llite.*.statahead_stats |
12898 grep "statahead wrong:" | awk '{print $3}')
12899 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
12900 cancel_lru_locks mdc
12901 cancel_lru_locks osc
12903 time $lsx $DIR/$tdir | wc -l
12905 delta_sa=$((etime - stime))
12906 log "$lsx $i files with statahead: $delta_sa sec"
12907 lctl get_param -n llite.*.statahead_stats
12908 ewrong=$(lctl get_param -n llite.*.statahead_stats |
12909 grep "statahead wrong:" | awk '{print $3}')
12911 [[ $swrong -lt $ewrong ]] &&
12912 log "statahead was stopped, maybe too many locks held!"
12913 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
12915 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
12916 max=$(lctl get_param -n llite.*.statahead_max |
12918 lctl set_param -n llite.*.statahead_max 0
12919 lctl get_param llite.*.statahead_max
12920 cancel_lru_locks mdc
12921 cancel_lru_locks osc
12923 time $lsx $DIR/$tdir | wc -l
12925 delta=$((etime - stime))
12926 log "$lsx $i files again without statahead: $delta sec"
12927 lctl set_param llite.*.statahead_max=$max
12928 if [ $((delta_sa * 100 > delta * 105 && delta_sa > delta + 2)) ]; then
12929 if [ $SLOWOK -eq 0 ]; then
12930 error "$lsx $i files is slower with statahead!"
12932 log "$lsx $i files is slower with statahead!"
12938 [ $delta -gt 20 ] && break
12939 [ $delta -gt 8 ] && MULT=$((50 / delta))
12940 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
12948 delta=$((etime - stime))
12949 log "rm -r $DIR/$tdir/: $delta seconds"
12951 lctl get_param -n llite.*.statahead_stats
12955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12957 test_123a_base "ls -l"
12959 run_test 123aa "verify statahead work"
12962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12964 statx_supported || skip_env "Test must be statx() syscall supported"
12966 test_123a_base "$STATX -l"
12968 run_test 123ab "verify statahead work by using statx"
12971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12973 statx_supported || skip_env "Test must be statx() syscall supported"
12980 cancel_lru_locks $OSC
12981 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
12982 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
12983 awk '/agl.total:/ {print $3}')
12984 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
12985 test_123a_base "$STATX --cached=always -D"
12986 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
12987 awk '/agl.total:/ {print $3}')
12988 [ $agl_before -eq $agl_after ] ||
12989 error "Should not trigger AGL thread - $agl_before:$agl_after"
12990 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
12991 [ $rpcs_after -eq $rpcs_before ] ||
12992 error "$STATX should not send glimpse RPCs to $OSC"
12994 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
12996 test_123b () { # statahead(bug 15027)
12997 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12999 test_mkdir $DIR/$tdir
13000 createmany -o $DIR/$tdir/$tfile-%d 1000
13002 cancel_lru_locks mdc
13003 cancel_lru_locks osc
13005 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
13006 lctl set_param fail_loc=0x80000803
13007 ls -lR $DIR/$tdir > /dev/null
13009 lctl set_param fail_loc=0x0
13010 lctl get_param -n llite.*.statahead_stats
13015 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
13018 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
13020 test_mkdir -i 0 -c 1 $DIR/$tdir.0
13021 test_mkdir -i 1 -c 1 $DIR/$tdir.1
13022 touch $DIR/$tdir.1/{1..3}
13023 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
13025 remount_client $MOUNT
13027 $MULTIOP $DIR/$tdir.0 Q
13029 # let statahead to complete
13030 ls -l $DIR/$tdir.0 > /dev/null
13032 testid=$(echo $TESTNAME | tr '_' ' ')
13033 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
13034 error "statahead warning" || true
13036 run_test 123c "Can not initialize inode warning on DNE statahead"
13039 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13040 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13041 skip_env "no lru resize on server"
13045 test_mkdir $DIR/$tdir
13047 log "create $NR files at $DIR/$tdir"
13048 createmany -o $DIR/$tdir/f $NR ||
13049 error "failed to create $NR files in $DIR/$tdir"
13051 cancel_lru_locks mdc
13052 ls -l $DIR/$tdir > /dev/null
13056 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
13057 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
13058 LRU_SIZE=$($LCTL get_param -n $PARAM)
13059 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
13060 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
13062 log "NS=$(basename $NSDIR)"
13067 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
13068 skip "Not enough cached locks created!"
13070 log "LRU=$LRU_SIZE"
13074 # We know that lru resize allows one client to hold $LIMIT locks
13075 # for 10h. After that locks begin to be killed by client.
13077 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
13079 if [ $LIMIT -lt $LRU_SIZE ]; then
13080 skip "Limit is too small $LIMIT"
13083 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
13084 # killing locks. Some time was spent for creating locks. This means
13085 # that up to the moment of sleep finish we must have killed some of
13086 # them (10-100 locks). This depends on how fast ther were created.
13087 # Many of them were touched in almost the same moment and thus will
13088 # be killed in groups.
13089 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
13091 # Use $LRU_SIZE_B here to take into account real number of locks
13092 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
13093 local LRU_SIZE_B=$LRU_SIZE
13095 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
13096 log "OLD_LVF=$OLD_LVF"
13097 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
13099 # Let's make sure that we really have some margin. Client checks
13100 # cached locks every 10 sec.
13101 SLEEP=$((SLEEP+20))
13102 log "Sleep ${SLEEP} sec"
13104 while ((SEC<$SLEEP)); do
13108 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
13109 echo -n "$LRU_SIZE"
13112 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
13113 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
13115 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
13116 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
13117 unlinkmany $DIR/$tdir/f $NR
13121 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
13122 log "unlink $NR files at $DIR/$tdir"
13123 unlinkmany $DIR/$tdir/f $NR
13125 run_test 124a "lru resize ======================================="
13127 get_max_pool_limit()
13129 local limit=$($LCTL get_param \
13130 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
13132 for l in $limit; do
13133 if [[ $l -gt $max ]]; then
13141 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13142 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13143 skip_env "no lru resize on server"
13145 LIMIT=$(get_max_pool_limit)
13147 NR=$(($(default_lru_size)*20))
13148 if [[ $NR -gt $LIMIT ]]; then
13149 log "Limit lock number by $LIMIT locks"
13153 IFree=$(mdsrate_inodes_available)
13154 if [ $IFree -lt $NR ]; then
13155 log "Limit lock number by $IFree inodes"
13159 lru_resize_disable mdc
13160 test_mkdir -p $DIR/$tdir/disable_lru_resize
13162 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
13163 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
13164 cancel_lru_locks mdc
13167 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13170 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13173 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13177 nolruresize_delta=$((etime-stime))
13178 log "ls -la time: $nolruresize_delta seconds"
13179 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13180 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
13182 lru_resize_enable mdc
13183 test_mkdir -p $DIR/$tdir/enable_lru_resize
13185 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
13186 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
13187 cancel_lru_locks mdc
13190 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13193 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13196 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13200 lruresize_delta=$((etime-stime))
13201 log "ls -la time: $lruresize_delta seconds"
13202 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13204 if [ $lruresize_delta -gt $nolruresize_delta ]; then
13205 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
13206 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
13207 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
13209 log "lru resize performs the same with no lru resize"
13211 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
13213 run_test 124b "lru resize (performance test) ======================="
13216 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13217 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13218 skip_env "no lru resize on server"
13220 # cache ununsed locks on client
13222 cancel_lru_locks mdc
13223 test_mkdir $DIR/$tdir
13224 createmany -o $DIR/$tdir/f $nr ||
13225 error "failed to create $nr files in $DIR/$tdir"
13226 ls -l $DIR/$tdir > /dev/null
13228 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13229 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13230 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13231 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13232 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13234 # set lru_max_age to 1 sec
13235 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13236 echo "sleep $((recalc_p * 2)) seconds..."
13237 sleep $((recalc_p * 2))
13239 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13240 # restore lru_max_age
13241 $LCTL set_param -n $nsdir.lru_max_age $max_age
13242 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13243 unlinkmany $DIR/$tdir/f $nr
13245 run_test 124c "LRUR cancel very aged locks"
13248 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13249 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13250 skip_env "no lru resize on server"
13252 # cache ununsed locks on client
13255 lru_resize_disable mdc
13256 stack_trap "lru_resize_enable mdc" EXIT
13258 cancel_lru_locks mdc
13260 # asynchronous object destroy at MDT could cause bl ast to client
13261 test_mkdir $DIR/$tdir
13262 createmany -o $DIR/$tdir/f $nr ||
13263 error "failed to create $nr files in $DIR/$tdir"
13264 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
13266 ls -l $DIR/$tdir > /dev/null
13268 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13269 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13270 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13271 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13273 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13275 # set lru_max_age to 1 sec
13276 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13277 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
13279 echo "sleep $((recalc_p * 2)) seconds..."
13280 sleep $((recalc_p * 2))
13282 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13284 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13286 run_test 124d "cancel very aged locks if lru-resize diasbaled"
13288 test_125() { # 13358
13289 $LCTL get_param -n llite.*.client_type | grep -q local ||
13290 skip "must run as local client"
13291 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
13292 skip_env "must have acl enabled"
13293 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13295 test_mkdir $DIR/$tdir
13296 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
13297 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
13298 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
13300 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
13302 test_126() { # bug 12829/13455
13303 $GSS && skip_env "must run as gss disabled"
13304 $LCTL get_param -n llite.*.client_type | grep -q local ||
13305 skip "must run as local client"
13306 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
13308 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
13309 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
13311 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
13313 run_test 126 "check that the fsgid provided by the client is taken into account"
13315 test_127a() { # bug 15521
13316 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13317 local name count samp unit min max sum sumsq
13319 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
13320 echo "stats before reset"
13321 $LCTL get_param osc.*.stats
13322 $LCTL set_param osc.*.stats=0
13323 local fsize=$((2048 * 1024))
13325 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
13326 cancel_lru_locks osc
13327 dd if=$DIR/$tfile of=/dev/null bs=$fsize
13329 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
13330 stack_trap "rm -f $TMP/$tfile.tmp"
13331 while read name count samp unit min max sum sumsq; do
13332 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13333 [ ! $min ] && error "Missing min value for $name proc entry"
13334 eval $name=$count || error "Wrong proc format"
13337 read_bytes|write_bytes)
13338 [[ "$unit" =~ "bytes" ]] ||
13339 error "unit is not 'bytes': $unit"
13340 (( $min >= 4096 )) || error "min is too small: $min"
13341 (( $min <= $fsize )) || error "min is too big: $min"
13342 (( $max >= 4096 )) || error "max is too small: $max"
13343 (( $max <= $fsize )) || error "max is too big: $max"
13344 (( $sum == $fsize )) || error "sum is wrong: $sum"
13345 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
13346 error "sumsquare is too small: $sumsq"
13347 (( $sumsq <= $fsize * $fsize )) ||
13348 error "sumsquare is too big: $sumsq"
13350 ost_read|ost_write)
13351 [[ "$unit" =~ "usec" ]] ||
13352 error "unit is not 'usec': $unit"
13356 done < $DIR/$tfile.tmp
13358 #check that we actually got some stats
13359 [ "$read_bytes" ] || error "Missing read_bytes stats"
13360 [ "$write_bytes" ] || error "Missing write_bytes stats"
13361 [ "$read_bytes" != 0 ] || error "no read done"
13362 [ "$write_bytes" != 0 ] || error "no write done"
13364 run_test 127a "verify the client stats are sane"
13366 test_127b() { # bug LU-333
13367 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13368 local name count samp unit min max sum sumsq
13370 echo "stats before reset"
13371 $LCTL get_param llite.*.stats
13372 $LCTL set_param llite.*.stats=0
13374 # perform 2 reads and writes so MAX is different from SUM.
13375 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13376 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13377 cancel_lru_locks osc
13378 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13379 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13381 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
13382 stack_trap "rm -f $TMP/$tfile.tmp"
13383 while read name count samp unit min max sum sumsq; do
13384 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13385 eval $name=$count || error "Wrong proc format"
13388 read_bytes|write_bytes)
13389 [[ "$unit" =~ "bytes" ]] ||
13390 error "unit is not 'bytes': $unit"
13391 (( $count == 2 )) || error "count is not 2: $count"
13392 (( $min == $PAGE_SIZE )) ||
13393 error "min is not $PAGE_SIZE: $min"
13394 (( $max == $PAGE_SIZE )) ||
13395 error "max is not $PAGE_SIZE: $max"
13396 (( $sum == $PAGE_SIZE * 2 )) ||
13397 error "sum is not $((PAGE_SIZE * 2)): $sum"
13400 [[ "$unit" =~ "usec" ]] ||
13401 error "unit is not 'usec': $unit"
13405 done < $TMP/$tfile.tmp
13407 #check that we actually got some stats
13408 [ "$read_bytes" ] || error "Missing read_bytes stats"
13409 [ "$write_bytes" ] || error "Missing write_bytes stats"
13410 [ "$read_bytes" != 0 ] || error "no read done"
13411 [ "$write_bytes" != 0 ] || error "no write done"
13413 run_test 127b "verify the llite client stats are sane"
13415 test_127c() { # LU-12394
13416 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13423 $LCTL set_param llite.*.extents_stats=1
13424 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
13426 # Use two stripes so there is enough space in default config
13427 $LFS setstripe -c 2 $DIR/$tfile
13429 # Extent stats start at 0-4K and go in power of two buckets
13430 # LL_HIST_START = 12 --> 2^12 = 4K
13431 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
13432 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
13434 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
13436 # Write and read, 2x each, second time at a non-zero offset
13437 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
13438 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
13439 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
13440 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
13444 $LCTL get_param llite.*.extents_stats
13447 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
13449 local bucket=$($LCTL get_param -n llite.*.extents_stats |
13451 reads=$(echo $bucket | awk '{print $5}')
13452 writes=$(echo $bucket | awk '{print $9}')
13453 [ "$reads" -eq $count ] ||
13454 error "$reads reads in < $bsize bucket, expect $count"
13455 [ "$writes" -eq $count ] ||
13456 error "$writes writes in < $bsize bucket, expect $count"
13459 # Test mmap write and read
13460 $LCTL set_param llite.*.extents_stats=c
13462 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
13463 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
13464 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
13466 $LCTL get_param llite.*.extents_stats
13468 count=$(((size*1024) / PAGE_SIZE))
13470 bsize=$((2 * PAGE_SIZE / 1024))K
13472 bucket=$($LCTL get_param -n llite.*.extents_stats |
13474 reads=$(echo $bucket | awk '{print $5}')
13475 writes=$(echo $bucket | awk '{print $9}')
13476 # mmap writes fault in the page first, creating an additonal read
13477 [ "$reads" -eq $((2 * count)) ] ||
13478 error "$reads reads in < $bsize bucket, expect $count"
13479 [ "$writes" -eq $count ] ||
13480 error "$writes writes in < $bsize bucket, expect $count"
13482 run_test 127c "test llite extent stats with regular & mmap i/o"
13484 test_128() { # bug 15212
13486 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
13491 result=$(grep error $TMP/$tfile.log)
13492 rm -f $DIR/$tfile $TMP/$tfile.log
13493 [ -z "$result" ] ||
13494 error "consecutive find's under interactive lfs failed"
13496 run_test 128 "interactive lfs for 2 consecutive find's"
13498 set_dir_limits () {
13503 local ldproc=/proc/fs/ldiskfs
13504 local facets=$(get_facets MDS)
13506 for facet in ${facets//,/ }; do
13507 canondev=$(ldiskfs_canon \
13508 *.$(convert_facet2label $facet).mntdev $facet)
13509 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
13510 ldproc=/sys/fs/ldiskfs
13511 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
13512 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
13516 check_mds_dmesg() {
13517 local facets=$(get_facets MDS)
13518 for facet in ${facets//,/ }; do
13519 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
13525 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13526 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
13527 skip "Need MDS version with at least 2.5.56"
13528 if [ "$mds1_FSTYPE" != ldiskfs ]; then
13529 skip_env "ldiskfs only test"
13531 remote_mds_nodsh && skip "remote MDS with nodsh"
13534 local has_warning=false
13537 mkdir -p $DIR/$tdir
13539 # block size of mds1
13540 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
13541 set_dir_limits $maxsize $((maxsize * 6 / 8))
13542 stack_trap "set_dir_limits 0 0"
13543 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
13544 local dirsize=$(stat -c%s "$DIR/$tdir")
13546 while (( $dirsize <= $maxsize )); do
13547 $MCREATE $DIR/$tdir/file_base_$nfiles
13549 # check two errors:
13550 # ENOSPC for ext4 max_dir_size, which has been used since
13551 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
13552 if (( rc == ENOSPC )); then
13554 echo "rc=$rc returned as expected after $nfiles files"
13556 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
13557 error "create failed w/o dir size limit"
13559 # messages may be rate limited if test is run repeatedly
13560 check_mds_dmesg '"is approaching max"' ||
13561 echo "warning message should be output"
13562 check_mds_dmesg '"has reached max"' ||
13563 echo "reached message should be output"
13565 dirsize=$(stat -c%s "$DIR/$tdir")
13567 [[ $dirsize -ge $maxsize ]] && return 0
13568 error "dirsize $dirsize < $maxsize after $nfiles files"
13569 elif (( rc != 0 )); then
13572 nfiles=$((nfiles + 1))
13573 dirsize=$(stat -c%s "$DIR/$tdir")
13576 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
13578 run_test 129 "test directory size limit ========================"
13587 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13588 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13590 trap cleanup_130 EXIT RETURN
13592 local fm_file=$DIR/$tfile
13593 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
13594 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
13595 error "dd failed for $fm_file"
13597 # LU-1795: test filefrag/FIEMAP once, even if unsupported
13598 filefrag -ves $fm_file
13600 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13601 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13602 [ $RC != 0 ] && error "filefrag $fm_file failed"
13604 filefrag_op=$(filefrag -ve -k $fm_file |
13605 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13606 lun=$($LFS getstripe -i $fm_file)
13608 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
13611 for line in $filefrag_op
13613 frag_lun=`echo $line | cut -d: -f5`
13614 ext_len=`echo $line | cut -d: -f4`
13615 if (( $frag_lun != $lun )); then
13617 error "FIEMAP on 1-stripe file($fm_file) failed"
13620 (( tot_len += ext_len ))
13623 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
13625 error "FIEMAP on 1-stripe file($fm_file) failed;"
13631 echo "FIEMAP on single striped file succeeded"
13633 run_test 130a "FIEMAP (1-stripe file)"
13636 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13638 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13639 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13641 trap cleanup_130 EXIT RETURN
13643 local fm_file=$DIR/$tfile
13644 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13645 error "setstripe on $fm_file"
13646 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13647 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13649 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
13650 error "dd failed on $fm_file"
13652 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13653 filefrag_op=$(filefrag -ve -k $fm_file |
13654 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13656 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13657 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13662 for line in $filefrag_op
13664 frag_lun=$(echo $line | cut -d: -f5 |
13665 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13666 ext_len=$(echo $line | cut -d: -f4)
13667 if (( $frag_lun != $last_lun )); then
13668 if (( tot_len != 1024 )); then
13670 error "FIEMAP on $fm_file failed; returned " \
13671 "len $tot_len for OST $last_lun instead of 1024"
13674 (( num_luns += 1 ))
13678 (( tot_len += ext_len ))
13681 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
13683 error "FIEMAP on $fm_file failed; returned wrong number of " \
13684 "luns or wrong len for OST $last_lun"
13690 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
13692 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
13695 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13697 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13698 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13700 trap cleanup_130 EXIT RETURN
13702 local fm_file=$DIR/$tfile
13703 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
13704 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13705 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13707 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
13708 error "dd failed on $fm_file"
13710 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13711 filefrag_op=$(filefrag -ve -k $fm_file |
13712 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13714 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13715 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13720 for line in $filefrag_op
13722 frag_lun=$(echo $line | cut -d: -f5 |
13723 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13724 ext_len=$(echo $line | cut -d: -f4)
13725 if (( $frag_lun != $last_lun )); then
13726 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
13727 if (( logical != 512 )); then
13729 error "FIEMAP on $fm_file failed; returned " \
13730 "logical start for lun $logical instead of 512"
13733 if (( tot_len != 512 )); then
13735 error "FIEMAP on $fm_file failed; returned " \
13736 "len $tot_len for OST $last_lun instead of 1024"
13739 (( num_luns += 1 ))
13743 (( tot_len += ext_len ))
13746 if (( num_luns != 2 || tot_len != 512 )); then
13748 error "FIEMAP on $fm_file failed; returned wrong number of " \
13749 "luns or wrong len for OST $last_lun"
13755 echo "FIEMAP on 2-stripe file with hole succeeded"
13757 run_test 130c "FIEMAP (2-stripe file with hole)"
13760 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
13762 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13763 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13765 trap cleanup_130 EXIT RETURN
13767 local fm_file=$DIR/$tfile
13768 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13769 error "setstripe on $fm_file"
13770 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13771 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13773 local actual_stripe_count=$($LFS getstripe -c $fm_file)
13774 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
13775 error "dd failed on $fm_file"
13777 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13778 filefrag_op=$(filefrag -ve -k $fm_file |
13779 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13781 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13782 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13787 for line in $filefrag_op
13789 frag_lun=$(echo $line | cut -d: -f5 |
13790 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13791 ext_len=$(echo $line | cut -d: -f4)
13792 if (( $frag_lun != $last_lun )); then
13793 if (( tot_len != 1024 )); then
13795 error "FIEMAP on $fm_file failed; returned " \
13796 "len $tot_len for OST $last_lun instead of 1024"
13799 (( num_luns += 1 ))
13803 (( tot_len += ext_len ))
13806 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
13808 error "FIEMAP on $fm_file failed; returned wrong number of " \
13809 "luns or wrong len for OST $last_lun"
13815 echo "FIEMAP on N-stripe file succeeded"
13817 run_test 130d "FIEMAP (N-stripe file)"
13820 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13822 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13823 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13825 trap cleanup_130 EXIT RETURN
13827 local fm_file=$DIR/$tfile
13828 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
13831 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
13832 for ((i = 0; i < $NUM_BLKS; i++)); do
13833 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
13834 conv=notrunc > /dev/null 2>&1
13837 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13838 filefrag_op=$(filefrag -ve -k $fm_file |
13839 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13841 last_lun=$(echo $filefrag_op | cut -d: -f5)
13846 for line in $filefrag_op; do
13847 frag_lun=$(echo $line | cut -d: -f5)
13848 ext_len=$(echo $line | cut -d: -f4)
13849 if [[ "$frag_lun" != "$last_lun" ]]; then
13850 if (( tot_len != $EXPECTED_LEN )); then
13852 error "OST$last_lun $tot_len != $EXPECTED_LEN"
13854 (( num_luns += 1 ))
13858 (( tot_len += ext_len ))
13861 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
13863 error "OST$last_lun $num_luns != 2, $tot_len != $EXPECTED_LEN"
13866 echo "FIEMAP with continuation calls succeeded"
13868 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
13871 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13872 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13874 local fm_file=$DIR/$tfile
13875 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
13876 error "multiop create with lov_delay_create on $fm_file"
13878 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13879 filefrag_extents=$(filefrag -vek $fm_file |
13880 awk '/extents? found/ { print $2 }')
13881 if [[ "$filefrag_extents" != "0" ]]; then
13882 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
13887 run_test 130f "FIEMAP (unstriped file)"
13890 local file=$DIR/$tfile
13891 local nr=$((OSTCOUNT * 100))
13893 $LFS setstripe -C $nr $file ||
13894 error "failed to setstripe -C $nr $file"
13896 dd if=/dev/zero of=$file count=$nr bs=1M
13898 nr=$($LFS getstripe -c $file)
13900 local extents=$(filefrag -v $file |
13901 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
13903 echo "filefrag list $extents extents in file with stripecount $nr"
13904 if (( extents < nr )); then
13905 $LFS getstripe $file
13907 error "filefrag printed $extents < $nr extents"
13912 run_test 130g "FIEMAP (overstripe file)"
13914 # Test for writev/readv
13916 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
13917 error "writev test failed"
13918 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
13919 error "readv failed"
13922 run_test 131a "test iov's crossing stripe boundary for writev/readv"
13925 local fsize=$((524288 + 1048576 + 1572864))
13926 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
13927 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
13928 error "append writev test failed"
13930 ((fsize += 1572864 + 1048576))
13931 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
13932 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
13933 error "append writev test failed"
13936 run_test 131b "test append writev"
13939 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
13942 run_test 131c "test read/write on file w/o objects"
13945 rwv -f $DIR/$tfile -w -n 1 1572864
13946 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
13947 if [ "$NOB" != 1572864 ]; then
13948 error "Short read filed: read $NOB bytes instead of 1572864"
13952 run_test 131d "test short read"
13955 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
13956 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
13957 error "read hitting hole failed"
13960 run_test 131e "test read hitting hole"
13969 mds*) res=$(do_facet $facet \
13970 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
13972 ost*) res=$(do_facet $facet \
13973 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
13975 *) error "Wrong facet '$facet'" ;;
13977 [ "$res" ] || error "The counter for $op on $facet was not incremented"
13978 # if the argument $3 is zero, it means any stat increment is ok.
13979 if [[ $want -gt 0 ]]; then
13980 local count=$(echo $res | awk '{ print $2 }')
13981 [[ $count -ne $want ]] &&
13982 error "The $op counter on $facet is $count, not $want"
13987 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13988 remote_ost_nodsh && skip "remote OST with nodsh"
13989 remote_mds_nodsh && skip "remote MDS with nodsh"
13990 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
13991 skip_env "MDS doesn't support rename stats"
13993 local testdir=$DIR/${tdir}/stats_testdir
13995 mkdir -p $DIR/${tdir}
13998 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
13999 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14001 # verify mdt stats first.
14002 mkdir ${testdir} || error "mkdir failed"
14003 check_stats $SINGLEMDS "mkdir" 1
14004 touch ${testdir}/${tfile} || error "touch failed"
14005 check_stats $SINGLEMDS "open" 1
14006 check_stats $SINGLEMDS "close" 1
14007 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
14008 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
14009 check_stats $SINGLEMDS "mknod" 2
14011 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
14012 check_stats $SINGLEMDS "unlink" 1
14013 rm -f ${testdir}/${tfile} || error "file remove failed"
14014 check_stats $SINGLEMDS "unlink" 2
14016 # remove working dir and check mdt stats again.
14017 rmdir ${testdir} || error "rmdir failed"
14018 check_stats $SINGLEMDS "rmdir" 1
14020 local testdir1=$DIR/${tdir}/stats_testdir1
14021 mkdir -p ${testdir}
14022 mkdir -p ${testdir1}
14023 touch ${testdir1}/test1
14024 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
14025 check_stats $SINGLEMDS "crossdir_rename" 1
14027 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
14028 check_stats $SINGLEMDS "samedir_rename" 1
14030 rm -rf $DIR/${tdir}
14032 run_test 133a "Verifying MDT stats ========================================"
14037 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14038 remote_ost_nodsh && skip "remote OST with nodsh"
14039 remote_mds_nodsh && skip "remote MDS with nodsh"
14041 local testdir=$DIR/${tdir}/stats_testdir
14043 mkdir -p ${testdir} || error "mkdir failed"
14044 touch ${testdir}/${tfile} || error "touch failed"
14045 cancel_lru_locks mdc
14048 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14049 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14051 # extra mdt stats verification.
14052 chmod 444 ${testdir}/${tfile} || error "chmod failed"
14053 check_stats $SINGLEMDS "setattr" 1
14054 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14055 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
14057 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
14058 check_stats $SINGLEMDS "getattr" 1
14060 rm -rf $DIR/${tdir}
14062 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
14063 # so the check below is not reliable
14064 [ $MDSCOUNT -eq 1 ] || return 0
14066 # Sleep to avoid a cached response.
14067 #define OBD_STATFS_CACHE_SECONDS 1
14069 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14070 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14071 $LFS df || error "lfs failed"
14072 check_stats $SINGLEMDS "statfs" 1
14074 # check aggregated statfs (LU-10018)
14075 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
14077 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
14080 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14081 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14083 check_stats $SINGLEMDS "statfs" 1
14085 # We want to check that the client didn't send OST_STATFS to
14086 # ost1 but the MDT also uses OST_STATFS for precreate. So some
14087 # extra care is needed here.
14088 if remote_mds; then
14089 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
14090 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
14092 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
14093 [ "$res" ] && error "OST got STATFS"
14098 run_test 133b "Verifying extra MDT stats =================================="
14101 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14102 remote_ost_nodsh && skip "remote OST with nodsh"
14103 remote_mds_nodsh && skip "remote MDS with nodsh"
14105 local testdir=$DIR/$tdir/stats_testdir
14107 test_mkdir -p $testdir
14109 # verify obdfilter stats.
14110 $LFS setstripe -c 1 -i 0 $testdir/$tfile
14112 cancel_lru_locks osc
14113 wait_delete_completed
14116 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14117 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14119 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
14122 cancel_lru_locks osc
14123 check_stats ost1 "write" 1
14125 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
14126 check_stats ost1 "read" 1
14128 > $testdir/$tfile || error "truncate failed"
14129 check_stats ost1 "punch" 1
14131 rm -f $testdir/$tfile || error "file remove failed"
14132 wait_delete_completed
14133 check_stats ost1 "destroy" 1
14137 run_test 133c "Verifying OST stats ========================================"
14144 while [ $value -ge 2 ]; do
14149 if [ $orig -gt $order ]; then
14157 local size=('K' 'M' 'G' 'T');
14159 local size_string=$value
14161 while [ $value -ge 1024 ]; do
14162 if [ $i -gt 3 ]; then
14163 #T is the biggest unit we get here, if that is bigger,
14165 size_string=${value}T
14168 value=$((value >> 10))
14169 if [ $value -lt 1024 ]; then
14170 size_string=${value}${size[$i]}
14179 get_rename_size() {
14181 local context=${2:-.}
14182 local sample=$(do_facet $SINGLEMDS $LCTL \
14183 get_param mdt.$FSNAME-MDT0000.rename_stats |
14184 grep -A1 $context |
14185 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
14190 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14191 remote_ost_nodsh && skip "remote OST with nodsh"
14192 remote_mds_nodsh && skip "remote MDS with nodsh"
14193 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14194 skip_env "MDS doesn't support rename stats"
14196 local testdir1=$DIR/${tdir}/stats_testdir1
14197 local testdir2=$DIR/${tdir}/stats_testdir2
14198 mkdir -p $DIR/${tdir}
14200 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14202 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
14203 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
14205 createmany -o $testdir1/test 512 || error "createmany failed"
14207 # check samedir rename size
14208 mv ${testdir1}/test0 ${testdir1}/test_0
14210 local testdir1_size=$(ls -l $DIR/${tdir} |
14211 awk '/stats_testdir1/ {print $5}')
14212 local testdir2_size=$(ls -l $DIR/${tdir} |
14213 awk '/stats_testdir2/ {print $5}')
14215 testdir1_size=$(order_2 $testdir1_size)
14216 testdir2_size=$(order_2 $testdir2_size)
14218 testdir1_size=$(size_in_KMGT $testdir1_size)
14219 testdir2_size=$(size_in_KMGT $testdir2_size)
14221 echo "source rename dir size: ${testdir1_size}"
14222 echo "target rename dir size: ${testdir2_size}"
14224 local cmd="do_facet $SINGLEMDS $LCTL "
14225 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
14227 eval $cmd || error "$cmd failed"
14228 local samedir=$($cmd | grep 'same_dir')
14229 local same_sample=$(get_rename_size $testdir1_size)
14230 [ -z "$samedir" ] && error "samedir_rename_size count error"
14231 [[ $same_sample -eq 1 ]] ||
14232 error "samedir_rename_size error $same_sample"
14233 echo "Check same dir rename stats success"
14235 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14237 # check crossdir rename size
14238 mv ${testdir1}/test_0 ${testdir2}/test_0
14240 testdir1_size=$(ls -l $DIR/${tdir} |
14241 awk '/stats_testdir1/ {print $5}')
14242 testdir2_size=$(ls -l $DIR/${tdir} |
14243 awk '/stats_testdir2/ {print $5}')
14245 testdir1_size=$(order_2 $testdir1_size)
14246 testdir2_size=$(order_2 $testdir2_size)
14248 testdir1_size=$(size_in_KMGT $testdir1_size)
14249 testdir2_size=$(size_in_KMGT $testdir2_size)
14251 echo "source rename dir size: ${testdir1_size}"
14252 echo "target rename dir size: ${testdir2_size}"
14254 eval $cmd || error "$cmd failed"
14255 local crossdir=$($cmd | grep 'crossdir')
14256 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
14257 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
14258 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
14259 [[ $src_sample -eq 1 ]] ||
14260 error "crossdir_rename_size error $src_sample"
14261 [[ $tgt_sample -eq 1 ]] ||
14262 error "crossdir_rename_size error $tgt_sample"
14263 echo "Check cross dir rename stats success"
14264 rm -rf $DIR/${tdir}
14266 run_test 133d "Verifying rename_stats ========================================"
14269 remote_mds_nodsh && skip "remote MDS with nodsh"
14270 remote_ost_nodsh && skip "remote OST with nodsh"
14271 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14273 local testdir=$DIR/${tdir}/stats_testdir
14274 local ctr f0 f1 bs=32768 count=42 sum
14276 mkdir -p ${testdir} || error "mkdir failed"
14278 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
14280 for ctr in {write,read}_bytes; do
14282 cancel_lru_locks osc
14284 do_facet ost1 $LCTL set_param -n \
14285 "obdfilter.*.exports.clear=clear"
14287 if [ $ctr = write_bytes ]; then
14289 f1=${testdir}/${tfile}
14291 f0=${testdir}/${tfile}
14295 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
14298 cancel_lru_locks osc
14300 sum=$(do_facet ost1 $LCTL get_param \
14301 "obdfilter.*.exports.*.stats" |
14302 awk -v ctr=$ctr 'BEGIN { sum = 0 }
14303 $1 == ctr { sum += $7 }
14304 END { printf("%0.0f", sum) }')
14306 if ((sum != bs * count)); then
14307 error "Bad $ctr sum, expected $((bs * count)), got $sum"
14311 rm -rf $DIR/${tdir}
14313 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
14316 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
14317 skip "too old lustre for get_param -R ($facet_ver)"
14319 # verifying readability.
14320 $LCTL get_param -R '*' &> /dev/null
14322 # Verifing writability with badarea_io.
14323 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14324 local skipped_params='force_lbug|changelog_mask|daemon_file'
14325 $LCTL list_param -FR '*' | grep '=' | tr -d = |
14326 egrep -v "$skipped_params" |
14327 xargs -n 1 find $proc_dirs -name |
14328 xargs -n 1 badarea_io ||
14329 error "client badarea_io failed"
14331 # remount the FS in case writes/reads /proc break the FS
14332 cleanup || error "failed to unmount"
14333 setup || error "failed to setup"
14335 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
14338 remote_mds_nodsh && skip "remote MDS with nodsh"
14339 remote_ost_nodsh && skip "remote OST with nodsh"
14341 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14342 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
14344 for facet in mds1 ost1; do
14345 local facet_ver=$(lustre_version_code $facet)
14346 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
14347 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
14349 log "$facet: too old lustre for get_param -R"
14351 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
14352 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
14353 tr -d = | egrep -v $skipped_params |
14354 xargs -n 1 find $proc_dirs -name |
14355 xargs -n 1 badarea_io" ||
14356 error "$facet badarea_io failed"
14358 skip_noexit "$facet: too old lustre for get_param -R"
14362 # remount the FS in case writes/reads /proc break the FS
14363 cleanup || error "failed to unmount"
14364 setup || error "failed to setup"
14366 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
14369 remote_mds_nodsh && skip "remote MDS with nodsh"
14370 remote_ost_nodsh && skip "remote OST with nodsh"
14371 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
14372 skip "Need MDS version at least 2.9.54"
14375 for facet in client mds1 ost1; do
14376 # Get the list of files that are missing the terminating newline
14377 local plist=$(do_facet $facet
14378 $LCTL list_param -FR '*' | grep '=' | tr -d =)
14380 for ent in $plist; do
14381 local missing=$(do_facet $facet $LCTL get_param $ent \|\
14382 awk -v FS='\v' -v RS='\v\v' \
14383 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
14384 print FILENAME}'" 2>/dev/null)
14385 [ -z $missing ] || {
14386 do_facet $facet $LCTL get_param $ent | od -An -tx1
14387 error "file does not end with newline: $facet-$ent"
14392 run_test 133h "Proc files should end with newlines"
14395 remote_mds_nodsh && skip "remote MDS with nodsh"
14396 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14397 skip "Need MDS version at least 2.7.54"
14399 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14400 cancel_lru_locks mdc
14402 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14403 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14404 [ $unused -eq 0 ] || error "$unused locks are not cleared"
14407 createmany -o $DIR/$tdir/f $nr ||
14408 error "failed to create $nr files in $DIR/$tdir"
14409 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14411 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
14412 do_facet mds1 $LCTL set_param fail_loc=0x327
14413 do_facet mds1 $LCTL set_param fail_val=500
14416 echo "sleep 10 seconds ..."
14418 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
14420 do_facet mds1 $LCTL set_param fail_loc=0
14421 do_facet mds1 $LCTL set_param fail_val=0
14422 [ $lck_cnt -lt $unused ] ||
14423 error "No locks reclaimed, before:$unused, after:$lck_cnt"
14426 unlinkmany $DIR/$tdir/f $nr
14428 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
14431 remote_mds_nodsh && skip "remote MDS with nodsh"
14432 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14433 skip "Need MDS version at least 2.7.54"
14435 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14436 cancel_lru_locks mdc
14438 local low_wm=$(do_facet mds1 $LCTL get_param -n \
14439 ldlm.lock_reclaim_threshold_mb)
14440 # disable reclaim temporarily
14441 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
14443 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
14444 do_facet mds1 $LCTL set_param fail_loc=0x328
14445 do_facet mds1 $LCTL set_param fail_val=500
14447 $LCTL set_param debug=+trace
14450 createmany -o $DIR/$tdir/f $nr &
14451 local create_pid=$!
14453 echo "Sleep $TIMEOUT seconds ..."
14455 if ! ps -p $create_pid > /dev/null 2>&1; then
14456 do_facet mds1 $LCTL set_param fail_loc=0
14457 do_facet mds1 $LCTL set_param fail_val=0
14458 do_facet mds1 $LCTL set_param \
14459 ldlm.lock_reclaim_threshold_mb=${low_wm}m
14460 error "createmany finished incorrectly!"
14462 do_facet mds1 $LCTL set_param fail_loc=0
14463 do_facet mds1 $LCTL set_param fail_val=0
14464 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
14465 wait $create_pid || return 1
14467 unlinkmany $DIR/$tdir/f $nr
14469 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
14472 remote_mds_nodsh && skip "remote MDS with nodsh"
14473 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14474 skip "Need MDS version at least 2.13.50"
14477 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14479 #define OBD_FAIL_PLAIN_RECORDS 0x1319
14480 #set only one record at plain llog
14481 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
14483 #fill already existed plain llog each 64767
14484 #wrapping whole catalog
14485 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14487 createmany -o $DIR/$tdir/$tfile_ 64700
14488 for (( i = 0; i < 64700; i = i + 2 ))
14490 rm $DIR/$tdir/$tfile_$i &
14491 rm $DIR/$tdir/$tfile_$((i + 1)) &
14496 #waiting osp synchronization
14497 wait_delete_completed
14499 run_test 135 "Race catalog processing"
14502 remote_mds_nodsh && skip "remote MDS with nodsh"
14503 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14504 skip "Need MDS version at least 2.13.50"
14507 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14508 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
14509 #set only one record at plain llog
14510 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
14511 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
14513 #fill already existed 2 plain llogs each 64767
14514 #wrapping whole catalog
14515 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14516 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
14517 wait_delete_completed
14519 createmany -o $DIR/$tdir/$tfile_ 10
14522 do_facet $SINGLEMDS $LCTL set_param fail_val=3
14523 for (( i = 0; i < 10; i = i + 3 ))
14525 rm $DIR/$tdir/$tfile_$i &
14526 rm $DIR/$tdir/$tfile_$((i + 1)) &
14530 rm $DIR/$tdir/$tfile_$((i + 2)) &
14533 #waiting osp synchronization
14534 wait_delete_completed
14536 run_test 136 "Race catalog processing 2"
14538 test_140() { #bug-17379
14539 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14541 test_mkdir $DIR/$tdir
14542 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
14543 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
14545 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
14546 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
14548 while i=$((i + 1)); do
14550 cd $i || error "Changing to $i"
14551 ln -s ../stat stat || error "Creating stat symlink"
14552 # Read the symlink until ELOOP present,
14553 # not LBUGing the system is considered success,
14554 # we didn't overrun the stack.
14555 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
14556 if [ $ret -ne 0 ]; then
14557 if [ $ret -eq 40 ]; then
14560 error "Open stat symlink"
14566 echo "The symlink depth = $i"
14567 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
14568 error "Invalid symlink depth"
14570 # Test recursive symlink
14571 ln -s symlink_self symlink_self
14572 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
14573 echo "open symlink_self returns $ret"
14574 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
14576 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
14579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14581 local TF="$TMP/$tfile"
14583 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14584 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14586 cancel_lru_locks $OSC
14587 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
14588 remount_client $MOUNT
14590 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
14593 $TRUNCATE $DIR/$tfile 6000
14594 cancel_lru_locks $OSC
14595 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
14598 echo "12345" >>$DIR/$tfile
14599 cancel_lru_locks $OSC
14600 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
14603 echo "12345" >>$DIR/$tfile
14604 cancel_lru_locks $OSC
14605 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
14607 run_test 150a "truncate/append tests"
14610 check_set_fallocate_or_skip
14613 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14614 check_fallocate $DIR/$tfile || skip_eopnotsupp "fallocate failed"
14616 run_test 150b "Verify fallocate (prealloc) functionality"
14619 check_set_fallocate_or_skip
14622 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14623 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
14625 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14626 # precomputed md5sum for 20MB of zeroes
14627 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
14628 local sum=($(md5sum $DIR/$tfile))
14630 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
14632 check_set_fallocate 1
14635 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14636 sum=($(md5sum $DIR/$tfile))
14638 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
14640 run_test 150bb "Verify fallocate modes both zero space"
14643 check_set_fallocate_or_skip
14644 local striping="-c2"
14646 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14647 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
14648 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
14649 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14650 local want=$((OSTCOUNT * 1048576))
14652 # Must allocate all requested space, not more than 5% extra
14653 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14654 error "bytes $bytes is not $want"
14658 echo "verify fallocate on PFL file"
14660 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14662 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
14663 error "Create $DIR/$tfile failed"
14664 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
14665 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14666 want=$((512 * 1048576))
14668 # Must allocate all requested space, not more than 5% extra
14669 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14670 error "bytes $bytes is not $want"
14672 run_test 150c "Verify fallocate Size and Blocks"
14675 check_set_fallocate_or_skip
14676 local striping="-c2"
14678 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14680 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14681 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
14682 error "setstripe failed"
14683 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
14684 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
14685 local want=$((OSTCOUNT * 1048576))
14687 # Must allocate all requested space, not more than 5% extra
14688 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14689 error "bytes $bytes is not $want"
14691 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
14694 check_set_fallocate_or_skip
14698 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14699 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
14700 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
14702 # Find OST with Minimum Size
14703 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
14704 sort -un | head -1)
14706 # Get 100MB per OST of the available space to reduce run time
14707 # else 60% of the available space if we are running SLOW tests
14708 if [ $SLOW == "no" ]; then
14709 local space=$((1024 * 100 * OSTCOUNT))
14711 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
14714 fallocate -l${space}k $DIR/$tfile ||
14715 error "fallocate ${space}k $DIR/$tfile failed"
14716 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
14718 # get size immediately after fallocate. This should be correctly
14720 local size=$(stat -c '%s' $DIR/$tfile)
14721 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
14723 # Sleep for a while for statfs to get updated. And not pull from cache.
14726 echo "df after fallocate:"
14729 (( size / 1024 == space )) || error "size $size != requested $space"
14730 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
14731 error "used $used < space $space"
14733 rm $DIR/$tfile || error "rm failed"
14735 wait_delete_completed
14737 echo "df after unlink:"
14740 run_test 150e "Verify 60% of available OST space consumed by fallocate"
14745 local want_size_before=20480 # in bytes
14746 local want_blocks_before=40 # 512 sized blocks
14747 local want_blocks_after=24 # 512 sized blocks
14748 local length=$(((want_blocks_before - want_blocks_after) * 512))
14750 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14751 skip "need at least 2.14.0 for fallocate punch"
14753 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14754 skip "LU-14160: punch mode is not implemented on OSD ZFS"
14757 check_set_fallocate_or_skip
14758 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14760 [[ "x$DOM" == "xyes" ]] &&
14761 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
14763 echo "Verify fallocate punch: Range within the file range"
14764 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14765 error "dd failed for bs 4096 and count 5"
14767 # Call fallocate with punch range which is within the file range
14768 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
14769 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
14770 # client must see changes immediately after fallocate
14771 size=$(stat -c '%s' $DIR/$tfile)
14772 blocks=$(stat -c '%b' $DIR/$tfile)
14774 # Verify punch worked.
14775 (( blocks == want_blocks_after )) ||
14776 error "punch failed: blocks $blocks != $want_blocks_after"
14778 (( size == want_size_before )) ||
14779 error "punch failed: size $size != $want_size_before"
14781 # Verify there is hole in file
14782 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
14783 # precomputed md5sum
14784 local expect="4a9a834a2db02452929c0a348273b4aa"
14786 cksum=($(md5sum $DIR/$tfile))
14787 [[ "${cksum[0]}" == "$expect" ]] ||
14788 error "unexpected MD5SUM after punch: ${cksum[0]}"
14790 # Start second sub-case for fallocate punch.
14791 echo "Verify fallocate punch: Range overlapping and less than blocksize"
14792 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14793 error "dd failed for bs 4096 and count 5"
14795 # Punch range less than block size will have no change in block count
14796 want_blocks_after=40 # 512 sized blocks
14798 # Punch overlaps two blocks and less than blocksize
14799 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
14800 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
14801 size=$(stat -c '%s' $DIR/$tfile)
14802 blocks=$(stat -c '%b' $DIR/$tfile)
14804 # Verify punch worked.
14805 (( blocks == want_blocks_after )) ||
14806 error "punch failed: blocks $blocks != $want_blocks_after"
14808 (( size == want_size_before )) ||
14809 error "punch failed: size $size != $want_size_before"
14811 # Verify if range is really zero'ed out. We expect Zeros.
14812 # precomputed md5sum
14813 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
14814 cksum=($(md5sum $DIR/$tfile))
14815 [[ "${cksum[0]}" == "$expect" ]] ||
14816 error "unexpected MD5SUM after punch: ${cksum[0]}"
14818 run_test 150f "Verify fallocate punch functionality"
14826 local BS=4096 # Block size in bytes
14828 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14829 skip "need at least 2.14.0 for fallocate punch"
14831 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14832 skip "LU-14160: punch mode is not implemented on OSD ZFS"
14835 check_set_fallocate_or_skip
14836 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14838 if [[ "x$DOM" == "xyes" ]]; then
14839 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
14840 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
14842 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
14843 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
14846 # Get 100MB per OST of the available space to reduce run time
14847 # else 60% of the available space if we are running SLOW tests
14848 if [ $SLOW == "no" ]; then
14849 space=$((1024 * 100 * OSTCOUNT))
14851 # Find OST with Minimum Size
14852 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
14853 sort -un | head -1)
14854 echo "min size OST: $space"
14855 space=$(((space * 60)/100 * OSTCOUNT))
14857 # space in 1k units, round to 4k blocks
14858 local blkcount=$((space * 1024 / $BS))
14860 echo "Verify fallocate punch: Very large Range"
14861 fallocate -l${space}k $DIR/$tfile ||
14862 error "fallocate ${space}k $DIR/$tfile failed"
14863 # write 1M at the end, start and in the middle
14864 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
14865 error "dd failed: bs $BS count 256"
14866 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
14867 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
14868 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
14869 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
14872 size=$(stat -c '%s' $DIR/$tfile)
14874 # gather punch length.
14875 local punch_size=$((size - (BS * 2)))
14877 echo "punch_size = $punch_size"
14878 echo "size - punch_size: $((size - punch_size))"
14879 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
14881 # Call fallocate to punch all except 2 blocks. We leave the
14882 # first and the last block
14883 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
14884 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
14885 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
14887 size_after=$(stat -c '%s' $DIR/$tfile)
14888 blocks_after=$(stat -c '%b' $DIR/$tfile)
14890 # Verify punch worked.
14891 # Size should be kept
14892 (( size == size_after )) ||
14893 error "punch failed: size $size != $size_after"
14895 # two 4k data blocks to remain plus possible 1 extra extent block
14896 (( blocks_after <= ((BS / 512) * 3) )) ||
14897 error "too many blocks remains: $blocks_after"
14899 # Verify that file has hole between the first and the last blocks
14900 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
14901 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
14903 echo "Hole at [$hole_start, $hole_end)"
14904 (( hole_start == BS )) ||
14905 error "no hole at offset $BS after punch"
14907 (( hole_end == BS + punch_size )) ||
14908 error "data at offset $hole_end < $((BS + punch_size))"
14910 run_test 150g "Verify fallocate punch on large range"
14912 #LU-2902 roc_hit was not able to read all values from lproc
14913 function roc_hit_init() {
14914 local list=$(comma_list $(osts_nodes))
14915 local dir=$DIR/$tdir-check
14916 local file=$dir/$tfile
14922 #use setstripe to do a write to every ost
14923 for i in $(seq 0 $((OSTCOUNT-1))); do
14924 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
14925 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
14926 idx=$(printf %04x $i)
14927 BEFORE=$(get_osd_param $list *OST*$idx stats |
14928 awk '$1 == "cache_access" {sum += $7}
14929 END { printf("%0.0f", sum) }')
14931 cancel_lru_locks osc
14932 cat $file >/dev/null
14934 AFTER=$(get_osd_param $list *OST*$idx stats |
14935 awk '$1 == "cache_access" {sum += $7}
14936 END { printf("%0.0f", sum) }')
14938 echo BEFORE:$BEFORE AFTER:$AFTER
14939 if ! let "AFTER - BEFORE == 4"; then
14941 error "roc_hit is not safe to use"
14949 function roc_hit() {
14950 local list=$(comma_list $(osts_nodes))
14951 echo $(get_osd_param $list '' stats |
14952 awk '$1 == "cache_hit" {sum += $7}
14953 END { printf("%0.0f", sum) }')
14956 function set_cache() {
14959 if [ "$2" == "off" ]; then
14962 local list=$(comma_list $(osts_nodes))
14963 set_osd_param $list '' $1_cache_enable $on
14965 cancel_lru_locks osc
14969 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14970 remote_ost_nodsh && skip "remote OST with nodsh"
14973 local list=$(comma_list $(osts_nodes))
14975 # check whether obdfilter is cache capable at all
14976 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
14977 skip "not cache-capable obdfilter"
14980 # check cache is enabled on all obdfilters
14981 if get_osd_param $list '' read_cache_enable | grep 0; then
14982 skip "oss cache is disabled"
14985 set_osd_param $list '' writethrough_cache_enable 1
14987 # check write cache is enabled on all obdfilters
14988 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
14989 skip "oss write cache is NOT enabled"
14994 #define OBD_FAIL_OBD_NO_LRU 0x609
14995 do_nodes $list $LCTL set_param fail_loc=0x609
14997 # pages should be in the case right after write
14998 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
15001 local BEFORE=$(roc_hit)
15002 cancel_lru_locks osc
15003 cat $DIR/$tfile >/dev/null
15004 local AFTER=$(roc_hit)
15006 do_nodes $list $LCTL set_param fail_loc=0
15008 if ! let "AFTER - BEFORE == CPAGES"; then
15009 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
15012 cancel_lru_locks osc
15013 # invalidates OST cache
15014 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
15015 set_osd_param $list '' read_cache_enable 0
15016 cat $DIR/$tfile >/dev/null
15018 # now data shouldn't be found in the cache
15020 cancel_lru_locks osc
15021 cat $DIR/$tfile >/dev/null
15023 if let "AFTER - BEFORE != 0"; then
15024 error "IN CACHE: before: $BEFORE, after: $AFTER"
15027 set_osd_param $list '' read_cache_enable 1
15030 run_test 151 "test cache on oss and controls ==============================="
15033 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15035 local TF="$TMP/$tfile"
15037 # simulate ENOMEM during write
15038 #define OBD_FAIL_OST_NOMEM 0x226
15039 lctl set_param fail_loc=0x80000226
15040 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15042 sync || error "sync failed"
15043 lctl set_param fail_loc=0
15045 # discard client's cache
15046 cancel_lru_locks osc
15048 # simulate ENOMEM during read
15049 lctl set_param fail_loc=0x80000226
15050 cmp $TF $DIR/$tfile || error "cmp failed"
15051 lctl set_param fail_loc=0
15055 run_test 152 "test read/write with enomem ============================"
15058 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
15060 run_test 153 "test if fdatasync does not crash ======================="
15062 dot_lustre_fid_permission_check() {
15064 local ffid=$MOUNT/.lustre/fid/$fid
15067 echo "stat fid $fid"
15068 stat $ffid > /dev/null || error "stat $ffid failed."
15069 echo "touch fid $fid"
15070 touch $ffid || error "touch $ffid failed."
15071 echo "write to fid $fid"
15072 cat /etc/hosts > $ffid || error "write $ffid failed."
15073 echo "read fid $fid"
15074 diff /etc/hosts $ffid || error "read $ffid failed."
15075 echo "append write to fid $fid"
15076 cat /etc/hosts >> $ffid || error "append write $ffid failed."
15077 echo "rename fid $fid"
15078 mv $ffid $test_dir/$tfile.1 &&
15079 error "rename $ffid to $tfile.1 should fail."
15080 touch $test_dir/$tfile.1
15081 mv $test_dir/$tfile.1 $ffid &&
15082 error "rename $tfile.1 to $ffid should fail."
15083 rm -f $test_dir/$tfile.1
15084 echo "truncate fid $fid"
15085 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
15086 echo "link fid $fid"
15087 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
15088 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
15089 echo "setfacl fid $fid"
15090 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
15091 echo "getfacl fid $fid"
15092 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
15094 echo "unlink fid $fid"
15095 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
15096 echo "mknod fid $fid"
15097 mknod $ffid c 1 3 && error "mknod $ffid should fail."
15099 fid=[0xf00000400:0x1:0x0]
15100 ffid=$MOUNT/.lustre/fid/$fid
15102 echo "stat non-exist fid $fid"
15103 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
15104 echo "write to non-exist fid $fid"
15105 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
15106 echo "link new fid $fid"
15107 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
15109 mkdir -p $test_dir/$tdir
15110 touch $test_dir/$tdir/$tfile
15111 fid=$($LFS path2fid $test_dir/$tdir)
15114 error "error: could not get fid for $test_dir/$dir/$tfile."
15116 ffid=$MOUNT/.lustre/fid/$fid
15119 ls $ffid > /dev/null || error "ls $ffid failed."
15120 echo "touch $fid/$tfile.1"
15121 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
15123 echo "touch $MOUNT/.lustre/fid/$tfile"
15124 touch $MOUNT/.lustre/fid/$tfile && \
15125 error "touch $MOUNT/.lustre/fid/$tfile should fail."
15127 echo "setxattr to $MOUNT/.lustre/fid"
15128 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
15130 echo "listxattr for $MOUNT/.lustre/fid"
15131 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
15133 echo "delxattr from $MOUNT/.lustre/fid"
15134 setfattr -x trusted.name1 $MOUNT/.lustre/fid
15136 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
15137 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
15138 error "touch invalid fid should fail."
15140 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
15141 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
15142 error "touch non-normal fid should fail."
15144 echo "rename $tdir to $MOUNT/.lustre/fid"
15145 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
15146 error "rename to $MOUNT/.lustre/fid should fail."
15148 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
15150 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
15151 local new_obf_mode=777
15153 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
15154 chmod $new_obf_mode $DIR/.lustre/fid ||
15155 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
15157 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
15158 [ $obf_mode -eq $new_obf_mode ] ||
15159 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
15161 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
15162 chmod $old_obf_mode $DIR/.lustre/fid ||
15163 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
15166 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
15167 fid=$($LFS path2fid $test_dir/$tfile-2)
15169 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
15171 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
15172 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
15173 error "create lov data thru .lustre failed"
15175 echo "cp /etc/passwd $test_dir/$tfile-2"
15176 cp /etc/passwd $test_dir/$tfile-2 ||
15177 error "copy to $test_dir/$tfile-2 failed."
15178 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
15179 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
15180 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
15182 rm -rf $test_dir/tfile.lnk
15183 rm -rf $test_dir/$tfile-2
15187 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15188 skip "Need MDS version at least 2.4.1"
15190 local tf=$DIR/$tfile
15193 local fid=$($LFS path2fid $tf)
15194 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
15196 # check that we get the same pathname back
15199 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
15200 echo "$rootpath $fid"
15201 found=$($LFS fid2path $rootpath "$fid")
15202 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
15203 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
15206 # check wrong root path format
15207 rootpath=$MOUNT"_wrong"
15208 found=$($LFS fid2path $rootpath "$fid")
15209 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
15211 run_test 154A "lfs path2fid and fid2path basic checks"
15214 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15215 skip "Need MDS version at least 2.4.1"
15217 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15218 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
15219 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
15220 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
15222 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
15223 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
15225 # check that we get the same pathname
15226 echo "PFID: $PFID, name: $name"
15227 local FOUND=$($LFS fid2path $MOUNT "$PFID")
15228 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
15229 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
15230 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
15232 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
15234 run_test 154B "verify the ll_decode_linkea tool"
15237 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15238 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15239 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15240 skip "Need MDS version at least 2.2.51"
15241 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
15243 cp /etc/hosts $DIR/$tfile
15245 fid=$($LFS path2fid $DIR/$tfile)
15247 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
15249 dot_lustre_fid_permission_check "$fid" $DIR ||
15250 error "dot lustre permission check $fid failed"
15252 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
15254 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
15256 touch $MOUNT/.lustre/file &&
15257 error "creation is not allowed under .lustre"
15259 mkdir $MOUNT/.lustre/dir &&
15260 error "mkdir is not allowed under .lustre"
15264 run_test 154a "Open-by-FID"
15267 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15268 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15269 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15270 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15271 skip "Need MDS version at least 2.2.51"
15273 local remote_dir=$DIR/$tdir/remote_dir
15277 mkdir -p $DIR/$tdir
15278 $LFS mkdir -i $MDTIDX $remote_dir ||
15279 error "create remote directory failed"
15281 cp /etc/hosts $remote_dir/$tfile
15283 fid=$($LFS path2fid $remote_dir/$tfile)
15285 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
15287 dot_lustre_fid_permission_check "$fid" $remote_dir ||
15288 error "dot lustre permission check $fid failed"
15291 run_test 154b "Open-by-FID for remote directory"
15294 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15295 skip "Need MDS version at least 2.4.1"
15297 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
15298 local FID1=$($LFS path2fid $DIR/$tfile.1)
15299 local FID2=$($LFS path2fid $DIR/$tfile.2)
15300 local FID3=$($LFS path2fid $DIR/$tfile.3)
15303 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
15304 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
15305 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
15307 [ "$FID" = "${!want}" ] ||
15308 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
15312 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
15314 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
15315 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
15319 run_test 154c "lfs path2fid and fid2path multiple arguments"
15322 remote_mds_nodsh && skip "remote MDS with nodsh"
15323 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
15324 skip "Need MDS version at least 2.5.53"
15326 if remote_mds; then
15327 nid=$($LCTL list_nids | sed "s/\./\\\./g")
15331 local proc_ofile="mdt.*.exports.'$nid'.open_files"
15338 local fid=$($LFS path2fid $DIR/$tfile)
15341 cmd="exec $fd<$DIR/$tfile"
15343 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
15344 echo "$fid_list" | grep "$fid"
15347 cmd="exec $fd>/dev/null"
15349 if [ $rc -ne 0 ]; then
15350 error "FID $fid not found in open files list $fid_list"
15353 run_test 154d "Verify open file fid"
15357 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
15358 skip "Need MDS version at least 2.6.50"
15360 if ls -a $MOUNT | grep -q '^\.lustre$'; then
15361 error ".lustre returned by readdir"
15364 run_test 154e ".lustre is not returned by readdir"
15367 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15369 # create parent directory on a single MDT to avoid cross-MDT hardlinks
15370 mkdir_on_mdt0 $DIR/$tdir
15371 # test dirs inherit from its stripe
15372 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
15373 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
15374 cp /etc/hosts $DIR/$tdir/foo1/$tfile
15375 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
15378 # get fid of parents
15379 local FID0=$($LFS path2fid $DIR/$tdir)
15380 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
15381 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
15382 local FID3=$($LFS path2fid $DIR)
15384 # check that path2fid --parents returns expected <parent_fid>/name
15385 # 1) test for a directory (single parent)
15386 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
15387 [ "$parent" == "$FID0/foo1" ] ||
15388 error "expected parent: $FID0/foo1, got: $parent"
15390 # 2) test for a file with nlink > 1 (multiple parents)
15391 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
15392 echo "$parent" | grep -F "$FID1/$tfile" ||
15393 error "$FID1/$tfile not returned in parent list"
15394 echo "$parent" | grep -F "$FID2/link" ||
15395 error "$FID2/link not returned in parent list"
15397 # 3) get parent by fid
15398 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
15399 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15400 echo "$parent" | grep -F "$FID1/$tfile" ||
15401 error "$FID1/$tfile not returned in parent list (by fid)"
15402 echo "$parent" | grep -F "$FID2/link" ||
15403 error "$FID2/link not returned in parent list (by fid)"
15405 # 4) test for entry in root directory
15406 parent=$($LFS path2fid --parents $DIR/f)
15407 echo "$parent" | grep -F "$FID3/f" ||
15408 error "$FID3/f not returned in parent list"
15410 # 5) test it on root directory
15411 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
15412 error "$MOUNT should not have parents"
15414 # enable xattr caching and check that linkea is correctly updated
15415 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
15416 save_lustre_params client "llite.*.xattr_cache" > $save
15417 lctl set_param llite.*.xattr_cache 1
15419 # 6.1) linkea update on rename
15420 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
15422 # get parents by fid
15423 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15424 # foo1 should no longer be returned in parent list
15425 echo "$parent" | grep -F "$FID1" &&
15426 error "$FID1 should no longer be in parent list"
15427 # the new path should appear
15428 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
15429 error "$FID2/$tfile.moved is not in parent list"
15431 # 6.2) linkea update on unlink
15432 rm -f $DIR/$tdir/foo2/link
15433 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15434 # foo2/link should no longer be returned in parent list
15435 echo "$parent" | grep -F "$FID2/link" &&
15436 error "$FID2/link should no longer be in parent list"
15440 restore_lustre_params < $save
15443 run_test 154f "get parent fids by reading link ea"
15447 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15448 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
15449 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
15450 skip "Need MDS version at least 2.6.92"
15452 mkdir_on_mdt0 $DIR/$tdir
15453 llapi_fid_test -d $DIR/$tdir
15455 run_test 154g "various llapi FID tests"
15457 test_155_small_load() {
15458 local temp=$TMP/$tfile
15459 local file=$DIR/$tfile
15461 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
15462 error "dd of=$temp bs=6096 count=1 failed"
15464 cancel_lru_locks $OSC
15465 cmp $temp $file || error "$temp $file differ"
15467 $TRUNCATE $temp 6000
15468 $TRUNCATE $file 6000
15469 cmp $temp $file || error "$temp $file differ (truncate1)"
15471 echo "12345" >>$temp
15472 echo "12345" >>$file
15473 cmp $temp $file || error "$temp $file differ (append1)"
15475 echo "12345" >>$temp
15476 echo "12345" >>$file
15477 cmp $temp $file || error "$temp $file differ (append2)"
15483 test_155_big_load() {
15484 remote_ost_nodsh && skip "remote OST with nodsh"
15486 local temp=$TMP/$tfile
15487 local file=$DIR/$tfile
15490 local cache_size=$(do_facet ost$((MAXI+1)) \
15491 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
15492 local large_file_size=$((cache_size * 2))
15494 echo "OSS cache size: $cache_size KB"
15495 echo "Large file size: $large_file_size KB"
15497 [ $MAXV -le $large_file_size ] &&
15498 skip_env "max available OST size needs > $large_file_size KB"
15500 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
15502 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
15503 error "dd of=$temp bs=$large_file_size count=1k failed"
15506 cancel_lru_locks osc
15507 cmp $temp $file || error "$temp $file differ"
15513 save_writethrough() {
15514 local facets=$(get_facets OST)
15516 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
15520 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15522 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15524 save_writethrough $p
15527 set_cache writethrough on
15528 test_155_small_load
15529 restore_lustre_params < $p
15532 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
15535 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15537 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15539 save_writethrough $p
15542 set_cache writethrough off
15543 test_155_small_load
15544 restore_lustre_params < $p
15547 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
15550 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15552 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15554 save_writethrough $p
15557 set_cache writethrough on
15558 test_155_small_load
15559 restore_lustre_params < $p
15562 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
15565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15567 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15569 save_writethrough $p
15572 set_cache writethrough off
15573 test_155_small_load
15574 restore_lustre_params < $p
15577 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
15580 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15582 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15584 save_writethrough $p
15587 set_cache writethrough on
15589 restore_lustre_params < $p
15592 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
15595 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15597 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15599 save_writethrough $p
15602 set_cache writethrough off
15604 restore_lustre_params < $p
15607 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
15610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15612 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15614 save_writethrough $p
15617 set_cache writethrough on
15619 restore_lustre_params < $p
15622 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
15625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15627 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15629 save_writethrough $p
15632 set_cache writethrough off
15634 restore_lustre_params < $p
15637 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
15640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15641 remote_ost_nodsh && skip "remote OST with nodsh"
15642 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
15643 skip "stats not implemented on old servers"
15644 [ "$ost1_FSTYPE" = "zfs" ] &&
15645 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
15650 local file="$DIR/$tfile"
15651 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15653 save_writethrough $p
15656 log "Turn on read and write cache"
15658 set_cache writethrough on
15660 log "Write data and read it back."
15661 log "Read should be satisfied from the cache."
15662 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15664 cancel_lru_locks osc
15665 cat $file >/dev/null
15667 if ! let "AFTER - BEFORE == CPAGES"; then
15668 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
15670 log "cache hits: before: $BEFORE, after: $AFTER"
15673 log "Read again; it should be satisfied from the cache."
15675 cancel_lru_locks osc
15676 cat $file >/dev/null
15678 if ! let "AFTER - BEFORE == CPAGES"; then
15679 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
15681 log "cache hits:: before: $BEFORE, after: $AFTER"
15684 log "Turn off the read cache and turn on the write cache"
15686 set_cache writethrough on
15688 log "Read again; it should be satisfied from the cache."
15690 cancel_lru_locks osc
15691 cat $file >/dev/null
15693 if ! let "AFTER - BEFORE == CPAGES"; then
15694 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
15696 log "cache hits:: before: $BEFORE, after: $AFTER"
15699 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15700 # > 2.12.56 uses pagecache if cached
15701 log "Read again; it should not be satisfied from the cache."
15703 cancel_lru_locks osc
15704 cat $file >/dev/null
15706 if ! let "AFTER - BEFORE == 0"; then
15707 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
15709 log "cache hits:: before: $BEFORE, after: $AFTER"
15713 log "Write data and read it back."
15714 log "Read should be satisfied from the cache."
15715 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15717 cancel_lru_locks osc
15718 cat $file >/dev/null
15720 if ! let "AFTER - BEFORE == CPAGES"; then
15721 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
15723 log "cache hits:: before: $BEFORE, after: $AFTER"
15726 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15727 # > 2.12.56 uses pagecache if cached
15728 log "Read again; it should not be satisfied from the cache."
15730 cancel_lru_locks osc
15731 cat $file >/dev/null
15733 if ! let "AFTER - BEFORE == 0"; then
15734 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
15736 log "cache hits:: before: $BEFORE, after: $AFTER"
15740 log "Turn off read and write cache"
15742 set_cache writethrough off
15744 log "Write data and read it back"
15745 log "It should not be satisfied from the cache."
15747 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15748 cancel_lru_locks osc
15750 cat $file >/dev/null
15752 if ! let "AFTER - BEFORE == 0"; then
15753 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
15755 log "cache hits:: before: $BEFORE, after: $AFTER"
15758 log "Turn on the read cache and turn off the write cache"
15760 set_cache writethrough off
15762 log "Write data and read it back"
15763 log "It should not be satisfied from the cache."
15765 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15767 cancel_lru_locks osc
15768 cat $file >/dev/null
15770 if ! let "AFTER - BEFORE == 0"; then
15771 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
15773 log "cache hits:: before: $BEFORE, after: $AFTER"
15776 log "Read again; it should be satisfied from the cache."
15778 cancel_lru_locks osc
15779 cat $file >/dev/null
15781 if ! let "AFTER - BEFORE == CPAGES"; then
15782 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
15784 log "cache hits:: before: $BEFORE, after: $AFTER"
15787 restore_lustre_params < $p
15790 run_test 156 "Verification of tunables"
15793 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15794 remote_mds_nodsh && skip "remote MDS with nodsh"
15795 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
15796 skip "Need MDS version at least 2.2.0"
15798 changelog_register || error "changelog_register failed"
15799 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
15800 changelog_users $SINGLEMDS | grep -q $cl_user ||
15801 error "User $cl_user not found in changelog_users"
15803 mkdir_on_mdt0 $DIR/$tdir
15806 test_mkdir -p $DIR/$tdir/pics/2008/zachy
15807 changelog_clear 0 || error "changelog_clear failed"
15808 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
15809 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
15810 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15811 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15812 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15813 rm $DIR/$tdir/pics/desktop.jpg
15815 echo "verifying changelog mask"
15816 changelog_chmask "-MKDIR"
15817 changelog_chmask "-CLOSE"
15819 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
15820 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
15822 changelog_chmask "+MKDIR"
15823 changelog_chmask "+CLOSE"
15825 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
15826 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
15828 MKDIRS=$(changelog_dump | grep -c "MKDIR")
15829 CLOSES=$(changelog_dump | grep -c "CLOSE")
15830 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
15831 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
15834 echo "verifying target fid"
15835 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
15836 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
15837 [ "$fidc" == "$fidf" ] ||
15838 error "changelog '$tfile' fid $fidc != file fid $fidf"
15839 echo "verifying parent fid"
15840 # The FID returned from the Changelog may be the directory shard on
15841 # a different MDT, and not the FID returned by path2fid on the parent.
15842 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
15843 # since this is what will matter when recreating this file in the tree.
15844 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
15845 local pathp=$($LFS fid2path $MOUNT "$fidp")
15846 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
15847 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
15849 echo "getting records for $cl_user"
15850 changelog_users $SINGLEMDS
15851 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
15853 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
15854 error "changelog_clear failed"
15855 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
15856 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
15857 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
15858 error "user index expect $user_rec1 + $nclr != $user_rec2"
15860 local min0_rec=$(changelog_users $SINGLEMDS |
15861 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
15862 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
15863 awk '{ print $1; exit; }')
15865 changelog_dump | tail -n 5
15866 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
15867 [ $first_rec == $((min0_rec + 1)) ] ||
15868 error "first index should be $min0_rec + 1 not $first_rec"
15870 # LU-3446 changelog index reset on MDT restart
15871 local cur_rec1=$(changelog_users $SINGLEMDS |
15872 awk '/^current.index:/ { print $NF }')
15873 changelog_clear 0 ||
15874 error "clear all changelog records for $cl_user failed"
15875 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
15876 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
15877 error "Fail to start $SINGLEMDS"
15878 local cur_rec2=$(changelog_users $SINGLEMDS |
15879 awk '/^current.index:/ { print $NF }')
15880 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
15881 [ $cur_rec1 == $cur_rec2 ] ||
15882 error "current index should be $cur_rec1 not $cur_rec2"
15884 echo "verifying users from this test are deregistered"
15885 changelog_deregister || error "changelog_deregister failed"
15886 changelog_users $SINGLEMDS | grep -q $cl_user &&
15887 error "User '$cl_user' still in changelog_users"
15889 # lctl get_param -n mdd.*.changelog_users
15890 # current_index: 144
15891 # ID index (idle seconds)
15892 # cl3 144 (2) mask=<list>
15893 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
15894 # this is the normal case where all users were deregistered
15895 # make sure no new records are added when no users are present
15896 local last_rec1=$(changelog_users $SINGLEMDS |
15897 awk '/^current.index:/ { print $NF }')
15898 touch $DIR/$tdir/chloe
15899 local last_rec2=$(changelog_users $SINGLEMDS |
15900 awk '/^current.index:/ { print $NF }')
15901 echo "verify changelogs are off: $last_rec1 == $last_rec2"
15902 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
15904 # any changelog users must be leftovers from a previous test
15905 changelog_users $SINGLEMDS
15906 echo "other changelog users; can't verify off"
15909 run_test 160a "changelog sanity"
15911 test_160b() { # LU-3587
15912 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15913 remote_mds_nodsh && skip "remote MDS with nodsh"
15914 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
15915 skip "Need MDS version at least 2.2.0"
15917 changelog_register || error "changelog_register failed"
15918 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
15919 changelog_users $SINGLEMDS | grep -q $cl_user ||
15920 error "User '$cl_user' not found in changelog_users"
15922 local longname1=$(str_repeat a 255)
15923 local longname2=$(str_repeat b 255)
15926 echo "creating very long named file"
15927 touch $longname1 || error "create of '$longname1' failed"
15928 echo "renaming very long named file"
15929 mv $longname1 $longname2
15931 changelog_dump | grep RENME | tail -n 5
15934 run_test 160b "Verify that very long rename doesn't crash in changelog"
15937 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15938 remote_mds_nodsh && skip "remote MDS with nodsh"
15940 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
15941 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
15942 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
15943 skip "Need MDS version at least 2.5.58 or 2.5.2+"
15947 # Registration step
15948 changelog_register || error "changelog_register failed"
15951 mkdir -p $DIR/$tdir
15952 $MCREATE $DIR/$tdir/foo_160c
15953 changelog_chmask "-TRUNC"
15954 $TRUNCATE $DIR/$tdir/foo_160c 200
15955 changelog_chmask "+TRUNC"
15956 $TRUNCATE $DIR/$tdir/foo_160c 199
15957 changelog_dump | tail -n 5
15958 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
15959 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
15961 run_test 160c "verify that changelog log catch the truncate event"
15964 remote_mds_nodsh && skip "remote MDS with nodsh"
15965 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15967 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
15968 skip "Need MDS version at least 2.7.60"
15970 # Registration step
15971 changelog_register || error "changelog_register failed"
15973 mkdir -p $DIR/$tdir/migrate_dir
15974 changelog_clear 0 || error "changelog_clear failed"
15976 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
15977 changelog_dump | tail -n 5
15978 local migrates=$(changelog_dump | grep -c "MIGRT")
15979 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
15981 run_test 160d "verify that changelog log catch the migrate event"
15984 remote_mds_nodsh && skip "remote MDS with nodsh"
15987 changelog_register || error "changelog_register failed"
15989 local MDT0=$(facet_svc $SINGLEMDS)
15992 # No user (expect fail)
15993 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
15995 if [ $rc -eq 0 ]; then
15996 error "Should fail without user"
15997 elif [ $rc -ne 4 ]; then
15998 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
16001 # Delete a future user (expect fail)
16002 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
16004 if [ $rc -eq 0 ]; then
16005 error "Deleted non-existant user cl77"
16006 elif [ $rc -ne 2 ]; then
16007 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
16010 # Clear to a bad index (1 billion should be safe)
16011 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
16014 if [ $rc -eq 0 ]; then
16015 error "Successfully cleared to invalid CL index"
16016 elif [ $rc -ne 22 ]; then
16017 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
16020 run_test 160e "changelog negative testing (should return errors)"
16023 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16024 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16025 skip "Need MDS version at least 2.10.56"
16027 local mdts=$(comma_list $(mdts_nodes))
16030 changelog_register || error "first changelog_register failed"
16031 changelog_register || error "second changelog_register failed"
16033 declare -A cl_user1
16034 declare -A cl_user2
16039 # generate some changelog records to accumulate on each MDT
16040 # use all_char because created files should be evenly distributed
16041 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16042 error "test_mkdir $tdir failed"
16043 log "$(date +%s): creating first files"
16044 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16045 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
16046 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
16049 # check changelogs have been generated
16050 local start=$SECONDS
16051 local idle_time=$((MDSCOUNT * 5 + 5))
16052 local nbcl=$(changelog_dump | wc -l)
16053 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16055 for param in "changelog_max_idle_time=$idle_time" \
16057 "changelog_min_gc_interval=2" \
16058 "changelog_min_free_cat_entries=3"; do
16059 local MDT0=$(facet_svc $SINGLEMDS)
16060 local var="${param%=*}"
16061 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16063 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16064 do_nodes $mdts $LCTL set_param mdd.*.$param
16067 # force cl_user2 to be idle (1st part), but also cancel the
16068 # cl_user1 records so that it is not evicted later in the test.
16069 local sleep1=$((idle_time / 2))
16070 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
16073 # simulate changelog catalog almost full
16074 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
16075 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
16077 for i in $(seq $MDSCOUNT); do
16078 cl_users=(${CL_USERS[mds$i]})
16079 cl_user1[mds$i]="${cl_users[0]}"
16080 cl_user2[mds$i]="${cl_users[1]}"
16082 [ -n "${cl_user1[mds$i]}" ] ||
16083 error "mds$i: no user registered"
16084 [ -n "${cl_user2[mds$i]}" ] ||
16085 error "mds$i: only ${cl_user2[mds$i]} is registered"
16087 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16088 [ -n "$user_rec1" ] ||
16089 error "mds$i: User ${cl_user1[mds$i]} not registered"
16090 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16091 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16092 [ -n "$user_rec2" ] ||
16093 error "mds$i: User ${cl_user1[mds$i]} not registered"
16094 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16095 "$user_rec1 + 2 == $user_rec2"
16096 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16097 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16098 "$user_rec1 + 2, but is $user_rec2"
16099 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16100 [ -n "$user_rec2" ] ||
16101 error "mds$i: User ${cl_user2[mds$i]} not registered"
16102 [ $user_rec1 == $user_rec2 ] ||
16103 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16104 "$user_rec1, but is $user_rec2"
16107 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
16108 local sleep2=$((idle_time - (SECONDS - start) + 1))
16109 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
16112 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16113 # cl_user1 should be OK because it recently processed records.
16114 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
16115 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16116 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
16117 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
16120 # ensure gc thread is done
16121 for i in $(mdts_nodes); do
16122 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16123 error "$i: GC-thread not done"
16127 for (( i = 1; i <= MDSCOUNT; i++ )); do
16128 # check cl_user1 still registered
16129 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16130 error "mds$i: User ${cl_user1[mds$i]} not registered"
16131 # check cl_user2 unregistered
16132 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16133 error "mds$i: User ${cl_user2[mds$i]} still registered"
16135 # check changelogs are present and starting at $user_rec1 + 1
16136 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16137 [ -n "$user_rec1" ] ||
16138 error "mds$i: User ${cl_user1[mds$i]} not registered"
16139 first_rec=$($LFS changelog $(facet_svc mds$i) |
16140 awk '{ print $1; exit; }')
16142 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16143 [ $((user_rec1 + 1)) == $first_rec ] ||
16144 error "mds$i: rec $first_rec != $user_rec1 + 1"
16147 run_test 160f "changelog garbage collect (timestamped users)"
16150 remote_mds_nodsh && skip "remote MDS with nodsh"
16151 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
16152 skip "Need MDS version at least 2.14.55"
16154 local mdts=$(comma_list $(mdts_nodes))
16157 changelog_register || error "first changelog_register failed"
16158 changelog_register || error "second changelog_register failed"
16160 declare -A cl_user1
16161 declare -A cl_user2
16166 # generate some changelog records to accumulate on each MDT
16167 # use all_char because created files should be evenly distributed
16168 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16169 error "test_mkdir $tdir failed"
16170 for ((i = 0; i < MDSCOUNT; i++)); do
16171 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16172 error "create $DIR/$tdir/d$i.1 failed"
16175 # check changelogs have been generated
16176 local nbcl=$(changelog_dump | wc -l)
16177 (( $nbcl > 0 )) || error "no changelogs found"
16179 # reduce the max_idle_indexes value to make sure we exceed it
16180 for param in "changelog_max_idle_indexes=2" \
16182 "changelog_min_gc_interval=2"; do
16183 local MDT0=$(facet_svc $SINGLEMDS)
16184 local var="${param%=*}"
16185 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16187 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16188 do_nodes $mdts $LCTL set_param mdd.*.$param ||
16189 error "unable to set mdd.*.$param"
16192 local start=$SECONDS
16193 for i in $(seq $MDSCOUNT); do
16194 cl_users=(${CL_USERS[mds$i]})
16195 cl_user1[mds$i]="${cl_users[0]}"
16196 cl_user2[mds$i]="${cl_users[1]}"
16198 [ -n "${cl_user1[mds$i]}" ] ||
16199 error "mds$i: user1 is not registered"
16200 [ -n "${cl_user2[mds$i]}" ] ||
16201 error "mds$i: only ${cl_user1[mds$i]} is registered"
16203 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16204 [ -n "$user_rec1" ] ||
16205 error "mds$i: user1 ${cl_user1[mds$i]} not found"
16206 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16207 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16208 [ -n "$user_rec2" ] ||
16209 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
16210 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
16211 "$user_rec1 + 2 == $user_rec2"
16212 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16213 error "mds$i: user1 ${cl_user1[mds$i]} index " \
16214 "expected $user_rec1 + 2, but is $user_rec2"
16215 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16216 [ -n "$user_rec2" ] ||
16217 error "mds$i: user2 ${cl_user2[mds$i]} not found"
16218 [ $user_rec1 == $user_rec2 ] ||
16219 error "mds$i: user2 ${cl_user2[mds$i]} index " \
16220 "expected $user_rec1, but is $user_rec2"
16223 # ensure we are past the previous changelog_min_gc_interval set above
16224 local sleep2=$((start + 2 - SECONDS))
16225 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
16226 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16227 # cl_user1 should be OK because it recently processed records.
16228 for ((i = 0; i < MDSCOUNT; i++)); do
16229 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
16230 error "create $DIR/$tdir/d$i.3 failed"
16233 # ensure gc thread is done
16234 for i in $(mdts_nodes); do
16235 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16236 error "$i: GC-thread not done"
16240 for (( i = 1; i <= MDSCOUNT; i++ )); do
16241 # check cl_user1 still registered
16242 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16243 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
16244 # check cl_user2 unregistered
16245 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16246 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
16248 # check changelogs are present and starting at $user_rec1 + 1
16249 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16250 [ -n "$user_rec1" ] ||
16251 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
16252 first_rec=$($LFS changelog $(facet_svc mds$i) |
16253 awk '{ print $1; exit; }')
16255 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16256 [ $((user_rec1 + 1)) == $first_rec ] ||
16257 error "mds$i: rec $first_rec != $user_rec1 + 1"
16260 run_test 160g "changelog garbage collect on idle records"
16263 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16264 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16265 skip "Need MDS version at least 2.10.56"
16267 local mdts=$(comma_list $(mdts_nodes))
16270 changelog_register || error "first changelog_register failed"
16271 changelog_register || error "second changelog_register failed"
16273 declare -A cl_user1
16274 declare -A cl_user2
16279 # generate some changelog records to accumulate on each MDT
16280 # use all_char because created files should be evenly distributed
16281 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16282 error "test_mkdir $tdir failed"
16283 for ((i = 0; i < MDSCOUNT; i++)); do
16284 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16285 error "create $DIR/$tdir/d$i.1 failed"
16288 # check changelogs have been generated
16289 local nbcl=$(changelog_dump | wc -l)
16290 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16292 for param in "changelog_max_idle_time=10" \
16294 "changelog_min_gc_interval=2"; do
16295 local MDT0=$(facet_svc $SINGLEMDS)
16296 local var="${param%=*}"
16297 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16299 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16300 do_nodes $mdts $LCTL set_param mdd.*.$param
16303 # force cl_user2 to be idle (1st part)
16306 for i in $(seq $MDSCOUNT); do
16307 cl_users=(${CL_USERS[mds$i]})
16308 cl_user1[mds$i]="${cl_users[0]}"
16309 cl_user2[mds$i]="${cl_users[1]}"
16311 [ -n "${cl_user1[mds$i]}" ] ||
16312 error "mds$i: no user registered"
16313 [ -n "${cl_user2[mds$i]}" ] ||
16314 error "mds$i: only ${cl_user2[mds$i]} is registered"
16316 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16317 [ -n "$user_rec1" ] ||
16318 error "mds$i: User ${cl_user1[mds$i]} not registered"
16319 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16320 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16321 [ -n "$user_rec2" ] ||
16322 error "mds$i: User ${cl_user1[mds$i]} not registered"
16323 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16324 "$user_rec1 + 2 == $user_rec2"
16325 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16326 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16327 "$user_rec1 + 2, but is $user_rec2"
16328 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16329 [ -n "$user_rec2" ] ||
16330 error "mds$i: User ${cl_user2[mds$i]} not registered"
16331 [ $user_rec1 == $user_rec2 ] ||
16332 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16333 "$user_rec1, but is $user_rec2"
16336 # force cl_user2 to be idle (2nd part) and to reach
16337 # changelog_max_idle_time
16340 # force each GC-thread start and block then
16341 # one per MDT/MDD, set fail_val accordingly
16342 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
16343 do_nodes $mdts $LCTL set_param fail_loc=0x1316
16345 # generate more changelogs to trigger fail_loc
16346 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16347 error "create $DIR/$tdir/${tfile}bis failed"
16349 # stop MDT to stop GC-thread, should be done in back-ground as it will
16350 # block waiting for the thread to be released and exit
16351 declare -A stop_pids
16352 for i in $(seq $MDSCOUNT); do
16354 stop_pids[mds$i]=$!
16357 for i in $(mdts_nodes); do
16360 local facets=$(facets_up_on_host $i)
16362 for facet in ${facets//,/ }; do
16363 if [[ $facet == mds* ]]; then
16367 # ensure each MDS's gc threads are still present and all in "R"
16368 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
16369 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
16370 error "$i: expected $nb GC-thread"
16372 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
16374 error "$i: GC-thread not found in R-state"
16375 # check umounts of each MDT on MDS have reached kthread_stop()
16376 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
16377 error "$i: expected $nb umount"
16379 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
16380 error "$i: umount not found in D-state"
16383 # release all GC-threads
16384 do_nodes $mdts $LCTL set_param fail_loc=0
16386 # wait for MDT stop to complete
16387 for i in $(seq $MDSCOUNT); do
16388 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
16392 # may try to check if any orphan changelog records are present
16393 # via ldiskfs/zfs and llog_reader...
16395 # re-start/mount MDTs
16396 for i in $(seq $MDSCOUNT); do
16397 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
16398 error "Fail to start mds$i"
16402 for i in $(seq $MDSCOUNT); do
16403 # check cl_user1 still registered
16404 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16405 error "mds$i: User ${cl_user1[mds$i]} not registered"
16406 # check cl_user2 unregistered
16407 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16408 error "mds$i: User ${cl_user2[mds$i]} still registered"
16410 # check changelogs are present and starting at $user_rec1 + 1
16411 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16412 [ -n "$user_rec1" ] ||
16413 error "mds$i: User ${cl_user1[mds$i]} not registered"
16414 first_rec=$($LFS changelog $(facet_svc mds$i) |
16415 awk '{ print $1; exit; }')
16417 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
16418 [ $((user_rec1 + 1)) == $first_rec ] ||
16419 error "mds$i: first index should be $user_rec1 + 1, " \
16420 "but is $first_rec"
16423 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
16428 local mdts=$(comma_list $(mdts_nodes))
16430 changelog_register || error "first changelog_register failed"
16432 # generate some changelog records to accumulate on each MDT
16433 # use all_char because created files should be evenly distributed
16434 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16435 error "test_mkdir $tdir failed"
16436 for ((i = 0; i < MDSCOUNT; i++)); do
16437 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16438 error "create $DIR/$tdir/d$i.1 failed"
16441 # check changelogs have been generated
16442 local nbcl=$(changelog_dump | wc -l)
16443 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16445 # simulate race between register and unregister
16446 # XXX as fail_loc is set per-MDS, with DNE configs the race
16447 # simulation will only occur for one MDT per MDS and for the
16448 # others the normal race scenario will take place
16449 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
16450 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
16451 do_nodes $mdts $LCTL set_param fail_val=1
16453 # unregister 1st user
16454 changelog_deregister &
16456 # wait some time for deregister work to reach race rdv
16458 # register 2nd user
16459 changelog_register || error "2nd user register failed"
16461 wait $pid1 || error "1st user deregister failed"
16465 declare -A LAST_REC
16466 for i in $(seq $MDSCOUNT); do
16467 if changelog_users mds$i | grep "^cl"; then
16468 # make sure new records are added with one user present
16469 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
16470 awk '/^current.index:/ { print $NF }')
16472 error "mds$i has no user registered"
16476 # generate more changelog records to accumulate on each MDT
16477 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16478 error "create $DIR/$tdir/${tfile}bis failed"
16480 for i in $(seq $MDSCOUNT); do
16481 last_rec=$(changelog_users $SINGLEMDS |
16482 awk '/^current.index:/ { print $NF }')
16483 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
16484 [ $last_rec != ${LAST_REC[mds$i]} ] ||
16485 error "changelogs are off on mds$i"
16488 run_test 160i "changelog user register/unregister race"
16491 remote_mds_nodsh && skip "remote MDS with nodsh"
16492 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
16493 skip "Need MDS version at least 2.12.56"
16495 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
16496 stack_trap "umount $MOUNT2" EXIT
16498 changelog_register || error "first changelog_register failed"
16499 stack_trap "changelog_deregister" EXIT
16501 # generate some changelog
16502 # use all_char because created files should be evenly distributed
16503 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16504 error "mkdir $tdir failed"
16505 for ((i = 0; i < MDSCOUNT; i++)); do
16506 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16507 error "create $DIR/$tdir/d$i.1 failed"
16510 # open the changelog device
16511 exec 3>/dev/changelog-$FSNAME-MDT0000
16512 stack_trap "exec 3>&-" EXIT
16513 exec 4</dev/changelog-$FSNAME-MDT0000
16514 stack_trap "exec 4<&-" EXIT
16516 # umount the first lustre mount
16518 stack_trap "mount_client $MOUNT" EXIT
16520 # read changelog, which may or may not fail, but should not crash
16524 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16525 changelog_users $SINGLEMDS | grep -q $cl_user ||
16526 error "User $cl_user not found in changelog_users"
16528 printf 'clear:'$cl_user':0' >&3
16530 run_test 160j "client can be umounted while its chanangelog is being used"
16533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16534 remote_mds_nodsh && skip "remote MDS with nodsh"
16536 mkdir -p $DIR/$tdir/1/1
16538 changelog_register || error "changelog_register failed"
16539 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16541 changelog_users $SINGLEMDS | grep -q $cl_user ||
16542 error "User '$cl_user' not found in changelog_users"
16543 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
16544 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
16545 rmdir $DIR/$tdir/1/1 & sleep 1
16547 touch $DIR/$tdir/2/2
16548 rm -rf $DIR/$tdir/2
16553 changelog_dump | grep rmdir || error "rmdir not recorded"
16555 run_test 160k "Verify that changelog records are not lost"
16557 # Verifies that a file passed as a parameter has recently had an operation
16558 # performed on it that has generated an MTIME changelog which contains the
16559 # correct parent FID. As files might reside on a different MDT from the
16560 # parent directory in DNE configurations, the FIDs are translated to paths
16561 # before being compared, which should be identical
16562 compare_mtime_changelog() {
16570 mdtidx=$($LFS getstripe --mdt-index $file)
16571 mdtidx=$(printf "%04x" $mdtidx)
16573 # Obtain the parent FID from the MTIME changelog
16574 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
16575 [ -z "$mtime" ] && error "MTIME changelog not recorded"
16577 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
16578 [ -z "$cl_fid" ] && error "parent FID not present"
16580 # Verify that the path for the parent FID is the same as the path for
16581 # the test directory
16582 pdir=$($LFS fid2path $MOUNT "$cl_fid")
16586 [[ "${pdir%/}" == "$dir" ]] ||
16587 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
16591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16593 remote_mds_nodsh && skip "remote MDS with nodsh"
16594 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
16595 skip "Need MDS version at least 2.13.55"
16599 changelog_register || error "changelog_register failed"
16600 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16602 changelog_users $SINGLEMDS | grep -q $cl_user ||
16603 error "User '$cl_user' not found in changelog_users"
16605 # Clear some types so that MTIME changelogs are generated
16606 changelog_chmask "-CREAT"
16607 changelog_chmask "-CLOSE"
16609 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
16611 # Test CL_MTIME during setattr
16612 touch $DIR/$tdir/$tfile
16613 compare_mtime_changelog $DIR/$tdir/$tfile
16615 # Test CL_MTIME during close
16616 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
16617 compare_mtime_changelog $DIR/$tdir/${tfile}_2
16619 run_test 160l "Verify that MTIME changelog records contain the parent FID"
16622 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16623 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16624 skip "Need MDS version at least 2.14.51"
16631 changelog_register || error "first changelog_register failed"
16632 changelog_register || error "second changelog_register failed"
16634 cl_users=(${CL_USERS[mds1]})
16635 cl_user1="${cl_users[0]}"
16636 cl_user2="${cl_users[1]}"
16637 # generate some changelog records to accumulate on MDT0
16638 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16639 createmany -m $DIR/$tdir/$tfile 50 ||
16640 error "create $DIR/$tdir/$tfile failed"
16641 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16644 # check changelogs have been generated
16645 local nbcl=$(changelog_dump | wc -l)
16646 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16648 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
16649 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
16651 __changelog_clear mds1 $cl_user1 +10
16652 __changelog_clear mds1 $cl_user2 0 &
16655 __changelog_clear mds1 $cl_user1 0 ||
16656 error "fail to cancel record for $cl_user1"
16658 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16660 run_test 160m "Changelog clear race"
16663 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16664 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16665 skip "Need MDS version at least 2.14.51"
16674 changelog_register || error "first changelog_register failed"
16676 cl_users=(${CL_USERS[mds1]})
16677 cl_user1="${cl_users[0]}"
16679 # generate some changelog records to accumulate on MDT0
16680 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16681 first_rec=$(changelog_users $SINGLEMDS |
16682 awk '/^current.index:/ { print $NF }')
16683 while (( last_rec < (( first_rec + 65000)) )); do
16684 createmany -m $DIR/$tdir/$tfile 10000 ||
16685 error "create $DIR/$tdir/$tfile failed"
16687 for i in $(seq 0 10000); do
16688 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
16692 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
16693 error "unlinkmany failed unlink"
16694 last_rec=$(changelog_users $SINGLEMDS |
16695 awk '/^current.index:/ { print $NF }')
16696 echo last record $last_rec
16697 (( last_rec == 0 )) && error "no changelog found"
16700 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
16701 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
16703 __changelog_clear mds1 $cl_user1 0 &
16706 __changelog_clear mds1 $cl_user1 0 ||
16707 error "fail to cancel record for $cl_user1"
16709 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16711 run_test 160n "Changelog destroy race"
16714 local mdt="$(facet_svc $SINGLEMDS)"
16716 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16717 remote_mds_nodsh && skip "remote MDS with nodsh"
16718 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
16719 skip "Need MDS version at least 2.14.52"
16721 changelog_register --user test_160o -m unlnk+close+open ||
16722 error "changelog_register failed"
16724 do_facet $SINGLEMDS $LCTL --device $mdt \
16725 changelog_register -u "Tt3_-#" &&
16726 error "bad symbols in name should fail"
16728 do_facet $SINGLEMDS $LCTL --device $mdt \
16729 changelog_register -u test_160o &&
16730 error "the same name registration should fail"
16732 do_facet $SINGLEMDS $LCTL --device $mdt \
16733 changelog_register -u test_160toolongname &&
16734 error "too long name registration should fail"
16736 changelog_chmask "MARK+HSM"
16737 lctl get_param mdd.*.changelog*mask
16738 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16739 changelog_users $SINGLEMDS | grep -q $cl_user ||
16740 error "User $cl_user not found in changelog_users"
16742 echo $cl_user | grep -q test_160o ||
16743 error "User $cl_user has no specific name 'test160o'"
16746 changelog_clear 0 || error "changelog_clear failed"
16747 # generate some changelog records to accumulate on MDT0
16748 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16749 touch $DIR/$tdir/$tfile # open 1
16751 OPENS=$(changelog_dump | grep -c "OPEN")
16752 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
16754 # must be no MKDIR it wasn't set as user mask
16755 MKDIR=$(changelog_dump | grep -c "MKDIR")
16756 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
16758 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
16759 mdd.$mdt.changelog_current_mask -n)
16760 # register maskless user
16761 changelog_register || error "changelog_register failed"
16762 # effective mask should be not changed because it is not minimal
16763 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16764 mdd.$mdt.changelog_current_mask -n)
16765 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
16766 # set server mask to minimal value
16767 changelog_chmask "MARK"
16768 # check effective mask again, should be treated as DEFMASK now
16769 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16770 mdd.$mdt.changelog_current_mask -n)
16771 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
16773 do_facet $SINGLEMDS $LCTL --device $mdt \
16774 changelog_deregister -u test_160o ||
16775 error "cannot deregister by name"
16777 run_test 160o "changelog user name and mask"
16780 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16781 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16782 skip "Need MDS version at least 2.14.51"
16783 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
16789 changelog_register || error "first changelog_register failed"
16791 cl_users=(${CL_USERS[mds1]})
16792 cl_user1="${cl_users[0]}"
16794 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16795 createmany -m $DIR/$tdir/$tfile 50 ||
16796 error "create $DIR/$tdir/$tfile failed"
16797 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16800 # check changelogs have been generated
16801 entry_count=$(changelog_dump | wc -l)
16802 ((entry_count != 0)) || error "no changelog entries found"
16804 # remove changelog_users and check that orphan entries are removed
16806 local dev=$(mdsdevname 1)
16807 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
16808 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
16809 entry_count=$(changelog_dump | wc -l)
16810 ((entry_count == 0)) ||
16811 error "found $entry_count changelog entries, expected none"
16813 run_test 160p "Changelog orphan cleanup with no users"
16816 local mdt="$(facet_svc $SINGLEMDS)"
16819 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16820 remote_mds_nodsh && skip "remote MDS with nodsh"
16821 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
16822 skip "Need MDS version at least 2.14.54"
16824 # set server mask to minimal value like server init does
16825 changelog_chmask "MARK"
16826 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
16827 error "changelog_register failed"
16828 # check effective mask again, should be treated as DEFMASK now
16829 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16830 mdd.$mdt.changelog_current_mask -n)
16831 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
16832 error "changelog_deregister failed"
16833 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
16835 run_test 160q "changelog effective mask is DEFMASK if not set"
16838 remote_mds_nodsh && skip "remote MDS with nodsh"
16839 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
16840 skip "Need MDS version at least 2.14.55"
16842 local mdts=$(comma_list $(mdts_nodes))
16844 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
16845 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
16846 fail_val=$((24 * 3600 * 10))
16848 # Create a user which is 10 days old
16849 changelog_register || error "first changelog_register failed"
16851 declare -A cl_user1
16854 # generate some changelog records to accumulate on each MDT
16855 # use all_char because created files should be evenly distributed
16856 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16857 error "test_mkdir $tdir failed"
16858 for ((i = 0; i < MDSCOUNT; i++)); do
16859 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16860 error "create $DIR/$tdir/d$i.1 failed"
16863 # check changelogs have been generated
16864 local nbcl=$(changelog_dump | wc -l)
16865 (( nbcl > 0 )) || error "no changelogs found"
16867 # reduce the max_idle_indexes value to make sure we exceed it
16868 for param in "changelog_max_idle_indexes=2097446912" \
16869 "changelog_max_idle_time=2592000" \
16871 "changelog_min_gc_interval=2"; do
16872 local MDT0=$(facet_svc $SINGLEMDS)
16873 local var="${param%=*}"
16874 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16876 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16877 do_nodes $mdts $LCTL set_param mdd.*.$param ||
16878 error "unable to set mdd.*.$param"
16881 local start=$SECONDS
16882 for i in $(seq $MDSCOUNT); do
16883 cl_users=(${CL_USERS[mds$i]})
16884 cl_user1[mds$i]="${cl_users[0]}"
16886 [[ -n "${cl_user1[mds$i]}" ]] ||
16887 error "mds$i: no user registered"
16890 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
16891 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
16893 # ensure we are past the previous changelog_min_gc_interval set above
16894 local sleep2=$((start + 2 - SECONDS))
16895 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
16897 # Generate one more changelog to trigger GC
16898 for ((i = 0; i < MDSCOUNT; i++)); do
16899 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
16900 error "create $DIR/$tdir/d$i.3 failed"
16903 # ensure gc thread is done
16904 for node in $(mdts_nodes); do
16905 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
16906 error "$node: GC-thread not done"
16909 do_nodes $mdts $LCTL set_param fail_loc=0
16911 for (( i = 1; i <= MDSCOUNT; i++ )); do
16912 # check cl_user1 is purged
16913 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
16914 error "mds$i: User ${cl_user1[mds$i]} is registered"
16918 run_test 160s "changelog garbage collect on idle records * time"
16921 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16923 test_mkdir -c1 $DIR/$tdir
16924 cp /etc/hosts $DIR/$tdir/$tfile
16925 test_mkdir -c1 $DIR/$tdir/foo1
16926 test_mkdir -c1 $DIR/$tdir/foo2
16927 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
16928 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
16929 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
16930 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
16931 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
16932 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
16933 $LFS fid2path $DIR $FID
16934 error "bad link ea"
16937 rm $DIR/$tdir/foo2/zachary
16939 rm $DIR/$tdir/foo2/thor
16941 rm $DIR/$tdir/$tfile
16943 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
16944 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
16945 { $LFS fid2path $DIR $FID; error "bad link rename"; }
16946 rm $DIR/$tdir/foo2/maggie
16949 local longname=$tfile.avg_len_is_thirty_two_
16950 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
16951 error_noexit 'failed to unlink many hardlinks'" EXIT
16952 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
16953 error "failed to hardlink many files"
16954 links=$($LFS fid2path $DIR $FID | wc -l)
16955 echo -n "${links}/1000 links in link EA"
16956 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
16958 run_test 161a "link ea sanity"
16961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16962 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
16965 local remote_dir=$DIR/$tdir/remote_dir
16967 mkdir -p $DIR/$tdir
16968 $LFS mkdir -i $MDTIDX $remote_dir ||
16969 error "create remote directory failed"
16971 cp /etc/hosts $remote_dir/$tfile
16972 mkdir -p $remote_dir/foo1
16973 mkdir -p $remote_dir/foo2
16974 ln $remote_dir/$tfile $remote_dir/foo1/sofia
16975 ln $remote_dir/$tfile $remote_dir/foo2/zachary
16976 ln $remote_dir/$tfile $remote_dir/foo1/luna
16977 ln $remote_dir/$tfile $remote_dir/foo2/thor
16979 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
16981 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
16982 $LFS fid2path $DIR $FID
16983 error "bad link ea"
16986 rm $remote_dir/foo2/zachary
16988 rm $remote_dir/foo2/thor
16990 rm $remote_dir/$tfile
16992 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
16993 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
16994 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
16995 $LFS fid2path $DIR $FID
16996 error "bad link rename"
16998 rm $remote_dir/foo2/maggie
17001 local longname=filename_avg_len_is_thirty_two_
17002 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
17003 error "failed to hardlink many files"
17004 links=$($LFS fid2path $DIR $FID | wc -l)
17005 echo -n "${links}/1000 links in link EA"
17006 [[ ${links} -gt 60 ]] ||
17007 error "expected at least 60 links in link EA"
17008 unlinkmany $remote_dir/foo2/$longname 1000 ||
17009 error "failed to unlink many hardlinks"
17011 run_test 161b "link ea sanity under remote directory"
17014 remote_mds_nodsh && skip "remote MDS with nodsh"
17015 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17016 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
17017 skip "Need MDS version at least 2.1.5"
17019 # define CLF_RENAME_LAST 0x0001
17020 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
17021 changelog_register || error "changelog_register failed"
17024 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
17025 touch $DIR/$tdir/foo_161c
17026 touch $DIR/$tdir/bar_161c
17027 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17028 changelog_dump | grep RENME | tail -n 5
17029 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17030 changelog_clear 0 || error "changelog_clear failed"
17031 if [ x$flags != "x0x1" ]; then
17032 error "flag $flags is not 0x1"
17035 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
17036 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
17037 touch $DIR/$tdir/foo_161c
17038 touch $DIR/$tdir/bar_161c
17039 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17040 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17041 changelog_dump | grep RENME | tail -n 5
17042 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17043 changelog_clear 0 || error "changelog_clear failed"
17044 if [ x$flags != "x0x0" ]; then
17045 error "flag $flags is not 0x0"
17047 echo "rename overwrite a target having nlink > 1," \
17048 "changelog record has flags of $flags"
17050 # rename doesn't overwrite a target (changelog flag 0x0)
17051 touch $DIR/$tdir/foo_161c
17052 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
17053 changelog_dump | grep RENME | tail -n 5
17054 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
17055 changelog_clear 0 || error "changelog_clear failed"
17056 if [ x$flags != "x0x0" ]; then
17057 error "flag $flags is not 0x0"
17059 echo "rename doesn't overwrite a target," \
17060 "changelog record has flags of $flags"
17062 # define CLF_UNLINK_LAST 0x0001
17063 # unlink a file having nlink = 1 (changelog flag 0x1)
17064 rm -f $DIR/$tdir/foo2_161c
17065 changelog_dump | grep UNLNK | tail -n 5
17066 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17067 changelog_clear 0 || error "changelog_clear failed"
17068 if [ x$flags != "x0x1" ]; then
17069 error "flag $flags is not 0x1"
17071 echo "unlink a file having nlink = 1," \
17072 "changelog record has flags of $flags"
17074 # unlink a file having nlink > 1 (changelog flag 0x0)
17075 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17076 rm -f $DIR/$tdir/foobar_161c
17077 changelog_dump | grep UNLNK | tail -n 5
17078 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17079 changelog_clear 0 || error "changelog_clear failed"
17080 if [ x$flags != "x0x0" ]; then
17081 error "flag $flags is not 0x0"
17083 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
17085 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
17088 remote_mds_nodsh && skip "remote MDS with nodsh"
17089 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
17094 changelog_register || error "changelog_register failed"
17096 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
17097 # interfer with $MOUNT/.lustre/fid/ access
17099 [[ $? -eq 0 ]] || error "mkdir failed"
17101 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
17102 $LCTL set_param fail_loc=0x8000140c
17104 $LCTL set_param fail_val=5
17107 echo foofoo > $DIR/$tdir/$tfile &
17110 # wait for create to be delayed
17114 [[ $? -eq 0 ]] || error "create should be blocked"
17116 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
17117 stack_trap "rm -f $tempfile"
17118 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
17119 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
17120 # some delay may occur during ChangeLog publishing and file read just
17121 # above, that could allow file write to happen finally
17122 [[ -s $tempfile ]] && echo "file should be empty"
17124 $LCTL set_param fail_loc=0
17127 [[ $? -eq 0 ]] || error "create failed"
17129 run_test 161d "create with concurrent .lustre/fid access"
17132 local expected="$1"
17137 path=$($LFS fid2path "$@")
17140 if [ $rc -ne 0 ]; then
17141 error "path looked up of '$expected' failed: rc=$rc"
17142 elif [ "$path" != "$expected" ]; then
17143 error "path looked up '$path' instead of '$expected'"
17145 echo "FID '$fid' resolves to path '$path' as expected"
17149 test_162a() { # was test_162
17150 test_mkdir -p -c1 $DIR/$tdir/d2
17151 touch $DIR/$tdir/d2/$tfile
17152 touch $DIR/$tdir/d2/x1
17153 touch $DIR/$tdir/d2/x2
17154 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
17155 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
17157 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
17158 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
17161 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
17162 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
17163 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
17165 # softlink to wrong file
17166 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
17167 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
17168 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
17171 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
17172 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
17173 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
17174 # fid2path dir/fsname should both work
17175 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
17176 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
17178 # hardlink count: check that there are 2 links
17179 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
17180 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
17182 # hardlink indexing: remove the first link
17183 rm $DIR/$tdir/d2/p/q/r/hlink
17184 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
17186 run_test 162a "path lookup sanity"
17189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17190 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17193 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17194 error "create striped dir failed"
17196 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
17197 tail -n 1 | awk '{print $2}')
17198 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
17200 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
17201 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
17204 for ((i=0;i<5;i++)); do
17205 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
17206 error "get fid for f$i failed"
17207 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
17209 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
17210 error "get fid for d$i failed"
17211 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
17216 run_test 162b "striped directory path lookup sanity"
17218 # LU-4239: Verify fid2path works with paths 100 or more directories deep
17220 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
17221 skip "Need MDS version at least 2.7.51"
17223 local lpath=$tdir.local
17224 local rpath=$tdir.remote
17226 test_mkdir $DIR/$lpath
17227 test_mkdir $DIR/$rpath
17229 for ((i = 0; i <= 101; i++)); do
17232 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
17233 error "get fid for local directory $DIR/$lpath failed"
17234 check_path "$DIR/$lpath" $MOUNT $FID --link 0
17237 test_mkdir $DIR/$rpath
17238 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
17239 error "get fid for remote directory $DIR/$rpath failed"
17240 check_path "$DIR/$rpath" $MOUNT $FID --link 0
17245 run_test 162c "fid2path works with paths 100 or more directories deep"
17247 oalr_event_count() {
17251 awk -v name="${FSNAME}-OST0000" \
17252 -v event="${event}" \
17253 '$1 == "TRACE" && $2 == event && $3 == name' \
17258 oalr_expect_event_count() {
17261 local expect="${3}"
17264 count=$(oalr_event_count "${event}" "${trace}")
17265 if ((count == expect)); then
17269 error_noexit "${event} event count was '${count}', expected ${expect}"
17275 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
17277 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
17281 sync # Flush previous IOs so we can count log entries.
17282 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
17283 stack_trap cleanup_165 EXIT
17287 local trace="/tmp/${tfile}.trace"
17291 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17292 skip "OFD access log unsupported"
17295 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17298 do_facet ost1 ofd_access_log_reader --list
17301 do_facet ost1 killall -TERM ofd_access_log_reader
17305 if ((rc != 0)); then
17306 error "ofd_access_log_reader exited with rc = '${rc}'"
17309 # Parse trace file for discovery events:
17310 oalr_expect_event_count alr_log_add "${trace}" 1
17311 oalr_expect_event_count alr_log_eof "${trace}" 1
17312 oalr_expect_event_count alr_log_free "${trace}" 1
17314 run_test 165a "ofd access log discovery"
17317 local trace="/tmp/${tfile}.trace"
17318 local file="${DIR}/${tfile}"
17327 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17328 skip "OFD access log unsupported"
17331 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17334 do_facet ost1 ofd_access_log_reader --list
17336 lfs setstripe -c 1 -i 0 "${file}"
17337 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17338 error "cannot create '${file}'"
17341 do_facet ost1 killall -TERM ofd_access_log_reader
17345 if ((rc != 0)); then
17346 error "ofd_access_log_reader exited with rc = '${rc}'"
17349 oalr_expect_event_count alr_log_entry "${trace}" 1
17351 pfid1=$($LFS path2fid "${file}")
17353 # 1 2 3 4 5 6 7 8 9 10
17354 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
17355 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17357 echo "entry = '${entry[*]}'" >&2
17360 if [[ "${pfid1}" != "${pfid2}" ]]; then
17361 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17365 if ((size != 1048576)); then
17366 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
17370 if [[ "${flags}" != "w" ]]; then
17371 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
17374 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17377 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
17378 error "cannot read '${file}'"
17381 do_facet ost1 killall -TERM ofd_access_log_reader
17385 if ((rc != 0)); then
17386 error "ofd_access_log_reader exited with rc = '${rc}'"
17389 oalr_expect_event_count alr_log_entry "${trace}" 1
17391 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17392 echo "entry = '${entry[*]}'" >&2
17395 if [[ "${pfid1}" != "${pfid2}" ]]; then
17396 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17400 if ((size != 524288)); then
17401 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
17405 if [[ "${flags}" != "r" ]]; then
17406 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
17409 run_test 165b "ofd access log entries are produced and consumed"
17412 local trace="/tmp/${tfile}.trace"
17413 local file="${DIR}/${tdir}/${tfile}"
17415 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17416 skip "OFD access log unsupported"
17418 test_mkdir "${DIR}/${tdir}"
17421 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17424 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
17426 # 4096 / 64 = 64. Create twice as many entries.
17427 for ((i = 0; i < 128; i++)); do
17428 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
17429 error "cannot create file"
17434 do_facet ost1 killall -TERM ofd_access_log_reader
17437 if ((rc != 0)); then
17438 error "ofd_access_log_reader exited with rc = '${rc}'"
17441 unlinkmany "${file}-%d" 128
17443 run_test 165c "full ofd access logs do not block IOs"
17445 oal_get_read_count() {
17448 # STATS lustre-OST0001 alr_read_count 1
17450 do_facet ost1 cat "${stats}" |
17451 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
17452 END { print count; }'
17455 oal_expect_read_count() {
17460 # Ask ofd_access_log_reader to write stats.
17461 do_facet ost1 killall -USR1 ofd_access_log_reader
17463 # Allow some time for things to happen.
17466 count=$(oal_get_read_count "${stats}")
17467 if ((count == expect)); then
17471 error_noexit "bad read count, got ${count}, expected ${expect}"
17472 do_facet ost1 cat "${stats}" >&2
17477 local stats="/tmp/${tfile}.stats"
17478 local file="${DIR}/${tdir}/${tfile}"
17479 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
17481 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17482 skip "OFD access log unsupported"
17484 test_mkdir "${DIR}/${tdir}"
17487 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
17490 lfs setstripe -c 1 -i 0 "${file}"
17492 do_facet ost1 lctl set_param "${param}=rw"
17493 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17494 error "cannot create '${file}'"
17495 oal_expect_read_count "${stats}" 1
17497 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17498 error "cannot read '${file}'"
17499 oal_expect_read_count "${stats}" 2
17501 do_facet ost1 lctl set_param "${param}=r"
17502 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17503 error "cannot create '${file}'"
17504 oal_expect_read_count "${stats}" 2
17506 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17507 error "cannot read '${file}'"
17508 oal_expect_read_count "${stats}" 3
17510 do_facet ost1 lctl set_param "${param}=w"
17511 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17512 error "cannot create '${file}'"
17513 oal_expect_read_count "${stats}" 4
17515 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17516 error "cannot read '${file}'"
17517 oal_expect_read_count "${stats}" 4
17519 do_facet ost1 lctl set_param "${param}=0"
17520 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17521 error "cannot create '${file}'"
17522 oal_expect_read_count "${stats}" 4
17524 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17525 error "cannot read '${file}'"
17526 oal_expect_read_count "${stats}" 4
17528 do_facet ost1 killall -TERM ofd_access_log_reader
17531 if ((rc != 0)); then
17532 error "ofd_access_log_reader exited with rc = '${rc}'"
17535 run_test 165d "ofd_access_log mask works"
17538 local stats="/tmp/${tfile}.stats"
17539 local file0="${DIR}/${tdir}-0/${tfile}"
17540 local file1="${DIR}/${tdir}-1/${tfile}"
17542 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17543 skip "OFD access log unsupported"
17545 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
17547 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
17548 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
17550 lfs setstripe -c 1 -i 0 "${file0}"
17551 lfs setstripe -c 1 -i 0 "${file1}"
17554 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
17557 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
17558 error "cannot create '${file0}'"
17560 oal_expect_read_count "${stats}" 0
17562 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
17563 error "cannot create '${file1}'"
17565 oal_expect_read_count "${stats}" 1
17567 do_facet ost1 killall -TERM ofd_access_log_reader
17570 if ((rc != 0)); then
17571 error "ofd_access_log_reader exited with rc = '${rc}'"
17574 run_test 165e "ofd_access_log MDT index filter works"
17577 local trace="/tmp/${tfile}.trace"
17582 do_facet ost1 timeout 60 ofd_access_log_reader \
17583 --exit-on-close --debug=- --trace=- > "${trace}" &
17590 if ((rc != 0)); then
17591 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
17596 run_test 165f "ofd_access_log_reader --exit-on-close works"
17599 # do directio so as not to populate the page cache
17600 log "creating a 10 Mb file"
17601 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
17602 error "multiop failed while creating a file"
17603 log "starting reads"
17604 dd if=$DIR/$tfile of=/dev/null bs=4096 &
17605 log "truncating the file"
17606 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
17607 error "multiop failed while truncating the file"
17609 kill %+ || true # reads might have finished
17610 echo "wait until dd is finished"
17612 log "removing the temporary file"
17613 rm -rf $DIR/$tfile || error "tmp file removal failed"
17615 run_test 169 "parallel read and truncate should not deadlock"
17618 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17620 $LCTL clear # bug 18514
17621 $LCTL debug_daemon start $TMP/${tfile}_log_good
17623 $LCTL debug_daemon stop
17624 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
17625 error "sed failed to read log_good"
17627 $LCTL debug_daemon start $TMP/${tfile}_log_good
17629 $LCTL debug_daemon stop
17631 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
17632 error "lctl df log_bad failed"
17634 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17635 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17637 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
17638 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
17640 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
17641 error "bad_line good_line1 good_line2 are empty"
17643 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17644 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
17645 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17647 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
17648 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17649 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17651 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
17652 error "bad_line_new good_line_new are empty"
17654 local expected_good=$((good_line1 + good_line2*2))
17656 rm -f $TMP/${tfile}*
17657 # LU-231, short malformed line may not be counted into bad lines
17658 if [ $bad_line -ne $bad_line_new ] &&
17659 [ $bad_line -ne $((bad_line_new - 1)) ]; then
17660 error "expected $bad_line bad lines, but got $bad_line_new"
17664 if [ $expected_good -ne $good_line_new ]; then
17665 error "expected $expected_good good lines, but got $good_line_new"
17670 run_test 170 "test lctl df to handle corrupted log ====================="
17672 test_171() { # bug20592
17673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17675 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
17676 $LCTL set_param fail_loc=0x50e
17677 $LCTL set_param fail_val=3000
17678 multiop_bg_pause $DIR/$tfile O_s || true
17680 kill -USR1 $MULTIPID
17684 if dmesg | grep "recursive fault"; then
17685 error "caught a recursive fault"
17687 $LCTL set_param fail_loc=0
17690 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
17692 # it would be good to share it with obdfilter-survey/iokit-libecho code
17693 setup_obdecho_osc () {
17696 local obdfilter_name=$2
17697 echo "Creating new osc for $obdfilter_name on $ost_nid"
17698 # make sure we can find loopback nid
17699 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
17701 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
17702 ${obdfilter_name}_osc_UUID || rc=2; }
17703 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
17704 ${obdfilter_name}_UUID $ost_nid || rc=3; }
17708 cleanup_obdecho_osc () {
17709 local obdfilter_name=$1
17710 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
17711 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
17718 local pages=${3:-64}
17723 local obd_size=$(get_obd_size $node $OBD)
17724 local page_size=$(get_page_size $node)
17725 if [[ -n "$obd_size" ]]; then
17726 local new_count=$((obd_size / (pages * page_size / 1024)))
17727 [[ $new_count -ge $count ]] || count=$new_count
17730 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
17731 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
17733 if [ $rc -eq 0 ]; then
17734 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
17735 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
17737 echo "New object id is $id"
17738 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
17740 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
17741 "test_brw $count w v $pages $id" || rc=4; }
17742 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
17744 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
17745 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
17746 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
17747 { do_facet $node "$LCTL --device ec detach" || rc=6; }
17748 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
17753 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17755 if ! [ -d /sys/fs/lustre/echo_client ] &&
17756 ! module_loaded obdecho; then
17757 load_module obdecho/obdecho &&
17758 stack_trap "rmmod obdecho" EXIT ||
17759 error "unable to load obdecho on client"
17762 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
17763 local host=$($LCTL get_param -n osc.$osc.import |
17764 awk '/current_connection:/ { print $2 }' )
17765 local target=$($LCTL get_param -n osc.$osc.import |
17766 awk '/target:/ { print $2 }' )
17767 target=${target%_UUID}
17769 if [ -n "$target" ]; then
17770 setup_obdecho_osc $host $target &&
17771 stack_trap "cleanup_obdecho_osc $target" EXIT ||
17772 { error "obdecho setup failed with $?"; return; }
17774 obdecho_test ${target}_osc client ||
17775 error "obdecho_test failed on ${target}_osc"
17777 $LCTL get_param osc.$osc.import
17778 error "there is no osc.$osc.import target"
17781 run_test 180a "test obdecho on osc"
17784 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17785 remote_ost_nodsh && skip "remote OST with nodsh"
17787 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17788 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17789 error "failed to load module obdecho"
17791 local target=$(do_facet ost1 $LCTL dl |
17792 awk '/obdfilter/ { print $4; exit; }')
17794 if [ -n "$target" ]; then
17795 obdecho_test $target ost1 || error "obdecho_test failed with $?"
17797 do_facet ost1 $LCTL dl
17798 error "there is no obdfilter target on ost1"
17801 run_test 180b "test obdecho directly on obdfilter"
17803 test_180c() { # LU-2598
17804 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17805 remote_ost_nodsh && skip "remote OST with nodsh"
17806 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
17807 skip "Need MDS version at least 2.4.0"
17809 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17810 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17811 error "failed to load module obdecho"
17813 local target=$(do_facet ost1 $LCTL dl |
17814 awk '/obdfilter/ { print $4; exit; }')
17816 if [ -n "$target" ]; then
17817 local pages=16384 # 64MB bulk I/O RPC size
17819 obdecho_test "$target" ost1 "$pages" ||
17820 error "obdecho_test with pages=$pages failed with $?"
17822 do_facet ost1 $LCTL dl
17823 error "there is no obdfilter target on ost1"
17826 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
17828 test_181() { # bug 22177
17829 test_mkdir $DIR/$tdir
17830 # create enough files to index the directory
17831 createmany -o $DIR/$tdir/foobar 4000
17832 # print attributes for debug purpose
17835 multiop_bg_pause $DIR/$tdir D_Sc || return 1
17837 # remove the files & current working dir
17838 unlinkmany $DIR/$tdir/foobar 4000
17840 kill -USR1 $MULTIPID
17842 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
17845 run_test 181 "Test open-unlinked dir ========================"
17851 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
17853 $LCTL set_param mdc.*.rpc_stats=clear
17855 for (( i = 0; i < $tcount; i++ )) ; do
17856 mkdir $DIR/$tdir/$i
17859 for (( i = 0; i < $tcount; i++ )) ; do
17860 createmany -o $DIR/$tdir/$i/f- $fcount &
17864 for (( i = 0; i < $tcount; i++ )) ; do
17865 unlinkmany $DIR/$tdir/$i/f- $fcount &
17869 $LCTL get_param mdc.*.rpc_stats
17873 run_test 182a "Test parallel modify metadata operations from mdc"
17876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17877 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17884 do_facet mds1 $LCTL list_param \
17885 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
17886 skip "MDS lacks parallel RPC handling"
17888 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
17890 rpc_count=$(do_facet mds1 $LCTL get_param -n \
17891 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
17894 createmany -i 0 -d $DIR/$tdir/t- $tcount
17896 for (( i = 0; i < $tcount; i++ )) ; do
17897 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
17901 delta=$((etime - stime))
17902 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
17905 for (( i = 0; i < $tcount; i++ )) ; do
17906 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
17910 delta=$((etime - stime))
17911 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
17915 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
17917 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
17920 createmany -i 0 -d $DIR/$tdir/t- $tcount
17922 for (( i = 0; i < $tcount; i++ )) ; do
17923 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
17927 delta=$((etime - stime))
17928 echo "Time for file creation $delta sec for 1 RPC sent at a time"
17931 for (( i = 0; i < $tcount; i++ )) ; do
17932 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
17936 delta=$((etime - stime))
17937 echo "Time for file removal $delta sec for 1 RPC sent at a time"
17939 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
17941 run_test 182b "Test parallel modify metadata operations from osp"
17943 test_183() { # LU-2275
17944 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17945 remote_mds_nodsh && skip "remote MDS with nodsh"
17946 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
17947 skip "Need MDS version at least 2.3.56"
17949 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
17950 echo aaa > $DIR/$tdir/$tfile
17952 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
17953 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
17955 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
17956 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
17958 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17960 # Flush negative dentry cache
17961 touch $DIR/$tdir/$tfile
17963 # We are not checking for any leaked references here, they'll
17964 # become evident next time we do cleanup with module unload.
17967 run_test 183 "No crash or request leak in case of strange dispositions ========"
17969 # test suite 184 is for LU-2016, LU-2017
17971 check_swap_layouts_support
17973 dir0=$DIR/$tdir/$testnum
17974 test_mkdir -p -c1 $dir0
17979 $LFS setstripe -c1 $file1
17981 $LFS setstripe -c2 $file2
17983 gen1=$($LFS getstripe -g $file1)
17984 gen2=$($LFS getstripe -g $file2)
17986 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
17987 gen=$($LFS getstripe -g $file1)
17988 [[ $gen1 != $gen ]] ||
17989 error "Layout generation on $file1 does not change"
17990 gen=$($LFS getstripe -g $file2)
17991 [[ $gen2 != $gen ]] ||
17992 error "Layout generation on $file2 does not change"
17994 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
17995 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
17997 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
17999 run_test 184a "Basic layout swap"
18002 check_swap_layouts_support
18004 dir0=$DIR/$tdir/$testnum
18005 mkdir -p $dir0 || error "creating dir $dir0"
18012 $LFS setstripe -c1 $file1
18013 $LFS setstripe -c2 $file2
18014 $LFS setstripe -c1 $file3
18015 chown $RUNAS_ID $file3
18016 gen1=$($LFS getstripe -g $file1)
18017 gen2=$($LFS getstripe -g $file2)
18019 $LFS swap_layouts $dir1 $dir2 &&
18020 error "swap of directories layouts should fail"
18021 $LFS swap_layouts $dir1 $file1 &&
18022 error "swap of directory and file layouts should fail"
18023 $RUNAS $LFS swap_layouts $file1 $file2 &&
18024 error "swap of file we cannot write should fail"
18025 $LFS swap_layouts $file1 $file3 &&
18026 error "swap of file with different owner should fail"
18027 /bin/true # to clear error code
18029 run_test 184b "Forbidden layout swap (will generate errors)"
18032 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
18033 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
18034 check_swap_layouts_support
18035 check_swap_layout_no_dom $DIR
18037 local dir0=$DIR/$tdir/$testnum
18038 mkdir -p $dir0 || error "creating dir $dir0"
18040 local ref1=$dir0/ref1
18041 local ref2=$dir0/ref2
18042 local file1=$dir0/file1
18043 local file2=$dir0/file2
18044 # create a file large enough for the concurrent test
18045 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
18046 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
18047 echo "ref file size: ref1($(stat -c %s $ref1))," \
18048 "ref2($(stat -c %s $ref2))"
18051 dd if=$ref1 of=$file1 bs=16k &
18054 # Make sure dd starts to copy file, but wait at most 5 seconds
18056 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
18058 $LFS swap_layouts $file1 $file2
18061 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
18062 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
18064 # how many bytes copied before swapping layout
18065 local copied=$(stat -c %s $file2)
18066 local remaining=$(stat -c %s $ref1)
18067 remaining=$((remaining - copied))
18068 echo "Copied $copied bytes before swapping layout..."
18070 cmp -n $copied $file1 $ref2 | grep differ &&
18071 error "Content mismatch [0, $copied) of ref2 and file1"
18072 cmp -n $copied $file2 $ref1 ||
18073 error "Content mismatch [0, $copied) of ref1 and file2"
18074 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
18075 error "Content mismatch [$copied, EOF) of ref1 and file1"
18078 rm -f $ref1 $ref2 $file1 $file2
18080 run_test 184c "Concurrent write and layout swap"
18083 check_swap_layouts_support
18084 check_swap_layout_no_dom $DIR
18085 [ -z "$(which getfattr 2>/dev/null)" ] &&
18086 skip_env "no getfattr command"
18088 local file1=$DIR/$tdir/$tfile-1
18089 local file2=$DIR/$tdir/$tfile-2
18090 local file3=$DIR/$tdir/$tfile-3
18094 mkdir -p $DIR/$tdir
18095 touch $file1 || error "create $file1 failed"
18096 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18097 error "create $file2 failed"
18098 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18099 error "create $file3 failed"
18100 lovea1=$(get_layout_param $file1)
18102 $LFS swap_layouts $file2 $file3 ||
18103 error "swap $file2 $file3 layouts failed"
18104 $LFS swap_layouts $file1 $file2 ||
18105 error "swap $file1 $file2 layouts failed"
18107 lovea2=$(get_layout_param $file2)
18110 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
18112 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18113 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
18115 run_test 184d "allow stripeless layouts swap"
18118 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
18119 skip "Need MDS version at least 2.6.94"
18120 check_swap_layouts_support
18121 check_swap_layout_no_dom $DIR
18122 [ -z "$(which getfattr 2>/dev/null)" ] &&
18123 skip_env "no getfattr command"
18125 local file1=$DIR/$tdir/$tfile-1
18126 local file2=$DIR/$tdir/$tfile-2
18127 local file3=$DIR/$tdir/$tfile-3
18130 mkdir -p $DIR/$tdir
18131 touch $file1 || error "create $file1 failed"
18132 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18133 error "create $file2 failed"
18134 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18135 error "create $file3 failed"
18137 $LFS swap_layouts $file1 $file2 ||
18138 error "swap $file1 $file2 layouts failed"
18140 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18141 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
18143 echo 123 > $file1 || error "Should be able to write into $file1"
18145 $LFS swap_layouts $file1 $file3 ||
18146 error "swap $file1 $file3 layouts failed"
18148 echo 123 > $file1 || error "Should be able to write into $file1"
18150 rm -rf $file1 $file2 $file3
18152 run_test 184e "Recreate layout after stripeless layout swaps"
18155 # Create a file with name longer than sizeof(struct stat) ==
18156 # 144 to see if we can get chars from the file name to appear
18157 # in the returned striping. Note that 'f' == 0x66.
18158 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
18160 mkdir -p $DIR/$tdir
18161 mcreate $DIR/$tdir/$file
18162 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
18163 error "IOC_MDC_GETFILEINFO returned garbage striping"
18166 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
18168 test_185() { # LU-2441
18169 # LU-3553 - no volatile file support in old servers
18170 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
18171 skip "Need MDS version at least 2.3.60"
18173 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18174 touch $DIR/$tdir/spoo
18175 local mtime1=$(stat -c "%Y" $DIR/$tdir)
18176 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
18177 error "cannot create/write a volatile file"
18178 [ "$FILESET" == "" ] &&
18179 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
18180 error "FID is still valid after close"
18182 multiop_bg_pause $DIR/$tdir vVw4096_c
18189 # assume that the next FID for this client is sequential, since stdout
18190 # is unfortunately eaten by multiop_bg_pause
18191 local n=$((${fidv[1]} + 1))
18192 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
18193 if [ "$FILESET" == "" ]; then
18194 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
18195 error "FID is missing before close"
18197 kill -USR1 $multi_pid
18198 # 1 second delay, so if mtime change we will see it
18200 local mtime2=$(stat -c "%Y" $DIR/$tdir)
18201 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
18203 run_test 185 "Volatile file support"
18205 function create_check_volatile() {
18209 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
18212 local FID=$(cat /tmp/${tfile}.fid)
18213 [ "$FID" == "" ] && error "can't get FID for volatile"
18214 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
18215 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
18216 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
18220 cancel_lru_locks mdc # flush opencache
18221 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
18226 # LU-12516 - volatile creation via .lustre
18227 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
18228 skip "Need MDS version at least 2.3.55"
18230 create_check_volatile 0
18231 [ $MDSCOUNT -lt 2 ] && return 0
18234 create_check_volatile 1
18238 run_test 185a "Volatile file creation in .lustre/fid/"
18241 remote_mds_nodsh && skip "remote MDS with nodsh"
18242 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18243 skip "Need MDS version at least 2.3.0"
18245 local dir0=$DIR/$tdir/$testnum
18246 mkdir -p $dir0 || error "creating dir $dir0"
18248 local file=$dir0/file1
18249 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
18250 local dv1=$($LFS data_version $file)
18251 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
18252 local dv2=$($LFS data_version $file)
18253 [[ $dv1 != $dv2 ]] ||
18254 error "data version did not change on write $dv1 == $dv2"
18259 run_test 187a "Test data version change"
18262 remote_mds_nodsh && skip "remote MDS with nodsh"
18263 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18264 skip "Need MDS version at least 2.3.0"
18266 local dir0=$DIR/$tdir/$testnum
18267 mkdir -p $dir0 || error "creating dir $dir0"
18269 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
18270 [[ ${DV[0]} != ${DV[1]} ]] ||
18271 error "data version did not change on write"\
18272 " ${DV[0]} == ${DV[1]}"
18277 run_test 187b "Test data version change on volatile file"
18280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18281 remote_mgs_nodsh && skip "remote MGS with nodsh"
18282 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
18284 local POOL=${POOL:-cea1}
18285 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
18286 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
18289 local last_ost=$(($OSTCOUNT - 1))
18291 local ost_list=$(seq $first_ost $ost_step $last_ost)
18292 local ost_range="$first_ost $last_ost $ost_step"
18293 local test_path=$POOL_ROOT/$POOL_DIR_NAME
18294 local file_dir=$POOL_ROOT/file_tst
18295 local subdir=$test_path/subdir
18299 # former test_200a test_200b
18300 pool_add $POOL || { rc=$? ; break; }
18301 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
18302 # former test_200c test_200d
18303 mkdir -p $test_path
18304 pool_set_dir $POOL $test_path || { rc=$? ; break; }
18305 pool_check_dir $POOL $test_path || { rc=$? ; break; }
18307 pool_check_dir $POOL $subdir || { rc=$? ; break; }
18308 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
18309 || { rc=$? ; break; }
18310 # former test_200e test_200f
18311 local files=$((OSTCOUNT*3))
18312 pool_alloc_files $POOL $test_path $files "$ost_list" \
18313 || { rc=$? ; break; }
18314 pool_create_files $POOL $file_dir $files "$ost_list" \
18315 || { rc=$? ; break; }
18316 # former test_200g test_200h
18317 pool_lfs_df $POOL || { rc=$? ; break; }
18318 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
18320 # former test_201a test_201b test_201c
18321 pool_remove_first_target $POOL || { rc=$? ; break; }
18323 local f=$test_path/$tfile
18324 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
18325 pool_remove $POOL $f || { rc=$? ; break; }
18333 run_test 200 "OST pools"
18335 # usage: default_attr <count | size | offset>
18337 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
18340 # usage: check_default_stripe_attr
18341 check_default_stripe_attr() {
18342 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
18345 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
18347 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
18351 error "unknown getstripe attr '$1'"
18354 [ $ACTUAL == $EXPECTED ] ||
18355 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
18359 test_mkdir $DIR/$tdir
18360 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
18362 check_default_stripe_attr --stripe-count
18363 check_default_stripe_attr --stripe-size
18364 check_default_stripe_attr --stripe-index
18366 run_test 204a "Print default stripe attributes"
18369 test_mkdir $DIR/$tdir
18370 $LFS setstripe --stripe-count 1 $DIR/$tdir
18372 check_default_stripe_attr --stripe-size
18373 check_default_stripe_attr --stripe-index
18375 run_test 204b "Print default stripe size and offset"
18378 test_mkdir $DIR/$tdir
18379 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18381 check_default_stripe_attr --stripe-count
18382 check_default_stripe_attr --stripe-index
18384 run_test 204c "Print default stripe count and offset"
18387 test_mkdir $DIR/$tdir
18388 $LFS setstripe --stripe-index 0 $DIR/$tdir
18390 check_default_stripe_attr --stripe-count
18391 check_default_stripe_attr --stripe-size
18393 run_test 204d "Print default stripe count and size"
18396 test_mkdir $DIR/$tdir
18397 $LFS setstripe -d $DIR/$tdir
18399 check_default_stripe_attr --stripe-count --raw
18400 check_default_stripe_attr --stripe-size --raw
18401 check_default_stripe_attr --stripe-index --raw
18403 run_test 204e "Print raw stripe attributes"
18406 test_mkdir $DIR/$tdir
18407 $LFS setstripe --stripe-count 1 $DIR/$tdir
18409 check_default_stripe_attr --stripe-size --raw
18410 check_default_stripe_attr --stripe-index --raw
18412 run_test 204f "Print raw stripe size and offset"
18415 test_mkdir $DIR/$tdir
18416 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18418 check_default_stripe_attr --stripe-count --raw
18419 check_default_stripe_attr --stripe-index --raw
18421 run_test 204g "Print raw stripe count and offset"
18424 test_mkdir $DIR/$tdir
18425 $LFS setstripe --stripe-index 0 $DIR/$tdir
18427 check_default_stripe_attr --stripe-count --raw
18428 check_default_stripe_attr --stripe-size --raw
18430 run_test 204h "Print raw stripe count and size"
18432 # Figure out which job scheduler is being used, if any,
18433 # or use a fake one
18434 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
18435 JOBENV=SLURM_JOB_ID
18436 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
18438 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
18440 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
18441 JOBENV=LOADL_STEP_ID
18442 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
18445 $LCTL list_param jobid_name > /dev/null 2>&1
18446 if [ $? -eq 0 ]; then
18452 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
18454 verify_jobstats() {
18459 # we don't really need to clear the stats for this test to work, since each
18460 # command has a unique jobid, but it makes debugging easier if needed.
18461 # for facet in $facets; do
18462 # local dev=$(convert_facet2label $facet)
18463 # # clear old jobstats
18464 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
18467 # use a new JobID for each test, or we might see an old one
18468 [ "$JOBENV" = "FAKE_JOBID" ] &&
18469 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
18471 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
18473 [ "$JOBENV" = "nodelocal" ] && {
18474 FAKE_JOBID=id.$testnum.%e.$RANDOM
18475 $LCTL set_param jobid_name=$FAKE_JOBID
18476 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
18479 log "Test: ${cmd[*]}"
18480 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
18482 if [ $JOBENV = "FAKE_JOBID" ]; then
18483 FAKE_JOBID=$JOBVAL ${cmd[*]}
18488 # all files are created on OST0000
18489 for facet in $facets; do
18490 local stats="*.$(convert_facet2label $facet).job_stats"
18492 # strip out libtool wrappers for in-tree executables
18493 if (( $(do_facet $facet lctl get_param $stats |
18494 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
18495 do_facet $facet lctl get_param $stats
18496 error "No jobstats for $JOBVAL found on $facet::$stats"
18502 local new_jobenv=$1
18504 set_persistent_param_and_check client "jobid_var" \
18505 "$FSNAME.sys.jobid_var" $new_jobenv
18508 test_205a() { # Job stats
18509 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18510 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
18511 skip "Need MDS version with at least 2.7.1"
18512 remote_mgs_nodsh && skip "remote MGS with nodsh"
18513 remote_mds_nodsh && skip "remote MDS with nodsh"
18514 remote_ost_nodsh && skip "remote OST with nodsh"
18515 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
18516 skip "Server doesn't support jobstats"
18517 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
18519 local old_jobenv=$($LCTL get_param -n jobid_var)
18520 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
18522 if [[ $PERM_CMD == *"set_param -P"* ]]; then
18523 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
18525 stack_trap "do_facet mgs $PERM_CMD \
18526 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
18530 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
18531 mdt.*.job_cleanup_interval | head -n 1)
18532 local new_interval=5
18533 do_facet $SINGLEMDS \
18534 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
18535 stack_trap "do_facet $SINGLEMDS \
18536 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
18537 local start=$SECONDS
18541 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
18542 verify_jobstats "$cmd" "$SINGLEMDS"
18544 cmd="rmdir $DIR/$tdir"
18545 verify_jobstats "$cmd" "$SINGLEMDS"
18546 # mkdir on secondary MDT
18547 if [ $MDSCOUNT -gt 1 ]; then
18548 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
18549 verify_jobstats "$cmd" "mds2"
18552 cmd="mknod $DIR/$tfile c 1 3"
18553 verify_jobstats "$cmd" "$SINGLEMDS"
18555 cmd="rm -f $DIR/$tfile"
18556 verify_jobstats "$cmd" "$SINGLEMDS"
18557 # create all files on OST0000 so verify_jobstats can find OST stats
18559 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
18560 verify_jobstats "$cmd" "$SINGLEMDS"
18562 cmd="touch $DIR/$tfile"
18563 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18565 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
18566 verify_jobstats "$cmd" "ost1"
18568 cancel_lru_locks osc
18569 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
18570 verify_jobstats "$cmd" "ost1"
18572 cmd="$TRUNCATE $DIR/$tfile 0"
18573 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18575 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
18576 verify_jobstats "$cmd" "$SINGLEMDS"
18577 # jobstats expiry - sleep until old stats should be expired
18578 local left=$((new_interval + 5 - (SECONDS - start)))
18579 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
18580 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
18582 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
18583 verify_jobstats "$cmd" "$SINGLEMDS"
18584 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
18585 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
18587 # Ensure that jobid are present in changelog (if supported by MDS)
18588 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
18589 changelog_dump | tail -10
18590 jobids=$(changelog_dump | tail -9 | grep -c "j=")
18591 [ $jobids -eq 9 ] ||
18592 error "Wrong changelog jobid count $jobids != 9"
18596 jobstats_set $JOBENV
18598 changelog_dump | grep $tfile
18599 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
18600 [ $jobids -eq 0 ] ||
18601 error "Unexpected jobids when jobid_var=$JOBENV"
18604 # test '%j' access to environment variable - if supported
18605 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
18606 JOBENV="JOBCOMPLEX"
18607 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
18609 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18612 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
18613 JOBENV="JOBCOMPLEX"
18614 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
18616 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18619 # test '%j' access to per-session jobid - if supported
18620 if lctl list_param jobid_this_session > /dev/null 2>&1
18622 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
18623 lctl set_param jobid_this_session=$USER
18625 JOBENV="JOBCOMPLEX"
18626 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
18628 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18631 run_test 205a "Verify job stats"
18633 # LU-13117, LU-13597
18635 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
18636 skip "Need MDS version at least 2.13.54.91"
18638 job_stats="mdt.*.job_stats"
18639 $LCTL set_param $job_stats=clear
18640 # Setting jobid_var to USER might not be supported
18641 $LCTL set_param jobid_var=USER || true
18642 $LCTL set_param jobid_name="%e.%u"
18643 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
18644 do_facet $SINGLEMDS $LCTL get_param $job_stats |
18645 grep "job_id:.*foolish" &&
18646 error "Unexpected jobid found"
18647 do_facet $SINGLEMDS $LCTL get_param $job_stats |
18648 grep "open:.*min.*max.*sum" ||
18649 error "wrong job_stats format found"
18651 run_test 205b "Verify job stats jobid and output format"
18655 $LCTL set_param llite.*.stats=0
18656 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
18657 $LCTL get_param llite.*.stats
18658 $LCTL get_param llite.*.stats | grep \
18659 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
18660 error "wrong client stats format found"
18662 run_test 205c "Verify client stats format"
18664 # LU-1480, LU-1773 and LU-1657
18666 mkdir -p $DIR/$tdir
18667 $LFS setstripe -c -1 $DIR/$tdir
18668 #define OBD_FAIL_LOV_INIT 0x1403
18669 $LCTL set_param fail_loc=0xa0001403
18670 $LCTL set_param fail_val=1
18671 touch $DIR/$tdir/$tfile || true
18673 run_test 206 "fail lov_init_raid0() doesn't lbug"
18676 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18677 local fsz=`stat -c %s $DIR/$tfile`
18678 cancel_lru_locks mdc
18680 # do not return layout in getattr intent
18681 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
18682 $LCTL set_param fail_loc=0x170
18683 local sz=`stat -c %s $DIR/$tfile`
18685 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
18689 run_test 207a "can refresh layout at glimpse"
18692 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18693 local cksum=`md5sum $DIR/$tfile`
18694 local fsz=`stat -c %s $DIR/$tfile`
18695 cancel_lru_locks mdc
18696 cancel_lru_locks osc
18698 # do not return layout in getattr intent
18699 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
18700 $LCTL set_param fail_loc=0x171
18702 # it will refresh layout after the file is opened but before read issues
18703 echo checksum is "$cksum"
18704 echo "$cksum" |md5sum -c --quiet || error "file differs"
18708 run_test 207b "can refresh layout at open"
18711 # FIXME: in this test suite, only RD lease is used. This is okay
18712 # for now as only exclusive open is supported. After generic lease
18713 # is done, this test suite should be revised. - Jinshan
18715 remote_mds_nodsh && skip "remote MDS with nodsh"
18716 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
18717 skip "Need MDS version at least 2.4.52"
18719 echo "==== test 1: verify get lease work"
18720 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
18722 echo "==== test 2: verify lease can be broken by upcoming open"
18723 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
18727 $MULTIOP $DIR/$tfile oO_RDWR:c
18728 kill -USR1 $PID && wait $PID || error "break lease error"
18730 echo "==== test 3: verify lease can't be granted if an open already exists"
18731 $MULTIOP $DIR/$tfile oO_RDWR:_c &
18735 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
18736 kill -USR1 $PID && wait $PID || error "open file error"
18738 echo "==== test 4: lease can sustain over recovery"
18739 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
18745 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
18747 echo "==== test 5: lease broken can't be regained by replay"
18748 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
18752 # open file to break lease and then recovery
18753 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
18756 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
18760 run_test 208 "Exclusive open"
18763 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
18764 skip_env "must have disp_stripe"
18767 sync; sleep 5; sync;
18769 echo 3 > /proc/sys/vm/drop_caches
18770 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18771 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18772 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18774 # open/close 500 times
18775 for i in $(seq 500); do
18779 echo 3 > /proc/sys/vm/drop_caches
18780 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18781 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18782 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18784 echo "before: $req_before, after: $req_after"
18785 [ $((req_after - req_before)) -ge 300 ] &&
18786 error "open/close requests are not freed"
18789 run_test 209 "read-only open/close requests should be freed promptly"
18794 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
18798 $LFS getstripe $DIR/$tfile
18800 wait $pid || error "multiop failed"
18802 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
18806 $LFS getstripe $DIR/$tfile
18808 wait $pid || error "multiop failed"
18810 run_test 210 "lfs getstripe does not break leases"
18814 size=$((size % 8192 + 1))
18815 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
18816 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
18817 rm -f $DIR/f212 $DIR/f212.xyz
18819 run_test 212 "Sendfile test ============================================"
18822 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
18823 cancel_lru_locks osc
18824 lctl set_param fail_loc=0x8000040f
18825 # generate a read lock
18826 cat $DIR/$tfile > /dev/null
18827 # write to the file, it will try to cancel the above read lock.
18828 cat /etc/hosts >> $DIR/$tfile
18830 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
18832 test_214() { # for bug 20133
18833 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
18834 for (( i=0; i < 340; i++ )) ; do
18835 touch $DIR/$tdir/d214c/a$i
18838 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
18839 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
18840 ls $DIR/d214c || error "ls $DIR/d214c failed"
18841 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
18842 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
18844 run_test 214 "hash-indexed directory test - bug 20133"
18846 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
18847 create_lnet_proc_files() {
18848 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
18851 # counterpart of create_lnet_proc_files
18852 remove_lnet_proc_files() {
18853 rm -f $TMP/lnet_$1.sys
18856 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
18857 # 3rd arg as regexp for body
18858 check_lnet_proc_stats() {
18859 local l=$(cat "$TMP/lnet_$1" |wc -l)
18860 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
18862 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
18865 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
18866 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
18867 # optional and can be regexp for 2nd line (lnet.routes case)
18868 check_lnet_proc_entry() {
18869 local blp=2 # blp stands for 'position of 1st line of body'
18870 [ -z "$5" ] || blp=3 # lnet.routes case
18872 local l=$(cat "$TMP/lnet_$1" |wc -l)
18873 # subtracting one from $blp because the body can be empty
18874 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
18876 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
18877 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
18879 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
18880 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
18882 # bail out if any unexpected line happened
18883 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
18884 [ "$?" != 0 ] || error "$2 misformatted"
18887 test_215() { # for bugs 18102, 21079, 21517
18888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18890 local N='(0|[1-9][0-9]*)' # non-negative numeric
18891 local P='[1-9][0-9]*' # positive numeric
18892 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
18893 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
18894 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
18895 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
18897 local L1 # regexp for 1st line
18898 local L2 # regexp for 2nd line (optional)
18899 local BR # regexp for the rest (body)
18901 # lnet.stats should look as 11 space-separated non-negative numerics
18902 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
18903 create_lnet_proc_files "stats"
18904 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
18905 remove_lnet_proc_files "stats"
18907 # lnet.routes should look like this:
18908 # Routing disabled/enabled
18909 # net hops priority state router
18910 # where net is a string like tcp0, hops > 0, priority >= 0,
18911 # state is up/down,
18912 # router is a string like 192.168.1.1@tcp2
18913 L1="^Routing (disabled|enabled)$"
18914 L2="^net +hops +priority +state +router$"
18915 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
18916 create_lnet_proc_files "routes"
18917 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
18918 remove_lnet_proc_files "routes"
18920 # lnet.routers should look like this:
18921 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
18922 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
18923 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
18924 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
18925 L1="^ref +rtr_ref +alive +router$"
18926 BR="^$P +$P +(up|down) +$NID$"
18927 create_lnet_proc_files "routers"
18928 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
18929 remove_lnet_proc_files "routers"
18931 # lnet.peers should look like this:
18932 # nid refs state last max rtr min tx min queue
18933 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
18934 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
18935 # numeric (0 or >0 or <0), queue >= 0.
18936 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
18937 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
18938 create_lnet_proc_files "peers"
18939 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
18940 remove_lnet_proc_files "peers"
18942 # lnet.buffers should look like this:
18943 # pages count credits min
18944 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
18945 L1="^pages +count +credits +min$"
18946 BR="^ +$N +$N +$I +$I$"
18947 create_lnet_proc_files "buffers"
18948 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
18949 remove_lnet_proc_files "buffers"
18951 # lnet.nis should look like this:
18952 # nid status alive refs peer rtr max tx min
18953 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
18954 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
18955 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
18956 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
18957 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
18958 create_lnet_proc_files "nis"
18959 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
18960 remove_lnet_proc_files "nis"
18962 # can we successfully write to lnet.stats?
18963 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
18965 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
18967 test_216() { # bug 20317
18968 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18969 remote_ost_nodsh && skip "remote OST with nodsh"
18972 local facets=$(get_facets OST)
18973 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
18975 save_lustre_params client "osc.*.contention_seconds" > $p
18976 save_lustre_params $facets \
18977 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
18978 save_lustre_params $facets \
18979 "ldlm.namespaces.filter-*.contended_locks" >> $p
18980 save_lustre_params $facets \
18981 "ldlm.namespaces.filter-*.contention_seconds" >> $p
18982 clear_stats osc.*.osc_stats
18984 # agressive lockless i/o settings
18985 do_nodes $(comma_list $(osts_nodes)) \
18986 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
18987 ldlm.namespaces.filter-*.contended_locks=0 \
18988 ldlm.namespaces.filter-*.contention_seconds=60"
18989 lctl set_param -n osc.*.contention_seconds=60
18991 $DIRECTIO write $DIR/$tfile 0 10 4096
18992 $CHECKSTAT -s 40960 $DIR/$tfile
18994 # disable lockless i/o
18995 do_nodes $(comma_list $(osts_nodes)) \
18996 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
18997 ldlm.namespaces.filter-*.contended_locks=32 \
18998 ldlm.namespaces.filter-*.contention_seconds=0"
18999 lctl set_param -n osc.*.contention_seconds=0
19000 clear_stats osc.*.osc_stats
19002 dd if=/dev/zero of=$DIR/$tfile count=0
19003 $CHECKSTAT -s 0 $DIR/$tfile
19005 restore_lustre_params <$p
19009 run_test 216 "check lockless direct write updates file size and kms correctly"
19011 test_217() { # bug 22430
19012 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19017 for node in $(nodes_list); do
19018 nid=$(host_nids_address $node $NETTYPE)
19019 if [[ $nid = *-* ]] ; then
19020 echo "lctl ping $(h2nettype $nid)"
19021 lctl ping $(h2nettype $nid)
19023 echo "skipping $node (no hyphen detected)"
19027 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
19030 # do directio so as not to populate the page cache
19031 log "creating a 10 Mb file"
19032 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
19033 log "starting reads"
19034 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19035 log "truncating the file"
19036 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
19038 kill %+ || true # reads might have finished
19039 echo "wait until dd is finished"
19041 log "removing the temporary file"
19042 rm -rf $DIR/$tfile || error "tmp file removal failed"
19044 run_test 218 "parallel read and truncate should not deadlock"
19047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19049 # write one partial page
19050 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
19051 # set no grant so vvp_io_commit_write will do sync write
19052 $LCTL set_param fail_loc=0x411
19053 # write a full page at the end of file
19054 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
19056 $LCTL set_param fail_loc=0
19057 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
19058 $LCTL set_param fail_loc=0x411
19059 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
19062 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
19063 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
19065 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
19067 test_220() { #LU-325
19068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19069 remote_ost_nodsh && skip "remote OST with nodsh"
19070 remote_mds_nodsh && skip "remote MDS with nodsh"
19071 remote_mgs_nodsh && skip "remote MGS with nodsh"
19075 # create on MDT0000 so the last_id and next_id are correct
19076 mkdir_on_mdt0 $DIR/$tdir
19077 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
19081 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
19082 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
19083 osp.$mdtosc_proc1.prealloc_last_id)
19084 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
19085 osp.$mdtosc_proc1.prealloc_next_id)
19089 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
19090 #define OBD_FAIL_OST_ENOINO 0x229
19091 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
19092 create_pool $FSNAME.$TESTNAME || return 1
19093 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
19095 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
19097 MDSOBJS=$((last_id - next_id))
19098 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
19100 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
19101 echo "OST still has $count kbytes free"
19103 echo "create $MDSOBJS files @next_id..."
19104 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
19106 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19107 osp.$mdtosc_proc1.prealloc_last_id)
19108 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19109 osp.$mdtosc_proc1.prealloc_next_id)
19111 echo "after creation, last_id=$last_id2, next_id=$next_id2"
19116 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
19117 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
19119 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
19120 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
19121 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
19122 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
19123 echo "unlink $MDSOBJS files @$next_id..."
19124 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
19126 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
19129 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19131 dd if=`which date` of=$MOUNT/date oflag=sync
19132 chmod +x $MOUNT/date
19134 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
19135 $LCTL set_param fail_loc=0x80001401
19137 $MOUNT/date > /dev/null
19140 run_test 221 "make sure fault and truncate race to not cause OOM"
19143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19146 test_mkdir $DIR/$tdir
19147 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19148 createmany -o $DIR/$tdir/$tfile 10
19149 cancel_lru_locks mdc
19150 cancel_lru_locks osc
19151 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19152 $LCTL set_param fail_loc=0x31a
19153 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
19154 $LCTL set_param fail_loc=0
19157 run_test 222a "AGL for ls should not trigger CLIO lock failure"
19160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19163 test_mkdir $DIR/$tdir
19164 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19165 createmany -o $DIR/$tdir/$tfile 10
19166 cancel_lru_locks mdc
19167 cancel_lru_locks osc
19168 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19169 $LCTL set_param fail_loc=0x31a
19170 rm -r $DIR/$tdir || error "AGL for rmdir failed"
19171 $LCTL set_param fail_loc=0
19173 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
19176 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19179 test_mkdir $DIR/$tdir
19180 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19181 createmany -o $DIR/$tdir/$tfile 10
19182 cancel_lru_locks mdc
19183 cancel_lru_locks osc
19184 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
19185 $LCTL set_param fail_loc=0x31b
19186 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
19187 $LCTL set_param fail_loc=0
19190 run_test 223 "osc reenqueue if without AGL lock granted ======================="
19192 test_224a() { # LU-1039, MRP-303
19193 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19194 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
19195 $LCTL set_param fail_loc=0x508
19196 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
19197 $LCTL set_param fail_loc=0
19200 run_test 224a "Don't panic on bulk IO failure"
19202 test_224bd_sub() { # LU-1039, MRP-303
19203 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19207 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
19209 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19211 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
19212 cancel_lru_locks osc
19214 stack_trap "set_checksums $ORIG_CSUM" EXIT
19215 local at_max_saved=0
19217 # adaptive timeouts may prevent seeing the issue
19218 if at_is_enabled; then
19219 at_max_saved=$(at_max_get mds)
19220 at_max_set 0 mds client
19221 stack_trap "at_max_set $at_max_saved mds client" EXIT
19224 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
19225 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
19226 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
19228 do_facet ost1 $LCTL set_param fail_loc=0
19229 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
19234 test_224bd_sub 3 error "dd failed"
19236 run_test 224b "Don't panic on bulk IO failure"
19238 test_224c() { # LU-6441
19239 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19240 remote_mds_nodsh && skip "remote MDS with nodsh"
19242 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19243 save_writethrough $p
19244 set_cache writethrough on
19246 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
19247 local at_max=$($LCTL get_param -n at_max)
19248 local timeout=$($LCTL get_param -n timeout)
19249 local test_at="at_max"
19250 local param_at="$FSNAME.sys.at_max"
19251 local test_timeout="timeout"
19252 local param_timeout="$FSNAME.sys.timeout"
19254 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
19256 set_persistent_param_and_check client "$test_at" "$param_at" 0
19257 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
19259 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
19260 do_facet ost1 "$LCTL set_param fail_loc=0x520"
19261 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19262 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
19264 do_facet ost1 "$LCTL set_param fail_loc=0"
19266 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
19267 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
19270 $LCTL set_param -n $pages_per_rpc
19271 restore_lustre_params < $p
19274 run_test 224c "Don't hang if one of md lost during large bulk RPC"
19276 test_224d() { # LU-11169
19277 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
19279 run_test 224d "Don't corrupt data on bulk IO timeout"
19281 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
19283 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19284 if [ -z ${MDSSURVEY} ]; then
19285 skip_env "mds-survey not found"
19287 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19288 skip "Need MDS version at least 2.2.51"
19290 local mds=$(facet_host $SINGLEMDS)
19291 local target=$(do_nodes $mds 'lctl dl' |
19292 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19294 local cmd1="file_count=1000 thrhi=4"
19295 local cmd2="dir_count=2 layer=mdd stripe_count=0"
19296 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19297 local cmd="$cmd1 $cmd2 $cmd3"
19299 rm -f ${TMP}/mds_survey*
19301 eval $cmd || error "mds-survey with zero-stripe failed"
19302 cat ${TMP}/mds_survey*
19303 rm -f ${TMP}/mds_survey*
19305 run_test 225a "Metadata survey sanity with zero-stripe"
19308 if [ -z ${MDSSURVEY} ]; then
19309 skip_env "mds-survey not found"
19311 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19312 skip "Need MDS version at least 2.2.51"
19313 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19314 remote_mds_nodsh && skip "remote MDS with nodsh"
19315 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
19316 skip_env "Need to mount OST to test"
19319 local mds=$(facet_host $SINGLEMDS)
19320 local target=$(do_nodes $mds 'lctl dl' |
19321 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19323 local cmd1="file_count=1000 thrhi=4"
19324 local cmd2="dir_count=2 layer=mdd stripe_count=1"
19325 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19326 local cmd="$cmd1 $cmd2 $cmd3"
19328 rm -f ${TMP}/mds_survey*
19330 eval $cmd || error "mds-survey with stripe_count failed"
19331 cat ${TMP}/mds_survey*
19332 rm -f ${TMP}/mds_survey*
19334 run_test 225b "Metadata survey sanity with stripe_count = 1"
19336 mcreate_path2fid () {
19342 local path=$DIR/$tdir/$name
19347 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
19348 error "cannot create $desc"
19350 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
19352 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
19354 fid_path=$($LFS fid2path $MOUNT $fid)
19356 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
19358 [ "$path" == "$fid_path" ] ||
19359 error "fid2path returned $fid_path, expected $path"
19361 echo "pass with $path and $fid"
19366 mkdir -p $DIR/$tdir
19368 mcreate_path2fid 0010666 0 0 fifo "FIFO"
19369 mcreate_path2fid 0020666 1 3 null "character special file (null)"
19370 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
19371 mcreate_path2fid 0040666 0 0 dir "directory"
19372 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
19373 mcreate_path2fid 0100666 0 0 file "regular file"
19374 mcreate_path2fid 0120666 0 0 link "symbolic link"
19375 mcreate_path2fid 0140666 0 0 sock "socket"
19377 run_test 226a "call path2fid and fid2path on files of all type"
19380 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19385 mkdir -p $DIR/$tdir
19386 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
19387 error "create remote directory failed"
19388 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
19389 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
19390 "character special file (null)"
19391 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
19392 "character special file (no device)"
19393 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
19394 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
19395 "block special file (loop)"
19396 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
19397 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
19398 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
19400 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
19403 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19404 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
19405 skip "Need MDS version at least 2.13.55"
19407 local submnt=/mnt/submnt
19408 local srcfile=/etc/passwd
19409 local dstfile=$submnt/passwd
19415 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
19416 error "create remote directory failed"
19417 mkdir -p $submnt || error "create $submnt failed"
19418 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
19419 error "mount $submnt failed"
19420 stack_trap "umount $submnt" EXIT
19422 cp $srcfile $dstfile
19423 fid=$($LFS path2fid $dstfile)
19424 path=$($LFS fid2path $submnt "$fid")
19425 [ "$path" = "$dstfile" ] ||
19426 error "fid2path $submnt $fid failed ($path != $dstfile)"
19428 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
19430 # LU-1299 Executing or running ldd on a truncated executable does not
19431 # cause an out-of-memory condition.
19433 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19434 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
19436 dd if=$(which date) of=$MOUNT/date bs=1k count=1
19437 chmod +x $MOUNT/date
19439 $MOUNT/date > /dev/null
19440 ldd $MOUNT/date > /dev/null
19443 run_test 227 "running truncated executable does not cause OOM"
19445 # LU-1512 try to reuse idle OI blocks
19447 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19448 remote_mds_nodsh && skip "remote MDS with nodsh"
19449 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19451 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19452 local myDIR=$DIR/$tdir
19455 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19456 $LCTL set_param fail_loc=0x80001002
19457 createmany -o $myDIR/t- 10000
19458 $LCTL set_param fail_loc=0
19459 # The guard is current the largest FID holder
19461 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19463 local IDX=$(($SEQ % 64))
19465 do_facet $SINGLEMDS sync
19466 # Make sure journal flushed.
19468 local blk1=$(do_facet $SINGLEMDS \
19469 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19470 grep Blockcount | awk '{print $4}')
19472 # Remove old files, some OI blocks will become idle.
19473 unlinkmany $myDIR/t- 10000
19474 # Create new files, idle OI blocks should be reused.
19475 createmany -o $myDIR/t- 2000
19476 do_facet $SINGLEMDS sync
19477 # Make sure journal flushed.
19479 local blk2=$(do_facet $SINGLEMDS \
19480 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19481 grep Blockcount | awk '{print $4}')
19483 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19485 run_test 228a "try to reuse idle OI blocks"
19488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19489 remote_mds_nodsh && skip "remote MDS with nodsh"
19490 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19492 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19493 local myDIR=$DIR/$tdir
19496 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19497 $LCTL set_param fail_loc=0x80001002
19498 createmany -o $myDIR/t- 10000
19499 $LCTL set_param fail_loc=0
19500 # The guard is current the largest FID holder
19502 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19504 local IDX=$(($SEQ % 64))
19506 do_facet $SINGLEMDS sync
19507 # Make sure journal flushed.
19509 local blk1=$(do_facet $SINGLEMDS \
19510 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19511 grep Blockcount | awk '{print $4}')
19513 # Remove old files, some OI blocks will become idle.
19514 unlinkmany $myDIR/t- 10000
19517 stop $SINGLEMDS || error "Fail to stop MDT."
19519 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
19520 error "Fail to start MDT."
19522 df $MOUNT || error "Fail to df."
19523 # Create new files, idle OI blocks should be reused.
19524 createmany -o $myDIR/t- 2000
19525 do_facet $SINGLEMDS sync
19526 # Make sure journal flushed.
19528 local blk2=$(do_facet $SINGLEMDS \
19529 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19530 grep Blockcount | awk '{print $4}')
19532 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19534 run_test 228b "idle OI blocks can be reused after MDT restart"
19538 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19539 remote_mds_nodsh && skip "remote MDS with nodsh"
19540 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19542 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19543 local myDIR=$DIR/$tdir
19546 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19547 $LCTL set_param fail_loc=0x80001002
19548 # 20000 files can guarantee there are index nodes in the OI file
19549 createmany -o $myDIR/t- 20000
19550 $LCTL set_param fail_loc=0
19551 # The guard is current the largest FID holder
19553 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19555 local IDX=$(($SEQ % 64))
19557 do_facet $SINGLEMDS sync
19558 # Make sure journal flushed.
19560 local blk1=$(do_facet $SINGLEMDS \
19561 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19562 grep Blockcount | awk '{print $4}')
19564 # Remove old files, some OI blocks will become idle.
19565 unlinkmany $myDIR/t- 20000
19567 # The OI file should become empty now
19569 # Create new files, idle OI blocks should be reused.
19570 createmany -o $myDIR/t- 2000
19571 do_facet $SINGLEMDS sync
19572 # Make sure journal flushed.
19574 local blk2=$(do_facet $SINGLEMDS \
19575 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19576 grep Blockcount | awk '{print $4}')
19578 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19580 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
19582 test_229() { # LU-2482, LU-3448
19583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19584 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19585 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
19586 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
19590 # Create a file with a released layout and stripe count 2.
19591 $MULTIOP $DIR/$tfile H2c ||
19592 error "failed to create file with released layout"
19594 $LFS getstripe -v $DIR/$tfile
19596 local pattern=$($LFS getstripe -L $DIR/$tfile)
19597 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
19599 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
19601 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
19602 stat $DIR/$tfile || error "failed to stat released file"
19604 chown $RUNAS_ID $DIR/$tfile ||
19605 error "chown $RUNAS_ID $DIR/$tfile failed"
19607 chgrp $RUNAS_ID $DIR/$tfile ||
19608 error "chgrp $RUNAS_ID $DIR/$tfile failed"
19610 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
19611 rm $DIR/$tfile || error "failed to remove released file"
19613 run_test 229 "getstripe/stat/rm/attr changes work on released files"
19616 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19617 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19618 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19619 skip "Need MDS version at least 2.11.52"
19623 test_mkdir $DIR/$tdir
19624 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
19625 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
19626 [ $mdt_idx -ne 0 ] &&
19627 error "create local directory on wrong MDT $mdt_idx"
19629 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
19630 error "create remote directory failed"
19631 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
19632 [ $mdt_idx -ne $MDTIDX ] &&
19633 error "create remote directory on wrong MDT $mdt_idx"
19635 createmany -o $DIR/$tdir/test_230/t- 10 ||
19636 error "create files on remote directory failed"
19637 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
19638 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
19639 rm -r $DIR/$tdir || error "unlink remote directory failed"
19641 run_test 230a "Create remote directory and files under the remote directory"
19644 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19645 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19646 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19647 skip "Need MDS version at least 2.11.52"
19655 local migrate_dir=$DIR/$tdir/migrate_dir
19656 local other_dir=$DIR/$tdir/other_dir
19658 test_mkdir $DIR/$tdir
19659 test_mkdir -i0 -c1 $migrate_dir
19660 test_mkdir -i0 -c1 $other_dir
19661 for ((i=0; i<10; i++)); do
19662 mkdir -p $migrate_dir/dir_${i}
19663 createmany -o $migrate_dir/dir_${i}/f 10 ||
19664 error "create files under remote dir failed $i"
19667 cp /etc/passwd $migrate_dir/$tfile
19668 cp /etc/passwd $other_dir/$tfile
19669 chattr +SAD $migrate_dir
19670 chattr +SAD $migrate_dir/$tfile
19672 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19673 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19674 local old_dir_mode=$(stat -c%f $migrate_dir)
19675 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
19677 mkdir -p $migrate_dir/dir_default_stripe2
19678 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
19679 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
19681 mkdir -p $other_dir
19682 ln $migrate_dir/$tfile $other_dir/luna
19683 ln $migrate_dir/$tfile $migrate_dir/sofia
19684 ln $other_dir/$tfile $migrate_dir/david
19685 ln -s $migrate_dir/$tfile $other_dir/zachary
19686 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
19687 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
19693 for len in 58 59 60; do
19694 lnktgt=$(str_repeat 'l' $len)
19695 touch $migrate_dir/$lnktgt
19696 ln -s $lnktgt $migrate_dir/${len}char_ln
19700 for len in 4094 4095; do
19701 lnktgt=$(str_repeat 'l' $len)
19702 ln -s $lnktgt $migrate_dir/${len}char_ln
19706 for len in 254 255; do
19707 touch $migrate_dir/$(str_repeat 'l' $len)
19710 $LFS migrate -m $MDTIDX $migrate_dir ||
19711 error "fails on migrating remote dir to MDT1"
19713 echo "migratate to MDT1, then checking.."
19714 for ((i = 0; i < 10; i++)); do
19715 for file in $(find $migrate_dir/dir_${i}); do
19716 mdt_index=$($LFS getstripe -m $file)
19717 # broken symlink getstripe will fail
19718 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19719 error "$file is not on MDT${MDTIDX}"
19723 # the multiple link file should still in MDT0
19724 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
19725 [ $mdt_index == 0 ] ||
19726 error "$file is not on MDT${MDTIDX}"
19728 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19729 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19730 error " expect $old_dir_flag get $new_dir_flag"
19732 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19733 [ "$old_file_flag" = "$new_file_flag" ] ||
19734 error " expect $old_file_flag get $new_file_flag"
19736 local new_dir_mode=$(stat -c%f $migrate_dir)
19737 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19738 error "expect mode $old_dir_mode get $new_dir_mode"
19740 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19741 [ "$old_file_mode" = "$new_file_mode" ] ||
19742 error "expect mode $old_file_mode get $new_file_mode"
19744 diff /etc/passwd $migrate_dir/$tfile ||
19745 error "$tfile different after migration"
19747 diff /etc/passwd $other_dir/luna ||
19748 error "luna different after migration"
19750 diff /etc/passwd $migrate_dir/sofia ||
19751 error "sofia different after migration"
19753 diff /etc/passwd $migrate_dir/david ||
19754 error "david different after migration"
19756 diff /etc/passwd $other_dir/zachary ||
19757 error "zachary different after migration"
19759 diff /etc/passwd $migrate_dir/${tfile}_ln ||
19760 error "${tfile}_ln different after migration"
19762 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
19763 error "${tfile}_ln_other different after migration"
19765 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
19766 [ $stripe_count = 2 ] ||
19767 error "dir strpe_count $d != 2 after migration."
19769 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
19770 [ $stripe_count = 2 ] ||
19771 error "file strpe_count $d != 2 after migration."
19773 #migrate back to MDT0
19776 $LFS migrate -m $MDTIDX $migrate_dir ||
19777 error "fails on migrating remote dir to MDT0"
19779 echo "migrate back to MDT0, checking.."
19780 for file in $(find $migrate_dir); do
19781 mdt_index=$($LFS getstripe -m $file)
19782 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19783 error "$file is not on MDT${MDTIDX}"
19786 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19787 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19788 error " expect $old_dir_flag get $new_dir_flag"
19790 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19791 [ "$old_file_flag" = "$new_file_flag" ] ||
19792 error " expect $old_file_flag get $new_file_flag"
19794 local new_dir_mode=$(stat -c%f $migrate_dir)
19795 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19796 error "expect mode $old_dir_mode get $new_dir_mode"
19798 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19799 [ "$old_file_mode" = "$new_file_mode" ] ||
19800 error "expect mode $old_file_mode get $new_file_mode"
19802 diff /etc/passwd ${migrate_dir}/$tfile ||
19803 error "$tfile different after migration"
19805 diff /etc/passwd ${other_dir}/luna ||
19806 error "luna different after migration"
19808 diff /etc/passwd ${migrate_dir}/sofia ||
19809 error "sofia different after migration"
19811 diff /etc/passwd ${other_dir}/zachary ||
19812 error "zachary different after migration"
19814 diff /etc/passwd $migrate_dir/${tfile}_ln ||
19815 error "${tfile}_ln different after migration"
19817 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
19818 error "${tfile}_ln_other different after migration"
19820 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
19821 [ $stripe_count = 2 ] ||
19822 error "dir strpe_count $d != 2 after migration."
19824 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
19825 [ $stripe_count = 2 ] ||
19826 error "file strpe_count $d != 2 after migration."
19828 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19830 run_test 230b "migrate directory"
19833 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19834 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19835 remote_mds_nodsh && skip "remote MDS with nodsh"
19836 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19837 skip "Need MDS version at least 2.11.52"
19843 local migrate_dir=$DIR/$tdir/migrate_dir
19845 #If migrating directory fails in the middle, all entries of
19846 #the directory is still accessiable.
19847 test_mkdir $DIR/$tdir
19848 test_mkdir -i0 -c1 $migrate_dir
19849 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
19851 createmany -o $migrate_dir/f $total ||
19852 error "create files under ${migrate_dir} failed"
19854 # fail after migrating top dir, and this will fail only once, so the
19855 # first sub file migration will fail (currently f3), others succeed.
19856 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
19857 do_facet mds1 lctl set_param fail_loc=0x1801
19858 local t=$(ls $migrate_dir | wc -l)
19859 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
19860 error "migrate should fail"
19861 local u=$(ls $migrate_dir | wc -l)
19862 [ "$u" == "$t" ] || error "$u != $t during migration"
19864 # add new dir/file should succeed
19865 mkdir $migrate_dir/dir ||
19866 error "mkdir failed under migrating directory"
19867 touch $migrate_dir/file ||
19868 error "create file failed under migrating directory"
19870 # add file with existing name should fail
19871 for file in $migrate_dir/f*; do
19872 stat $file > /dev/null || error "stat $file failed"
19873 $OPENFILE -f O_CREAT:O_EXCL $file &&
19874 error "open(O_CREAT|O_EXCL) $file should fail"
19875 $MULTIOP $file m && error "create $file should fail"
19876 touch $DIR/$tdir/remote_dir/$tfile ||
19877 error "touch $tfile failed"
19878 ln $DIR/$tdir/remote_dir/$tfile $file &&
19879 error "link $file should fail"
19880 mdt_index=$($LFS getstripe -m $file)
19881 if [ $mdt_index == 0 ]; then
19882 # file failed to migrate is not allowed to rename to
19883 mv $DIR/$tdir/remote_dir/$tfile $file &&
19884 error "rename to $file should fail"
19886 mv $DIR/$tdir/remote_dir/$tfile $file ||
19887 error "rename to $file failed"
19889 echo hello >> $file || error "write $file failed"
19892 # resume migration with different options should fail
19893 $LFS migrate -m 0 $migrate_dir &&
19894 error "migrate -m 0 $migrate_dir should fail"
19896 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
19897 error "migrate -c 2 $migrate_dir should fail"
19899 # resume migration should succeed
19900 $LFS migrate -m $MDTIDX $migrate_dir ||
19901 error "migrate $migrate_dir failed"
19903 echo "Finish migration, then checking.."
19904 for file in $(find $migrate_dir); do
19905 mdt_index=$($LFS getstripe -m $file)
19906 [ $mdt_index == $MDTIDX ] ||
19907 error "$file is not on MDT${MDTIDX}"
19910 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19912 run_test 230c "check directory accessiblity if migration failed"
19915 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19916 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19917 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19918 skip "Need MDS version at least 2.11.52"
19920 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
19922 local migrate_dir=$DIR/$tdir/migrate_dir
19932 old_index=$((RANDOM % MDSCOUNT))
19933 old_count=$((MDSCOUNT - old_index))
19934 new_index=$((RANDOM % MDSCOUNT))
19935 new_count=$((MDSCOUNT - new_index))
19936 new_hash=1 # for all_char
19938 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
19939 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
19941 test_mkdir $DIR/$tdir
19942 test_mkdir -i $old_index -c $old_count $migrate_dir
19944 for ((i=0; i<100; i++)); do
19945 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
19946 createmany -o $migrate_dir/dir_${i}/f 100 ||
19947 error "create files under remote dir failed $i"
19950 echo -n "Migrate from MDT$old_index "
19951 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
19952 echo -n "to MDT$new_index"
19953 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
19956 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
19957 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
19958 error "migrate remote dir error"
19960 echo "Finish migration, then checking.."
19961 for file in $(find $migrate_dir -maxdepth 1); do
19962 mdt_index=$($LFS getstripe -m $file)
19963 if [ $mdt_index -lt $new_index ] ||
19964 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
19965 error "$file is on MDT$mdt_index"
19969 rm -rf $DIR/$tdir || error "rm dir failed after migration"
19971 run_test 230d "check migrate big directory"
19974 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19975 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19976 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19977 skip "Need MDS version at least 2.11.52"
19984 mkdir_on_mdt0 $DIR/$tdir
19985 mkdir $DIR/$tdir/migrate_dir
19986 mkdir $DIR/$tdir/other_dir
19987 touch $DIR/$tdir/migrate_dir/a
19988 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
19989 ls $DIR/$tdir/other_dir
19991 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
19992 error "migrate dir fails"
19994 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
19995 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
19997 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
19998 [ $mdt_index == 0 ] || error "a is not on MDT0"
20000 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
20001 error "migrate dir fails"
20003 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
20004 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
20006 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20007 [ $mdt_index == 1 ] || error "a is not on MDT1"
20009 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
20010 [ $mdt_index == 1 ] || error "b is not on MDT1"
20012 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20013 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
20015 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
20017 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20019 run_test 230e "migrate mulitple local link files"
20022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20023 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20024 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20025 skip "Need MDS version at least 2.11.52"
20030 mkdir -p $DIR/$tdir
20031 mkdir $DIR/$tdir/migrate_dir
20032 $LFS mkdir -i1 $DIR/$tdir/other_dir
20033 touch $DIR/$tdir/migrate_dir/a
20034 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
20035 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
20036 ls $DIR/$tdir/other_dir
20038 # a should be migrated to MDT1, since no other links on MDT0
20039 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20040 error "#1 migrate dir fails"
20041 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20042 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20043 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20044 [ $mdt_index == 1 ] || error "a is not on MDT1"
20046 # a should stay on MDT1, because it is a mulitple link file
20047 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20048 error "#2 migrate dir fails"
20049 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20050 [ $mdt_index == 1 ] || error "a is not on MDT1"
20052 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20053 error "#3 migrate dir fails"
20055 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20056 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
20057 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
20059 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
20060 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
20062 # a should be migrated to MDT0, since no other links on MDT1
20063 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20064 error "#4 migrate dir fails"
20065 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20066 [ $mdt_index == 0 ] || error "a is not on MDT0"
20068 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20070 run_test 230f "migrate mulitple remote link files"
20073 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20074 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20075 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20076 skip "Need MDS version at least 2.11.52"
20078 mkdir -p $DIR/$tdir/migrate_dir
20080 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
20081 error "migrating dir to non-exist MDT succeeds"
20084 run_test 230g "migrate dir to non-exist MDT"
20087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20088 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20089 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20090 skip "Need MDS version at least 2.11.52"
20094 mkdir -p $DIR/$tdir/migrate_dir
20096 $LFS migrate -m1 $DIR &&
20097 error "migrating mountpoint1 should fail"
20099 $LFS migrate -m1 $DIR/$tdir/.. &&
20100 error "migrating mountpoint2 should fail"
20103 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
20104 error "migrating $tdir/migrate_dir/.. should fail"
20108 run_test 230h "migrate .. and root"
20111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20112 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20113 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20114 skip "Need MDS version at least 2.11.52"
20116 mkdir -p $DIR/$tdir/migrate_dir
20118 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
20119 error "migration fails with a tailing slash"
20121 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
20122 error "migration fails with two tailing slashes"
20124 run_test 230i "lfs migrate -m tolerates trailing slashes"
20127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20128 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20129 skip "Need MDS version at least 2.11.52"
20131 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20132 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
20133 error "create $tfile failed"
20134 cat /etc/passwd > $DIR/$tdir/$tfile
20136 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20138 cmp /etc/passwd $DIR/$tdir/$tfile ||
20139 error "DoM file mismatch after migration"
20141 run_test 230j "DoM file data not changed after dir migration"
20144 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
20145 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20146 skip "Need MDS version at least 2.11.56"
20149 local files_on_starting_mdt=0
20151 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
20152 $LFS getdirstripe $DIR/$tdir
20153 for i in $(seq $total); do
20154 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
20155 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20156 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20159 echo "$files_on_starting_mdt files on MDT0"
20161 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
20162 $LFS getdirstripe $DIR/$tdir
20164 files_on_starting_mdt=0
20165 for i in $(seq $total); do
20166 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20167 error "file $tfile.$i mismatch after migration"
20168 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
20169 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20172 echo "$files_on_starting_mdt files on MDT1 after migration"
20173 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
20175 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
20176 $LFS getdirstripe $DIR/$tdir
20178 files_on_starting_mdt=0
20179 for i in $(seq $total); do
20180 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20181 error "file $tfile.$i mismatch after 2nd migration"
20182 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20183 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20186 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
20187 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
20191 run_test 230k "file data not changed after dir migration"
20194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20195 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20196 skip "Need MDS version at least 2.11.56"
20198 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
20199 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
20200 error "create files under remote dir failed $i"
20201 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20203 run_test 230l "readdir between MDTs won't crash"
20206 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20207 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20208 skip "Need MDS version at least 2.11.56"
20211 local mig_dir=$DIR/$tdir/migrate_dir
20212 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
20216 echo "Creating files and dirs with xattrs"
20217 test_mkdir $DIR/$tdir
20218 test_mkdir -i0 -c1 $mig_dir
20220 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
20221 error "cannot set xattr attr1 on dir"
20222 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
20223 error "cannot set xattr attr2 on dir"
20224 touch $mig_dir/dir/f0
20225 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
20226 error "cannot set xattr attr1 on file"
20227 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
20228 error "cannot set xattr attr2 on file"
20229 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20230 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20231 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
20232 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20233 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
20234 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20235 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
20236 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20237 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
20239 echo "Migrating to MDT1"
20240 $LFS migrate -m $MDTIDX $mig_dir ||
20241 error "fails on migrating dir to MDT1"
20243 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20244 echo "Checking xattrs"
20245 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20246 [ "$val" = $longstr ] ||
20247 error "expecting xattr1 $longstr on dir, found $val"
20248 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20249 [ "$val" = $shortstr ] ||
20250 error "expecting xattr2 $shortstr on dir, found $val"
20251 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20252 [ "$val" = $longstr ] ||
20253 error "expecting xattr1 $longstr on file, found $val"
20254 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20255 [ "$val" = $shortstr ] ||
20256 error "expecting xattr2 $shortstr on file, found $val"
20258 run_test 230m "xattrs not changed after dir migration"
20261 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20262 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
20263 skip "Need MDS version at least 2.13.53"
20265 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
20266 cat /etc/hosts > $DIR/$tdir/$tfile
20267 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
20268 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
20270 cmp /etc/hosts $DIR/$tdir/$tfile ||
20271 error "File data mismatch after migration"
20273 run_test 230n "Dir migration with mirrored file"
20276 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
20277 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
20278 skip "Need MDS version at least 2.13.52"
20280 local mdts=$(comma_list $(mdts_nodes))
20282 local restripe_status
20286 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20288 # in case "crush" hash type is not set
20289 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20291 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20292 mdt.*MDT0000.enable_dir_restripe)
20293 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20294 stack_trap "do_nodes $mdts $LCTL set_param \
20295 mdt.*.enable_dir_restripe=$restripe_status"
20298 createmany -m $DIR/$tdir/f 100 ||
20299 error "create files under remote dir failed $i"
20300 createmany -d $DIR/$tdir/d 100 ||
20301 error "create dirs under remote dir failed $i"
20303 for i in $(seq 2 $MDSCOUNT); do
20304 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20305 $LFS setdirstripe -c $i $DIR/$tdir ||
20306 error "split -c $i $tdir failed"
20307 wait_update $HOSTNAME \
20308 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
20309 error "dir split not finished"
20310 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20311 awk '/migrate/ {sum += $2} END { print sum }')
20312 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
20313 # delta is around total_files/stripe_count
20314 (( $delta < 200 / (i - 1) + 4 )) ||
20315 error "$delta files migrated >= $((200 / (i - 1) + 4))"
20318 run_test 230o "dir split"
20321 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
20322 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20323 skip "Need MDS version at least 2.13.52"
20325 local mdts=$(comma_list $(mdts_nodes))
20327 local restripe_status
20331 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20333 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20335 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20336 mdt.*MDT0000.enable_dir_restripe)
20337 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20338 stack_trap "do_nodes $mdts $LCTL set_param \
20339 mdt.*.enable_dir_restripe=$restripe_status"
20341 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
20342 createmany -m $DIR/$tdir/f 100 ||
20343 error "create files under remote dir failed"
20344 createmany -d $DIR/$tdir/d 100 ||
20345 error "create dirs under remote dir failed"
20347 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
20348 local mdt_hash="crush"
20350 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20351 $LFS setdirstripe -c $c $DIR/$tdir ||
20352 error "split -c $c $tdir failed"
20353 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
20354 mdt_hash="$mdt_hash,fixed"
20355 elif [ $c -eq 1 ]; then
20358 wait_update $HOSTNAME \
20359 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
20360 error "dir merge not finished"
20361 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20362 awk '/migrate/ {sum += $2} END { print sum }')
20363 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
20364 # delta is around total_files/stripe_count
20365 (( delta < 200 / c + 4 )) ||
20366 error "$delta files migrated >= $((200 / c + 4))"
20369 run_test 230p "dir merge"
20372 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
20373 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20374 skip "Need MDS version at least 2.13.52"
20376 local mdts=$(comma_list $(mdts_nodes))
20377 local saved_threshold=$(do_facet mds1 \
20378 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
20379 local saved_delta=$(do_facet mds1 \
20380 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
20381 local threshold=100
20384 local stripe_count=0
20389 # test with fewer files on ZFS
20390 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
20392 stack_trap "do_nodes $mdts $LCTL set_param \
20393 mdt.*.dir_split_count=$saved_threshold"
20394 stack_trap "do_nodes $mdts $LCTL set_param \
20395 mdt.*.dir_split_delta=$saved_delta"
20396 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
20397 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
20398 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
20399 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
20400 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
20401 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20403 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20404 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20406 create=$((threshold * 3 / 2))
20407 while [ $stripe_count -lt $MDSCOUNT ]; do
20408 createmany -m $DIR/$tdir/f $total $create ||
20409 error "create sub files failed"
20410 stat $DIR/$tdir > /dev/null
20411 total=$((total + create))
20412 stripe_count=$((stripe_count + delta))
20413 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
20415 wait_update $HOSTNAME \
20416 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
20417 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
20419 wait_update $HOSTNAME \
20420 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
20421 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
20423 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
20424 echo "$nr_files/$total files on MDT$stripe_index after split"
20425 # allow 10% margin of imbalance with crush hash
20426 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
20427 error "$nr_files files on MDT$stripe_index after split"
20429 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
20430 [ $nr_files -eq $total ] ||
20431 error "total sub files $nr_files != $total"
20434 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
20436 echo "fixed layout directory won't auto split"
20437 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
20438 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
20439 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
20440 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
20441 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
20443 run_test 230q "dir auto split"
20446 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
20447 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20448 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
20449 skip "Need MDS version at least 2.13.54"
20451 # maximum amount of local locks:
20452 # parent striped dir - 2 locks
20453 # new stripe in parent to migrate to - 1 lock
20454 # source and target - 2 locks
20455 # Total 5 locks for regular file
20456 mkdir -p $DIR/$tdir
20457 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
20458 touch $DIR/$tdir/dir1/eee
20460 # create 4 hardlink for 4 more locks
20461 # Total: 9 locks > RS_MAX_LOCKS (8)
20462 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
20463 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
20464 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
20465 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
20466 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
20467 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
20468 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
20469 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
20471 cancel_lru_locks mdc
20473 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
20474 error "migrate dir fails"
20476 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20478 run_test 230r "migrate with too many local locks"
20481 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
20482 skip "Need MDS version at least 2.14.52"
20484 local mdts=$(comma_list $(mdts_nodes))
20485 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
20486 mdt.*MDT0000.enable_dir_restripe)
20488 stack_trap "do_nodes $mdts $LCTL set_param \
20489 mdt.*.enable_dir_restripe=$restripe_status"
20493 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
20494 test_mkdir $DIR/$tdir
20495 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
20496 error "$LFS mkdir should return EEXIST if target exists"
20500 run_test 230s "lfs mkdir should return -EEXIST if target exists"
20504 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20505 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
20506 skip "Need MDS version at least 2.14.50"
20508 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
20509 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
20510 $LFS project -p 1 -s $DIR/$tdir ||
20511 error "set $tdir project id failed"
20512 $LFS project -p 2 -s $DIR/$tdir/subdir ||
20513 error "set subdir project id failed"
20514 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
20516 run_test 230t "migrate directory with project ID set"
20520 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20521 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20522 skip "Need MDS version at least 2.14.53"
20526 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
20527 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20528 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
20529 for i in $(seq 0 $((MDSCOUNT - 1))); do
20530 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20531 echo "$count dirs migrated to MDT$i"
20533 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
20534 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
20536 run_test 230u "migrate directory by QOS"
20540 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20541 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20542 skip "Need MDS version at least 2.14.53"
20546 mkdir $DIR/$tdir || error "mkdir $tdir failed"
20547 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20548 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
20549 for i in $(seq 0 $((MDSCOUNT - 1))); do
20550 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20551 echo "$count subdirs migrated to MDT$i"
20552 (( i == 3 )) && (( count > 0 )) &&
20553 error "subdir shouldn't be migrated to MDT3"
20555 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
20556 (( count == 3 )) || error "dirs migrated to $count MDTs"
20558 run_test 230v "subdir migrated to the MDT where its parent is located"
20561 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
20562 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20563 skip "Need MDS version at least 2.14.53"
20565 mkdir -p $DIR/$tdir/sub || error "mkdir failed"
20567 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
20568 error "migrate failed"
20570 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
20571 error "$tdir stripe count mismatch"
20573 (( $($LFS getdirstripe -c $DIR/$tdir/sub) == 0 )) ||
20574 error "$tdir/sub is striped"
20576 run_test 230w "non-recursive mode dir migration"
20580 # For simplicity this test assumes that max_pages_per_rpc
20581 # is the same across all OSCs
20582 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
20583 local bulk_size=$((max_pages * PAGE_SIZE))
20584 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
20587 mkdir -p $DIR/$tdir
20588 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
20589 error "failed to set stripe with -S ${brw_size}M option"
20591 # clear the OSC stats
20592 $LCTL set_param osc.*.stats=0 &>/dev/null
20595 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
20596 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
20597 oflag=direct &>/dev/null || error "dd failed"
20599 sync; sleep 1; sync # just to be safe
20600 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
20601 if [ x$nrpcs != "x1" ]; then
20602 $LCTL get_param osc.*.stats
20603 error "found $nrpcs ost_write RPCs, not 1 as expected"
20607 # Drop the OSC cache, otherwise we will read from it
20608 cancel_lru_locks osc
20610 # clear the OSC stats
20611 $LCTL set_param osc.*.stats=0 &>/dev/null
20613 # Client reads $bulk_size.
20614 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
20615 iflag=direct &>/dev/null || error "dd failed"
20617 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
20618 if [ x$nrpcs != "x1" ]; then
20619 $LCTL get_param osc.*.stats
20620 error "found $nrpcs ost_read RPCs, not 1 as expected"
20623 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
20626 mkdir -p $DIR/$tdir
20628 for i in {0..1023}; do
20629 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
20630 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
20631 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
20635 run_test 231b "must not assert on fully utilized OST request buffer"
20638 mkdir -p $DIR/$tdir
20639 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
20641 #define OBD_FAIL_LDLM_OST_LVB 0x31c
20642 do_facet ost1 $LCTL set_param fail_loc=0x31c
20644 # ignore dd failure
20645 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
20647 do_facet ost1 $LCTL set_param fail_loc=0
20648 umount_client $MOUNT || error "umount failed"
20649 mount_client $MOUNT || error "mount failed"
20650 stop ost1 || error "cannot stop ost1"
20651 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
20653 run_test 232a "failed lock should not block umount"
20656 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
20657 skip "Need MDS version at least 2.10.58"
20659 mkdir -p $DIR/$tdir
20660 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
20661 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
20663 cancel_lru_locks osc
20665 #define OBD_FAIL_LDLM_OST_LVB 0x31c
20666 do_facet ost1 $LCTL set_param fail_loc=0x31c
20669 $LFS data_version $DIR/$tdir/$tfile || true
20671 do_facet ost1 $LCTL set_param fail_loc=0
20672 umount_client $MOUNT || error "umount failed"
20673 mount_client $MOUNT || error "mount failed"
20674 stop ost1 || error "cannot stop ost1"
20675 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
20677 run_test 232b "failed data version lock should not block umount"
20680 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
20681 skip "Need MDS version at least 2.3.64"
20682 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
20684 local fid=$($LFS path2fid $MOUNT)
20686 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20687 error "cannot access $MOUNT using its FID '$fid'"
20689 run_test 233a "checking that OBF of the FS root succeeds"
20692 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
20693 skip "Need MDS version at least 2.5.90"
20694 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
20696 local fid=$($LFS path2fid $MOUNT/.lustre)
20698 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20699 error "cannot access $MOUNT/.lustre using its FID '$fid'"
20701 fid=$($LFS path2fid $MOUNT/.lustre/fid)
20702 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20703 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
20705 run_test 233b "checking that OBF of the FS .lustre succeeds"
20708 local p="$TMP/sanityN-$TESTNAME.parameters"
20709 save_lustre_params client "llite.*.xattr_cache" > $p
20710 lctl set_param llite.*.xattr_cache 1 ||
20711 skip_env "xattr cache is not supported"
20713 mkdir -p $DIR/$tdir || error "mkdir failed"
20714 touch $DIR/$tdir/$tfile || error "touch failed"
20715 # OBD_FAIL_LLITE_XATTR_ENOMEM
20716 $LCTL set_param fail_loc=0x1405
20717 getfattr -n user.attr $DIR/$tdir/$tfile &&
20718 error "getfattr should have failed with ENOMEM"
20719 $LCTL set_param fail_loc=0x0
20722 restore_lustre_params < $p
20725 run_test 234 "xattr cache should not crash on ENOMEM"
20728 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
20729 skip "Need MDS version at least 2.4.52"
20731 flock_deadlock $DIR/$tfile
20736 124) error "process hangs on a deadlock"
20738 *) error "error executing flock_deadlock $DIR/$tfile"
20742 run_test 235 "LU-1715: flock deadlock detection does not work properly"
20746 check_swap_layouts_support
20748 local ref1=/etc/passwd
20749 local ref2=/etc/group
20750 local file1=$DIR/$tdir/f1
20751 local file2=$DIR/$tdir/f2
20753 test_mkdir -c1 $DIR/$tdir
20754 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
20755 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
20756 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
20757 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
20758 local fd=$(free_fd)
20759 local cmd="exec $fd<>$file2"
20762 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
20763 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
20766 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
20771 run_test 236 "Layout swap on open unlinked file"
20773 # LU-4659 linkea consistency
20775 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
20776 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
20777 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
20778 skip "Need MDS version at least 2.5.58 or 2.5.2+"
20781 ln $DIR/$tfile $DIR/$tfile.lnk
20782 touch $DIR/$tfile.new
20783 mv $DIR/$tfile.new $DIR/$tfile
20784 local fid1=$($LFS path2fid $DIR/$tfile)
20785 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
20786 local path1=$($LFS fid2path $FSNAME "$fid1")
20787 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
20788 local path2=$($LFS fid2path $FSNAME "$fid2")
20789 [ $tfile.lnk == $path2 ] ||
20790 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
20793 run_test 238 "Verify linkea consistency"
20795 test_239A() { # was test_239
20796 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
20797 skip "Need MDS version at least 2.5.60"
20799 local list=$(comma_list $(mdts_nodes))
20801 mkdir -p $DIR/$tdir
20802 createmany -o $DIR/$tdir/f- 5000
20803 unlinkmany $DIR/$tdir/f- 5000
20804 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
20805 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
20806 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
20807 osp.*MDT*.sync_in_flight" | calc_sum)
20808 [ "$changes" -eq 0 ] || error "$changes not synced"
20810 run_test 239A "osp_sync test"
20812 test_239a() { #LU-5297
20813 remote_mds_nodsh && skip "remote MDS with nodsh"
20816 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
20817 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
20818 chgrp $RUNAS_GID $DIR/$tfile
20819 wait_delete_completed
20821 run_test 239a "process invalid osp sync record correctly"
20823 test_239b() { #LU-5297
20824 remote_mds_nodsh && skip "remote MDS with nodsh"
20827 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
20828 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
20829 chgrp $RUNAS_GID $DIR/$tfile1
20830 wait_delete_completed
20831 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
20833 chgrp $RUNAS_GID $DIR/$tfile2
20834 wait_delete_completed
20836 run_test 239b "process osp sync record with ENOMEM error correctly"
20839 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20840 remote_mds_nodsh && skip "remote MDS with nodsh"
20842 mkdir -p $DIR/$tdir
20844 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
20845 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
20846 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
20847 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
20849 umount_client $MOUNT || error "umount failed"
20850 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
20851 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
20852 mount_client $MOUNT || error "failed to mount client"
20854 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
20855 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
20857 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
20863 for LOOP in $(seq $count); do
20864 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
20865 cancel_lru_locks $OSC || true
20873 for LOOP in $(seq $1); do
20874 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
20879 test_241a() { # was test_241
20880 local bsize=$PAGE_SIZE
20882 (( bsize < 40960 )) && bsize=40960
20883 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
20885 cancel_lru_locks $OSC
20886 test_241_bio 1000 $bsize &
20888 test_241_dio 1000 $bsize
20891 run_test 241a "bio vs dio"
20894 local bsize=$PAGE_SIZE
20896 (( bsize < 40960 )) && bsize=40960
20897 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
20899 test_241_dio 1000 $bsize &
20901 test_241_dio 1000 $bsize
20904 run_test 241b "dio vs dio"
20907 remote_mds_nodsh && skip "remote MDS with nodsh"
20909 mkdir_on_mdt0 $DIR/$tdir
20910 touch $DIR/$tdir/$tfile
20912 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
20913 do_facet mds1 lctl set_param fail_loc=0x105
20914 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
20916 do_facet mds1 lctl set_param fail_loc=0
20917 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
20919 run_test 242 "mdt_readpage failure should not cause directory unreadable"
20923 test_mkdir $DIR/$tdir
20924 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
20926 run_test 243 "various group lock tests"
20930 test_mkdir $DIR/$tdir
20931 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
20932 sendfile_grouplock $DIR/$tdir/$tfile || \
20933 error "sendfile+grouplock failed"
20936 run_test 244a "sendfile with group lock tests"
20940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
20943 local size=$((1024*1024))
20945 test_mkdir $DIR/$tdir
20946 for i in $(seq 1 $threads); do
20947 local file=$DIR/$tdir/file_$((i / 10))
20948 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
20951 for i in $(seq 1 $threads); do
20955 run_test 244b "multi-threaded write with group lock"
20958 local flagname="multi_mod_rpcs"
20959 local connect_data_name="max_mod_rpcs"
20962 # check if multiple modify RPCs flag is set
20963 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
20964 grep "connect_flags:")
20967 echo "$out" | grep -qw $flagname
20968 if [ $? -ne 0 ]; then
20969 echo "connect flag $flagname is not set"
20973 # check if multiple modify RPCs data is set
20974 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
20977 echo "$out" | grep -qw $connect_data_name ||
20978 error "import should have connect data $connect_data_name"
20980 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
20983 local flagname="multi_mod_rpcs"
20984 local connect_data_name="max_mod_rpcs"
20987 remote_mds_nodsh && skip "remote MDS with nodsh" && return
20988 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
20990 # check if multiple modify RPCs flag is set
20991 out=$(do_facet mds1 \
20992 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
20993 grep "connect_flags:")
20996 if [[ "$out" =~ $flagname ]]; then
20997 echo "connect flag $flagname is not set"
21001 # check if multiple modify RPCs data is set
21002 out=$(do_facet mds1 \
21003 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
21005 [[ "$out" =~ $connect_data_name ]] ||
21006 error "import should have connect data $connect_data_name"
21008 run_test 245b "check osp connection flag/data: multiple modify RPCs"
21014 umount_client $submount
21019 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21021 skip_env "Fileset feature is not supported"
21023 local submount=${MOUNT}_$tdir
21026 mkdir -p $submount || error "mkdir $submount failed"
21027 FILESET="$FILESET/$tdir" mount_client $submount ||
21028 error "mount $submount failed"
21029 trap "cleanup_247 $submount" EXIT
21030 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
21031 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
21032 error "read $MOUNT/$tdir/$tfile failed"
21033 cleanup_247 $submount
21035 run_test 247a "mount subdir as fileset"
21038 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21039 skip_env "Fileset feature is not supported"
21041 local submount=${MOUNT}_$tdir
21043 rm -rf $MOUNT/$tdir
21044 mkdir -p $submount || error "mkdir $submount failed"
21046 FILESET="$FILESET/$tdir" mount_client $submount &&
21047 error "mount $submount should fail"
21050 run_test 247b "mount subdir that dose not exist"
21053 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21054 skip_env "Fileset feature is not supported"
21056 local submount=${MOUNT}_$tdir
21058 mkdir -p $MOUNT/$tdir/dir1
21059 mkdir -p $submount || error "mkdir $submount failed"
21060 trap "cleanup_247 $submount" EXIT
21061 FILESET="$FILESET/$tdir" mount_client $submount ||
21062 error "mount $submount failed"
21063 local fid=$($LFS path2fid $MOUNT/)
21064 $LFS fid2path $submount $fid && error "fid2path should fail"
21065 cleanup_247 $submount
21067 run_test 247c "running fid2path outside subdirectory root"
21070 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21071 skip "Fileset feature is not supported"
21073 local submount=${MOUNT}_$tdir
21075 mkdir -p $MOUNT/$tdir/dir1
21076 mkdir -p $submount || error "mkdir $submount failed"
21077 FILESET="$FILESET/$tdir" mount_client $submount ||
21078 error "mount $submount failed"
21079 trap "cleanup_247 $submount" EXIT
21081 local td=$submount/dir1
21082 local fid=$($LFS path2fid $td)
21083 [ -z "$fid" ] && error "path2fid unable to get $td FID"
21085 # check that we get the same pathname back
21088 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
21089 echo "$rootpath $fid"
21090 found=$($LFS fid2path $rootpath "$fid")
21091 [ -n "$found" ] || error "fid2path should succeed"
21092 [ "$found" == "$td" ] || error "fid2path $found != $td"
21094 # check wrong root path format
21095 rootpath=$submount"_wrong"
21096 found=$($LFS fid2path $rootpath "$fid")
21097 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
21099 cleanup_247 $submount
21101 run_test 247d "running fid2path inside subdirectory root"
21105 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21107 skip "Fileset feature is not supported"
21109 local submount=${MOUNT}_$tdir
21112 mkdir -p $submount || error "mkdir $submount failed"
21113 FILESET="$FILESET/.." mount_client $submount &&
21114 error "mount $submount should fail"
21117 run_test 247e "mount .. as fileset"
21120 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21121 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
21122 skip "Need at least version 2.13.52"
21123 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21124 skip "Need at least version 2.14.50"
21125 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21127 skip "Fileset feature is not supported"
21129 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21130 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
21131 error "mkdir remote failed"
21132 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
21133 error "mkdir remote/subdir failed"
21134 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
21135 error "mkdir striped failed"
21136 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
21138 local submount=${MOUNT}_$tdir
21140 mkdir -p $submount || error "mkdir $submount failed"
21141 stack_trap "rmdir $submount"
21145 local fileset=$FILESET
21146 local mdts=$(comma_list $(mdts_nodes))
21148 stat=$(do_facet mds1 $LCTL get_param -n \
21149 mdt.*MDT0000.enable_remote_subdir_mount)
21150 stack_trap "do_nodes $mdts $LCTL set_param \
21151 mdt.*.enable_remote_subdir_mount=$stat"
21153 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
21154 stack_trap "umount_client $submount"
21155 FILESET="$fileset/$tdir/remote" mount_client $submount &&
21156 error "mount remote dir $dir should fail"
21158 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
21159 $tdir/striped/. ; do
21160 FILESET="$fileset/$dir" mount_client $submount ||
21161 error "mount $dir failed"
21162 umount_client $submount
21165 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
21166 FILESET="$fileset/$tdir/remote" mount_client $submount ||
21167 error "mount $tdir/remote failed"
21169 run_test 247f "mount striped or remote directory as fileset"
21172 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
21173 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21174 skip "Need at least version 2.14.50"
21176 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
21177 error "mkdir $tdir failed"
21178 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
21180 local submount=${MOUNT}_$tdir
21182 mkdir -p $submount || error "mkdir $submount failed"
21183 stack_trap "rmdir $submount"
21185 FILESET="$fileset/$tdir" mount_client $submount ||
21186 error "mount $dir failed"
21187 stack_trap "umount $submount"
21189 local mdts=$(comma_list $(mdts_nodes))
21193 stat $submount > /dev/null
21194 cancel_lru_locks $MDC
21195 stat $submount > /dev/null
21196 stat $submount/$tfile > /dev/null
21197 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
21198 stat $submount/$tfile > /dev/null
21199 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
21200 awk '/getattr/ {sum += $2} END {print sum}')
21202 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
21204 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
21207 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
21208 [ -z "$fast_read_sav" ] && skip "no fast read support"
21210 # create a large file for fast read verification
21211 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
21213 # make sure the file is created correctly
21214 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
21215 { rm -f $DIR/$tfile; skip "file creation error"; }
21217 echo "Test 1: verify that fast read is 4 times faster on cache read"
21219 # small read with fast read enabled
21220 $LCTL set_param -n llite.*.fast_read=1
21221 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21222 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21223 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21224 # small read with fast read disabled
21225 $LCTL set_param -n llite.*.fast_read=0
21226 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21227 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21228 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21230 # verify that fast read is 4 times faster for cache read
21231 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
21232 error_not_in_vm "fast read was not 4 times faster: " \
21233 "$t_fast vs $t_slow"
21235 echo "Test 2: verify the performance between big and small read"
21236 $LCTL set_param -n llite.*.fast_read=1
21238 # 1k non-cache read
21239 cancel_lru_locks osc
21240 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21241 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21242 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21244 # 1M non-cache read
21245 cancel_lru_locks osc
21246 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21247 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21248 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21250 # verify that big IO is not 4 times faster than small IO
21251 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
21252 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
21254 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
21257 run_test 248a "fast read verification"
21260 # Default short_io_bytes=16384, try both smaller and larger sizes.
21261 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
21262 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
21263 echo "bs=53248 count=113 normal buffered write"
21264 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
21265 error "dd of initial data file failed"
21266 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
21268 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
21269 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
21270 error "dd with sync normal writes failed"
21271 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
21273 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
21274 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
21275 error "dd with sync small writes failed"
21276 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
21278 cancel_lru_locks osc
21280 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
21281 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
21282 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
21283 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
21284 iflag=direct || error "dd with O_DIRECT small read failed"
21285 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
21286 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
21287 error "compare $TMP/$tfile.1 failed"
21289 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
21290 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
21292 # just to see what the maximum tunable value is, and test parsing
21293 echo "test invalid parameter 2MB"
21294 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
21295 error "too-large short_io_bytes allowed"
21296 echo "test maximum parameter 512KB"
21297 # if we can set a larger short_io_bytes, run test regardless of version
21298 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
21299 # older clients may not allow setting it this large, that's OK
21300 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
21301 skip "Need at least client version 2.13.50"
21302 error "medium short_io_bytes failed"
21304 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21305 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
21307 echo "test large parameter 64KB"
21308 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
21309 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21311 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
21312 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
21313 error "dd with sync large writes failed"
21314 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
21316 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
21317 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
21318 num=$((113 * 4096 / PAGE_SIZE))
21319 echo "bs=$size count=$num oflag=direct large write $tfile.3"
21320 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
21321 error "dd with O_DIRECT large writes failed"
21322 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
21323 error "compare $DIR/$tfile.3 failed"
21325 cancel_lru_locks osc
21327 echo "bs=$size count=$num iflag=direct large read $tfile.2"
21328 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
21329 error "dd with O_DIRECT large read failed"
21330 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
21331 error "compare $TMP/$tfile.2 failed"
21333 echo "bs=$size count=$num iflag=direct large read $tfile.3"
21334 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
21335 error "dd with O_DIRECT large read failed"
21336 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
21337 error "compare $TMP/$tfile.3 failed"
21339 run_test 248b "test short_io read and write for both small and large sizes"
21341 test_249() { # LU-7890
21342 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
21343 skip "Need at least version 2.8.54"
21346 $LFS setstripe -c 1 $DIR/$tfile
21347 # Offset 2T == 4k * 512M
21348 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
21349 error "dd to 2T offset failed"
21351 run_test 249 "Write above 2T file size"
21354 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
21355 && skip "no 16TB file size limit on ZFS"
21357 $LFS setstripe -c 1 $DIR/$tfile
21358 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
21359 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
21360 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
21361 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
21362 conv=notrunc,fsync && error "append succeeded"
21365 run_test 250 "Write above 16T limit"
21368 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
21370 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
21371 #Skip once - writing the first stripe will succeed
21372 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21373 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
21374 error "short write happened"
21376 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21377 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
21378 error "short read happened"
21382 run_test 251 "Handling short read and write correctly"
21385 remote_mds_nodsh && skip "remote MDS with nodsh"
21386 remote_ost_nodsh && skip "remote OST with nodsh"
21387 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
21388 skip_env "ldiskfs only test"
21398 # check lr_reader on OST0000
21400 dev=$(facet_device $tgt)
21401 out=$(do_facet $tgt $LR_READER $dev)
21402 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21404 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
21405 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
21406 error "Invalid uuid returned by $LR_READER on target $tgt"
21407 echo -e "uuid returned by $LR_READER is '$uuid'\n"
21409 # check lr_reader -c on MDT0000
21411 dev=$(facet_device $tgt)
21412 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
21413 skip "$LR_READER does not support additional options"
21415 out=$(do_facet $tgt $LR_READER -c $dev)
21416 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21418 num=$(echo "$out" | grep -c "mdtlov")
21419 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
21420 error "Invalid number of mdtlov clients returned by $LR_READER"
21421 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
21423 # check lr_reader -cr on MDT0000
21424 out=$(do_facet $tgt $LR_READER -cr $dev)
21425 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21427 echo "$out" | grep -q "^reply_data:$" ||
21428 error "$LR_READER should have returned 'reply_data' section"
21429 num=$(echo "$out" | grep -c "client_generation")
21430 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
21432 run_test 252 "check lr_reader tool"
21435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21436 remote_mds_nodsh && skip "remote MDS with nodsh"
21437 remote_mgs_nodsh && skip "remote MGS with nodsh"
21441 local ost_name=$(ostname_from_index $ostidx)
21444 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
21445 do_facet $SINGLEMDS $LCTL get_param -n \
21446 osp.$mdtosc_proc1.reserved_mb_high ||
21447 skip "remote MDS does not support reserved_mb_high"
21451 wait_delete_completed
21454 pool_add $TESTNAME || error "Pool creation failed"
21455 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
21457 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
21458 error "Setstripe failed"
21460 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
21462 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
21464 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
21466 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21467 osp.$mdtosc_proc1.prealloc_status)
21468 echo "prealloc_status $oa_status"
21470 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
21471 error "File creation should fail"
21473 #object allocation was stopped, but we still able to append files
21474 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
21475 oflag=append || error "Append failed"
21477 rm -f $DIR/$tdir/$tfile.0
21479 # For this test, we want to delete the files we created to go out of
21480 # space but leave the watermark, so we remain nearly out of space
21481 ost_watermarks_enospc_delete_files $tfile $ostidx
21483 wait_delete_completed
21487 for i in $(seq 10 12); do
21488 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
21489 2>/dev/null || error "File creation failed after rm"
21492 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21493 osp.$mdtosc_proc1.prealloc_status)
21494 echo "prealloc_status $oa_status"
21496 if (( oa_status != 0 )); then
21497 error "Object allocation still disable after rm"
21500 run_test 253 "Check object allocation limit"
21503 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21504 remote_mds_nodsh && skip "remote MDS with nodsh"
21506 local mdt=$(facet_svc $SINGLEMDS)
21508 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
21509 skip "MDS does not support changelog_size"
21513 changelog_register || error "changelog_register failed"
21515 changelog_clear 0 || error "changelog_clear failed"
21517 local size1=$(do_facet $SINGLEMDS \
21518 $LCTL get_param -n mdd.$mdt.changelog_size)
21519 echo "Changelog size $size1"
21522 $LFS mkdir -i 0 $DIR/$tdir
21524 mkdir -p $DIR/$tdir/pics/2008/zachy
21525 touch $DIR/$tdir/pics/2008/zachy/timestamp
21526 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
21527 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
21528 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
21529 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
21530 rm $DIR/$tdir/pics/desktop.jpg
21532 local size2=$(do_facet $SINGLEMDS \
21533 $LCTL get_param -n mdd.$mdt.changelog_size)
21534 echo "Changelog size after work $size2"
21536 (( $size2 > $size1 )) ||
21537 error "new Changelog size=$size2 less than old size=$size1"
21539 run_test 254 "Check changelog size"
21546 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
21547 awk -F: '{print $2}' | grep $type > /dev/null
21548 if [ $? -ne 0 ]; then
21558 lfs ladvise -a willread $file > /dev/null 2>&1
21559 if [ $? -eq 0 ]; then
21563 lfs ladvise -a willread $file 2>&1 |
21564 grep "Inappropriate ioctl for device" > /dev/null
21565 if [ $? -eq 0 ]; then
21572 bc <<<"scale=2; ($1 - $2) * 100 / $2"
21575 # run a random read IO workload
21576 # usage: random_read_iops <filename> <filesize> <iosize>
21577 random_read_iops() {
21580 local iosize=${3:-4096}
21582 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
21583 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
21586 drop_file_oss_cache() {
21590 $LFS ladvise -a dontneed $file 2>/dev/null ||
21591 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
21594 ladvise_willread_performance()
21597 local average_origin=0
21598 local average_cache=0
21599 local average_ladvise=0
21601 for ((i = 1; i <= $repeat; i++)); do
21602 echo "Iter $i/$repeat: reading without willread hint"
21603 cancel_lru_locks osc
21604 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
21605 local speed_origin=$(random_read_iops $DIR/$tfile $size)
21606 echo "Iter $i/$repeat: uncached speed: $speed_origin"
21607 average_origin=$(bc <<<"$average_origin + $speed_origin")
21609 cancel_lru_locks osc
21610 local speed_cache=$(random_read_iops $DIR/$tfile $size)
21611 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
21612 average_cache=$(bc <<<"$average_cache + $speed_cache")
21614 cancel_lru_locks osc
21615 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
21616 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
21617 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
21618 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
21619 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
21621 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
21622 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
21623 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
21625 speedup_cache=$(percent $average_cache $average_origin)
21626 speedup_ladvise=$(percent $average_ladvise $average_origin)
21628 echo "Average uncached read: $average_origin"
21629 echo "Average speedup with OSS cached read: " \
21630 "$average_cache = +$speedup_cache%"
21631 echo "Average speedup with ladvise willread: " \
21632 "$average_ladvise = +$speedup_ladvise%"
21634 local lowest_speedup=20
21635 if (( ${average_cache%.*} < $lowest_speedup )); then
21636 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
21637 " got $average_cache%. Skipping ladvise willread check."
21641 # the test won't work on ZFS until it supports 'ladvise dontneed', but
21642 # it is still good to run until then to exercise 'ladvise willread'
21643 ! $LFS ladvise -a dontneed $DIR/$tfile &&
21644 [ "$ost1_FSTYPE" = "zfs" ] &&
21645 echo "osd-zfs does not support dontneed or drop_caches" &&
21648 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
21649 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
21650 error_not_in_vm "Speedup with willread is less than " \
21651 "$lowest_speedup%, got $average_ladvise%"
21655 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
21656 skip "lustre < 2.8.54 does not support ladvise "
21657 remote_ost_nodsh && skip "remote OST with nodsh"
21659 stack_trap "rm -f $DIR/$tfile"
21660 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
21662 ladvise_no_type willread $DIR/$tfile &&
21663 skip "willread ladvise is not supported"
21665 ladvise_no_ioctl $DIR/$tfile &&
21666 skip "ladvise ioctl is not supported"
21669 local size=$((size_mb * 1048576))
21670 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
21671 error "dd to $DIR/$tfile failed"
21673 lfs ladvise -a willread $DIR/$tfile ||
21674 error "Ladvise failed with no range argument"
21676 lfs ladvise -a willread -s 0 $DIR/$tfile ||
21677 error "Ladvise failed with no -l or -e argument"
21679 lfs ladvise -a willread -e 1 $DIR/$tfile ||
21680 error "Ladvise failed with only -e argument"
21682 lfs ladvise -a willread -l 1 $DIR/$tfile ||
21683 error "Ladvise failed with only -l argument"
21685 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
21686 error "End offset should not be smaller than start offset"
21688 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
21689 error "End offset should not be equal to start offset"
21691 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
21692 error "Ladvise failed with overflowing -s argument"
21694 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
21695 error "Ladvise failed with overflowing -e argument"
21697 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
21698 error "Ladvise failed with overflowing -l argument"
21700 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
21701 error "Ladvise succeeded with conflicting -l and -e arguments"
21703 echo "Synchronous ladvise should wait"
21705 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
21706 do_nodes $(comma_list $(osts_nodes)) \
21707 $LCTL set_param fail_val=$delay fail_loc=0x237
21709 local start_ts=$SECONDS
21710 lfs ladvise -a willread $DIR/$tfile ||
21711 error "Ladvise failed with no range argument"
21712 local end_ts=$SECONDS
21713 local inteval_ts=$((end_ts - start_ts))
21715 if [ $inteval_ts -lt $(($delay - 1)) ]; then
21716 error "Synchronous advice didn't wait reply"
21719 echo "Asynchronous ladvise shouldn't wait"
21720 local start_ts=$SECONDS
21721 lfs ladvise -a willread -b $DIR/$tfile ||
21722 error "Ladvise failed with no range argument"
21723 local end_ts=$SECONDS
21724 local inteval_ts=$((end_ts - start_ts))
21726 if [ $inteval_ts -gt $(($delay / 2)) ]; then
21727 error "Asynchronous advice blocked"
21730 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
21731 ladvise_willread_performance
21733 run_test 255a "check 'lfs ladvise -a willread'"
21739 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
21743 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
21744 skip "lustre < 2.8.54 does not support ladvise "
21745 remote_ost_nodsh && skip "remote OST with nodsh"
21747 stack_trap "rm -f $DIR/$tfile"
21748 lfs setstripe -c 1 -i 0 $DIR/$tfile
21750 ladvise_no_type dontneed $DIR/$tfile &&
21751 skip "dontneed ladvise is not supported"
21753 ladvise_no_ioctl $DIR/$tfile &&
21754 skip "ladvise ioctl is not supported"
21756 ! $LFS ladvise -a dontneed $DIR/$tfile &&
21757 [ "$ost1_FSTYPE" = "zfs" ] &&
21758 skip "zfs-osd does not support 'ladvise dontneed'"
21761 local size=$((size_mb * 1048576))
21762 # In order to prevent disturbance of other processes, only check 3/4
21763 # of the memory usage
21764 local kibibytes=$((size_mb * 1024 * 3 / 4))
21766 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
21767 error "dd to $DIR/$tfile failed"
21769 #force write to complete before dropping OST cache & checking memory
21772 local total=$(facet_meminfo ost1 MemTotal)
21773 echo "Total memory: $total KiB"
21775 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
21776 local before_read=$(facet_meminfo ost1 Cached)
21777 echo "Cache used before read: $before_read KiB"
21779 lfs ladvise -a willread $DIR/$tfile ||
21780 error "Ladvise willread failed"
21781 local after_read=$(facet_meminfo ost1 Cached)
21782 echo "Cache used after read: $after_read KiB"
21784 lfs ladvise -a dontneed $DIR/$tfile ||
21785 error "Ladvise dontneed again failed"
21786 local no_read=$(facet_meminfo ost1 Cached)
21787 echo "Cache used after dontneed ladvise: $no_read KiB"
21789 if [ $total -lt $((before_read + kibibytes)) ]; then
21790 echo "Memory is too small, abort checking"
21794 if [ $((before_read + kibibytes)) -gt $after_read ]; then
21795 error "Ladvise willread should use more memory" \
21796 "than $kibibytes KiB"
21799 if [ $((no_read + kibibytes)) -gt $after_read ]; then
21800 error "Ladvise dontneed should release more memory" \
21801 "than $kibibytes KiB"
21804 run_test 255b "check 'lfs ladvise -a dontneed'"
21807 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
21808 skip "lustre < 2.10.50 does not support lockahead"
21810 local ost1_imp=$(get_osc_import_name client ost1)
21811 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
21819 test_mkdir -p $DIR/$tdir
21820 $LFS setstripe -i 0 -c 1 $DIR/$tdir
21822 #test 10 returns only success/failure
21824 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21826 if [ $rc -eq 255 ]; then
21827 error "Ladvise test${i} failed, ${rc}"
21830 #test 11 counts lock enqueue requests, all others count new locks
21832 count=$(do_facet ost1 \
21833 $LCTL get_param -n ost.OSS.ost.stats)
21834 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
21836 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21838 if [ $rc -eq 255 ]; then
21839 error "Ladvise test${i} failed, ${rc}"
21842 new_count=$(do_facet ost1 \
21843 $LCTL get_param -n ost.OSS.ost.stats)
21844 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
21845 awk '{ print $2 }')
21847 difference="$((new_count - count))"
21848 if [ $difference -ne $rc ]; then
21849 error "Ladvise test${i}, bad enqueue count, returned " \
21850 "${rc}, actual ${difference}"
21853 for i in $(seq 12 21); do
21854 # If we do not do this, we run the risk of having too many
21855 # locks and starting lock cancellation while we are checking
21857 cancel_lru_locks osc
21859 count=$($LCTL get_param -n \
21860 ldlm.namespaces.$imp_name.lock_unused_count)
21862 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21864 if [ $rc -eq 255 ]; then
21865 error "Ladvise test ${i} failed, ${rc}"
21868 new_count=$($LCTL get_param -n \
21869 ldlm.namespaces.$imp_name.lock_unused_count)
21870 difference="$((new_count - count))"
21872 # Test 15 output is divided by 100 to map down to valid return
21873 if [ $i -eq 15 ]; then
21877 if [ $difference -ne $rc ]; then
21878 error "Ladvise test ${i}, bad lock count, returned " \
21879 "${rc}, actual ${difference}"
21883 #test 22 returns only success/failure
21885 lockahead_test -d $DIR/$tdir -t $i -f $tfile
21887 if [ $rc -eq 255 ]; then
21888 error "Ladvise test${i} failed, ${rc}"
21891 run_test 255c "suite of ladvise lockahead tests"
21894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21895 remote_mds_nodsh && skip "remote MDS with nodsh"
21896 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
21897 changelog_users $SINGLEMDS | grep "^cl" &&
21898 skip "active changelog user"
21904 mdt_dev=$(facet_device $SINGLEMDS)
21907 changelog_register || error "changelog_register failed"
21910 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
21912 changelog_clear 0 || error "changelog_clear failed"
21915 touch $DIR/$tdir/{1..10}
21918 stop $SINGLEMDS || error "Fail to stop MDT"
21921 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
21922 error "Fail to start MDT"
21924 #after mount new plainllog is used
21925 touch $DIR/$tdir/{11..19}
21926 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
21927 stack_trap "rm -f $tmpfile"
21928 cat_sl=$(do_facet $SINGLEMDS "sync; \
21929 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
21930 llog_reader $tmpfile | grep -c type=1064553b")
21931 do_facet $SINGLEMDS llog_reader $tmpfile
21933 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
21935 changelog_clear 0 || error "changelog_clear failed"
21937 cat_sl=$(do_facet $SINGLEMDS "sync; \
21938 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
21939 llog_reader $tmpfile | grep -c type=1064553b")
21941 if (( cat_sl == 2 )); then
21942 error "Empty plain llog was not deleted from changelog catalog"
21943 elif (( cat_sl != 1 )); then
21944 error "Active plain llog shouldn't be deleted from catalog"
21947 run_test 256 "Check llog delete for empty and not full state"
21950 remote_mds_nodsh && skip "remote MDS with nodsh"
21951 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
21952 skip "Need MDS version at least 2.8.55"
21954 test_mkdir $DIR/$tdir
21956 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
21957 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
21960 #define OBD_FAIL_MDS_XATTR_REP 0x161
21961 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
21962 local facet=mds$((mdtidx + 1))
21963 set_nodes_failloc $(facet_active_host $facet) 0x80000161
21964 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
21966 stop $facet || error "stop MDS failed"
21967 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
21968 error "start MDS fail"
21969 wait_recovery_complete $facet
21971 run_test 257 "xattr locks are not lost"
21973 # Verify we take the i_mutex when security requires it
21975 #define OBD_FAIL_IMUTEX_SEC 0x141c
21976 $LCTL set_param fail_loc=0x141c
21978 chmod u+s $DIR/$tfile
21979 chmod a+rwx $DIR/$tfile
21980 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
21982 if [ $RC -ne 0 ]; then
21983 error "error, failed to take i_mutex, rc=$?"
21987 run_test 258a "verify i_mutex security behavior when suid attributes is set"
21989 # Verify we do NOT take the i_mutex in the normal case
21991 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
21992 $LCTL set_param fail_loc=0x141d
21995 chmod a+rw $DIR/$tfile
21996 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
21998 if [ $RC -ne 0 ]; then
21999 error "error, took i_mutex unnecessarily, rc=$?"
22004 run_test 258b "verify i_mutex security behavior"
22007 local file=$DIR/$tfile
22011 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22013 stack_trap "rm -f $file" EXIT
22015 wait_delete_completed
22016 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22017 echo "before: $before"
22019 $LFS setstripe -i 0 -c 1 $file
22020 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
22022 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22023 echo "after write: $after"
22025 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
22026 do_facet ost1 $LCTL set_param fail_loc=0x2301
22028 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22029 echo "after truncate: $after"
22032 do_facet ost1 $LCTL set_param fail_loc=0
22033 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22035 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22036 echo "after restart: $after"
22037 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
22038 error "missing truncate?"
22042 run_test 259 "crash at delayed truncate"
22045 #define OBD_FAIL_MDC_CLOSE 0x806
22046 $LCTL set_param fail_loc=0x80000806
22050 run_test 260 "Check mdc_close fail"
22052 ### Data-on-MDT sanity tests ###
22054 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22055 skip "Need MDS version at least 2.10.55 for DoM"
22058 local dom=$DIR/$tdir/dom_file
22059 local tmp=$DIR/$tdir/tmp_file
22061 mkdir_on_mdt0 $DIR/$tdir
22063 # basic checks for DoM component creation
22064 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
22065 error "Can set MDT layout to non-first entry"
22067 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
22068 error "Can define multiple entries as MDT layout"
22070 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
22072 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
22073 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
22074 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
22076 local mdtidx=$($LFS getstripe -m $dom)
22077 local mdtname=MDT$(printf %04x $mdtidx)
22078 local facet=mds$((mdtidx + 1))
22079 local space_check=1
22081 # Skip free space checks with ZFS
22082 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
22086 local size_tmp=$((65536 * 3))
22087 local mdtfree1=$(do_facet $facet \
22088 lctl get_param -n osd*.*$mdtname.kbytesfree)
22090 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22091 # check also direct IO along write
22092 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
22093 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22095 cmp $tmp $dom || error "file data is different"
22096 [ $(stat -c%s $dom) == $size_tmp ] ||
22097 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22098 if [ $space_check == 1 ]; then
22099 local mdtfree2=$(do_facet $facet \
22100 lctl get_param -n osd*.*$mdtname.kbytesfree)
22102 # increase in usage from by $size_tmp
22103 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22104 error "MDT free space wrong after write: " \
22105 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22109 local size_dom=10000
22111 $TRUNCATE $dom $size_dom
22112 [ $(stat -c%s $dom) == $size_dom ] ||
22113 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
22114 if [ $space_check == 1 ]; then
22115 mdtfree1=$(do_facet $facet \
22116 lctl get_param -n osd*.*$mdtname.kbytesfree)
22117 # decrease in usage from $size_tmp to new $size_dom
22118 [ $(($mdtfree1 - $mdtfree2)) -ge \
22119 $(((size_tmp - size_dom) / 1024)) ] ||
22120 error "MDT free space is wrong after truncate: " \
22121 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
22127 size_dom=$((size_dom + size_tmp))
22128 [ $(stat -c%s $dom) == $size_dom ] ||
22129 error "bad size after append: $(stat -c%s $dom) != $size_dom"
22130 if [ $space_check == 1 ]; then
22131 mdtfree2=$(do_facet $facet \
22132 lctl get_param -n osd*.*$mdtname.kbytesfree)
22133 # increase in usage by $size_tmp from previous
22134 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22135 error "MDT free space is wrong after append: " \
22136 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22141 if [ $space_check == 1 ]; then
22142 mdtfree1=$(do_facet $facet \
22143 lctl get_param -n osd*.*$mdtname.kbytesfree)
22144 # decrease in usage by $size_dom from previous
22145 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
22146 error "MDT free space is wrong after removal: " \
22147 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
22150 # combined striping
22151 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
22152 error "Can't create DoM + OST striping"
22154 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
22155 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22156 # check also direct IO along write
22157 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22159 cmp $tmp $dom || error "file data is different"
22160 [ $(stat -c%s $dom) == $size_tmp ] ||
22161 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22166 run_test 270a "DoM: basic functionality tests"
22169 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22170 skip "Need MDS version at least 2.10.55"
22172 local dom=$DIR/$tdir/dom_file
22173 local max_size=1048576
22175 mkdir -p $DIR/$tdir
22176 $LFS setstripe -E $max_size -L mdt $dom
22178 # truncate over the limit
22179 $TRUNCATE $dom $(($max_size + 1)) &&
22180 error "successful truncate over the maximum size"
22181 # write over the limit
22182 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
22183 error "successful write over the maximum size"
22184 # append over the limit
22185 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
22186 echo "12345" >> $dom && error "successful append over the maximum size"
22191 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
22194 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22195 skip "Need MDS version at least 2.10.55"
22197 mkdir -p $DIR/$tdir
22198 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22200 # check files inherit DoM EA
22201 touch $DIR/$tdir/first
22202 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
22203 error "bad pattern"
22204 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
22205 error "bad stripe count"
22206 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
22207 error "bad stripe size"
22209 # check directory inherits DoM EA and uses it as default
22210 mkdir $DIR/$tdir/subdir
22211 touch $DIR/$tdir/subdir/second
22212 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
22213 error "bad pattern in sub-directory"
22214 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
22215 error "bad stripe count in sub-directory"
22216 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
22217 error "bad stripe size in sub-directory"
22220 run_test 270c "DoM: DoM EA inheritance tests"
22223 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22224 skip "Need MDS version at least 2.10.55"
22226 mkdir -p $DIR/$tdir
22227 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22229 # inherit default DoM striping
22230 mkdir $DIR/$tdir/subdir
22231 touch $DIR/$tdir/subdir/f1
22233 # change default directory striping
22234 $LFS setstripe -c 1 $DIR/$tdir/subdir
22235 touch $DIR/$tdir/subdir/f2
22236 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
22237 error "wrong default striping in file 2"
22238 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
22239 error "bad pattern in file 2"
22242 run_test 270d "DoM: change striping from DoM to RAID0"
22245 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22246 skip "Need MDS version at least 2.10.55"
22248 mkdir -p $DIR/$tdir/dom
22249 mkdir -p $DIR/$tdir/norm
22252 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
22253 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
22255 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
22256 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
22258 # find DoM files by layout
22259 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
22260 [ $NUM -eq $DOMFILES ] ||
22261 error "lfs find -L: found $NUM, expected $DOMFILES"
22262 echo "Test 1: lfs find 20 DOM files by layout: OK"
22264 # there should be 1 dir with default DOM striping
22265 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
22267 error "lfs find -L: found $NUM, expected 1 dir"
22268 echo "Test 2: lfs find 1 DOM dir by layout: OK"
22270 # find DoM files by stripe size
22271 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
22272 [ $NUM -eq $DOMFILES ] ||
22273 error "lfs find -S: found $NUM, expected $DOMFILES"
22274 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
22276 # find files by stripe offset except DoM files
22277 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
22278 [ $NUM -eq $NORMFILES ] ||
22279 error "lfs find -i: found $NUM, expected $NORMFILES"
22280 echo "Test 5: lfs find no DOM files by stripe index: OK"
22283 run_test 270e "DoM: lfs find with DoM files test"
22286 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22287 skip "Need MDS version at least 2.10.55"
22289 local mdtname=${FSNAME}-MDT0000-mdtlov
22290 local dom=$DIR/$tdir/dom_file
22291 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
22292 lod.$mdtname.dom_stripesize)
22293 local dom_limit=131072
22295 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
22296 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22297 lod.$mdtname.dom_stripesize)
22298 [ ${dom_limit} -eq ${dom_current} ] ||
22299 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
22301 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22302 $LFS setstripe -d $DIR/$tdir
22303 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
22304 error "Can't set directory default striping"
22306 # exceed maximum stripe size
22307 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22308 error "Can't create file with $((dom_limit * 2)) DoM stripe"
22309 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
22310 error "Able to create DoM component size more than LOD limit"
22312 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22313 dom_current=$(do_facet mds1 $LCTL get_param -n \
22314 lod.$mdtname.dom_stripesize)
22315 [ 0 -eq ${dom_current} ] ||
22316 error "Can't set zero DoM stripe limit"
22319 # attempt to create DoM file on server with disabled DoM should
22320 # remove DoM entry from layout and be succeed
22321 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
22322 error "Can't create DoM file (DoM is disabled)"
22323 [ $($LFS getstripe -L $dom) == "mdt" ] &&
22324 error "File has DoM component while DoM is disabled"
22327 # attempt to create DoM file with only DoM stripe should return error
22328 $LFS setstripe -E $dom_limit -L mdt $dom &&
22329 error "Able to create DoM-only file while DoM is disabled"
22331 # too low values to be aligned with smallest stripe size 64K
22332 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
22333 dom_current=$(do_facet mds1 $LCTL get_param -n \
22334 lod.$mdtname.dom_stripesize)
22335 [ 30000 -eq ${dom_current} ] &&
22336 error "Can set too small DoM stripe limit"
22338 # 64K is a minimal stripe size in Lustre, expect limit of that size
22339 [ 65536 -eq ${dom_current} ] ||
22340 error "Limit is not set to 64K but ${dom_current}"
22342 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
22343 dom_current=$(do_facet mds1 $LCTL get_param -n \
22344 lod.$mdtname.dom_stripesize)
22346 [ 2147483648 -eq ${dom_current} ] &&
22347 error "Can set too large DoM stripe limit"
22349 do_facet mds1 $LCTL set_param -n \
22350 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
22351 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22352 error "Can't create DoM component size after limit change"
22353 do_facet mds1 $LCTL set_param -n \
22354 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
22355 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
22356 error "Can't create DoM file after limit decrease"
22357 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
22358 error "Can create big DoM component after limit decrease"
22359 touch ${dom}_def ||
22360 error "Can't create file with old default layout"
22362 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
22365 run_test 270f "DoM: maximum DoM stripe size checks"
22368 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
22369 skip "Need MDS version at least 2.13.52"
22370 local dom=$DIR/$tdir/$tfile
22372 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22373 local lodname=${FSNAME}-MDT0000-mdtlov
22375 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22376 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
22377 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
22378 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22380 local dom_limit=1024
22381 local dom_threshold="50%"
22383 $LFS setstripe -d $DIR/$tdir
22384 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
22385 error "Can't set directory default striping"
22387 do_facet mds1 $LCTL set_param -n \
22388 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
22389 # set 0 threshold and create DOM file to change tunable stripesize
22390 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
22391 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22392 error "Failed to create $dom file"
22393 # now tunable dom_cur_stripesize should reach maximum
22394 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22395 lod.${lodname}.dom_stripesize_cur_kb)
22396 [[ $dom_current == $dom_limit ]] ||
22397 error "Current DOM stripesize is not maximum"
22400 # set threshold for further tests
22401 do_facet mds1 $LCTL set_param -n \
22402 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
22403 echo "DOM threshold is $dom_threshold free space"
22406 # Spoof bfree to exceed threshold
22407 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
22408 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
22409 for spfree in 40 20 0 15 30 55; do
22410 do_facet mds1 $LCTL set_param -n fail_val=$spfree
22411 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22412 error "Failed to create $dom file"
22413 dom_def=$(do_facet mds1 $LCTL get_param -n \
22414 lod.${lodname}.dom_stripesize_cur_kb)
22415 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
22416 [[ $dom_def != $dom_current ]] ||
22417 error "Default stripe size was not changed"
22418 if (( spfree > 0 )) ; then
22419 dom_set=$($LFS getstripe -S $dom)
22420 (( dom_set == dom_def * 1024 )) ||
22421 error "DOM component size is still old"
22423 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22424 error "DoM component is set with no free space"
22427 dom_current=$dom_def
22430 run_test 270g "DoM: default DoM stripe size depends on free space"
22433 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
22434 skip "Need MDS version at least 2.13.53"
22436 local mdtname=${FSNAME}-MDT0000-mdtlov
22437 local dom=$DIR/$tdir/$tfile
22438 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22440 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
22441 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22443 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22444 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
22445 error "can't create OST file"
22446 # mirrored file with DOM entry in the second mirror
22447 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
22448 error "can't create mirror with DoM component"
22450 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22452 # DOM component in the middle and has other enries in the same mirror,
22453 # should succeed but lost DoM component
22454 $LFS setstripe --copy=${dom}_1 $dom ||
22455 error "Can't create file from OST|DOM mirror layout"
22456 # check new file has no DoM layout after all
22457 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22458 error "File has DoM component while DoM is disabled"
22460 run_test 270h "DoM: DoM stripe removal when disabled on server"
22463 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
22464 skip "Need MDS version at least 2.14.54"
22467 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
22468 error "setstripe should fail" || true
22470 run_test 270i "DoM: setting invalid DoM striping should fail"
22473 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22474 skip "Need MDS version at least 2.10.55"
22476 local dom=$DIR/$tdir/dom
22478 mkdir -p $DIR/$tdir
22480 $LFS setstripe -E 1024K -L mdt $dom
22482 lctl set_param -n mdc.*.stats=clear
22483 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
22484 cat $dom > /dev/null
22485 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
22486 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
22490 run_test 271a "DoM: data is cached for read after write"
22493 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22494 skip "Need MDS version at least 2.10.55"
22496 local dom=$DIR/$tdir/dom
22498 mkdir -p $DIR/$tdir
22500 $LFS setstripe -E 1024K -L mdt -E EOF $dom
22502 lctl set_param -n mdc.*.stats=clear
22503 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
22504 cancel_lru_locks mdc
22505 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
22506 # second stat to check size is cached on client
22507 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
22508 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
22509 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
22512 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
22515 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22516 skip "Need MDS version at least 2.10.55"
22518 local dom=$DIR/$tdir/dom
22520 mkdir -p $DIR/$tdir
22522 $LFS setstripe -E 1024K -L mdt -E EOF $dom
22524 lctl set_param -n mdc.*.stats=clear
22525 lctl set_param -n osc.*.stats=clear
22526 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
22527 cancel_lru_locks mdc
22528 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
22529 # second stat to check size is cached on client
22530 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
22531 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
22532 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
22533 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
22534 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
22537 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
22543 local mdt=MDT$(printf %04x $mdtidx)
22545 if [ -z $param ]; then
22546 lctl get_param -n mdc.*$mdt*.stats
22548 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
22553 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22554 skip "Need MDS version at least 2.10.55"
22556 local dom=$DIR/$tdir/dom
22558 mkdir -p $DIR/$tdir
22560 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22562 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22563 local facet=mds$((mdtidx + 1))
22565 cancel_lru_locks mdc
22566 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
22567 createmany -o $dom 1000
22568 lctl set_param -n mdc.*.stats=clear
22569 smalliomany -w $dom 1000 200
22570 get_mdc_stats $mdtidx
22571 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
22572 # Each file has 1 open, 1 IO enqueues, total 2000
22573 # but now we have also +1 getxattr for security.capability, total 3000
22574 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
22575 unlinkmany $dom 1000
22577 cancel_lru_locks mdc
22578 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
22579 createmany -o $dom 1000
22580 lctl set_param -n mdc.*.stats=clear
22581 smalliomany -w $dom 1000 200
22582 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
22583 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
22584 # for OPEN and IO lock.
22585 [ $((enq - enq_2)) -ge 1000 ] ||
22586 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
22587 unlinkmany $dom 1000
22590 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
22592 cleanup_271def_tests() {
22598 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
22599 skip "Need MDS version at least 2.10.57"
22601 local dom=$DIR/$tdir/dom
22602 local tmp=$TMP/$tfile
22603 trap "cleanup_271def_tests $tmp" EXIT
22605 mkdir -p $DIR/$tdir
22607 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22609 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
22611 cancel_lru_locks mdc
22612 dd if=/dev/urandom of=$tmp bs=1000 count=1
22613 dd if=$tmp of=$dom bs=1000 count=1
22614 cancel_lru_locks mdc
22616 cat /etc/hosts >> $tmp
22617 lctl set_param -n mdc.*.stats=clear
22619 # append data to the same file it should update local page
22620 echo "Append to the same page"
22621 cat /etc/hosts >> $dom
22622 local num=$(get_mdc_stats $mdtidx ost_read)
22623 local ra=$(get_mdc_stats $mdtidx req_active)
22624 local rw=$(get_mdc_stats $mdtidx req_waittime)
22626 [ -z $num ] || error "$num READ RPC occured"
22627 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22631 cmp $tmp $dom || error "file miscompare"
22633 cancel_lru_locks mdc
22634 lctl set_param -n mdc.*.stats=clear
22636 echo "Open and read file"
22637 cat $dom > /dev/null
22638 local num=$(get_mdc_stats $mdtidx ost_read)
22639 local ra=$(get_mdc_stats $mdtidx req_active)
22640 local rw=$(get_mdc_stats $mdtidx req_waittime)
22642 [ -z $num ] || error "$num READ RPC occured"
22643 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22647 cmp $tmp $dom || error "file miscompare"
22651 run_test 271d "DoM: read on open (1K file in reply buffer)"
22654 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
22655 skip "Need MDS version at least 2.10.57"
22657 local dom=$DIR/$tdir/dom
22658 local tmp=$TMP/$tfile
22659 trap "cleanup_271def_tests $tmp" EXIT
22661 mkdir -p $DIR/$tdir
22663 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22665 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
22667 cancel_lru_locks mdc
22668 dd if=/dev/urandom of=$tmp bs=265000 count=1
22669 dd if=$tmp of=$dom bs=265000 count=1
22670 cancel_lru_locks mdc
22671 cat /etc/hosts >> $tmp
22672 lctl set_param -n mdc.*.stats=clear
22674 echo "Append to the same page"
22675 cat /etc/hosts >> $dom
22676 local num=$(get_mdc_stats $mdtidx ost_read)
22677 local ra=$(get_mdc_stats $mdtidx req_active)
22678 local rw=$(get_mdc_stats $mdtidx req_waittime)
22680 [ -z $num ] || error "$num READ RPC occured"
22681 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22685 cmp $tmp $dom || error "file miscompare"
22687 cancel_lru_locks mdc
22688 lctl set_param -n mdc.*.stats=clear
22690 echo "Open and read file"
22691 cat $dom > /dev/null
22692 local num=$(get_mdc_stats $mdtidx ost_read)
22693 local ra=$(get_mdc_stats $mdtidx req_active)
22694 local rw=$(get_mdc_stats $mdtidx req_waittime)
22696 [ -z $num ] && num=0
22697 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
22698 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22702 cmp $tmp $dom || error "file miscompare"
22706 run_test 271f "DoM: read on open (200K file and read tail)"
22709 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
22710 skip "Skipping due to old client or server version"
22712 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
22714 $CHECKSTAT -t file $DIR1/$tfile
22716 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
22719 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
22720 $LCTL set_param fail_loc=0x80000314
22721 rm $DIR1/$tfile || error "Unlink fails"
22723 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
22724 [ $RC -eq 0 ] || error "Failed write to stale object"
22726 run_test 271g "Discard DoM data vs client flush race"
22729 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22730 skip "Need MDS version at least 2.11.50"
22732 local dom=$DIR/$tdir/dom
22733 mkdir -p $DIR/$tdir
22735 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
22736 dd if=/dev/urandom of=$dom bs=512K count=1 ||
22737 error "failed to write data into $dom"
22738 local old_md5=$(md5sum $dom)
22740 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
22741 error "failed to migrate to the same DoM component"
22743 local new_md5=$(md5sum $dom)
22745 [ "$old_md5" == "$new_md5" ] ||
22746 error "md5sum differ: $old_md5, $new_md5"
22748 [ $($LFS getstripe -c $dom) -eq 2 ] ||
22749 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
22751 run_test 272a "DoM migration: new layout with the same DOM component"
22754 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22755 skip "Need MDS version at least 2.11.50"
22757 local dom=$DIR/$tdir/dom
22758 mkdir -p $DIR/$tdir
22759 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22761 local mdtidx=$($LFS getstripe -m $dom)
22762 local mdtname=MDT$(printf %04x $mdtidx)
22763 local facet=mds$((mdtidx + 1))
22765 local mdtfree1=$(do_facet $facet \
22766 lctl get_param -n osd*.*$mdtname.kbytesfree)
22767 dd if=/dev/urandom of=$dom bs=2M count=1 ||
22768 error "failed to write data into $dom"
22769 local old_md5=$(md5sum $dom)
22770 cancel_lru_locks mdc
22771 local mdtfree1=$(do_facet $facet \
22772 lctl get_param -n osd*.*$mdtname.kbytesfree)
22774 $LFS migrate -c2 $dom ||
22775 error "failed to migrate to the new composite layout"
22776 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22777 error "MDT stripe was not removed"
22779 cancel_lru_locks mdc
22780 local new_md5=$(md5sum $dom)
22781 [ "$old_md5" == "$new_md5" ] ||
22782 error "$old_md5 != $new_md5"
22784 # Skip free space checks with ZFS
22785 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22786 local mdtfree2=$(do_facet $facet \
22787 lctl get_param -n osd*.*$mdtname.kbytesfree)
22788 [ $mdtfree2 -gt $mdtfree1 ] ||
22789 error "MDT space is not freed after migration"
22793 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
22796 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22797 skip "Need MDS version at least 2.11.50"
22799 local dom=$DIR/$tdir/$tfile
22800 mkdir -p $DIR/$tdir
22801 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22803 local mdtidx=$($LFS getstripe -m $dom)
22804 local mdtname=MDT$(printf %04x $mdtidx)
22805 local facet=mds$((mdtidx + 1))
22807 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22808 error "failed to write data into $dom"
22809 local old_md5=$(md5sum $dom)
22810 cancel_lru_locks mdc
22811 local mdtfree1=$(do_facet $facet \
22812 lctl get_param -n osd*.*$mdtname.kbytesfree)
22814 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
22815 error "failed to migrate to the new composite layout"
22816 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
22817 error "MDT stripe was not removed"
22819 cancel_lru_locks mdc
22820 local new_md5=$(md5sum $dom)
22821 [ "$old_md5" == "$new_md5" ] ||
22822 error "$old_md5 != $new_md5"
22824 # Skip free space checks with ZFS
22825 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22826 local mdtfree2=$(do_facet $facet \
22827 lctl get_param -n osd*.*$mdtname.kbytesfree)
22828 [ $mdtfree2 -gt $mdtfree1 ] ||
22829 error "MDS space is not freed after migration"
22833 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
22836 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22837 skip "Need MDS version at least 2.12.55"
22839 local dom=$DIR/$tdir/$tfile
22840 mkdir -p $DIR/$tdir
22841 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22843 local mdtidx=$($LFS getstripe -m $dom)
22844 local mdtname=MDT$(printf %04x $mdtidx)
22845 local facet=mds$((mdtidx + 1))
22847 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22848 error "failed to write data into $dom"
22849 local old_md5=$(md5sum $dom)
22850 cancel_lru_locks mdc
22851 local mdtfree1=$(do_facet $facet \
22852 lctl get_param -n osd*.*$mdtname.kbytesfree)
22854 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
22855 error "failed mirroring to the new composite layout"
22856 $LFS mirror resync $dom ||
22857 error "failed mirror resync"
22858 $LFS mirror split --mirror-id 1 -d $dom ||
22859 error "failed mirror split"
22861 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22862 error "MDT stripe was not removed"
22864 cancel_lru_locks mdc
22865 local new_md5=$(md5sum $dom)
22866 [ "$old_md5" == "$new_md5" ] ||
22867 error "$old_md5 != $new_md5"
22869 # Skip free space checks with ZFS
22870 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22871 local mdtfree2=$(do_facet $facet \
22872 lctl get_param -n osd*.*$mdtname.kbytesfree)
22873 [ $mdtfree2 -gt $mdtfree1 ] ||
22874 error "MDS space is not freed after DOM mirror deletion"
22878 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
22881 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22882 skip "Need MDS version at least 2.12.55"
22884 local dom=$DIR/$tdir/$tfile
22885 mkdir -p $DIR/$tdir
22886 $LFS setstripe -c 2 $dom
22888 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22889 error "failed to write data into $dom"
22890 local old_md5=$(md5sum $dom)
22893 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
22894 error "failed mirroring to the DOM layout"
22895 $LFS mirror resync $dom ||
22896 error "failed mirror resync"
22897 $LFS mirror split --mirror-id 1 -d $dom ||
22898 error "failed mirror split"
22900 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
22901 error "MDT stripe wasn't set"
22904 local new_md5=$(md5sum $dom)
22905 [ "$old_md5" == "$new_md5" ] ||
22906 error "$old_md5 != $new_md5"
22910 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
22913 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
22914 skip "Need MDS version at least 2.12.55"
22916 local dom=$DIR/$tdir/$tfile
22917 mkdir -p $DIR/$tdir
22918 $LFS setstripe -c 2 $dom
22920 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22921 error "failed to write data into $dom"
22922 local old_md5=$(md5sum $dom)
22925 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
22926 error "failed migrating to the DOM file"
22928 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
22929 error "MDT stripe wasn't set"
22932 local new_md5=$(md5sum $dom)
22933 [ "$old_md5" != "$new_md5" ] &&
22934 error "$old_md5 != $new_md5"
22938 run_test 272f "DoM migration: OST-striped file to DOM file"
22941 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22942 skip "Need MDS version at least 2.11.50"
22944 # Layout swap cannot be done if either file has DOM component,
22945 # this will never be supported, migration should be used instead
22947 local dom=$DIR/$tdir/$tfile
22948 mkdir -p $DIR/$tdir
22950 $LFS setstripe -c2 ${dom}_plain
22951 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
22952 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
22953 error "can swap layout with DoM component"
22954 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
22955 error "can swap layout with DoM component"
22957 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
22958 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
22959 error "can swap layout with DoM component"
22960 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
22961 error "can swap layout with DoM component"
22964 run_test 273a "DoM: layout swapping should fail with DOM"
22967 mkdir -p $DIR/$tdir
22968 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
22970 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
22971 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
22973 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
22975 run_test 273b "DoM: race writeback and object destroy"
22978 remote_ost_nodsh && skip "remote OST with nodsh"
22979 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
22980 skip "Need OST version >= 2.10.57"
22982 local file=$DIR/$tfile
22985 oss=$(comma_list $(osts_nodes))
22987 dd if=/dev/urandom of=$file bs=1M count=2 ||
22988 error "failed to create a file"
22989 cancel_lru_locks osc
22992 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
22993 error "failed to read a file"
22995 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
22996 $LCTL set_param fail_loc=0x8000031f
22998 cancel_lru_locks osc &
23001 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
23002 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
23003 #IO takes another lock, but matches the PENDING one
23004 #and places it to the IO RPC
23005 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23006 error "failed to read a file with PENDING lock"
23008 run_test 275 "Read on a canceled duplicate lock"
23011 remote_ost_nodsh && skip "remote OST with nodsh"
23014 do_facet ost1 "(while true; do \
23015 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
23016 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
23019 for LOOP in $(seq 20); do
23021 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
23024 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
23025 rm $TMP/sanity_276_pid"
23027 run_test 276 "Race between mount and obd_statfs"
23030 $LCTL set_param ldlm.namespaces.*.lru_size=0
23031 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23032 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23033 grep ^used_mb | awk '{print $2}')
23034 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
23035 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
23036 oflag=direct conv=notrunc
23037 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23038 grep ^used_mb | awk '{print $2}')
23039 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
23041 run_test 277 "Direct IO shall drop page cache"
23044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
23045 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23046 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
23047 skip "needs the same host for mdt1 mdt2" && return
23052 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
23053 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
23059 echo "Starting MDTs"
23060 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
23062 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
23064 do_facet mds2 $LCTL set_param fail_loc=0
23066 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
23067 wait_recovery_complete mds2
23069 run_test 278 "Race starting MDS between MDTs stop/start"
23072 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
23073 skip "Need MGS version at least 2.13.52"
23074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23075 combined_mgs_mds || skip "needs combined MGS/MDT"
23077 umount_client $MOUNT
23078 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
23079 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
23081 mount_client $MOUNT &
23083 stop mgs || error "stop mgs failed"
23084 #for a race mgs would crash
23085 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
23086 # make sure we unmount client before remounting
23088 umount_client $MOUNT
23089 mount_client $MOUNT || error "mount client failed"
23091 run_test 280 "Race between MGS umount and client llog processing"
23093 cleanup_test_300() {
23097 test_striped_dir() {
23102 mkdir -p $DIR/$tdir
23104 SAVE_UMASK=$(umask)
23105 trap cleanup_test_300 RETURN EXIT
23107 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
23108 $DIR/$tdir/striped_dir ||
23109 error "set striped dir error"
23111 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
23112 [ "$mode" = "755" ] || error "expect 755 got $mode"
23114 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
23115 error "getdirstripe failed"
23116 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
23117 if [ "$stripe_count" != "2" ]; then
23118 error "1:stripe_count is $stripe_count, expect 2"
23120 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
23121 if [ "$stripe_count" != "2" ]; then
23122 error "2:stripe_count is $stripe_count, expect 2"
23125 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
23126 if [ "$stripe_index" != "$mdt_index" ]; then
23127 error "stripe_index is $stripe_index, expect $mdt_index"
23130 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23131 error "nlink error after create striped dir"
23133 mkdir $DIR/$tdir/striped_dir/a
23134 mkdir $DIR/$tdir/striped_dir/b
23136 stat $DIR/$tdir/striped_dir/a ||
23137 error "create dir under striped dir failed"
23138 stat $DIR/$tdir/striped_dir/b ||
23139 error "create dir under striped dir failed"
23141 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
23142 error "nlink error after mkdir"
23144 rmdir $DIR/$tdir/striped_dir/a
23145 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
23146 error "nlink error after rmdir"
23148 rmdir $DIR/$tdir/striped_dir/b
23149 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23150 error "nlink error after rmdir"
23152 chattr +i $DIR/$tdir/striped_dir
23153 createmany -o $DIR/$tdir/striped_dir/f 10 &&
23154 error "immutable flags not working under striped dir!"
23155 chattr -i $DIR/$tdir/striped_dir
23157 rmdir $DIR/$tdir/striped_dir ||
23158 error "rmdir striped dir error"
23166 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23167 skip "skipped for lustre < 2.7.0"
23168 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23169 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23171 test_striped_dir 0 || error "failed on striped dir on MDT0"
23172 test_striped_dir 1 || error "failed on striped dir on MDT0"
23174 run_test 300a "basic striped dir sanity test"
23177 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23178 skip "skipped for lustre < 2.7.0"
23179 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23180 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23187 test_mkdir $DIR/$tdir || error "mkdir fail"
23188 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23189 error "set striped dir error"
23190 for i in {0..9}; do
23191 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
23193 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
23194 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
23195 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
23197 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
23198 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
23199 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
23203 run_test 300b "check ctime/mtime for striped dir"
23206 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23207 skip "skipped for lustre < 2.7.0"
23208 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23209 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23213 mkdir_on_mdt0 $DIR/$tdir
23214 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
23215 error "set striped dir error"
23217 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
23218 error "chown striped dir failed"
23220 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
23221 error "create 5k files failed"
23223 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
23225 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
23229 run_test 300c "chown && check ls under striped directory"
23232 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23233 skip "skipped for lustre < 2.7.0"
23234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23235 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23240 mkdir -p $DIR/$tdir
23241 $LFS setstripe -c 2 $DIR/$tdir
23243 #local striped directory
23244 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23245 error "set striped dir error"
23246 #look at the directories for debug purposes
23248 $LFS getdirstripe $DIR/$tdir
23249 ls -l $DIR/$tdir/striped_dir
23250 $LFS getdirstripe $DIR/$tdir/striped_dir
23251 createmany -o $DIR/$tdir/striped_dir/f 10 ||
23252 error "create 10 files failed"
23254 #remote striped directory
23255 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
23256 error "set striped dir error"
23257 #look at the directories for debug purposes
23259 $LFS getdirstripe $DIR/$tdir
23260 ls -l $DIR/$tdir/remote_striped_dir
23261 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
23262 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
23263 error "create 10 files failed"
23265 for file in $(find $DIR/$tdir); do
23266 stripe_count=$($LFS getstripe -c $file)
23267 [ $stripe_count -eq 2 ] ||
23268 error "wrong stripe $stripe_count for $file"
23273 run_test 300d "check default stripe under striped directory"
23276 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23277 skip "Need MDS version at least 2.7.55"
23278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23279 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23284 mkdir -p $DIR/$tdir
23286 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23287 error "set striped dir error"
23289 touch $DIR/$tdir/striped_dir/a
23290 touch $DIR/$tdir/striped_dir/b
23291 touch $DIR/$tdir/striped_dir/c
23293 mkdir $DIR/$tdir/striped_dir/dir_a
23294 mkdir $DIR/$tdir/striped_dir/dir_b
23295 mkdir $DIR/$tdir/striped_dir/dir_c
23297 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
23298 error "set striped adir under striped dir error"
23300 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
23301 error "set striped bdir under striped dir error"
23303 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
23304 error "set striped cdir under striped dir error"
23306 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
23307 error "rename dir under striped dir fails"
23309 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
23310 error "rename dir under different stripes fails"
23312 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
23313 error "rename file under striped dir should succeed"
23315 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
23316 error "rename dir under striped dir should succeed"
23320 run_test 300e "check rename under striped directory"
23323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23324 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23325 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23326 skip "Need MDS version at least 2.7.55"
23332 mkdir -p $DIR/$tdir
23334 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23335 error "set striped dir error"
23337 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
23338 error "set striped dir error"
23340 touch $DIR/$tdir/striped_dir/a
23341 mkdir $DIR/$tdir/striped_dir/dir_a
23342 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
23343 error "create striped dir under striped dir fails"
23345 touch $DIR/$tdir/striped_dir1/b
23346 mkdir $DIR/$tdir/striped_dir1/dir_b
23347 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
23348 error "create striped dir under striped dir fails"
23350 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
23351 error "rename dir under different striped dir should fail"
23353 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
23354 error "rename striped dir under diff striped dir should fail"
23356 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
23357 error "rename file under diff striped dirs fails"
23361 run_test 300f "check rename cross striped directory"
23363 test_300_check_default_striped_dir()
23366 local default_count=$2
23367 local default_index=$3
23370 local dir_stripe_index
23373 echo "checking $dirname $default_count $default_index"
23374 $LFS setdirstripe -D -c $default_count -i $default_index \
23375 -H all_char $DIR/$tdir/$dirname ||
23376 error "set default stripe on striped dir error"
23377 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
23378 [ $stripe_count -eq $default_count ] ||
23379 error "expect $default_count get $stripe_count for $dirname"
23381 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
23382 [ $stripe_index -eq $default_index ] ||
23383 error "expect $default_index get $stripe_index for $dirname"
23385 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
23386 error "create dirs failed"
23388 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
23389 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
23390 for dir in $(find $DIR/$tdir/$dirname/*); do
23391 stripe_count=$($LFS getdirstripe -c $dir)
23392 (( $stripe_count == $default_count )) ||
23393 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
23394 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
23395 error "stripe count $default_count != $stripe_count for $dir"
23397 stripe_index=$($LFS getdirstripe -i $dir)
23398 [ $default_index -eq -1 ] ||
23399 [ $stripe_index -eq $default_index ] ||
23400 error "$stripe_index != $default_index for $dir"
23402 #check default stripe
23403 stripe_count=$($LFS getdirstripe -D -c $dir)
23404 [ $stripe_count -eq $default_count ] ||
23405 error "default count $default_count != $stripe_count for $dir"
23407 stripe_index=$($LFS getdirstripe -D -i $dir)
23408 [ $stripe_index -eq $default_index ] ||
23409 error "default index $default_index != $stripe_index for $dir"
23411 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
23415 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23416 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23417 skip "Need MDS version at least 2.7.55"
23423 mkdir_on_mdt0 $DIR/$tdir
23424 mkdir $DIR/$tdir/normal_dir
23426 #Checking when client cache stripe index
23427 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
23428 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
23429 error "create striped_dir failed"
23431 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
23432 error "create dir0 fails"
23433 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
23434 [ $stripe_index -eq 0 ] ||
23435 error "dir0 expect index 0 got $stripe_index"
23437 mkdir $DIR/$tdir/striped_dir/dir1 ||
23438 error "create dir1 fails"
23439 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
23440 [ $stripe_index -eq 1 ] ||
23441 error "dir1 expect index 1 got $stripe_index"
23443 #check default stripe count/stripe index
23444 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
23445 test_300_check_default_striped_dir normal_dir 1 0
23446 test_300_check_default_striped_dir normal_dir -1 1
23447 test_300_check_default_striped_dir normal_dir 2 -1
23449 #delete default stripe information
23450 echo "delete default stripeEA"
23451 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
23452 error "set default stripe on striped dir error"
23454 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
23455 for dir in $(find $DIR/$tdir/normal_dir/*); do
23456 stripe_count=$($LFS getdirstripe -c $dir)
23457 [ $stripe_count -eq 0 ] ||
23458 error "expect 1 get $stripe_count for $dir"
23461 run_test 300g "check default striped directory for normal directory"
23464 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23465 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23466 skip "Need MDS version at least 2.7.55"
23472 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23473 error "set striped dir error"
23475 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
23476 test_300_check_default_striped_dir striped_dir 1 0
23477 test_300_check_default_striped_dir striped_dir -1 1
23478 test_300_check_default_striped_dir striped_dir 2 -1
23480 #delete default stripe information
23481 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
23482 error "set default stripe on striped dir error"
23484 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
23485 for dir in $(find $DIR/$tdir/striped_dir/*); do
23486 stripe_count=$($LFS getdirstripe -c $dir)
23487 [ $stripe_count -eq 0 ] ||
23488 error "expect 1 get $stripe_count for $dir"
23491 run_test 300h "check default striped directory for striped directory"
23494 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23495 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23496 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23497 skip "Need MDS version at least 2.7.55"
23504 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23505 error "set striped dir error"
23507 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
23508 error "create files under striped dir failed"
23510 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
23511 error "set striped hashdir error"
23513 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
23514 error "create dir0 under hash dir failed"
23515 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
23516 error "create dir1 under hash dir failed"
23517 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
23518 error "create dir2 under hash dir failed"
23520 # unfortunately, we need to umount to clear dir layout cache for now
23521 # once we fully implement dir layout, we can drop this
23522 umount_client $MOUNT || error "umount failed"
23523 mount_client $MOUNT || error "mount failed"
23525 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
23526 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
23527 [ $dircnt -eq 2 ] || error "lfs find striped dir got:$dircnt,except:1"
23529 #set the stripe to be unknown hash type
23530 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
23531 $LCTL set_param fail_loc=0x1901
23532 for ((i = 0; i < 10; i++)); do
23533 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
23534 error "stat f-$i failed"
23535 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
23538 touch $DIR/$tdir/striped_dir/f0 &&
23539 error "create under striped dir with unknown hash should fail"
23541 $LCTL set_param fail_loc=0
23543 umount_client $MOUNT || error "umount failed"
23544 mount_client $MOUNT || error "mount failed"
23548 run_test 300i "client handle unknown hash type striped directory"
23551 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23552 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23553 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23554 skip "Need MDS version at least 2.7.55"
23561 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
23562 $LCTL set_param fail_loc=0x1702
23563 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23564 error "set striped dir error"
23566 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
23567 error "create files under striped dir failed"
23569 $LCTL set_param fail_loc=0
23571 rm -rf $DIR/$tdir || error "unlink striped dir fails"
23575 run_test 300j "test large update record"
23578 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23579 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23580 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23581 skip "Need MDS version at least 2.7.55"
23583 # this test needs a huge transaction
23585 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23586 osd*.$FSNAME-MDT0000.kbytestotal")
23587 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
23594 #define OBD_FAIL_LARGE_STRIPE 0x1703
23595 $LCTL set_param fail_loc=0x1703
23596 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
23597 error "set striped dir error"
23598 $LCTL set_param fail_loc=0
23600 $LFS getdirstripe $DIR/$tdir/striped_dir ||
23601 error "getstripeddir fails"
23602 rm -rf $DIR/$tdir/striped_dir ||
23603 error "unlink striped dir fails"
23607 run_test 300k "test large striped directory"
23610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23611 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23612 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23613 skip "Need MDS version at least 2.7.55"
23617 test_mkdir -p $DIR/$tdir/striped_dir
23618 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
23619 error "chown $RUNAS_ID failed"
23620 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
23621 error "set default striped dir failed"
23623 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
23624 $LCTL set_param fail_loc=0x80000158
23625 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
23627 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
23628 [ $stripe_index -eq 1 ] ||
23629 error "expect 1 get $stripe_index for $dir"
23631 run_test 300l "non-root user to create dir under striped dir with stale layout"
23634 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23635 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
23636 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23637 skip "Need MDS version at least 2.7.55"
23639 mkdir -p $DIR/$tdir/striped_dir
23640 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
23641 error "set default stripes dir error"
23643 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
23645 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
23646 [ $stripe_count -eq 0 ] ||
23647 error "expect 0 get $stripe_count for a"
23649 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
23650 error "set default stripes dir error"
23652 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
23654 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
23655 [ $stripe_count -eq 0 ] ||
23656 error "expect 0 get $stripe_count for b"
23658 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
23659 error "set default stripes dir error"
23661 mkdir $DIR/$tdir/striped_dir/c &&
23662 error "default stripe_index is invalid, mkdir c should fails"
23664 rm -rf $DIR/$tdir || error "rmdir fails"
23666 run_test 300m "setstriped directory on single MDT FS"
23669 local list=$(comma_list $(mdts_nodes))
23672 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23677 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23678 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23679 skip "Need MDS version at least 2.7.55"
23680 remote_mds_nodsh && skip "remote MDS with nodsh"
23683 local list=$(comma_list $(mdts_nodes))
23685 trap cleanup_300n RETURN EXIT
23686 mkdir -p $DIR/$tdir
23687 chmod 777 $DIR/$tdir
23688 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
23689 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
23690 error "create striped dir succeeds with gid=0"
23692 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
23693 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
23694 error "create striped dir fails with gid=-1"
23696 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23697 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
23698 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
23699 error "set default striped dir succeeds with gid=0"
23702 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
23703 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
23704 error "set default striped dir fails with gid=-1"
23707 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23708 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
23709 error "create test_dir fails"
23710 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
23711 error "create test_dir1 fails"
23712 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
23713 error "create test_dir2 fails"
23716 run_test 300n "non-root user to create dir under striped dir with default EA"
23719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23720 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23721 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23722 skip "Need MDS version at least 2.7.55"
23727 mkdir -p $DIR/$tdir
23729 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
23730 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
23731 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
23732 skip "not enough free inodes $numfree1 $numfree2"
23735 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
23736 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
23737 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
23738 skip "not enough free space $numfree1 $numfree2"
23741 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
23742 error "setdirstripe fails"
23744 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
23745 error "create dirs fails"
23747 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
23748 ls $DIR/$tdir/striped_dir > /dev/null ||
23749 error "ls striped dir fails"
23750 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
23751 error "unlink big striped dir fails"
23753 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
23756 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23757 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23758 remote_mds_nodsh && skip "remote MDS with nodsh"
23760 mkdir_on_mdt0 $DIR/$tdir
23762 #define OBD_FAIL_OUT_ENOSPC 0x1704
23763 do_facet mds2 lctl set_param fail_loc=0x80001704
23764 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
23765 && error "create striped directory should fail"
23767 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
23769 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
23772 run_test 300p "create striped directory without space"
23775 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23776 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23778 local fd=$(free_fd)
23779 local cmd="exec $fd<$tdir"
23781 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
23784 trap "eval $cmd" EXIT
23785 cd $tdir || error "cd $tdir fails"
23786 rmdir ../$tdir || error "rmdir $tdir fails"
23787 mkdir local_dir && error "create dir succeeds"
23788 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
23792 run_test 300q "create remote directory under orphan directory"
23795 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23796 skip "Need MDS version at least 2.7.55" && return
23797 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23801 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
23802 error "set striped dir error"
23804 $LFS getdirstripe $DIR/$tdir/striped_dir ||
23805 error "getstripeddir fails"
23808 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
23809 awk '/lmv_stripe_count:/ { print $2 }')
23811 [ $MDSCOUNT -ne $stripe_count ] &&
23812 error "wrong stripe count $stripe_count expected $MDSCOUNT"
23814 rm -rf $DIR/$tdir/striped_dir ||
23815 error "unlink striped dir fails"
23817 run_test 300r "test -1 striped directory"
23819 test_300s_helper() {
23822 local stripe_dir=$DIR/$tdir/striped_dir.$count
23824 $LFS mkdir -c $count $stripe_dir ||
23825 error "lfs mkdir -c error"
23827 $LFS getdirstripe $stripe_dir ||
23828 error "lfs getdirstripe fails"
23831 stripe_count=$($LFS getdirstripe $stripe_dir |
23832 awk '/lmv_stripe_count:/ { print $2 }')
23834 [ $count -ne $stripe_count ] &&
23835 error_noexit "bad stripe count $stripe_count expected $count"
23838 dupe_stripes=$($LFS getdirstripe $stripe_dir |
23839 awk '/0x/ {count[$1] += 1}; END {
23840 for (idx in count) {
23841 if (count[idx]>1) {
23842 print "index " idx " count " count[idx]
23847 if [[ -n "$dupe_stripes" ]] ; then
23848 lfs getdirstripe $stripe_dir
23849 error_noexit "Dupe MDT above: $dupe_stripes "
23852 rm -rf $stripe_dir ||
23853 error_noexit "unlink $stripe_dir fails"
23857 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23858 skip "Need MDS version at least 2.7.55" && return
23859 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23862 for count in $(seq 2 $MDSCOUNT); do
23863 test_300s_helper $count
23866 run_test 300s "test lfs mkdir -c without -i"
23869 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
23870 skip "need MDS 2.14.55 or later"
23871 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
23873 local testdir="$DIR/$tdir/striped_dir"
23874 local dir1=$testdir/dir1
23875 local dir2=$testdir/dir2
23879 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
23880 error "failed to set default stripe count for $testdir"
23883 local stripe_count=$($LFS getdirstripe -c $dir1)
23885 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
23887 local max_count=$((MDSCOUNT - 1))
23888 local mdts=$(comma_list $(mdts_nodes))
23890 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
23891 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
23894 stripe_count=$($LFS getdirstripe -c $dir2)
23896 (( $stripe_count == $max_count )) || error "wrong stripe count"
23898 run_test 300t "test max_mdt_stripecount"
23900 prepare_remote_file() {
23901 mkdir $DIR/$tdir/src_dir ||
23902 error "create remote source failed"
23904 cp /etc/hosts $DIR/$tdir/src_dir/a ||
23905 error "cp to remote source failed"
23906 touch $DIR/$tdir/src_dir/a
23908 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
23909 error "create remote target dir failed"
23911 touch $DIR/$tdir/tgt_dir/b
23913 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
23914 error "rename dir cross MDT failed!"
23916 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
23917 error "src_child still exists after rename"
23919 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
23920 error "missing file(a) after rename"
23922 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
23923 error "diff after rename"
23927 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
23928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23930 local remote_file=$DIR/$tdir/tgt_dir/b
23932 mkdir -p $DIR/$tdir
23934 prepare_remote_file || error "prepare remote file failed"
23937 $OPENUNLINK $remote_file $remote_file ||
23938 error "openunlink $remote_file failed"
23939 $CHECKSTAT -a $remote_file || error "$remote_file exists"
23941 run_test 310a "open unlink remote file"
23944 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
23945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23947 local remote_file=$DIR/$tdir/tgt_dir/b
23949 mkdir -p $DIR/$tdir
23951 prepare_remote_file || error "prepare remote file failed"
23953 ln $remote_file $DIR/$tfile || error "link failed for remote file"
23954 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
23955 $CHECKSTAT -t file $remote_file || error "check file failed"
23957 run_test 310b "unlink remote file with multiple links while open"
23960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23961 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
23963 local remote_file=$DIR/$tdir/tgt_dir/b
23965 mkdir -p $DIR/$tdir
23967 prepare_remote_file || error "prepare remote file failed"
23969 ln $remote_file $DIR/$tfile || error "link failed for remote file"
23970 multiop_bg_pause $remote_file O_uc ||
23971 error "mulitop failed for remote file"
23973 $MULTIOP $DIR/$tfile Ouc
23974 kill -USR1 $MULTIPID
23977 run_test 310c "open-unlink remote file with multiple links"
23981 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23982 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
23983 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
23984 skip "lustre < 2.8.54 does not contain LU-4825 fix"
23985 remote_mds_nodsh && skip "remote MDS with nodsh"
23987 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
23988 local mdts=$(comma_list $(mdts_nodes))
23990 mkdir -p $DIR/$tdir
23991 $LFS setstripe -i 0 -c 1 $DIR/$tdir
23992 createmany -o $DIR/$tdir/$tfile. 1000
23994 # statfs data is not real time, let's just calculate it
23995 old_iused=$((old_iused + 1000))
23997 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23998 osp.*OST0000*MDT0000.create_count")
23999 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24000 osp.*OST0000*MDT0000.max_create_count")
24001 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
24003 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
24004 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
24005 [ $index -ne 0 ] || error "$tfile stripe index is 0"
24007 unlinkmany $DIR/$tdir/$tfile. 1000
24009 do_nodes $mdts "$LCTL set_param -n \
24010 osp.*OST0000*.max_create_count=$max_count"
24011 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
24012 do_nodes $mdts "$LCTL set_param -n \
24013 osp.*OST0000*.create_count=$count"
24014 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
24015 grep "=0" && error "create_count is zero"
24018 for i in $(seq 120); do
24019 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24020 # system may be too busy to destroy all objs in time, use
24021 # a somewhat small value to not fail autotest
24022 [ $((old_iused - new_iused)) -gt 400 ] && break
24026 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
24027 [ $((old_iused - new_iused)) -gt 400 ] ||
24028 error "objs not destroyed after unlink"
24030 run_test 311 "disable OSP precreate, and unlink should destroy objs"
24037 local vdevdir=$(dirname $(facet_vdevice $ost))
24038 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
24039 local zfs_zapid=$(do_facet $ost $cmd |
24040 grep -w "/O/0/d$((objid%32))" -C 5 |
24041 awk '/Object/{getline; print $1}')
24042 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
24043 awk "/$objid = /"'{printf $3}')
24048 zfs_object_blksz() {
24052 local vdevdir=$(dirname $(facet_vdevice $ost))
24053 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
24054 local blksz=$(do_facet $ost $cmd $objid |
24055 awk '/dblk/{getline; printf $4}')
24057 case "${blksz: -1}" in
24058 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
24059 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
24066 test_312() { # LU-4856
24067 remote_ost_nodsh && skip "remote OST with nodsh"
24068 [ "$ost1_FSTYPE" = "zfs" ] ||
24069 skip_env "the test only applies to zfs"
24071 local max_blksz=$(do_facet ost1 \
24072 $ZFS get -p recordsize $(facet_device ost1) |
24073 awk '!/VALUE/{print $3}')
24075 # to make life a little bit easier
24076 $LFS mkdir -c 1 -i 0 $DIR/$tdir
24077 $LFS setstripe -c 1 -i 0 $DIR/$tdir
24079 local tf=$DIR/$tdir/$tfile
24081 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24083 # Get ZFS object id
24084 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24085 # block size change by sequential overwrite
24088 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
24089 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
24091 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
24092 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
24096 # block size change by sequential append write
24097 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
24098 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24099 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24102 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
24103 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
24104 oflag=sync conv=notrunc
24106 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24107 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
24108 error "blksz error, actual $blksz, " \
24109 "expected: 2 * $count * $PAGE_SIZE"
24115 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24116 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24118 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
24119 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24120 [ $blksz -eq $PAGE_SIZE ] ||
24121 error "blksz error: $blksz, expected: $PAGE_SIZE"
24123 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
24124 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24125 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
24127 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
24128 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24129 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
24131 run_test 312 "make sure ZFS adjusts its block size by write pattern"
24134 remote_ost_nodsh && skip "remote OST with nodsh"
24136 local file=$DIR/$tfile
24139 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
24141 # define OBD_FAIL_TGT_RCVD_EIO 0x720
24142 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24143 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
24144 error "write should failed"
24145 do_facet ost1 "$LCTL set_param fail_loc=0"
24148 run_test 313 "io should fail after last_rcvd update fail"
24151 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24153 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
24154 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24156 wait_delete_completed
24157 do_facet ost1 "$LCTL set_param fail_loc=0"
24159 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
24161 test_315() { # LU-618
24162 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
24164 local file=$DIR/$tfile
24167 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
24168 error "multiop file write failed"
24169 $MULTIOP $file oO_RDONLY:r4063232_c &
24174 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
24177 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
24180 run_test 315 "read should be accounted"
24183 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24184 large_xattr_enabled || skip "ea_inode feature disabled"
24186 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
24187 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
24188 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
24189 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
24191 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
24193 run_test 316 "lfs migrate of file with large_xattr enabled"
24196 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
24197 skip "Need MDS version at least 2.11.53"
24198 if [ "$ost1_FSTYPE" == "zfs" ]; then
24199 skip "LU-10370: no implementation for ZFS"
24203 local grant_blk_size
24205 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
24206 awk '/grant_block_size:/ { print $2; exit; }')
24208 # Create File of size 5M. Truncate it to below size's and verify
24211 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
24212 error "Create file $DIR/$tfile failed"
24213 stack_trap "rm -f $DIR/$tfile" EXIT
24215 for trunc_sz in 2097152 4097 4000 509 0; do
24216 $TRUNCATE $DIR/$tfile $trunc_sz ||
24217 error "truncate $tfile to $trunc_sz failed"
24218 local sz=$(stat --format=%s $DIR/$tfile)
24219 local blk=$(stat --format=%b $DIR/$tfile)
24220 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
24221 grant_blk_size) * 8))
24223 if [[ $blk -ne $trunc_blk ]]; then
24224 $(which stat) $DIR/$tfile
24225 error "Expected Block $trunc_blk got $blk for $tfile"
24228 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24229 error "Expected Size $trunc_sz got $sz for $tfile"
24234 # Create file with a hole and write actual 65536 bytes which aligned
24235 # with 4K and 64K PAGE_SIZE. Block count must be 128.
24238 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
24239 error "Create file : $DIR/$tfile"
24242 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
24243 # blocks. The block count must drop to 8.
24245 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
24246 ((bs - grant_blk_size) + 1)))
24247 $TRUNCATE $DIR/$tfile $trunc_sz ||
24248 error "truncate $tfile to $trunc_sz failed"
24250 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
24251 sz=$(stat --format=%s $DIR/$tfile)
24252 blk=$(stat --format=%b $DIR/$tfile)
24254 if [[ $blk -ne $trunc_bsz ]]; then
24255 $(which stat) $DIR/$tfile
24256 error "Expected Block $trunc_bsz got $blk for $tfile"
24259 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24260 error "Expected Size $trunc_sz got $sz for $tfile"
24262 run_test 317 "Verify blocks get correctly update after truncate"
24265 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
24266 local old_max_active=$($LCTL get_param -n \
24267 ${llite_name}.max_read_ahead_async_active \
24270 $LCTL set_param llite.*.max_read_ahead_async_active=256
24271 local max_active=$($LCTL get_param -n \
24272 ${llite_name}.max_read_ahead_async_active \
24274 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
24276 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
24277 error "set max_read_ahead_async_active should succeed"
24279 $LCTL set_param llite.*.max_read_ahead_async_active=512
24280 max_active=$($LCTL get_param -n \
24281 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
24282 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
24284 # restore @max_active
24285 [ $old_max_active -ne 0 ] && $LCTL set_param \
24286 llite.*.max_read_ahead_async_active=$old_max_active
24288 local old_threshold=$($LCTL get_param -n \
24289 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24290 local max_per_file_mb=$($LCTL get_param -n \
24291 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
24293 local invalid=$(($max_per_file_mb + 1))
24295 llite.*.read_ahead_async_file_threshold_mb=$invalid\
24296 && error "set $invalid should fail"
24298 local valid=$(($invalid - 1))
24300 llite.*.read_ahead_async_file_threshold_mb=$valid ||
24301 error "set $valid should succeed"
24302 local threshold=$($LCTL get_param -n \
24303 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24304 [ $threshold -eq $valid ] || error \
24305 "expect threshold $valid got $threshold"
24307 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
24309 run_test 318 "Verify async readahead tunables"
24312 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24314 local before=$(date +%s)
24316 local mdir=$DIR/$tdir
24317 local file=$mdir/xxx
24319 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
24322 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
24323 $LCTL set_param fail_val=5 fail_loc=0x8000032c
24324 $LFS migrate -m1 $mdir &
24327 dd if=$file of=/dev/null
24329 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
24330 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
24332 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
24334 run_test 319 "lost lease lock on migrate error"
24336 test_398a() { # LU-4198
24337 local ost1_imp=$(get_osc_import_name client ost1)
24338 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24341 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24342 $LCTL set_param ldlm.namespaces.*.lru_size=clear
24344 # Disabled: DIO does not push out buffered I/O pages, see LU-12587
24345 # request a new lock on client
24346 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24348 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
24349 #local lock_count=$($LCTL get_param -n \
24350 # ldlm.namespaces.$imp_name.lru_size)
24351 #[[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
24353 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24355 # no lock cached, should use lockless DIO and not enqueue new lock
24356 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct \
24358 error "dio write failed"
24359 lock_count=$($LCTL get_param -n \
24360 ldlm.namespaces.$imp_name.lru_size)
24361 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
24363 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24365 # no lock cached, should use locked DIO append
24366 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
24367 conv=notrunc || error "DIO append failed"
24368 lock_count=$($LCTL get_param -n \
24369 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
24370 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
24372 run_test 398a "direct IO should cancel lock otherwise lockless"
24374 test_398b() { # LU-4198
24375 which fio || skip_env "no fio installed"
24376 $LFS setstripe -c -1 $DIR/$tfile
24379 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
24382 echo "mix direct rw ${size}M to OST0 by fio with $njobs jobs..."
24383 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
24384 --numjobs=$njobs --fallocate=none \
24385 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24386 --filename=$DIR/$tfile &
24389 echo "mix buffer rw ${size}M to OST0 by fio with $njobs jobs..."
24390 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE \
24391 --numjobs=$njobs --fallocate=none \
24392 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24393 --filename=$DIR/$tfile || true
24398 run_test 398b "DIO and buffer IO race"
24400 test_398c() { # LU-4198
24401 local ost1_imp=$(get_osc_import_name client ost1)
24402 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24405 which fio || skip_env "no fio installed"
24407 saved_debug=$($LCTL get_param -n debug)
24408 $LCTL set_param debug=0
24410 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
24411 ((size /= 1024)) # by megabytes
24412 ((size /= 2)) # write half of the OST at most
24413 [ $size -gt 40 ] && size=40 #reduce test time anyway
24415 $LFS setstripe -c 1 $DIR/$tfile
24417 # it seems like ldiskfs reserves more space than necessary if the
24418 # writing blocks are not mapped, so it extends the file firstly
24419 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
24420 cancel_lru_locks osc
24422 # clear and verify rpc_stats later
24423 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
24426 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
24427 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
24428 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24429 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24430 --filename=$DIR/$tfile
24431 [ $? -eq 0 ] || error "fio write error"
24433 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
24434 error "Locks were requested while doing AIO"
24436 # get the percentage of 1-page I/O
24437 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
24438 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
24440 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
24442 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
24443 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
24444 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24445 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24446 --filename=$DIR/$tfile
24447 [ $? -eq 0 ] || error "fio mixed read write error"
24449 echo "AIO with large block size ${size}M"
24450 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
24451 --numjobs=1 --fallocate=none --ioengine=libaio \
24452 --iodepth=16 --allow_file_create=0 --size=${size}M \
24453 --filename=$DIR/$tfile
24454 [ $? -eq 0 ] || error "fio large block size failed"
24457 $LCTL set_param debug="$saved_debug"
24459 run_test 398c "run fio to test AIO"
24461 test_398d() { # LU-13846
24462 which aiocp || skip_env "no aiocp installed"
24463 local aio_file=$DIR/$tfile.aio
24465 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
24467 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
24468 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
24469 stack_trap "rm -f $DIR/$tfile $aio_file"
24471 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
24473 # make sure we don't crash and fail properly
24474 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
24475 error "aio not aligned with PAGE SIZE should fail"
24477 rm -f $DIR/$tfile $aio_file
24479 run_test 398d "run aiocp to verify block size > stripe size"
24482 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
24483 touch $DIR/$tfile.new
24484 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
24486 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
24488 test_398f() { # LU-14687
24489 which aiocp || skip_env "no aiocp installed"
24490 local aio_file=$DIR/$tfile.aio
24492 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
24494 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
24495 stack_trap "rm -f $DIR/$tfile $aio_file"
24497 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
24498 $LCTL set_param fail_loc=0x1418
24499 # make sure we don't crash and fail properly
24500 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
24501 error "aio with page allocation failure succeeded"
24502 $LCTL set_param fail_loc=0
24503 diff $DIR/$tfile $aio_file
24504 [[ $? != 0 ]] || error "no diff after failed aiocp"
24506 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
24508 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
24509 # stripe and i/o size must be > stripe size
24510 # Old style synchronous DIO waits after submitting each chunk, resulting in a
24511 # single RPC in flight. This test shows async DIO submission is working by
24512 # showing multiple RPCs in flight.
24513 test_398g() { # LU-13798
24514 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
24516 # We need to do some i/o first to acquire enough grant to put our RPCs
24517 # in flight; otherwise a new connection may not have enough grant
24519 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24520 error "parallel dio failed"
24521 stack_trap "rm -f $DIR/$tfile"
24523 # Reduce RPC size to 1M to avoid combination in to larger RPCs
24524 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
24525 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
24526 stack_trap "$LCTL set_param -n $pages_per_rpc"
24528 # Recreate file so it's empty
24530 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
24531 #Pause rpc completion to guarantee we see multiple rpcs in flight
24532 #define OBD_FAIL_OST_BRW_PAUSE_BULK
24533 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
24534 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24537 $LCTL set_param osc.*.rpc_stats=c
24539 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24540 error "parallel dio failed"
24541 stack_trap "rm -f $DIR/$tfile"
24543 $LCTL get_param osc.*-OST0000-*.rpc_stats
24544 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
24545 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
24546 grep "8:" | awk '{print $8}')
24547 # We look at the "8 rpcs in flight" field, and verify A) it is present
24548 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
24549 # as expected for an 8M DIO to a file with 1M stripes.
24550 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
24552 # Verify turning off parallel dio works as expected
24554 $LCTL set_param osc.*.rpc_stats=c
24555 $LCTL set_param llite.*.parallel_dio=0
24556 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
24558 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24559 error "dio with parallel dio disabled failed"
24561 # Ideally, we would see only one RPC in flight here, but there is an
24562 # unavoidable race between i/o completion and RPC in flight counting,
24563 # so while only 1 i/o is in flight at a time, the RPC in flight counter
24564 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
24565 # So instead we just verify it's always < 8.
24566 $LCTL get_param osc.*-OST0000-*.rpc_stats
24567 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
24568 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
24569 grep '^$' -B1 | grep . | awk '{print $1}')
24570 [ $ret != "8:" ] ||
24571 error "we should see fewer than 8 RPCs in flight (saw $ret)"
24573 run_test 398g "verify parallel dio async RPC submission"
24575 test_398h() { # LU-13798
24576 local dio_file=$DIR/$tfile.dio
24578 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
24580 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
24581 stack_trap "rm -f $DIR/$tfile $dio_file"
24583 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
24584 error "parallel dio failed"
24585 diff $DIR/$tfile $dio_file
24586 [[ $? == 0 ]] || error "file diff after aiocp"
24588 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
24590 test_398i() { # LU-13798
24591 local dio_file=$DIR/$tfile.dio
24593 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
24595 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
24596 stack_trap "rm -f $DIR/$tfile $dio_file"
24598 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
24599 $LCTL set_param fail_loc=0x1418
24600 # make sure we don't crash and fail properly
24601 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
24602 error "parallel dio page allocation failure succeeded"
24603 diff $DIR/$tfile $dio_file
24604 [[ $? != 0 ]] || error "no diff after failed aiocp"
24606 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
24608 test_398j() { # LU-13798
24609 # Stripe size > RPC size but less than i/o size tests split across
24610 # stripes and RPCs for individual i/o op
24611 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
24613 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
24614 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
24615 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
24616 stack_trap "$LCTL set_param -n $pages_per_rpc"
24618 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24619 error "parallel dio write failed"
24620 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
24622 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
24623 error "parallel dio read failed"
24624 diff $DIR/$tfile $DIR/$tfile.2
24625 [[ $? == 0 ]] || error "file diff after parallel dio read"
24627 run_test 398j "test parallel dio where stripe size > rpc_size"
24629 test_398k() { # LU-13798
24630 wait_delete_completed
24633 # 4 stripe file; we will cause out of space on OST0
24634 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
24636 # Fill OST0 (if it's not too large)
24637 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
24639 if [[ $ORIGFREE -gt $MAXFREE ]]; then
24640 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
24642 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
24643 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
24644 error "dd should fill OST0"
24645 stack_trap "rm -f $DIR/$tfile.1"
24647 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
24651 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
24652 error "file is not 0 bytes in size"
24654 # dd above should not succeed, but don't error until here so we can
24655 # get debug info above
24657 error "parallel dio write with enospc succeeded"
24658 stack_trap "rm -f $DIR/$tfile"
24660 run_test 398k "test enospc on first stripe"
24662 test_398l() { # LU-13798
24663 wait_delete_completed
24666 # 4 stripe file; we will cause out of space on OST0
24667 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
24668 # happens on the second i/o chunk we issue
24669 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
24671 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
24672 stack_trap "rm -f $DIR/$tfile"
24674 # Fill OST0 (if it's not too large)
24675 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
24677 if [[ $ORIGFREE -gt $MAXFREE ]]; then
24678 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
24680 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
24681 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
24682 error "dd should fill OST0"
24683 stack_trap "rm -f $DIR/$tfile.1"
24685 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
24687 stack_trap "rm -f $DIR/$tfile.2"
24689 # Check that short write completed as expected
24690 ls -la $DIR/$tfile.2
24691 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
24692 error "file is not 1M in size"
24694 # dd above should not succeed, but don't error until here so we can
24695 # get debug info above
24697 error "parallel dio write with enospc succeeded"
24699 # Truncate source file to same length as output file and diff them
24700 $TRUNCATE $DIR/$tfile 1048576
24701 diff $DIR/$tfile $DIR/$tfile.2
24702 [[ $? == 0 ]] || error "data incorrect after short write"
24704 run_test 398l "test enospc on intermediate stripe/RPC"
24706 test_398m() { # LU-13798
24707 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
24709 # Set up failure on OST0, the first stripe:
24710 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
24711 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
24712 # So this fail_val specifies OST0
24713 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
24714 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24716 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
24717 error "parallel dio write with failure on first stripe succeeded"
24718 stack_trap "rm -f $DIR/$tfile"
24719 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24721 # Place data in file for read
24722 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24723 error "parallel dio write failed"
24725 # Fail read on OST0, first stripe
24726 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
24727 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
24728 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
24729 error "parallel dio read with error on first stripe succeeded"
24730 rm -f $DIR/$tfile.2
24731 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24733 # Switch to testing on OST1, second stripe
24734 # Clear file contents, maintain striping
24736 # Set up failure on OST1, second stripe:
24737 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=2
24738 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24740 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
24741 error "parallel dio write with failure on first stripe succeeded"
24742 stack_trap "rm -f $DIR/$tfile"
24743 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24745 # Place data in file for read
24746 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24747 error "parallel dio write failed"
24749 # Fail read on OST1, second stripe
24750 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
24751 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
24752 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
24753 error "parallel dio read with error on first stripe succeeded"
24754 rm -f $DIR/$tfile.2
24755 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
24757 run_test 398m "test RPC failures with parallel dio"
24759 # Parallel submission of DIO should not cause problems for append, but it's
24760 # important to verify.
24761 test_398n() { # LU-13798
24762 $LFS setstripe -C 2 -S 1M $DIR/$tfile
24764 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
24765 error "dd to create source file failed"
24766 stack_trap "rm -f $DIR/$tfile"
24768 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
24769 error "parallel dio write with failure on second stripe succeeded"
24770 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
24771 diff $DIR/$tfile $DIR/$tfile.1
24772 [[ $? == 0 ]] || error "data incorrect after append"
24775 run_test 398n "test append with parallel DIO"
24778 local read_write=$1
24779 if [ "$read_write" = "write" ]; then
24780 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
24781 elif [ "$read_write" = "read" ]; then
24782 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
24784 error "argument error"
24787 # turn off debug for performance testing
24788 local saved_debug=$($LCTL get_param -n debug)
24789 $LCTL set_param debug=0
24791 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24793 # get ost1 size - $FSNAME-OST0000
24794 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
24795 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
24796 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
24798 if [ "$read_write" = "read" ]; then
24799 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
24802 local start_time=$(date +%s.%N)
24803 $dd_cmd bs=1M count=$blocks oflag=sync ||
24804 error "real dd $read_write error"
24805 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
24807 if [ "$read_write" = "write" ]; then
24811 # define OBD_FAIL_OST_FAKE_RW 0x238
24812 do_facet ost1 $LCTL set_param fail_loc=0x238
24814 local start_time=$(date +%s.%N)
24815 $dd_cmd bs=1M count=$blocks oflag=sync ||
24816 error "fake dd $read_write error"
24817 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
24819 if [ "$read_write" = "write" ]; then
24821 cancel_lru_locks osc
24822 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
24823 error "$tfile size not $blocks MB"
24825 do_facet ost1 $LCTL set_param fail_loc=0
24827 echo "fake $read_write $duration_fake vs. normal $read_write" \
24828 "$duration in seconds"
24829 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
24830 error_not_in_vm "fake write is slower"
24832 $LCTL set_param -n debug="$saved_debug"
24835 test_399a() { # LU-7655 for OST fake write
24836 remote_ost_nodsh && skip "remote OST with nodsh"
24840 run_test 399a "fake write should not be slower than normal write"
24842 test_399b() { # LU-8726 for OST fake read
24843 remote_ost_nodsh && skip "remote OST with nodsh"
24844 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
24845 skip_env "ldiskfs only test"
24850 run_test 399b "fake read should not be slower than normal read"
24852 test_400a() { # LU-1606, was conf-sanity test_74
24853 if ! which $CC > /dev/null 2>&1; then
24854 skip_env "$CC is not installed"
24857 local extra_flags=''
24858 local out=$TMP/$tfile
24859 local prefix=/usr/include/lustre
24862 # Oleg removes c files in his test rig so test if any c files exist
24863 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
24864 skip_env "Needed c test files are missing"
24866 if ! [[ -d $prefix ]]; then
24867 # Assume we're running in tree and fixup the include path.
24868 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
24869 extra_flags+=" -L$LUSTRE/utils/.lib"
24872 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
24873 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
24874 error "client api broken"
24878 run_test 400a "Lustre client api program can compile and link"
24880 test_400b() { # LU-1606, LU-5011
24882 local out=$TMP/$tfile
24883 local prefix=/usr/include/linux/lustre
24885 # We use a hard coded prefix so that this test will not fail
24886 # when run in tree. There are headers in lustre/include/lustre/
24887 # that are not packaged (like lustre_idl.h) and have more
24888 # complicated include dependencies (like config.h and lnet/types.h).
24889 # Since this test about correct packaging we just skip them when
24890 # they don't exist (see below) rather than try to fixup cppflags.
24892 if ! which $CC > /dev/null 2>&1; then
24893 skip_env "$CC is not installed"
24896 for header in $prefix/*.h; do
24897 if ! [[ -f "$header" ]]; then
24901 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
24902 continue # lustre_ioctl.h is internal header
24905 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
24906 error "cannot compile '$header'"
24910 run_test 400b "packaged headers can be compiled"
24912 test_401a() { #LU-7437
24913 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
24914 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
24916 #count the number of parameters by "list_param -R"
24917 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
24918 #count the number of parameters by listing proc files
24919 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
24920 echo "proc_dirs='$proc_dirs'"
24921 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
24922 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
24925 [ $params -eq $procs ] ||
24926 error "found $params parameters vs. $procs proc files"
24928 # test the list_param -D option only returns directories
24929 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
24930 #count the number of parameters by listing proc directories
24931 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
24934 [ $params -eq $procs ] ||
24935 error "found $params parameters vs. $procs proc files"
24937 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
24940 # jobid_var may not allow arbitrary values, so use jobid_name
24942 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24943 local testname=jobid_name tmp='testing%p'
24945 local testname=jobid_var tmp=testing
24948 local save=$($LCTL get_param -n $testname)
24950 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
24951 error "no error returned when setting bad parameters"
24953 local jobid_new=$($LCTL get_param -n foe $testname baz)
24954 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
24956 $LCTL set_param -n fog=bam $testname=$save bat=fog
24957 local jobid_old=$($LCTL get_param -n foe $testname bag)
24958 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
24960 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
24963 # jobid_var may not allow arbitrary values, so use jobid_name
24965 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24966 local testname=jobid_name
24968 local testname=jobid_var
24971 local jobid_var_old=$($LCTL get_param -n $testname)
24972 local jobid_var_new
24974 $LCTL set_param $testname= &&
24975 error "no error returned for 'set_param a='"
24977 jobid_var_new=$($LCTL get_param -n $testname)
24978 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
24979 error "$testname was changed by setting without value"
24981 $LCTL set_param $testname &&
24982 error "no error returned for 'set_param a'"
24984 jobid_var_new=$($LCTL get_param -n $testname)
24985 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
24986 error "$testname was changed by setting without value"
24988 run_test 401c "Verify 'lctl set_param' without value fails in either format."
24991 # jobid_var may not allow arbitrary values, so use jobid_name
24993 if $LCTL list_param jobid_name > /dev/null 2>&1; then
24994 local testname=jobid_name new_value='foo=bar%p'
24996 local testname=jobid_var new_valuie=foo=bar
24999 local jobid_var_old=$($LCTL get_param -n $testname)
25000 local jobid_var_new
25002 $LCTL set_param $testname=$new_value ||
25003 error "'set_param a=b' did not accept a value containing '='"
25005 jobid_var_new=$($LCTL get_param -n $testname)
25006 [[ "$jobid_var_new" == "$new_value" ]] ||
25007 error "'set_param a=b' failed on a value containing '='"
25009 # Reset the $testname to test the other format
25010 $LCTL set_param $testname=$jobid_var_old
25011 jobid_var_new=$($LCTL get_param -n $testname)
25012 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25013 error "failed to reset $testname"
25015 $LCTL set_param $testname $new_value ||
25016 error "'set_param a b' did not accept a value containing '='"
25018 jobid_var_new=$($LCTL get_param -n $testname)
25019 [[ "$jobid_var_new" == "$new_value" ]] ||
25020 error "'set_param a b' failed on a value containing '='"
25022 $LCTL set_param $testname $jobid_var_old
25023 jobid_var_new=$($LCTL get_param -n $testname)
25024 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25025 error "failed to reset $testname"
25027 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
25029 test_401e() { # LU-14779
25030 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
25031 error "lctl list_param MGC* failed"
25032 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
25033 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
25034 error "lctl get_param lru_size failed"
25036 run_test 401e "verify 'lctl get_param' works with NID in parameter"
25039 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
25040 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
25041 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
25042 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
25043 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
25044 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
25045 remote_mds_nodsh && skip "remote MDS with nodsh"
25047 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
25048 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
25049 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
25050 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
25051 echo "Touch failed - OK"
25053 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
25056 local file1=$DIR/$tfile.1
25057 local file2=$DIR/$tfile.2
25058 local tfile=$TMP/$tfile
25060 rm -f $file1 $file2 $tfile
25065 # 30 sec OBD_TIMEOUT in ll_getattr()
25066 # right before populating st_nlink
25067 $LCTL set_param fail_loc=0x80001409
25068 stat -c %h $file1 > $tfile &
25070 # create an alias, drop all locks and reclaim the dentry
25072 cancel_lru_locks mdc
25073 cancel_lru_locks osc
25074 sysctl -w vm.drop_caches=2
25078 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
25080 rm -f $tfile $file1 $file2
25082 run_test 403 "i_nlink should not drop to zero due to aliasing"
25084 test_404() { # LU-6601
25085 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
25086 skip "Need server version newer than 2.8.52"
25087 remote_mds_nodsh && skip "remote MDS with nodsh"
25089 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
25090 awk '/osp .*-osc-MDT/ { print $4}')
25093 for osp in $mosps; do
25094 echo "Deactivate: " $osp
25095 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
25096 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25097 awk -vp=$osp '$4 == p { print $2 }')
25098 [ $stat = IN ] || {
25099 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25100 error "deactivate error"
25102 echo "Activate: " $osp
25103 do_facet $SINGLEMDS $LCTL --device %$osp activate
25104 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25105 awk -vp=$osp '$4 == p { print $2 }')
25106 [ $stat = UP ] || {
25107 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25108 error "activate error"
25112 run_test 404 "validate manual {de}activated works properly for OSPs"
25115 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
25116 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
25117 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
25118 skip "Layout swap lock is not supported"
25120 check_swap_layouts_support
25121 check_swap_layout_no_dom $DIR
25123 test_mkdir $DIR/$tdir
25124 swap_lock_test -d $DIR/$tdir ||
25125 error "One layout swap locked test failed"
25127 run_test 405 "Various layout swap lock tests"
25130 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25131 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
25132 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
25133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25134 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
25135 skip "Need MDS version at least 2.8.50"
25137 local def_stripe_size=$($LFS getstripe -S $MOUNT)
25138 local test_pool=$TESTNAME
25140 pool_add $test_pool || error "pool_add failed"
25141 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
25142 error "pool_add_targets failed"
25144 save_layout_restore_at_exit $MOUNT
25146 # parent set default stripe count only, child will stripe from both
25147 # parent and fs default
25148 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
25149 error "setstripe $MOUNT failed"
25150 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
25151 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
25152 for i in $(seq 10); do
25153 local f=$DIR/$tdir/$tfile.$i
25154 touch $f || error "touch failed"
25155 local count=$($LFS getstripe -c $f)
25156 [ $count -eq $OSTCOUNT ] ||
25157 error "$f stripe count $count != $OSTCOUNT"
25158 local offset=$($LFS getstripe -i $f)
25159 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
25160 local size=$($LFS getstripe -S $f)
25161 [ $size -eq $((def_stripe_size * 2)) ] ||
25162 error "$f stripe size $size != $((def_stripe_size * 2))"
25163 local pool=$($LFS getstripe -p $f)
25164 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
25167 # change fs default striping, delete parent default striping, now child
25168 # will stripe from new fs default striping only
25169 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
25170 error "change $MOUNT default stripe failed"
25171 $LFS setstripe -c 0 $DIR/$tdir ||
25172 error "delete $tdir default stripe failed"
25173 for i in $(seq 11 20); do
25174 local f=$DIR/$tdir/$tfile.$i
25175 touch $f || error "touch $f failed"
25176 local count=$($LFS getstripe -c $f)
25177 [ $count -eq 1 ] || error "$f stripe count $count != 1"
25178 local offset=$($LFS getstripe -i $f)
25179 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
25180 local size=$($LFS getstripe -S $f)
25181 [ $size -eq $def_stripe_size ] ||
25182 error "$f stripe size $size != $def_stripe_size"
25183 local pool=$($LFS getstripe -p $f)
25184 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
25187 unlinkmany $DIR/$tdir/$tfile. 1 20
25189 local f=$DIR/$tdir/$tfile
25190 pool_remove_all_targets $test_pool $f
25191 pool_remove $test_pool $f
25193 run_test 406 "DNE support fs default striping"
25196 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25197 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
25198 skip "Need MDS version at least 2.8.55"
25199 remote_mds_nodsh && skip "remote MDS with nodsh"
25201 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
25202 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
25203 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
25204 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
25205 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
25207 #define OBD_FAIL_DT_TXN_STOP 0x2019
25208 for idx in $(seq $MDSCOUNT); do
25209 do_facet mds$idx "lctl set_param fail_loc=0x2019"
25211 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
25212 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
25213 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
25216 run_test 407 "transaction fail should cause operation fail"
25219 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
25221 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
25222 lctl set_param fail_loc=0x8000040a
25223 # let ll_prepare_partial_page() fail
25224 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
25228 # create at least 100 unused inodes so that
25229 # shrink_icache_memory(0) should not return 0
25230 touch $DIR/$tfile-{0..100}
25231 rm -f $DIR/$tfile-{0..100}
25234 echo 2 > /proc/sys/vm/drop_caches
25236 run_test 408 "drop_caches should not hang due to page leaks"
25240 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25242 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
25243 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
25244 touch $DIR/$tdir/guard || error "(2) Fail to create"
25246 local PREFIX=$(str_repeat 'A' 128)
25247 echo "Create 1K hard links start at $(date)"
25248 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25249 error "(3) Fail to hard link"
25251 echo "Links count should be right although linkEA overflow"
25252 stat $DIR/$tdir/guard || error "(4) Fail to stat"
25253 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
25254 [ $linkcount -eq 1001 ] ||
25255 error "(5) Unexpected hard links count: $linkcount"
25257 echo "List all links start at $(date)"
25258 ls -l $DIR/$tdir/foo > /dev/null ||
25259 error "(6) Fail to list $DIR/$tdir/foo"
25261 echo "Unlink hard links start at $(date)"
25262 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25263 error "(7) Fail to unlink"
25264 echo "Unlink hard links finished at $(date)"
25266 run_test 409 "Large amount of cross-MDTs hard links on the same file"
25270 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
25271 skip "Need client version at least 2.9.59"
25272 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
25273 skip "Need MODULES build"
25275 # Create a file, and stat it from the kernel
25276 local testfile=$DIR/$tfile
25279 local run_id=$RANDOM
25280 local my_ino=$(stat --format "%i" $testfile)
25282 # Try to insert the module. This will always fail as the
25283 # module is designed to not be inserted.
25284 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
25287 # Anything but success is a test failure
25289 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
25290 error "no inode match"
25292 run_test 410 "Test inode number returned from kernel thread"
25294 cleanup_test411_cgroup() {
25300 local cg_basedir=/sys/fs/cgroup/memory
25302 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
25303 skip "no setup for cgroup"
25305 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
25306 error "test file creation failed"
25307 cancel_lru_locks osc
25309 # Create a very small memory cgroup to force a slab allocation error
25310 local cgdir=$cg_basedir/osc_slab_alloc
25311 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
25312 trap "cleanup_test411_cgroup $cgdir" EXIT
25313 echo 2M > $cgdir/memory.kmem.limit_in_bytes
25314 echo 1M > $cgdir/memory.limit_in_bytes
25316 # Should not LBUG, just be killed by oom-killer
25317 # dd will return 0 even allocation failure in some environment.
25318 # So don't check return value
25319 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
25320 cleanup_test411_cgroup $cgdir
25324 run_test 411 "Slab allocation error with cgroup does not LBUG"
25327 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
25328 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
25329 skip "Need server version at least 2.10.55"
25331 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
25332 error "mkdir failed"
25333 $LFS getdirstripe $DIR/$tdir
25334 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
25335 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
25336 error "expect $((MDSCOUT - 1)) get $stripe_index"
25337 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
25338 [ $stripe_count -eq 2 ] ||
25339 error "expect 2 get $stripe_count"
25341 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
25346 # subdirs should be on the same MDT as parent
25347 for i in $(seq 0 $((MDSCOUNT - 1))); do
25348 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
25349 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
25350 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
25351 (( index == i )) || error "mdt$i/sub on MDT$index"
25354 # stripe offset -1, ditto
25355 for i in {1..10}; do
25356 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
25357 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
25358 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
25359 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
25360 (( index == index2 )) ||
25361 error "qos$i on MDT$index, sub on MDT$index2"
25364 local testdir=$DIR/$tdir/inherit
25366 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
25369 testdir=$testdir/s$i
25370 mkdir $testdir || error "mkdir $testdir failed"
25371 index=$($LFS getstripe -m $testdir)
25372 (( index == 1 )) ||
25373 error "$testdir on MDT$index"
25376 # not inherit any more
25377 testdir=$testdir/s3
25378 mkdir $testdir || error "mkdir $testdir failed"
25379 getfattr -d -m dmv $testdir | grep dmv &&
25380 error "default LMV set on $testdir" || true
25382 run_test 412 "mkdir on specific MDTs"
25384 generate_uneven_mdts() {
25386 local lmv_qos_maxage
25387 local lod_qos_maxage
25397 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25398 $LCTL set_param lmv.*.qos_maxage=1
25399 stack_trap "$LCTL set_param \
25400 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
25401 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25402 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25403 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25404 lod.*.mdt_qos_maxage=1
25405 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25406 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
25409 echo "Check for uneven MDTs: "
25411 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25412 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25413 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25415 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25416 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25419 for ((i = 1; i < ${#ffree[@]}; i++)); do
25420 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25421 if [ $tmp -gt $max ]; then
25425 if [ $tmp -lt $min ]; then
25431 (( ${ffree[min_index]} > 0 )) ||
25432 skip "no free files in MDT$min_index"
25433 (( ${ffree[min_index]} < 10000000 )) ||
25434 skip "too many free files in MDT$min_index"
25436 # Check if we need to generate uneven MDTs
25437 local diff=$(((max - min) * 100 / min))
25438 local testdir=$DIR/$tdir-fillmdt
25444 while (( diff < threshold )); do
25445 # generate uneven MDTs, create till $threshold% diff
25446 echo -n "weight diff=$diff% must be > $threshold% ..."
25447 echo "Fill MDT$min_index with 1000 files: loop $i"
25448 testdir=$DIR/$tdir-fillmdt/$i
25449 [ -d $testdir ] || $LFS mkdir -i $min_index $testdir ||
25450 error "mkdir $testdir failed"
25451 $LFS setstripe -E 1M -L mdt $testdir ||
25452 error "setstripe $testdir failed"
25454 for F in f.{0..999}; do
25455 dd if=/dev/zero of=$testdir/$F bs=64K count=1 > \
25456 /dev/null 2>&1 || error "dd $F failed"
25459 # wait for QOS to update
25460 (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
25462 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
25463 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
25464 max=$(((${ffree[max_index]} >> 8) *
25465 (${bavail[max_index]} * bsize >> 16)))
25466 min=$(((${ffree[min_index]} >> 8) *
25467 (${bavail[min_index]} * bsize >> 16)))
25468 diff=$(((max - min) * 100 / min))
25472 echo "MDT filesfree available: ${ffree[*]}"
25473 echo "MDT blocks available: ${bavail[*]}"
25474 echo "weight diff=$diff%"
25479 local stripe_count=$2
25480 local mdts=$(comma_list $(mdts_nodes))
25483 local lmv_qos_prio_free
25484 local lmv_qos_threshold_rr
25485 local lmv_qos_maxage
25486 local lod_qos_prio_free
25487 local lod_qos_threshold_rr
25488 local lod_qos_maxage
25492 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
25493 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
25494 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
25496 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
25497 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25498 stack_trap "$LCTL set_param \
25499 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
25500 stack_trap "$LCTL set_param \
25501 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
25502 stack_trap "$LCTL set_param \
25503 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
25505 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
25506 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
25507 lod_qos_prio_free=${lod_qos_prio_free%%%}
25508 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
25509 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
25510 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
25511 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25512 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25513 stack_trap "do_nodes $mdts $LCTL set_param \
25514 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
25515 stack_trap "do_nodes $mdts $LCTL set_param \
25516 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
25517 stack_trap "do_nodes $mdts $LCTL set_param \
25518 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
25520 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
25521 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
25523 testdir=$DIR/$tdir-s$stripe_count/rr
25525 local stripe_index=$($LFS getstripe -m $testdir)
25526 local test_mkdir_rr=true
25528 getfattr -d -m dmv -e hex $testdir | grep dmv
25529 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
25530 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
25531 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
25532 test_mkdir_rr=false
25537 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
25538 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
25540 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
25541 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
25542 eval $mkdir_cmd $testdir/subdir$i ||
25543 error "$mkdir_cmd subdir$i failed"
25546 for (( i = 0; i < $MDSCOUNT; i++ )); do
25547 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
25548 echo "$count directories created on MDT$i"
25549 if $test_mkdir_rr; then
25550 (( $count == 100 )) ||
25551 error "subdirs are not evenly distributed"
25552 elif (( $i == $stripe_index )); then
25553 (( $count == 100 * MDSCOUNT )) ||
25554 error "$count subdirs created on MDT$i"
25556 (( $count == 0 )) ||
25557 error "$count subdirs created on MDT$i"
25560 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
25561 count=$($LFS getdirstripe $testdir/* |
25562 grep -c -P "^\s+$i\t")
25563 echo "$count stripes created on MDT$i"
25564 # deviation should < 5% of average
25565 (( $count >= 95 * stripe_count &&
25566 $count <= 105 * stripe_count)) ||
25567 error "stripes are not evenly distributed"
25572 echo "Check for uneven MDTs: "
25582 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25583 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25584 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25586 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25587 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25590 for ((i = 1; i < ${#ffree[@]}; i++)); do
25591 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25592 if [ $tmp -gt $max ]; then
25596 if [ $tmp -lt $min ]; then
25602 (( ${ffree[min_index]} > 0 )) ||
25603 skip "no free files in MDT$min_index"
25604 (( ${ffree[min_index]} < 10000000 )) ||
25605 skip "too many free files in MDT$min_index"
25607 echo "MDT filesfree available: ${ffree[*]}"
25608 echo "MDT blocks available: ${bavail[*]}"
25609 echo "weight diff=$(((max - min) * 100 / min))%"
25611 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
25613 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
25614 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
25615 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
25616 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
25617 # decrease statfs age, so that it can be updated in time
25618 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
25619 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
25623 testdir=$DIR/$tdir-s$stripe_count/qos
25626 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
25627 for (( i = 0; i < num * MDSCOUNT; i++ )); do
25628 eval $mkdir_cmd $testdir/subdir$i ||
25629 error "$mkdir_cmd subdir$i failed"
25633 for (( i = 0; i < $MDSCOUNT; i++ )); do
25634 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
25635 (( count > max )) && max=$count
25636 echo "$count directories created on MDT$i"
25639 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
25641 # D-value should > 10% of averge
25642 (( max - min > num / 10 )) ||
25643 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
25645 # ditto for stripes
25646 if (( stripe_count > 1 )); then
25648 for (( i = 0; i < $MDSCOUNT; i++ )); do
25649 count=$($LFS getdirstripe $testdir/* |
25650 grep -c -P "^\s+$i\t")
25651 (( count > max )) && max=$count
25652 echo "$count stripes created on MDT$i"
25655 min=$($LFS getdirstripe $testdir/* |
25656 grep -c -P "^\s+$min_index\t")
25657 (( max - min > num * stripe_count / 10 )) ||
25658 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 10)) * $stripe_count"
25670 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25671 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25672 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25674 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25676 for ((i = 1; i < ${#ffree[@]}; i++)); do
25677 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25678 (( tmp < min )) && min=$tmp && min_index=$i
25685 [ $MDSCOUNT -lt 2 ] &&
25686 skip "We need at least 2 MDTs for this test"
25688 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
25689 skip "Need server version at least 2.12.52"
25693 generate_uneven_mdts 100
25694 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
25695 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
25696 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
25697 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
25698 error "mkdir failed"
25699 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
25702 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
25705 [ $MDSCOUNT -lt 2 ] &&
25706 skip "We need at least 2 MDTs for this test"
25708 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
25709 skip "Need server version at least 2.12.52"
25714 generate_uneven_mdts 100
25715 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
25716 testdir=$DIR/$tdir-s$stripe_count
25717 mkdir $testdir || error "mkdir $testdir failed"
25718 mkdir $testdir/rr || error "mkdir rr failed"
25719 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
25720 error "mkdir qos failed"
25721 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
25722 $testdir/rr || error "setdirstripe rr failed"
25723 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
25724 error "setdirstripe failed"
25725 test_qos_mkdir "mkdir" $stripe_count
25728 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
25731 (( $MDSCOUNT >= 2 )) ||
25732 skip "We need at least 2 MDTs for this test"
25734 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
25735 skip "Need server version at least 2.14.51"
25741 testdir=$DIR/${tdir}-s1
25742 mkdir $testdir || error "mkdir $testdir failed"
25743 mkdir $testdir/rr || error "mkdir rr failed"
25744 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
25745 # default max_inherit is -1, default max_inherit_rr is 0
25746 $LFS setdirstripe -D -c 1 $testdir/rr ||
25747 error "setdirstripe rr failed"
25748 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
25749 error "setdirstripe qos failed"
25750 test_qos_mkdir "mkdir" 1
25752 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
25753 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
25754 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
25755 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
25756 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
25758 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
25759 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
25760 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
25761 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
25762 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
25763 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
25764 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
25765 error "level2 shouldn't have default LMV" || true
25767 run_test 413c "mkdir with default LMV max inherit rr"
25770 (( MDSCOUNT >= 2 )) ||
25771 skip "We need at least 2 MDTs for this test"
25773 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
25774 skip "Need server version at least 2.14.51"
25776 local lmv_qos_threshold_rr
25778 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
25780 stack_trap "$LCTL set_param \
25781 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
25783 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
25784 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
25785 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
25786 error "$tdir shouldn't have default LMV"
25787 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
25788 error "mkdir sub failed"
25790 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
25792 (( count == 100 )) || error "$count subdirs on MDT0"
25794 run_test 413d "inherit ROOT default LMV"
25797 (( MDSCOUNT >= 2 )) ||
25798 skip "We need at least 2 MDTs for this test"
25799 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
25800 skip "Need server version at least 2.14.55"
25802 local testdir=$DIR/$tdir
25803 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
25805 local sub_max_inherit
25807 mkdir -p $testdir || error "failed to create $testdir"
25809 # set default max-inherit to -1 if stripe count is 0 or 1
25810 $LFS setdirstripe -D -c 1 $testdir ||
25811 error "failed to set default LMV"
25812 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
25813 (( max_inherit == -1 )) ||
25814 error "wrong max_inherit value $max_inherit"
25816 # set default max_inherit to a fixed value if stripe count is not 0 or 1
25817 $LFS setdirstripe -D -c -1 $testdir ||
25818 error "failed to set default LMV"
25819 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
25820 (( max_inherit > 0 )) ||
25821 error "wrong max_inherit value $max_inherit"
25823 # and the subdir will decrease the max_inherit by 1
25824 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
25825 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
25826 (( sub_max_inherit == max_inherit - 1)) ||
25827 error "wrong max-inherit of subdir $sub_max_inherit"
25829 # check specified --max-inherit and warning message
25830 stack_trap "rm -f $tmpfile"
25831 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
25832 error "failed to set default LMV"
25833 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
25834 (( max_inherit == -1 )) ||
25835 error "wrong max_inherit value $max_inherit"
25837 # check the warning messages
25838 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
25839 error "failed to detect warning string"
25842 run_test 413e "check default max-inherit value"
25845 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
25847 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
25848 skip "Need server version at least 2.14.55"
25850 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
25851 error "dump $DIR default LMV failed"
25852 stack_trap "setfattr --restore=$TMP/dmv.ea"
25854 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
25855 error "set $DIR default LMV failed"
25857 local testdir=$DIR/$tdir
25863 for i in $(seq 3); do
25864 mkdir $testdir || error "mkdir $testdir failed"
25865 count=$($LFS getdirstripe -D -c $testdir)
25866 (( count == 1 )) ||
25867 error "$testdir default LMV count mismatch $count != 1"
25868 inherit=$($LFS getdirstripe -D -X $testdir)
25869 (( inherit == 3 - i )) ||
25870 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
25871 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
25872 (( inherit_rr == 3 - i )) ||
25873 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
25874 testdir=$testdir/sub
25877 mkdir $testdir || error "mkdir $testdir failed"
25878 count=$($LFS getdirstripe -D -c $testdir)
25879 (( count == 0 )) ||
25880 error "$testdir default LMV count not zero: $count"
25882 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
25889 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
25890 unlinkmany $subdir/f. 1000 &
25894 for pid in $pids; do
25898 run_test 413z "413 test cleanup"
25901 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
25902 $LCTL set_param fail_loc=0x80000521
25903 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
25906 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
25909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25910 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
25911 skip "Need server version at least 2.11.52"
25921 # this test may be slow on ZFS
25922 [ "$mds1_FSTYPE" == "zfs" ] && total=50
25924 # though this test is designed for striped directory, let's test normal
25925 # directory too since lock is always saved as CoS lock.
25926 test_mkdir $DIR/$tdir || error "mkdir $tdir"
25927 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
25936 start_time=$(date +%s)
25937 for i in $(seq $total); do
25938 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
25941 end_time=$(date +%s)
25942 duration=$((end_time - start_time))
25944 kill -9 $setattr_pid
25946 echo "rename $total files took $duration sec"
25947 [ $duration -lt 100 ] || error "rename took $duration sec"
25949 run_test 415 "lock revoke is not missing"
25952 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
25953 skip "Need server version at least 2.11.55"
25955 # define OBD_FAIL_OSD_TXN_START 0x19a
25956 do_facet mds1 lctl set_param fail_loc=0x19a
25958 lfs mkdir -c $MDSCOUNT $DIR/$tdir
25962 run_test 416 "transaction start failure won't cause system hung"
25966 do_nodes $(comma_list $(mdts_nodes)) \
25967 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
25968 do_nodes $(comma_list $(mdts_nodes)) \
25969 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
25970 do_nodes $(comma_list $(mdts_nodes)) \
25971 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
25975 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25976 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
25977 skip "Need MDS version at least 2.11.56"
25979 trap cleanup_417 RETURN EXIT
25981 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
25982 do_nodes $(comma_list $(mdts_nodes)) \
25983 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
25984 $LFS migrate -m 0 $DIR/$tdir.1 &&
25985 error "migrate dir $tdir.1 should fail"
25987 do_nodes $(comma_list $(mdts_nodes)) \
25988 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
25989 $LFS mkdir -i 1 $DIR/$tdir.2 &&
25990 error "create remote dir $tdir.2 should fail"
25992 do_nodes $(comma_list $(mdts_nodes)) \
25993 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
25994 $LFS mkdir -c 2 $DIR/$tdir.3 &&
25995 error "create striped dir $tdir.3 should fail"
25998 run_test 417 "disable remote dir, striped dir and dir migration"
26000 # Checks that the outputs of df [-i] and lfs df [-i] match
26002 # usage: check_lfs_df <blocks | inodes> <mountpoint>
26012 [ "$1" == "blocks" ] && inodes= || inodes="-i"
26014 for count in {1..100}; do
26015 do_nodes "$CLIENTS" \
26016 $LCTL set_param ldlm.namespaces.*.lru_size=clear
26019 # read the lines of interest
26020 df_out=($(df -P $inodes $dir | tail -n +2)) ||
26021 error "df $inodes $dir | tail -n +2 failed"
26022 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
26023 error "lfs df $inodes $dir | grep summary: failed"
26025 # skip first substrings of each output as they are different
26026 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
26027 # compare the two outputs
26029 # skip "available" on MDT until LU-13997 is fixed.
26030 #for i in {1..5}; do
26031 for i in 1 2 4 5; do
26032 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
26040 lfs df $inodes $dir
26041 error "df and lfs df $1 output mismatch: " \
26042 "df ${inodes}: ${df_out[*]}, " \
26043 "lfs df ${inodes}: ${lfs_df_out[*]}"
26048 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26050 local dir=$DIR/$tdir
26051 local numfiles=$((RANDOM % 4096 + 2))
26052 local numblocks=$((RANDOM % 256 + 1))
26054 wait_delete_completed
26057 # check block output
26058 check_lfs_df blocks $dir
26059 # check inode output
26060 check_lfs_df inodes $dir
26062 # create a single file and retest
26063 echo "Creating a single file and testing"
26064 createmany -o $dir/$tfile- 1 &>/dev/null ||
26065 error "creating 1 file in $dir failed"
26066 check_lfs_df blocks $dir
26067 check_lfs_df inodes $dir
26069 # create a random number of files
26070 echo "Creating $((numfiles - 1)) files and testing"
26071 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
26072 error "creating $((numfiles - 1)) files in $dir failed"
26074 # write a random number of blocks to the first test file
26075 echo "Writing $numblocks 4K blocks and testing"
26076 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
26077 count=$numblocks &>/dev/null ||
26078 error "dd to $dir/${tfile}-0 failed"
26081 check_lfs_df blocks $dir
26082 check_lfs_df inodes $dir
26084 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
26085 error "unlinking $numfiles files in $dir failed"
26087 run_test 418 "df and lfs df outputs match"
26091 local dir=$DIR/$tdir
26096 cancel_lru_locks mdc
26098 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
26099 $LCTL set_param fail_loc=0x1410
26101 $LCTL set_param fail_loc=0
26104 run_test 419 "Verify open file by name doesn't crash kernel"
26108 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
26109 skip "Need MDS version at least 2.12.53"
26111 local SAVE_UMASK=$(umask)
26112 local dir=$DIR/$tdir
26113 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
26117 mkdir -m03777 $dir/testdir
26118 ls -dn $dir/testdir
26119 # Need to remove trailing '.' when SELinux is enabled
26120 local dirperms=$(ls -dn $dir/testdir |
26121 awk '{ sub(/\.$/, "", $1); print $1}')
26122 [ $dirperms == "drwxrwsrwt" ] ||
26123 error "incorrect perms on $dir/testdir"
26125 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
26126 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
26127 ls -n $dir/testdir/testfile
26128 local fileperms=$(ls -n $dir/testdir/testfile |
26129 awk '{ sub(/\.$/, "", $1); print $1}')
26130 [ $fileperms == "-rwxr-xr-x" ] ||
26131 error "incorrect perms on $dir/testdir/testfile"
26135 run_test 420 "clear SGID bit on non-directories for non-members"
26142 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26143 skip "Need MDS version at least 2.12.54"
26145 test_mkdir $DIR/$tdir
26146 createmany -o $DIR/$tdir/f 3
26147 cnt=$(ls -1 $DIR/$tdir | wc -l)
26148 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26150 fid1=$(lfs path2fid $DIR/$tdir/f1)
26151 fid2=$(lfs path2fid $DIR/$tdir/f2)
26152 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
26154 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
26155 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
26157 cnt=$(ls -1 $DIR/$tdir | wc -l)
26158 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26160 rm -f $DIR/$tdir/f3 || error "can't remove f3"
26161 createmany -o $DIR/$tdir/f 3
26162 cnt=$(ls -1 $DIR/$tdir | wc -l)
26163 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26165 fid1=$(lfs path2fid $DIR/$tdir/f1)
26166 fid2=$(lfs path2fid $DIR/$tdir/f2)
26167 echo "remove using fsname $FSNAME"
26168 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
26170 cnt=$(ls -1 $DIR/$tdir | wc -l)
26171 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26173 run_test 421a "simple rm by fid"
26180 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26181 skip "Need MDS version at least 2.12.54"
26183 test_mkdir $DIR/$tdir
26184 createmany -o $DIR/$tdir/f 3
26185 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
26188 FID1=$(lfs path2fid $DIR/$tdir/f1)
26189 FID2=$(lfs path2fid $DIR/$tdir/f2)
26190 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
26192 kill -USR1 $MULTIPID
26195 cnt=$(ls $DIR/$tdir | wc -l)
26196 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
26198 run_test 421b "rm by fid on open file"
26204 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26205 skip "Need MDS version at least 2.12.54"
26207 test_mkdir $DIR/$tdir
26208 createmany -o $DIR/$tdir/f 3
26209 touch $DIR/$tdir/$tfile
26210 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
26211 cnt=$(ls -1 $DIR/$tdir | wc -l)
26212 [ $cnt != 184 ] && error "unexpected #files: $cnt"
26214 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
26215 $LFS rmfid $DIR $FID1 || error "rmfid failed"
26217 cnt=$(ls $DIR/$tdir | wc -l)
26218 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
26220 run_test 421c "rm by fid against hardlinked files"
26226 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26227 skip "Need MDS version at least 2.12.54"
26229 test_mkdir $DIR/$tdir
26230 createmany -o $DIR/$tdir/f 4097
26231 cnt=$(ls -1 $DIR/$tdir | wc -l)
26232 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
26234 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
26235 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26237 cnt=$(ls $DIR/$tdir | wc -l)
26239 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26241 run_test 421d "rmfid en masse"
26247 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26248 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26249 skip "Need MDS version at least 2.12.54"
26251 mkdir -p $DIR/$tdir
26252 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26253 createmany -o $DIR/$tdir/striped_dir/f 512
26254 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26255 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26257 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26258 sed "s/[/][^:]*://g")
26259 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26261 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
26263 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26265 run_test 421e "rmfid in DNE"
26271 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26272 skip "Need MDS version at least 2.12.54"
26274 test_mkdir $DIR/$tdir
26276 cnt=$(ls -1 $DIR/$tdir | wc -l)
26277 [ $cnt != 1 ] && error "unexpected #files: $cnt"
26279 FID=$(lfs path2fid $DIR/$tdir/f)
26280 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
26281 # rmfid should fail
26282 cnt=$(ls -1 $DIR/$tdir | wc -l)
26283 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
26285 chmod a+rw $DIR/$tdir
26287 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
26288 # rmfid should fail
26289 cnt=$(ls -1 $DIR/$tdir | wc -l)
26290 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
26293 $RUNAS touch $DIR/$tdir/f
26294 FID=$(lfs path2fid $DIR/$tdir/f)
26295 echo "rmfid as root"
26296 $LFS rmfid $DIR $FID || error "rmfid as root failed"
26297 cnt=$(ls -1 $DIR/$tdir | wc -l)
26298 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
26301 $RUNAS touch $DIR/$tdir/f
26302 cnt=$(ls -1 $DIR/$tdir | wc -l)
26303 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
26304 FID=$(lfs path2fid $DIR/$tdir/f)
26305 # rmfid w/o user_fid2path mount option should fail
26306 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
26307 cnt=$(ls -1 $DIR/$tdir | wc -l)
26308 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
26310 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
26311 stack_trap "rmdir $tmpdir"
26312 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
26313 error "failed to mount client'"
26314 stack_trap "umount_client $tmpdir"
26316 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
26317 # rmfid should succeed
26318 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
26319 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
26321 # rmfid shouldn't allow to remove files due to dir's permission
26322 chmod a+rwx $tmpdir/$tdir
26323 touch $tmpdir/$tdir/f
26324 ls -la $tmpdir/$tdir
26325 FID=$(lfs path2fid $tmpdir/$tdir/f)
26326 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
26329 run_test 421f "rmfid checks permissions"
26335 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26336 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26337 skip "Need MDS version at least 2.12.54"
26339 mkdir -p $DIR/$tdir
26340 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26341 createmany -o $DIR/$tdir/striped_dir/f 512
26342 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26343 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26345 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26346 sed "s/[/][^:]*://g")
26348 rm -f $DIR/$tdir/striped_dir/f1*
26349 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26350 removed=$((512 - cnt))
26352 # few files have been just removed, so we expect
26353 # rmfid to fail on their fids
26354 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
26355 [ $removed != $errors ] && error "$errors != $removed"
26357 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
26359 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26361 run_test 421g "rmfid to return errors properly"
26364 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
26365 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
26366 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
26367 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
26368 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
26370 local amc=$(at_max_get client)
26371 local amo=$(at_max_get mds1)
26372 local timeout=`lctl get_param -n timeout`
26374 at_max_set 0 client
26377 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
26378 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
26379 fail_val=$(((2*timeout + 10)*1000))
26380 touch $DIR/$tdir/d3/file &
26382 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
26383 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
26384 fail_val=$((2*timeout + 5))
26385 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
26389 sleep $((2 * timeout))
26393 touch $DIR/$tdir/d2/file3
26394 touch $DIR/$tdir/d2/file4
26395 touch $DIR/$tdir/d2/file5
26398 at_max_set $amc client
26399 at_max_set $amo mds1
26401 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
26402 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
26403 error "Watchdog is always throttled"
26405 run_test 422 "kill a process with RPC in progress"
26418 # ensure statfs cache is expired
26421 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
26422 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
26426 run_test 423 "statfs should return a right data"
26429 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
26430 $LCTL set_param fail_loc=0x80000522
26431 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
26434 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
26437 test_mkdir -c -1 $DIR/$tdir
26438 $LFS setstripe -c -1 $DIR/$tdir
26440 lru_resize_disable "" 100
26441 stack_trap "lru_resize_enable" EXIT
26445 for i in $(seq $((MDSCOUNT * 125))); do
26446 local t=$DIR/$tdir/$tfile_$i
26448 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
26449 error_noexit "Create file $t"
26451 stack_trap "rm -rf $DIR/$tdir" EXIT
26453 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
26454 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
26455 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
26457 [ $lock_count -le $lru_size ] ||
26458 error "osc lock count $lock_count > lru size $lru_size"
26461 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
26462 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
26463 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
26465 [ $lock_count -le $lru_size ] ||
26466 error "mdc lock count $lock_count > lru size $lru_size"
26469 run_test 425 "lock count should not exceed lru size"
26472 splice-test -r $DIR/$tfile
26473 splice-test -rd $DIR/$tfile
26474 splice-test $DIR/$tfile
26475 splice-test -d $DIR/$tfile
26477 run_test 426 "splice test on Lustre"
26480 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
26481 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
26482 skip "Need MDS version at least 2.12.4"
26488 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
26489 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
26491 $LFS getdirstripe $DIR/$tdir/1/dir
26493 #first setfattr for creating updatelog
26494 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
26496 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
26497 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
26498 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
26499 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
26503 wait_recovery_complete mds2 $((2*TIMEOUT))
26505 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
26506 echo $log | grep "get update log failed" &&
26507 error "update log corruption is detected" || true
26509 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
26512 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26513 local cache_limit=$CACHE_MAX
26515 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
26516 $LCTL set_param -n llite.*.max_cached_mb=64
26519 $LFS setstripe -c 1 $DIR/$tdir
26520 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
26521 stack_trap "rm -f $DIR/$tdir/$tfile.*"
26523 for f in $(seq 4); do
26524 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
26528 cancel_lru_locks osc
26530 for f in $(seq 4); do
26531 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
26535 run_test 428 "large block size IO should not hang"
26537 test_429() { # LU-7915 / LU-10948
26538 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
26539 local testfile=$DIR/$tfile
26540 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
26546 $LCTL get_param $ll_opencache_threshold_count ||
26547 skip "client does not have opencache parameter"
26549 set_opencache $new_flag
26550 stack_trap "restore_opencache"
26551 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
26552 error "enable opencache failed"
26554 # drop MDC DLM locks
26555 cancel_lru_locks mdc
26556 # clear MDC RPC stats counters
26557 $LCTL set_param $mdc_rpcstats=clear
26559 # According to the current implementation, we need to run 3 times
26560 # open & close file to verify if opencache is enabled correctly.
26561 # 1st, RPCs are sent for lookup/open and open handle is released on
26563 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
26564 # so open handle won't be released thereafter.
26565 # 3rd, No RPC is sent out.
26566 $MULTIOP $testfile oc || error "multiop failed"
26567 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
26568 echo "1st: $first_rpc RPCs in flight"
26570 $MULTIOP $testfile oc || error "multiop failed"
26571 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
26572 echo "2nd: $second_rpc RPCs in flight"
26574 $MULTIOP $testfile oc || error "multiop failed"
26575 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
26576 echo "3rd: $third_rpc RPCs in flight"
26578 #verify no MDC RPC is sent
26579 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
26581 run_test 429 "verify if opencache flag on client side does work"
26587 # data at [200K, 400K)
26588 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
26589 error "256K->512K dd fails"
26591 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
26592 error "2M->3M dd fails"
26594 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
26595 error "4M->5M dd fails"
26596 echo "Data at 256K...512K, 2M...3M and 4M...5M"
26597 # start at first component hole #1
26598 printf "Seeking hole from 1000 ... "
26599 offset=$(lseek_test -l 1000 $file)
26601 [[ $offset == 1000 ]] || error "offset $offset != 1000"
26602 printf "Seeking data from 1000 ... "
26603 offset=$(lseek_test -d 1000 $file)
26605 [[ $offset == 262144 ]] || error "offset $offset != 262144"
26607 # start at first component data block
26608 printf "Seeking hole from 300000 ... "
26609 offset=$(lseek_test -l 300000 $file)
26611 [[ $offset == 524288 ]] || error "offset $offset != 524288"
26612 printf "Seeking data from 300000 ... "
26613 offset=$(lseek_test -d 300000 $file)
26615 [[ $offset == 300000 ]] || error "offset $offset != 300000"
26617 # start at the first component but beyond end of object size
26618 printf "Seeking hole from 1000000 ... "
26619 offset=$(lseek_test -l 1000000 $file)
26621 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
26622 printf "Seeking data from 1000000 ... "
26623 offset=$(lseek_test -d 1000000 $file)
26625 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
26627 # start at second component stripe 2 (empty file)
26628 printf "Seeking hole from 1500000 ... "
26629 offset=$(lseek_test -l 1500000 $file)
26631 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
26632 printf "Seeking data from 1500000 ... "
26633 offset=$(lseek_test -d 1500000 $file)
26635 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
26637 # start at second component stripe 1 (all data)
26638 printf "Seeking hole from 3000000 ... "
26639 offset=$(lseek_test -l 3000000 $file)
26641 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
26642 printf "Seeking data from 3000000 ... "
26643 offset=$(lseek_test -d 3000000 $file)
26645 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
26647 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
26648 error "2nd dd fails"
26649 echo "Add data block at 640K...1280K"
26651 # start at before new data block, in hole
26652 printf "Seeking hole from 600000 ... "
26653 offset=$(lseek_test -l 600000 $file)
26655 [[ $offset == 600000 ]] || error "offset $offset != 600000"
26656 printf "Seeking data from 600000 ... "
26657 offset=$(lseek_test -d 600000 $file)
26659 [[ $offset == 655360 ]] || error "offset $offset != 655360"
26661 # start at the first component new data block
26662 printf "Seeking hole from 1000000 ... "
26663 offset=$(lseek_test -l 1000000 $file)
26665 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
26666 printf "Seeking data from 1000000 ... "
26667 offset=$(lseek_test -d 1000000 $file)
26669 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
26671 # start at second component stripe 2, new data
26672 printf "Seeking hole from 1200000 ... "
26673 offset=$(lseek_test -l 1200000 $file)
26675 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
26676 printf "Seeking data from 1200000 ... "
26677 offset=$(lseek_test -d 1200000 $file)
26679 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
26681 # start beyond file end
26682 printf "Using offset > filesize ... "
26683 lseek_test -l 4000000 $file && error "lseek should fail"
26684 printf "Using offset > filesize ... "
26685 lseek_test -d 4000000 $file && error "lseek should fail"
26691 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
26692 skip "MDT does not support SEEK_HOLE"
26694 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
26695 skip "OST does not support SEEK_HOLE"
26697 local file=$DIR/$tdir/$tfile
26699 mkdir -p $DIR/$tdir
26701 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
26702 # OST stripe #1 will have continuous data at [1M, 3M)
26703 # OST stripe #2 is empty
26704 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
26705 lseek_test_430 $file
26707 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
26708 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
26709 lseek_test_430 $file
26711 $LFS setstripe -c2 -S 512K $file
26712 echo "Two stripes, stripe size 512K"
26713 lseek_test_430 $file
26715 # FLR with stale mirror
26716 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
26718 echo "Mirrored file:"
26719 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
26720 echo "Plain 2 stripes 1M"
26721 lseek_test_430 $file
26724 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
26727 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
26728 skip "OST does not support SEEK_HOLE"
26731 local file=$DIR/$tdir/$tfile
26733 mkdir -p $DIR/$tdir
26734 # Empty layout lseek should fail
26737 printf "Seeking hole from 0 ... "
26738 lseek_test -l 0 $file && error "lseek should fail"
26739 printf "Seeking data from 0 ... "
26740 lseek_test -d 0 $file && error "lseek should fail"
26744 $LFS setstripe -E 1M -c2 -E eof $file
26745 $TRUNCATE $file 1048576
26746 printf "Seeking hole from 1000000 ... "
26747 offset=$(lseek_test -l 1000000 $file)
26749 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
26750 printf "Seeking data from 1000000 ... "
26751 lseek_test -d 1000000 $file && error "lseek should fail"
26754 # full component followed by non-inited one
26755 $LFS setstripe -E 1M -c2 -E eof $file
26756 dd if=/dev/urandom of=$file bs=1M count=1
26757 printf "Seeking hole from 1000000 ... "
26758 offset=$(lseek_test -l 1000000 $file)
26760 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
26761 printf "Seeking hole from 1048576 ... "
26762 lseek_test -l 1048576 $file && error "lseek should fail"
26763 # init second component and truncate back
26764 echo "123" >> $file
26765 $TRUNCATE $file 1048576
26766 printf "Seeking hole from 1000000 ... "
26767 offset=$(lseek_test -l 1000000 $file)
26769 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
26770 printf "Seeking hole from 1048576 ... "
26771 lseek_test -l 1048576 $file && error "lseek should fail"
26772 # boundary checks for big values
26773 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
26774 offset=$(lseek_test -d 0 $file.10g)
26775 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
26776 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
26777 offset=$(lseek_test -d 0 $file.100g)
26778 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
26781 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
26784 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
26785 skip "OST does not support SEEK_HOLE"
26787 local file=$DIR/$tdir/$tfile
26790 mkdir -p $DIR/$tdir
26791 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
26793 # cp version 8.33+ prefers lseek over fiemap
26794 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
26796 time cp $file /dev/null
26797 (( SECONDS - start < 5 )) ||
26798 error "cp: too long runtime $((SECONDS - start))"
26801 # tar version 1.29+ supports SEEK_HOLE/DATA
26802 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
26804 time tar cS $file - | cat > /dev/null
26805 (( SECONDS - start < 5 )) ||
26806 error "tar: too long runtime $((SECONDS - start))"
26809 run_test 430c "lseek: external tools check"
26811 test_431() { # LU-14187
26812 local file=$DIR/$tdir/$tfile
26814 mkdir -p $DIR/$tdir
26815 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
26816 dd if=/dev/urandom of=$file bs=4k count=1
26817 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
26818 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
26819 #define OBD_FAIL_OST_RESTART_IO 0x251
26820 do_facet ost1 "$LCTL set_param fail_loc=0x251"
26821 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
26825 echo 3 > /proc/sys/vm/drop_caches
26826 diff $file $file.0 || error "data diff"
26828 run_test 431 "Restart transaction for IO"
26830 cleanup_test_432() {
26831 do_facet mgs $LCTL nodemap_activate 0
26832 wait_nm_sync active
26836 local tmpdir=$TMP/dir432
26838 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
26839 skip "Need MDS version at least 2.14.52"
26841 stack_trap cleanup_test_432 EXIT
26845 do_facet mgs $LCTL nodemap_activate 1
26846 wait_nm_sync active
26847 do_facet mgs $LCTL nodemap_modify --name default \
26848 --property admin --value 1
26849 do_facet mgs $LCTL nodemap_modify --name default \
26850 --property trusted --value 1
26851 cancel_lru_locks mdc
26852 wait_nm_sync default admin_nodemap
26853 wait_nm_sync default trusted_nodemap
26855 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
26856 grep -ci "Operation not permitted") -ne 0 ]; then
26857 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
26860 run_test 432 "mv dir from outside Lustre"
26863 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
26864 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
26865 skip "Need server version at least 2.9.55"
26867 start_full_debug_logging
26871 stop_full_debug_logging
26875 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
26876 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
26877 awk '/The barrier for/ { print $7 }')
26880 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
26885 barrier_expired() {
26888 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
26889 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
26890 awk '/will be expired/ { print $7 }')
26892 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
26901 echo "Start barrier_freeze at: $(date)"
26902 #define OBD_FAIL_BARRIER_DELAY 0x2202
26903 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
26904 # Do not reduce barrier time - See LU-11873
26905 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
26908 local b_status=$(barrier_stat)
26909 echo "Got barrier status at: $(date)"
26910 [ "$b_status" = "'freezing_p1'" ] ||
26911 error "(1) unexpected barrier status $b_status"
26913 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
26915 b_status=$(barrier_stat)
26916 [ "$b_status" = "'frozen'" ] ||
26917 error "(2) unexpected barrier status $b_status"
26919 local expired=$(barrier_expired)
26920 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
26921 sleep $((expired + 3))
26923 b_status=$(barrier_stat)
26924 [ "$b_status" = "'expired'" ] ||
26925 error "(3) unexpected barrier status $b_status"
26927 # Do not reduce barrier time - See LU-11873
26928 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
26929 error "(4) fail to freeze barrier"
26931 b_status=$(barrier_stat)
26932 [ "$b_status" = "'frozen'" ] ||
26933 error "(5) unexpected barrier status $b_status"
26935 echo "Start barrier_thaw at: $(date)"
26936 #define OBD_FAIL_BARRIER_DELAY 0x2202
26937 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
26938 do_facet mgs $LCTL barrier_thaw $FSNAME &
26941 b_status=$(barrier_stat)
26942 echo "Got barrier status at: $(date)"
26943 [ "$b_status" = "'thawing'" ] ||
26944 error "(6) unexpected barrier status $b_status"
26946 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
26948 b_status=$(barrier_stat)
26949 [ "$b_status" = "'thawed'" ] ||
26950 error "(7) unexpected barrier status $b_status"
26952 #define OBD_FAIL_BARRIER_FAILURE 0x2203
26953 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
26954 do_facet mgs $LCTL barrier_freeze $FSNAME
26956 b_status=$(barrier_stat)
26957 [ "$b_status" = "'failed'" ] ||
26958 error "(8) unexpected barrier status $b_status"
26960 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
26961 do_facet mgs $LCTL barrier_thaw $FSNAME
26965 run_test 801a "write barrier user interfaces and stat machine"
26970 mkdir $DIR/$tdir || error "(1) fail to mkdir"
26971 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
26972 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
26973 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
26974 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
26976 cancel_lru_locks mdc
26978 # 180 seconds should be long enough
26979 do_facet mgs $LCTL barrier_freeze $FSNAME 180
26981 local b_status=$(barrier_stat)
26982 [ "$b_status" = "'frozen'" ] ||
26983 error "(6) unexpected barrier status $b_status"
26985 mkdir $DIR/$tdir/d0/d10 &
26988 touch $DIR/$tdir/d1/f13 &
26991 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
26994 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
26997 rm -f $DIR/$tdir/d4/f12 &
27000 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
27002 # To guarantee taht the 'stat' is not blocked
27003 b_status=$(barrier_stat)
27004 [ "$b_status" = "'frozen'" ] ||
27005 error "(8) unexpected barrier status $b_status"
27007 # let above commands to run at background
27010 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
27011 ps -p $touch_pid || error "(10) touch should be blocked"
27012 ps -p $ln_pid || error "(11) link should be blocked"
27013 ps -p $mv_pid || error "(12) rename should be blocked"
27014 ps -p $rm_pid || error "(13) unlink should be blocked"
27016 b_status=$(barrier_stat)
27017 [ "$b_status" = "'frozen'" ] ||
27018 error "(14) unexpected barrier status $b_status"
27020 do_facet mgs $LCTL barrier_thaw $FSNAME
27021 b_status=$(barrier_stat)
27022 [ "$b_status" = "'thawed'" ] ||
27023 error "(15) unexpected barrier status $b_status"
27025 wait $mkdir_pid || error "(16) mkdir should succeed"
27026 wait $touch_pid || error "(17) touch should succeed"
27027 wait $ln_pid || error "(18) link should succeed"
27028 wait $mv_pid || error "(19) rename should succeed"
27029 wait $rm_pid || error "(20) unlink should succeed"
27033 run_test 801b "modification will be blocked by write barrier"
27036 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27040 stop mds2 || error "(1) Fail to stop mds2"
27042 do_facet mgs $LCTL barrier_freeze $FSNAME 30
27044 local b_status=$(barrier_stat)
27045 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
27046 do_facet mgs $LCTL barrier_thaw $FSNAME
27047 error "(2) unexpected barrier status $b_status"
27050 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27051 error "(3) Fail to rescan barrier bitmap"
27053 # Do not reduce barrier time - See LU-11873
27054 do_facet mgs $LCTL barrier_freeze $FSNAME 20
27056 b_status=$(barrier_stat)
27057 [ "$b_status" = "'frozen'" ] ||
27058 error "(4) unexpected barrier status $b_status"
27060 do_facet mgs $LCTL barrier_thaw $FSNAME
27061 b_status=$(barrier_stat)
27062 [ "$b_status" = "'thawed'" ] ||
27063 error "(5) unexpected barrier status $b_status"
27065 local devname=$(mdsdevname 2)
27067 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
27069 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27070 error "(7) Fail to rescan barrier bitmap"
27074 run_test 801c "rescan barrier bitmap"
27076 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
27077 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
27078 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
27079 saved_MOUNT_OPTS=$MOUNT_OPTS
27085 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
27086 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
27087 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
27088 MOUNT_OPTS=$saved_MOUNT_OPTS
27093 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
27094 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27095 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27096 skip "Need server version at least 2.9.55"
27098 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
27100 mkdir $DIR/$tdir || error "(1) fail to mkdir"
27102 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27103 error "(2) Fail to copy"
27105 trap cleanup_802a EXIT
27107 # sync by force before remount as readonly
27108 sync; sync_all_data; sleep 3; sync_all_data
27112 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
27113 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
27114 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
27116 echo "Mount the server as read only"
27117 setupall server_only || error "(3) Fail to start servers"
27119 echo "Mount client without ro should fail"
27120 mount_client $MOUNT &&
27121 error "(4) Mount client without 'ro' should fail"
27123 echo "Mount client with ro should succeed"
27124 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
27125 mount_client $MOUNT ||
27126 error "(5) Mount client with 'ro' should succeed"
27128 echo "Modify should be refused"
27129 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27131 echo "Read should be allowed"
27132 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27133 error "(7) Read should succeed under ro mode"
27137 run_test 802a "simulate readonly device"
27140 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27141 remote_mds_nodsh && skip "remote MDS with nodsh"
27143 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
27144 skip "readonly option not available"
27146 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
27148 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27149 error "(2) Fail to copy"
27151 # write back all cached data before setting MDT to readonly
27155 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
27156 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
27158 echo "Modify should be refused"
27159 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27161 echo "Read should be allowed"
27162 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27163 error "(7) Read should succeed under ro mode"
27166 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
27168 run_test 802b "be able to set MDTs to readonly"
27171 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27172 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27173 skip "MDS needs to be newer than 2.10.54"
27175 mkdir_on_mdt0 $DIR/$tdir
27176 # Create some objects on all MDTs to trigger related logs objects
27177 for idx in $(seq $MDSCOUNT); do
27178 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
27179 $DIR/$tdir/dir${idx} ||
27180 error "Fail to create $DIR/$tdir/dir${idx}"
27184 wait_delete_completed # ensure old test cleanups are finished
27185 echo "before create:"
27187 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27189 for i in {1..10}; do
27190 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
27191 error "Fail to create $DIR/$tdir/foo$i"
27195 echo "after create:"
27197 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27199 # allow for an llog to be cleaned up during the test
27200 [ $after_used -ge $((before_used + 10 - 1)) ] ||
27201 error "before ($before_used) + 10 > after ($after_used)"
27203 for i in {1..10}; do
27204 rm -rf $DIR/$tdir/foo$i ||
27205 error "Fail to remove $DIR/$tdir/foo$i"
27208 sleep 3 # avoid MDT return cached statfs
27209 wait_delete_completed
27210 echo "after unlink:"
27212 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27214 # allow for an llog to be created during the test
27215 [ $after_used -le $((before_used + 1)) ] ||
27216 error "after ($after_used) > before ($before_used) + 1"
27218 run_test 803a "verify agent object for remote object"
27221 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27222 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
27223 skip "MDS needs to be newer than 2.13.56"
27224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27226 for i in $(seq 0 $((MDSCOUNT - 1))); do
27227 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
27235 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27236 for i in $(seq 0 $((MDSCOUNT - 1))); do
27237 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27238 awk '/getattr/ { print $2 }')
27239 before=$((before + tmp))
27241 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27242 for i in $(seq 0 $((MDSCOUNT - 1))); do
27243 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27244 awk '/getattr/ { print $2 }')
27245 after=$((after + tmp))
27248 [ $before -eq $after ] || error "getattr count $before != $after"
27250 run_test 803b "remote object can getattr from cache"
27253 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27254 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27255 skip "MDS needs to be newer than 2.10.54"
27256 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
27258 mkdir -p $DIR/$tdir
27259 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
27260 error "Fail to create $DIR/$tdir/dir0"
27262 local fid=$($LFS path2fid $DIR/$tdir/dir0)
27263 local dev=$(mdsdevname 2)
27265 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27266 grep ${fid} || error "NOT found agent entry for dir0"
27268 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
27269 error "Fail to create $DIR/$tdir/dir1"
27271 touch $DIR/$tdir/dir1/foo0 ||
27272 error "Fail to create $DIR/$tdir/dir1/foo0"
27273 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
27276 for idx in $(seq $MDSCOUNT); do
27277 dev=$(mdsdevname $idx)
27278 do_facet mds${idx} \
27279 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27280 grep ${fid} && rc=$idx
27283 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
27284 error "Fail to rename foo0 to foo1"
27285 if [ $rc -eq 0 ]; then
27286 for idx in $(seq $MDSCOUNT); do
27287 dev=$(mdsdevname $idx)
27288 do_facet mds${idx} \
27289 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27290 grep ${fid} && rc=$idx
27294 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
27295 error "Fail to rename foo1 to foo2"
27296 if [ $rc -eq 0 ]; then
27297 for idx in $(seq $MDSCOUNT); do
27298 dev=$(mdsdevname $idx)
27299 do_facet mds${idx} \
27300 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27301 grep ${fid} && rc=$idx
27305 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
27307 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
27308 error "Fail to link to $DIR/$tdir/dir1/foo2"
27309 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
27310 error "Fail to rename foo2 to foo0"
27311 unlink $DIR/$tdir/dir1/foo0 ||
27312 error "Fail to unlink $DIR/$tdir/dir1/foo0"
27313 rm -rf $DIR/$tdir/dir0 ||
27314 error "Fail to rm $DIR/$tdir/dir0"
27316 for idx in $(seq $MDSCOUNT); do
27320 dev=$(mdsdevname $idx)
27321 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
27323 start mds${idx} $dev $MDS_MOUNT_OPTS ||
27324 error "mount mds$idx failed"
27325 df $MOUNT > /dev/null 2>&1
27327 # e2fsck should not return error
27329 error "e2fsck detected error on MDT${idx}: rc=$rc"
27332 run_test 804 "verify agent entry for remote entry"
27335 do_facet $SINGLEMDS zfs set quota=$old $fsset
27336 unlinkmany $DIR/$tdir/f- 1000000
27341 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
27342 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
27343 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
27344 skip "netfree not implemented before 0.7"
27345 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
27346 skip "Need MDS version at least 2.10.57"
27353 local pref="osd-zfs.$FSNAME-MDT0000."
27355 # limit available space on MDS dataset to meet nospace issue
27356 # quickly. then ZFS 0.7.2 can use reserved space if asked
27357 # properly (using netfree flag in osd_declare_destroy()
27358 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
27359 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
27361 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
27362 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
27363 let "usedkb=usedkb-freekb"
27364 let "freekb=freekb/2"
27365 if let "freekb > 5000"; then
27368 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
27369 trap cleanup_805 EXIT
27370 mkdir_on_mdt0 $DIR/$tdir
27371 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
27372 error "Can't set PFL layout"
27373 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
27374 rm -rf $DIR/$tdir || error "not able to remove"
27375 do_facet $SINGLEMDS zfs set quota=$old $fsset
27378 run_test 805 "ZFS can remove from full fs"
27384 local expect=$(stat -c %s $file)
27386 check_lsom_size $1 $expect
27388 local blocks=$($LFS getsom -b $file)
27389 expect=$(stat -c %b $file)
27390 [[ $blocks == $expect ]] ||
27391 error "$file expected blocks: $expect, got: $blocks"
27399 cancel_lru_locks mdc
27401 size=$($LFS getsom -s $1)
27402 [[ $size == $expect ]] ||
27403 error "$file expected size: $expect, got: $size"
27407 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
27408 skip "Need MDS version at least 2.11.52"
27412 touch $DIR/$tfile || error "touch $tfile failed"
27414 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
27415 save_lustre_params client "llite.*.xattr_cache" > $save
27416 lctl set_param llite.*.xattr_cache=0
27417 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
27419 # single-threaded write
27420 echo "Test SOM for single-threaded write"
27421 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
27422 error "write $tfile failed"
27423 check_lsom_size $DIR/$tfile $bs
27426 local size=$(($num * $bs))
27430 echo "Test SOM for single client multi-threaded($num) write"
27431 $TRUNCATE $DIR/$tfile 0
27432 for ((i = 0; i < $num; i++)); do
27433 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27435 offset=$((offset + $bs))
27437 for (( i=0; i < $num; i++ )); do
27440 check_lsom_size $DIR/$tfile $size
27442 $TRUNCATE $DIR/$tfile 0
27443 for ((i = 0; i < $num; i++)); do
27444 offset=$((offset - $bs))
27445 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27448 for (( i=0; i < $num; i++ )); do
27451 check_lsom_size $DIR/$tfile $size
27453 # multi-client writes
27454 num=$(get_node_count ${CLIENTS//,/ })
27455 size=$(($num * $bs))
27459 echo "Test SOM for multi-client ($num) writes"
27460 $TRUNCATE $DIR/$tfile 0
27461 for client in ${CLIENTS//,/ }; do
27462 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27465 offset=$((offset + $bs))
27467 for (( i=0; i < $num; i++ )); do
27470 check_lsom_size $DIR/$tfile $offset
27473 $TRUNCATE $DIR/$tfile 0
27474 for client in ${CLIENTS//,/ }; do
27475 offset=$((offset - $bs))
27476 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27480 for (( i=0; i < $num; i++ )); do
27483 check_lsom_size $DIR/$tfile $size
27486 echo "Test SOM for truncate"
27487 $TRUNCATE $DIR/$tfile 1048576
27488 check_lsom_size $DIR/$tfile 1048576
27489 $TRUNCATE $DIR/$tfile 1234
27490 check_lsom_size $DIR/$tfile 1234
27492 # verify SOM blocks count
27493 echo "Verify SOM block count"
27494 $TRUNCATE $DIR/$tfile 0
27495 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
27496 error "failed to write file $tfile"
27497 check_lsom_data $DIR/$tfile
27499 run_test 806 "Verify Lazy Size on MDS"
27502 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
27503 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
27504 skip "Need MDS version at least 2.11.52"
27506 # Registration step
27507 changelog_register || error "changelog_register failed"
27508 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
27509 changelog_users $SINGLEMDS | grep -q $cl_user ||
27510 error "User $cl_user not found in changelog_users"
27512 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
27513 save_lustre_params client "llite.*.xattr_cache" > $save
27514 lctl set_param llite.*.xattr_cache=0
27515 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
27517 rm -rf $DIR/$tdir || error "rm $tdir failed"
27518 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
27519 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
27520 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
27521 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
27522 error "truncate $tdir/trunc failed"
27525 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
27526 error "write $tfile failed"
27528 # multi-client wirtes
27529 local num=$(get_node_count ${CLIENTS//,/ })
27533 echo "Test SOM for multi-client ($num) writes"
27534 touch $DIR/$tfile || error "touch $tfile failed"
27535 $TRUNCATE $DIR/$tfile 0
27536 for client in ${CLIENTS//,/ }; do
27537 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27540 offset=$((offset + $bs))
27542 for (( i=0; i < $num; i++ )); do
27546 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
27547 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
27548 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
27549 check_lsom_data $DIR/$tdir/trunc
27550 check_lsom_data $DIR/$tdir/single_dd
27551 check_lsom_data $DIR/$tfile
27554 # Deregistration step
27555 changelog_deregister || error "changelog_deregister failed"
27557 run_test 807 "verify LSOM syncing tool"
27559 check_som_nologged()
27561 local lines=$($LFS changelog $FSNAME-MDT0000 |
27562 grep 'x=trusted.som' | wc -l)
27563 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
27567 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
27568 skip "Need MDS version at least 2.11.55"
27570 # Registration step
27571 changelog_register || error "changelog_register failed"
27573 touch $DIR/$tfile || error "touch $tfile failed"
27576 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
27577 error "write $tfile failed"
27580 $TRUNCATE $DIR/$tfile 1234
27583 $TRUNCATE $DIR/$tfile 1048576
27586 # Deregistration step
27587 changelog_deregister || error "changelog_deregister failed"
27589 run_test 808 "Check trusted.som xattr not logged in Changelogs"
27594 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
27598 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
27599 skip "Need MDS version at least 2.11.56"
27601 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
27602 error "failed to create DoM-only file $DIR/$tfile"
27603 touch $DIR/$tfile || error "touch $tfile failed"
27604 check_som_nodata $DIR/$tfile
27606 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
27607 error "write $tfile failed"
27608 check_som_nodata $DIR/$tfile
27610 $TRUNCATE $DIR/$tfile 1234
27611 check_som_nodata $DIR/$tfile
27613 $TRUNCATE $DIR/$tfile 4097
27614 check_som_nodata $DIR/$file
27616 run_test 809 "Verify no SOM xattr store for DoM-only files"
27619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27620 $GSS && skip_env "could not run with gss"
27621 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
27622 skip "OST < 2.12.58 doesn't align checksum"
27625 stack_trap "set_checksums $ORIG_CSUM" EXIT
27626 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
27631 for csum in $CKSUM_TYPES; do
27632 #define OBD_FAIL_OSC_NO_GRANT 0x411
27633 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
27634 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
27636 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
27637 before=$(md5sum $DIR/$tfile)
27638 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
27639 after=$(md5sum $DIR/$tfile)
27640 [ "$before" == "$after" ] ||
27641 error "$csum: $before != $after bs=$1 seek=$2"
27645 run_test 810 "partial page writes on ZFS (LU-11663)"
27648 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
27649 skip "OST < 2.12.51 doesn't support this fail_loc"
27651 $LFS setstripe -c 1 -i 0 $DIR/$tfile
27652 # ensure ost1 is connected
27653 stat $DIR/$tfile >/dev/null || error "can't stat"
27654 wait_osc_import_state client ost1 FULL
27655 # no locks, no reqs to let the connection idle
27656 cancel_lru_locks osc
27658 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
27659 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
27660 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
27661 wait_osc_import_state client ost1 CONNECTING
27662 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
27664 stat $DIR/$tfile >/dev/null || error "can't stat file"
27666 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
27668 test_812b() { # LU-12378
27669 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
27670 skip "OST < 2.12.51 doesn't support this fail_loc"
27672 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
27673 # ensure ost1 is connected
27674 stat $DIR/$tfile >/dev/null || error "can't stat"
27675 wait_osc_import_state client ost1 FULL
27676 # no locks, no reqs to let the connection idle
27677 cancel_lru_locks osc
27679 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
27680 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
27681 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
27682 wait_osc_import_state client ost1 CONNECTING
27683 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
27685 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
27686 wait_osc_import_state client ost1 IDLE
27688 run_test 812b "do not drop no resend request for idle connect"
27693 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
27695 $LFS setstripe -c 1 -o 0 $DIR/$tfile
27696 $LFS getstripe $DIR/$tfile
27697 $LCTL set_param osc.*.idle_timeout=10
27698 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
27699 # ensure ost1 is connected
27700 stat $DIR/$tfile >/dev/null || error "can't stat"
27701 wait_osc_import_state client ost1 FULL
27702 # no locks, no reqs to let the connection idle
27703 cancel_lru_locks osc
27705 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
27706 $LCTL set_param fail_loc=0x80000533
27708 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
27710 run_test 812c "idle import vs lock enqueue race"
27713 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
27714 [ -z "$file_heat_sav" ] && skip "no file heat support"
27725 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
27726 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
27728 $LCTL set_param -n llite.*.file_heat=1
27729 echo "Turn on file heat"
27730 echo "Period second: $period_second, Decay percentage: $decay_pct"
27732 echo "QQQQ" > $DIR/$tfile
27733 echo "QQQQ" > $DIR/$tfile
27734 echo "QQQQ" > $DIR/$tfile
27735 cat $DIR/$tfile > /dev/null
27736 cat $DIR/$tfile > /dev/null
27737 cat $DIR/$tfile > /dev/null
27738 cat $DIR/$tfile > /dev/null
27740 local out=$($LFS heat_get $DIR/$tfile)
27742 $LFS heat_get $DIR/$tfile
27743 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27744 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27745 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27746 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27748 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
27749 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
27750 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
27751 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
27753 sleep $((period_second + 3))
27754 echo "Sleep $((period_second + 3)) seconds..."
27755 # The recursion formula to calculate the heat of the file f is as
27757 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
27758 # Where Hi is the heat value in the period between time points i*I and
27759 # (i+1)*I; Ci is the access count in the period; the symbol P refers
27760 # to the weight of Ci.
27761 out=$($LFS heat_get $DIR/$tfile)
27762 $LFS heat_get $DIR/$tfile
27763 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27764 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27765 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27766 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27768 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
27769 error "read sample ($readsample) is wrong"
27770 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
27771 error "write sample ($writesample) is wrong"
27772 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
27773 error "read bytes ($readbyte) is wrong"
27774 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
27775 error "write bytes ($writebyte) is wrong"
27777 echo "QQQQ" > $DIR/$tfile
27778 echo "QQQQ" > $DIR/$tfile
27779 echo "QQQQ" > $DIR/$tfile
27780 cat $DIR/$tfile > /dev/null
27781 cat $DIR/$tfile > /dev/null
27782 cat $DIR/$tfile > /dev/null
27783 cat $DIR/$tfile > /dev/null
27785 sleep $((period_second + 3))
27786 echo "Sleep $((period_second + 3)) seconds..."
27788 out=$($LFS heat_get $DIR/$tfile)
27789 $LFS heat_get $DIR/$tfile
27790 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27791 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27792 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27793 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27795 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
27796 4 * $decay_pct) / 100") -eq 1 ] ||
27797 error "read sample ($readsample1) is wrong"
27798 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
27799 3 * $decay_pct) / 100") -eq 1 ] ||
27800 error "write sample ($writesample1) is wrong"
27801 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
27802 20 * $decay_pct) / 100") -eq 1 ] ||
27803 error "read bytes ($readbyte1) is wrong"
27804 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
27805 15 * $decay_pct) / 100") -eq 1 ] ||
27806 error "write bytes ($writebyte1) is wrong"
27808 echo "Turn off file heat for the file $DIR/$tfile"
27809 $LFS heat_set -o $DIR/$tfile
27811 echo "QQQQ" > $DIR/$tfile
27812 echo "QQQQ" > $DIR/$tfile
27813 echo "QQQQ" > $DIR/$tfile
27814 cat $DIR/$tfile > /dev/null
27815 cat $DIR/$tfile > /dev/null
27816 cat $DIR/$tfile > /dev/null
27817 cat $DIR/$tfile > /dev/null
27819 out=$($LFS heat_get $DIR/$tfile)
27820 $LFS heat_get $DIR/$tfile
27821 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27822 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27823 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27824 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27826 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
27827 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
27828 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
27829 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
27831 echo "Trun on file heat for the file $DIR/$tfile"
27832 $LFS heat_set -O $DIR/$tfile
27834 echo "QQQQ" > $DIR/$tfile
27835 echo "QQQQ" > $DIR/$tfile
27836 echo "QQQQ" > $DIR/$tfile
27837 cat $DIR/$tfile > /dev/null
27838 cat $DIR/$tfile > /dev/null
27839 cat $DIR/$tfile > /dev/null
27840 cat $DIR/$tfile > /dev/null
27842 out=$($LFS heat_get $DIR/$tfile)
27843 $LFS heat_get $DIR/$tfile
27844 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27845 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27846 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27847 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27849 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
27850 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
27851 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
27852 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
27854 $LFS heat_set -c $DIR/$tfile
27855 $LCTL set_param -n llite.*.file_heat=0
27856 echo "Turn off file heat support for the Lustre filesystem"
27858 echo "QQQQ" > $DIR/$tfile
27859 echo "QQQQ" > $DIR/$tfile
27860 echo "QQQQ" > $DIR/$tfile
27861 cat $DIR/$tfile > /dev/null
27862 cat $DIR/$tfile > /dev/null
27863 cat $DIR/$tfile > /dev/null
27864 cat $DIR/$tfile > /dev/null
27866 out=$($LFS heat_get $DIR/$tfile)
27867 $LFS heat_get $DIR/$tfile
27868 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
27869 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
27870 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
27871 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
27873 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
27874 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
27875 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
27876 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
27878 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
27881 run_test 813 "File heat verfication"
27885 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
27886 echo -n y >> $DIR/$tfile
27887 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
27888 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
27890 run_test 814 "sparse cp works as expected (LU-12361)"
27894 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
27895 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
27897 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
27900 local ost1_imp=$(get_osc_import_name client ost1)
27901 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
27904 $LFS setstripe -c 1 -i 0 $DIR/$tfile
27905 # ensure ost1 is connected
27907 stat $DIR/$tfile >/dev/null || error "can't stat"
27908 wait_osc_import_state client ost1 FULL
27909 # no locks, no reqs to let the connection idle
27910 cancel_lru_locks osc
27911 lru_resize_disable osc
27914 before=$($LCTL get_param -n \
27915 ldlm.namespaces.$imp_name.lru_size)
27917 wait_osc_import_state client ost1 IDLE
27918 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
27919 now=$($LCTL get_param -n \
27920 ldlm.namespaces.$imp_name.lru_size)
27921 [ $before == $now ] || error "lru_size changed $before != $now"
27923 run_test 816 "do not reset lru_resize on idle reconnect"
27927 exportfs -u localhost:$DIR/nfsexp
27932 systemctl restart nfs-server.service || skip "failed to restart nfsd"
27934 mkdir -p $DIR/nfsexp
27935 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
27936 error "failed to export nfs"
27938 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
27939 stack_trap cleanup_817 EXIT
27941 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
27942 error "failed to mount nfs to $tmpdir"
27944 cp /bin/true $tmpdir
27945 $DIR/nfsexp/true || error "failed to execute 'true' command"
27947 run_test 817 "nfsd won't cache write lock for exec file"
27950 test_mkdir -i0 -c1 $DIR/$tdir
27951 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
27952 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
27955 # restore osp-syn threads
27956 stack_trap "fail $SINGLEMDS"
27958 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
27959 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
27960 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
27961 error "start $SINGLEMDS failed"
27964 local testid=$(echo $TESTNAME | tr '_' ' ')
27966 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
27967 grep "run LFSCK" || error "run LFSCK is not suggested"
27969 run_test 818 "unlink with failed llog"
27972 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27973 cancel_lru_locks osc
27974 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
27975 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
27976 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
27979 run_test 819a "too big niobuf in read"
27982 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
27983 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
27984 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
27985 cancel_lru_locks osc
27989 run_test 819b "too big niobuf in write"
27992 function test_820_start_ost() {
27995 for num in $(seq $OSTCOUNT); do
27996 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
28001 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28004 umount_client $MOUNT || error "umount failed"
28005 for num in $(seq $OSTCOUNT); do
28009 # mount client with no active OSTs
28010 # so that the client can't initialize max LOV EA size
28011 # from OSC notifications
28012 mount_client $MOUNT || error "mount failed"
28013 # delay OST starting to keep this 0 max EA size for a while
28014 test_820_start_ost &
28016 # create a directory on MDS2
28017 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
28018 error "Failed to create directory"
28019 # open intent should update default EA size
28020 # see mdc_update_max_ea_from_body()
28021 # notice this is the very first RPC to MDS2
28022 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
28025 # With SSK, this situation can lead to -EPERM being returned.
28026 # In that case, simply retry.
28027 if [ $ret -ne 0 ] && $SHARED_KEY; then
28028 if echo "$out" | grep -q "not permitted"; then
28029 cp /etc/services $DIR/$tdir/mds2
28033 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
28035 run_test 820 "update max EA from open intent"
28038 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28040 save_lustre_params mds1 \
28041 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
28042 do_facet $SINGLEMDS "$LCTL set_param -n \
28043 osp.$FSNAME-OST*MDT0000.max_create_count=0"
28044 do_facet $SINGLEMDS "$LCTL set_param -n \
28045 osp.$FSNAME-OST0000*MDT0000.max_create_count=20000"
28047 # wait for statfs update to clear OS_STATFS_NOPRECREATE
28048 local maxage=$(do_facet mds1 $LCTL get_param -n \
28049 osp.$FSNAME-OST0000*MDT0000.maxage)
28050 sleep $((maxage + 1))
28052 #define OBD_FAIL_NET_ERROR_RPC 0x532
28053 do_facet mds1 "$LCTL set_param fail_loc=0x80000532 fail_val=5"
28055 stack_trap "restore_lustre_params < $p; rm $p"
28057 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
28058 osp.$FSNAME-OST0000*MDT0000.create_count")
28059 for i in $(seq 1 $count); do
28060 touch $DIR/$tfile.${i} || error "touch failed"
28063 run_test 822 "test precreate failure"
28066 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28067 local OST_MAX_PRECREATE=20000
28069 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
28070 skip "Need MDS version at least 2.14.56"
28072 save_lustre_params mds1 \
28073 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
28074 do_facet $SINGLEMDS "$LCTL set_param -n \
28075 osp.$FSNAME-OST*MDT0000.max_create_count=0"
28076 do_facet $SINGLEMDS "$LCTL set_param -n \
28077 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
28079 stack_trap "restore_lustre_params < $p; rm $p"
28081 do_facet $SINGLEMDS "$LCTL set_param -n \
28082 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
28084 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28085 osp.$FSNAME-OST0000*MDT0000.create_count")
28086 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28087 osp.$FSNAME-OST0000*MDT0000.max_create_count")
28088 local expect_count=$(((($max/2)/256) * 256))
28090 log "setting create_count to 100200:"
28091 log " -result- count: $count with max: $max, expecting: $expect_count"
28093 [[ $count -eq expect_count ]] ||
28094 error "Create count not set to max precreate."
28096 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
28099 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
28100 skip "Need MDS version 2.14.56"
28102 local sync_changes=$(do_facet $SINGLEMDS \
28103 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28105 [ "$sync_changes" -gt 100 ] &&
28106 skip "Sync changes $sync_changes > 100 already"
28108 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28110 $LFS mkdir -i 0 $DIR/$tdir
28111 $LFS setstripe -c 1 -i 0 $DIR/$tdir
28113 save_lustre_params mds1 \
28114 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
28115 save_lustre_params mds1 \
28116 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
28118 do_facet mds1 "$LCTL set_param -n \
28119 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
28120 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
28121 stack_trap "restore_lustre_params < $p" EXIT
28123 createmany -o $DIR/$tdir/f- 1000
28124 unlinkmany $DIR/$tdir/f- 1000 &
28125 local UNLINK_PID=$!
28128 sync_changes=$(do_facet mds1 \
28129 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28130 # the check in the code is racy, fail the test
28131 # if the value above the limit by 10.
28132 [ $sync_changes -gt 110 ] && {
28133 kill -2 $UNLINK_PID
28135 error "osp changes throttling failed, $sync_changes>110"
28137 kill -0 $UNLINK_PID 2> /dev/null || break
28141 run_test 831 "throttling unlink/setattr queuing on OSP"
28144 # tests that do cleanup/setup should be run at the end
28148 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28151 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
28152 $LCTL set_param fail_loc=0x903
28154 cancel_lru_locks MGC
28156 FAIL_ON_ERROR=true cleanup
28157 FAIL_ON_ERROR=true setup
28159 run_test 900 "umount should not race with any mgc requeue thread"
28161 # LUS-6253/LU-11185
28169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28171 # some get_param have a bug to handle dot in param name
28172 cancel_lru_locks MGC
28173 old=$(mount -t lustre | wc -l)
28181 while [ $old -ne $oldc ]; do
28182 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28185 if [ $count -ge $TIMEOUT ]; then
28186 error "too large timeout"
28189 umount_client $MOUNT || error "umount failed"
28190 mount_client $MOUNT || error "mount failed"
28191 cancel_lru_locks MGC
28192 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28194 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
28198 run_test 901 "don't leak a mgc lock on client umount"
28202 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
28203 skip "client does not have LU-13377 fix"
28204 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
28205 $LCTL set_param fail_loc=0x1415
28206 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28207 cancel_lru_locks osc
28210 run_test 902 "test short write doesn't hang lustre"
28214 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
28215 echo "blah" > $DIR/${tfile}-2
28216 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
28217 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
28218 $LCTL set_param fail_loc=0x417 fail_val=20
28220 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
28221 sleep 1 # To start the destroy
28222 wait_destroy_complete 150 || error "Destroy taking too long"
28223 cat $DIR/$tfile > /dev/null || error "Evicted"
28225 run_test 903 "Test long page discard does not cause evictions"
28228 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
28229 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
28230 grep -q project || skip "skip project quota not supported"
28232 local testfile="$DIR/$tdir/$tfile"
28233 local xattr="trusted.projid"
28235 local mdts=$(comma_list $(mdts_nodes))
28236 local saved=$(do_facet mds1 $LCTL get_param -n \
28237 osd-ldiskfs.*MDT0000.enable_projid_xattr)
28239 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
28240 stack_trap "do_nodes $mdts $LCTL set_param \
28241 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
28243 mkdir -p $DIR/$tdir
28245 #hide projid xattr on server
28246 $LFS project -p 1 $testfile ||
28247 error "set $testfile project id failed"
28248 getfattr -m - $testfile | grep $xattr &&
28249 error "do not show trusted.projid when disabled on server"
28250 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
28251 #should be hidden when projid is 0
28252 $LFS project -p 0 $testfile ||
28253 error "set $testfile project id failed"
28254 getfattr -m - $testfile | grep $xattr &&
28255 error "do not show trusted.projid with project ID 0"
28257 #still can getxattr explicitly
28258 projid=$(getfattr -n $xattr $testfile |
28259 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28260 [ $projid == "0" ] ||
28261 error "projid expected 0 not $projid"
28263 #set the projid via setxattr
28264 setfattr -n $xattr -v "1000" $testfile ||
28265 error "setattr failed with $?"
28266 projid=($($LFS project $testfile))
28267 [ ${projid[0]} == "1000" ] ||
28268 error "projid expected 1000 not $projid"
28270 #check the new projid via getxattr
28271 $LFS project -p 1001 $testfile ||
28272 error "set $testfile project id failed"
28273 getfattr -m - $testfile | grep $xattr ||
28274 error "should show trusted.projid when project ID != 0"
28275 projid=$(getfattr -n $xattr $testfile |
28276 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28277 [ $projid == "1001" ] ||
28278 error "projid expected 1001 not $projid"
28280 #try to set invalid projid
28281 setfattr -n $xattr -v "4294967295" $testfile &&
28282 error "set invalid projid should fail"
28284 #remove the xattr means setting projid to 0
28285 setfattr -x $xattr $testfile ||
28286 error "setfattr failed with $?"
28287 projid=($($LFS project $testfile))
28288 [ ${projid[0]} == "0" ] ||
28289 error "projid expected 0 not $projid"
28291 #should be hidden when parent has inherit flag and same projid
28292 $LFS project -srp 1002 $DIR/$tdir ||
28293 error "set $tdir project id failed"
28294 getfattr -m - $testfile | grep $xattr &&
28295 error "do not show trusted.projid with inherit flag"
28297 #still can getxattr explicitly
28298 projid=$(getfattr -n $xattr $testfile |
28299 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28300 [ $projid == "1002" ] ||
28301 error "projid expected 1002 not $projid"
28303 run_test 904 "virtual project ID xattr"
28306 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
28307 check_and_cleanup_lustre
28308 if [ "$I_MOUNTED" != "yes" ]; then
28309 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true