3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 SOCKETSERVER=${SOCKETSERVER:-socketserver}
23 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
24 MEMHOG=${MEMHOG:-memhog}
25 DIRECTIO=${DIRECTIO:-directio}
26 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
28 CHECK_GRANT=${CHECK_GRANT:-"yes"}
29 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
32 LUSTRE=${LUSTRE:-$(dirname $0)/..}
33 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
34 . $LUSTRE/tests/test-framework.sh
39 ALWAYS_EXCEPT="$SANITY_EXCEPT "
40 always_except LU-9693 42a 42c
41 always_except LU-6493 42b
42 always_except LU-16515 118c 118d
43 always_except LU-8411 407
46 always_except LU-14181 64e 64f
49 # skip the grant tests for ARM until they are fixed
50 if [[ $(uname -m) = aarch64 ]]; then
51 always_except LU-11671 45
54 # skip nfs tests on kernels >= 4.12.0 until they are fixed
55 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
56 always_except LU-12661 817
58 # skip cgroup tests on RHEL8.1 kernels until they are fixed
59 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
60 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
61 always_except LU-13063 411a
64 # skip cgroup tests for kernels < v4.18.0
65 if (( $LINUX_VERSION_CODE < $(version_code 4.18.0) )); then
66 always_except LU-13063 411b
70 [[ "$SLOW" = "no" ]] && EXCEPT_SLOW="27m 60i 64b 68 71 135 136 230d 300o"
72 if [[ "$mds1_FSTYPE" == "zfs" ]]; then
74 [[ "$SLOW" == "no" ]] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
77 if [[ "$ost1_FSTYPE" = "zfs" ]]; then
78 always_except LU-1941 130b 130c 130d 130e 130f 130g
79 always_except LU-9054 312
82 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
84 # Get the SLES distro version
86 # Returns a version string that should only be used in comparing
87 # strings returned by version_code()
90 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
92 # All SuSE Linux versions have one decimal. version_code expects two
93 local sles_version=$version.0
94 version_code $sles_version
97 # Check if we are running on Ubuntu or SLES so we can make decisions on
99 if [ -r /etc/SuSE-release ] || [ -r /etc/SUSE-brand ]; then
100 sles_version=$(sles_version_code)
101 [ $sles_version -lt $(version_code 11.4.0) ] &&
102 always_except LU-4341 170
104 [ $sles_version -lt $(version_code 12.0.0) ] &&
105 always_except LU-3703 234
106 elif [ -r /etc/os-release ]; then
107 if grep -qi ubuntu /etc/os-release; then
108 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
109 -e 's/^VERSION=//p' \
113 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
114 always_except LU-10366 410
124 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
125 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
134 check_swap_layouts_support()
136 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
137 skip "Does not support layout lock."
140 check_swap_layout_no_dom()
143 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
144 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
147 check_and_setup_lustre
151 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
153 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
154 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
155 rm -rf $DIR/[Rdfs][0-9]*
157 # $RUNAS_ID may get set incorrectly somewhere else
158 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
159 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
161 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
163 if [ "${ONLY}" = "MOUNT" ] ; then
164 echo "Lustre is up, please go on"
168 echo "preparing for tests involving mounts"
169 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
171 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
172 echo # add a newline after mke2fs.
176 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
178 # ensure all internal functions know we want full debug
180 lctl set_param debug=$PTLDEBUG 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 ="
1160 test_mkdir $DIR/R16a
1161 test_mkdir $DIR/R16a/b
1162 test_mkdir $DIR/R16a/b/c
1163 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1164 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1165 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1167 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1169 test_24u() { # bug12192
1170 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1171 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1173 run_test 24u "create stripe file"
1175 simple_cleanup_common() {
1179 [[ -z "$DIR" || -z "$tdir" || ! -d "$DIR/$tdir" ]] && return 0
1181 local start=$SECONDS
1183 [[ -n "$createmany" ]] && unlinkmany $DIR/$tdir/$tfile $createmany
1184 rm -rf $DIR/$tdir || error "cleanup $DIR/$tdir failed"
1186 wait_delete_completed
1187 echo "cleanup time $((SECONDS - start))"
1191 max_pages_per_rpc() {
1192 local mdtname="$(printf "MDT%04x" ${1:-0})"
1193 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1197 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1199 local nrfiles=${COUNT:-100000}
1200 local fname="$DIR/$tdir/$tfile"
1202 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1203 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1205 test_mkdir "$(dirname $fname)"
1206 # assume MDT0000 has the fewest inodes
1207 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1208 local free_inodes=$(($(mdt_free_inodes 0) * ${stripes/#0/1}))
1209 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1211 stack_trap "simple_cleanup_common $nrfiles"
1213 createmany -m "$fname" $nrfiles
1215 cancel_lru_locks mdc
1216 lctl set_param mdc.*.stats clear
1218 # was previously test_24D: LU-6101
1219 # readdir() returns correct number of entries after cursor reload
1220 local num_ls=$(ls $DIR/$tdir | wc -l)
1221 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1222 local num_all=$(ls -a $DIR/$tdir | wc -l)
1223 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1224 [ $num_all -ne $((nrfiles + 2)) ]; then
1225 error "Expected $nrfiles files, got $num_ls " \
1226 "($num_uniq unique $num_all .&..)"
1228 # LU-5 large readdir
1229 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1230 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1231 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1232 # take into account of overhead in lu_dirpage header and end mark in
1233 # each page, plus one in rpc_num calculation.
1234 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1235 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1236 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1237 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1238 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1239 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1240 echo "readpages: $mds_readpage rpc_max: $rpc_max-2/+1"
1241 (( $mds_readpage >= $rpc_max - 2 && $mds_readpage <= $rpc_max + 1)) ||
1242 error "large readdir doesn't take effect: " \
1243 "$mds_readpage should be about $rpc_max"
1245 run_test 24v "list large directory (test hash collision, b=17560)"
1247 test_24w() { # bug21506
1249 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1250 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1251 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1252 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1253 [[ "$SZ1" -eq "$SZ2" ]] ||
1254 error "Error reading at the end of the file $tfile"
1256 run_test 24w "Reading a file larger than 4Gb"
1259 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1260 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1261 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1262 skip "Need MDS version at least 2.7.56"
1265 local remote_dir=$DIR/$tdir/remote_dir
1267 test_mkdir $DIR/$tdir
1268 $LFS mkdir -i $MDTIDX $remote_dir ||
1269 error "create remote directory failed"
1271 test_mkdir $DIR/$tdir/src_dir
1272 touch $DIR/$tdir/src_file
1273 test_mkdir $remote_dir/tgt_dir
1274 touch $remote_dir/tgt_file
1276 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1277 error "rename dir cross MDT failed!"
1279 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1280 error "rename file cross MDT failed!"
1282 touch $DIR/$tdir/ln_file
1283 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1284 error "ln file cross MDT failed"
1286 rm -rf $DIR/$tdir || error "Can not delete directories"
1288 run_test 24x "cross MDT rename/link"
1291 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1294 local remote_dir=$DIR/$tdir/remote_dir
1297 test_mkdir $DIR/$tdir
1298 $LFS mkdir -i $mdtidx $remote_dir ||
1299 error "create remote directory failed"
1301 test_mkdir $remote_dir/src_dir
1302 touch $remote_dir/src_file
1303 test_mkdir $remote_dir/tgt_dir
1304 touch $remote_dir/tgt_file
1306 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1307 error "rename subdir in the same remote dir failed!"
1309 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1310 error "rename files in the same remote dir failed!"
1312 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1313 error "link files in the same remote dir failed!"
1315 rm -rf $DIR/$tdir || error "Can not delete directories"
1317 run_test 24y "rename/link on the same dir should succeed"
1320 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1321 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1322 skip "Need MDS version at least 2.12.51"
1326 for index in 0 1; do
1327 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1328 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1331 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1333 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1334 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1336 local mdts=$(comma_list $(mdts_nodes))
1338 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1339 stack_trap "do_nodes $mdts $LCTL \
1340 set_param mdt.*.enable_remote_rename=1" EXIT
1342 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1344 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1345 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1347 run_test 24z "cross-MDT rename is done as cp"
1349 test_24A() { # LU-3182
1352 test_mkdir $DIR/$tdir
1353 stack_trap "simple_cleanup_common $NFILES"
1354 createmany -m $DIR/$tdir/$tfile $NFILES
1355 local t=$(ls $DIR/$tdir | wc -l)
1356 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1357 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1359 (( $t == $NFILES && $u == $NFILES && $v == NFILES + 2 )) ||
1360 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1362 run_test 24A "readdir() returns correct number of entries."
1364 test_24B() { # LU-4805
1365 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1369 test_mkdir $DIR/$tdir
1370 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir/ ||
1371 error "create striped dir failed"
1373 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1374 [ $count -eq 2 ] || error "Expected 2, got $count"
1376 touch $DIR/$tdir/striped_dir/a
1378 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1379 [ $count -eq 3 ] || error "Expected 3, got $count"
1381 touch $DIR/$tdir/striped_dir/.f
1383 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1384 [ $count -eq 4 ] || error "Expected 4, got $count"
1386 rm -rf $DIR/$tdir || error "Can not delete directories"
1388 run_test 24B "readdir for striped dir return correct number of entries"
1391 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1397 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1398 error "create striped dir failed"
1400 cd $DIR/$tdir/d0/striped_dir
1402 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1403 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1404 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1406 [ "$d0_ino" = "$parent_ino" ] ||
1407 error ".. wrong, expect $d0_ino, get $parent_ino"
1409 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1410 error "mv striped dir failed"
1412 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1414 [ "$d1_ino" = "$parent_ino" ] ||
1415 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1417 run_test 24C "check .. in striped dir"
1420 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1421 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1424 mkdir $DIR/$tdir/src_dir
1425 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1426 error "create remote source failed"
1428 touch $DIR/$tdir/src_dir/src_child/a
1430 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1431 error "create remote target dir failed"
1433 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1434 error "create remote target child failed"
1436 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1437 error "rename dir cross MDT failed!"
1441 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1442 error "src_child still exists after rename"
1444 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1445 error "missing file(a) after rename"
1447 rm -rf $DIR/$tdir || error "Can not delete directories"
1449 run_test 24E "cross MDT rename/link"
1452 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1455 [ "$SLOW" = "no" ] && repeats=100
1459 echo "$repeats repeats"
1460 for ((i = 0; i < repeats; i++)); do
1461 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1462 touch $DIR/$tdir/test/a || error "touch fails"
1463 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1464 rm -rf $DIR/$tdir/test || error "rmdir fails"
1469 run_test 24F "hash order vs readdir (LU-11330)"
1472 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1477 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1478 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1479 touch $DIR/$tdir-0/f1 || error "touch f1"
1480 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1481 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1482 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1483 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1484 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1486 run_test 24G "migrate symlink in rename"
1489 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1490 [[ $(hostname) != $(facet_active_host mds2) ]] ||
1491 skip "MDT1 should be on another node"
1493 test_mkdir -i 1 -c 1 $DIR/$tdir
1494 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
1495 do_facet mds2 $LCTL set_param fail_loc=0x80001103
1496 touch $DIR/$tdir/$tfile || error "touch failed"
1498 run_test 24H "repeat FLD_QUERY rpc"
1501 echo '== symlink sanity ============================================='
1505 touch $DIR/s25/foo ||
1506 error "File creation in symlinked directory failed"
1508 run_test 25a "create file in symlinked directory ==============="
1511 [ ! -d $DIR/d25 ] && test_25a
1512 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1514 run_test 25b "lookup file in symlinked directory ==============="
1518 test_mkdir $DIR/d26/d26-2
1519 ln -s d26/d26-2 $DIR/s26
1520 touch $DIR/s26/foo || error "File creation failed"
1522 run_test 26a "multiple component symlink ======================="
1525 test_mkdir -p $DIR/$tdir/d26-2
1526 ln -s $tdir/d26-2/foo $DIR/s26-2
1527 touch $DIR/s26-2 || error "File creation failed"
1529 run_test 26b "multiple component symlink at end of lookup ======"
1532 test_mkdir $DIR/d26.2
1533 touch $DIR/d26.2/foo
1534 ln -s d26.2 $DIR/s26.2-1
1535 ln -s s26.2-1 $DIR/s26.2-2
1536 ln -s s26.2-2 $DIR/s26.2-3
1537 chmod 0666 $DIR/s26.2-3/foo
1539 run_test 26c "chain of symlinks"
1541 # recursive symlinks (bug 439)
1543 ln -s d26-3/foo $DIR/d26-3
1545 run_test 26d "create multiple component recursive symlink"
1548 [ ! -h $DIR/d26-3 ] && test_26d
1551 run_test 26e "unlink multiple component recursive symlink"
1553 # recursive symlinks (bug 7022)
1555 test_mkdir $DIR/$tdir
1556 test_mkdir $DIR/$tdir/$tfile
1557 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1558 test_mkdir -p lndir/bar1
1559 test_mkdir $DIR/$tdir/$tfile/$tfile
1560 cd $tfile || error "cd $tfile failed"
1561 ln -s .. dotdot || error "ln dotdot failed"
1562 ln -s dotdot/lndir lndir || error "ln lndir failed"
1563 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1564 output=`ls $tfile/$tfile/lndir/bar1`
1565 [ "$output" = bar1 ] && error "unexpected output"
1566 rm -r $tfile || error "rm $tfile failed"
1567 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1569 run_test 26f "rm -r of a directory which has recursive symlink"
1572 test_mkdir $DIR/$tdir
1573 $LFS getstripe $DIR/$tdir
1574 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1575 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1576 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1578 run_test 27a "one stripe file"
1581 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1583 test_mkdir $DIR/$tdir
1584 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1585 $LFS getstripe -c $DIR/$tdir/$tfile
1586 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1587 error "two-stripe file doesn't have two stripes"
1589 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1591 run_test 27b "create and write to two stripe file"
1593 # 27c family tests specific striping, setstripe -o
1595 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1596 test_mkdir -p $DIR/$tdir
1599 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1600 $LFS getstripe -i $DIR/$tdir/$tfile
1601 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1602 error "stripe not on specified OST"
1604 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1606 run_test 27ca "one stripe on specified OST"
1609 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1610 test_mkdir -p $DIR/$tdir
1612 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1613 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1616 # Strip getstripe output to a space separated list of OSTs
1617 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1618 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1619 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1620 error "stripes not on specified OSTs"
1622 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1624 run_test 27cb "two stripes on specified OSTs"
1627 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1628 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1629 skip "server does not support overstriping"
1631 test_mkdir -p $DIR/$tdir
1633 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1634 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1637 # Strip getstripe output to a space separated list of OSTs
1638 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1639 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1640 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1641 error "stripes not on specified OSTs"
1643 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1645 run_test 27cc "two stripes on the same OST"
1648 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1649 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1650 skip "server does not support overstriping"
1651 test_mkdir -p $DIR/$tdir
1652 local osts="0,1,1,0"
1653 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1654 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1657 # Strip getstripe output to a space separated list of OSTs
1658 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1659 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1660 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1661 error "stripes not on specified OSTs"
1663 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1665 run_test 27cd "four stripes on two OSTs"
1668 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1669 skip_env "too many osts, skipping"
1670 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1671 skip "server does not support overstriping"
1672 # We do one more stripe than we have OSTs
1673 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1674 skip_env "ea_inode feature disabled"
1676 test_mkdir -p $DIR/$tdir
1678 for i in $(seq 0 $OSTCOUNT);
1681 if [ $i -ne $OSTCOUNT ]; then
1685 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1686 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1689 # Strip getstripe output to a space separated list of OSTs
1690 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1691 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1692 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1693 error "stripes not on specified OSTs"
1695 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1697 run_test 27ce "more stripes than OSTs with -o"
1700 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1703 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1704 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1705 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1706 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1707 error "failed to set $osp_proc=0"
1709 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1712 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1713 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1714 error "failed to set $osp_proc=1"
1717 error "should return error due to $osp_proc=0"
1719 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1722 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1723 skip "server does not support overstriping"
1724 [[ $mds1_FSTYPE != "ldiskfs" ]] && skip_env "ldiskfs only test"
1725 large_xattr_enabled || skip_env "ea_inode feature disabled"
1729 for ((i=1;i<1000;i++)); do
1730 osts+=",$((i % OSTCOUNT))"
1733 local mdts=$(comma_list $(mdts_nodes))
1734 local before=$(do_nodes $mdts \
1735 "$LCTL get_param -n osd-ldiskfs.*MDT*.stats" |
1736 awk '/many credits/{print $3}' |
1739 $LFS setstripe -o $osts $DIR/$tfile || error "setstripe failed"
1740 $LFS getstripe $DIR/$tfile | grep stripe
1742 rm -f $DIR/$tfile || error "can't unlink"
1744 after=$(do_nodes $mdts \
1745 "$LCTL get_param -n osd-ldiskfs.*MDT*.stats" |
1746 awk '/many credits/{print $3}' |
1749 (( before == after )) ||
1750 error "too many credits happened: $after > $before"
1752 run_test 27cg "1000 shouldn't cause too many credits"
1755 test_mkdir $DIR/$tdir
1756 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1757 error "setstripe failed"
1758 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1759 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1761 run_test 27d "create file with default settings"
1764 # LU-5839 adds check for existed layout before setting it
1765 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1766 skip "Need MDS version at least 2.7.56"
1768 test_mkdir $DIR/$tdir
1769 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1770 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1771 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1773 run_test 27e "setstripe existing file (should return error)"
1776 test_mkdir $DIR/$tdir
1777 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1778 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1779 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1780 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1781 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1782 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1784 run_test 27f "setstripe with bad stripe size (should return error)"
1787 test_mkdir $DIR/$tdir
1788 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1789 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1790 error "$DIR/$tdir/$tfile has object"
1792 run_test 27g "$LFS getstripe with no objects"
1795 test_mkdir $DIR/$tdir
1796 touch $DIR/$tdir/$tfile || error "touch failed"
1797 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1798 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1800 (( rc == 2 )) || error "getstripe did not return ENOENT"
1802 run_test 27ga "$LFS getstripe with missing file (should return error)"
1805 test_mkdir $DIR/$tdir
1806 touch $DIR/$tdir/$tfile || error "touch failed"
1807 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1808 error "missing objects"
1810 run_test 27i "$LFS getstripe with some objects"
1813 test_mkdir $DIR/$tdir
1814 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1815 error "setstripe failed" || true
1817 run_test 27j "setstripe with bad stripe offset (should return error)"
1819 test_27k() { # bug 2844
1820 test_mkdir $DIR/$tdir
1821 local file=$DIR/$tdir/$tfile
1822 local ll_max_blksize=$((4 * 1024 * 1024))
1823 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1824 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1825 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1826 dd if=/dev/zero of=$file bs=4k count=1
1827 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1828 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1830 run_test 27k "limit i_blksize for broken user apps"
1833 mcreate $DIR/$tfile || error "creating file"
1834 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1835 error "setstripe should have failed" || true
1837 run_test 27l "check setstripe permissions (should return error)"
1840 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1842 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1843 skip_env "multiple clients -- skipping"
1845 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1847 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1848 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1850 stack_trap simple_cleanup_common
1851 test_mkdir $DIR/$tdir
1852 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1853 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1854 error "dd should fill OST0"
1856 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1858 [ $i -gt 256 ] && break
1861 touch $DIR/$tdir/$tfile.$i
1862 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1863 awk '{print $1}'| grep -w "0") ] &&
1864 error "OST0 was full but new created file still use it"
1866 touch $DIR/$tdir/$tfile.$i
1867 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1868 awk '{print $1}'| grep -w "0") ] &&
1869 error "OST0 was full but new created file still use it" || true
1871 run_test 27m "create file while OST0 was full"
1873 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1874 # if the OST isn't full anymore.
1876 local ostidx=${1:-""}
1881 local list=$(comma_list $(osts_nodes))
1882 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1884 do_nodes $list lctl set_param fail_loc=0
1885 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1886 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1887 awk '{print $1 * 2;exit;}')
1888 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1890 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1894 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1895 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1896 remote_mds_nodsh && skip "remote MDS with nodsh"
1897 remote_ost_nodsh && skip "remote OST with nodsh"
1900 rm -f $DIR/$tdir/$tfile
1901 exhaust_precreations 0 0x80000215
1902 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1903 touch $DIR/$tdir/$tfile || error "touch failed"
1904 $LFS getstripe $DIR/$tdir/$tfile
1907 run_test 27n "create file with some full OSTs"
1910 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1912 remote_mds_nodsh && skip "remote MDS with nodsh"
1913 remote_ost_nodsh && skip "remote OST with nodsh"
1916 rm -f $DIR/$tdir/$tfile
1917 exhaust_all_precreations 0x215
1919 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1924 run_test 27o "create file with all full OSTs (should error)"
1926 function create_and_checktime() {
1931 for ((i=0; i < $loops; i++)); do
1932 local start=$SECONDS
1933 multiop $fname-$i Oc
1934 ((SECONDS-start < TIMEOUT)) ||
1935 error "creation took " $((SECONDS-$start)) && return 1
1940 local mdts=$(comma_list $(mdts_nodes))
1942 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1943 skip "Need MDS version at least 2.13.57"
1945 local f0=$DIR/${tfile}-0
1946 local f1=$DIR/${tfile}-1
1948 wait_delete_completed
1950 # refill precreated objects
1951 $LFS setstripe -i0 -c1 $f0
1953 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1954 # force QoS allocation policy
1955 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1956 stack_trap "do_nodes $mdts $LCTL set_param \
1957 lov.*.qos_threshold_rr=$saved" EXIT
1960 # one OST is unavailable, but still have few objects preallocated
1962 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1963 rm -rf $f1 $DIR/$tdir*" EXIT
1965 for ((i=0; i < 7; i++)); do
1966 mkdir $DIR/$tdir$i || error "can't create dir"
1967 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1968 error "can't set striping"
1970 for ((i=0; i < 7; i++)); do
1971 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1975 run_test 27oo "don't let few threads to reserve too many objects"
1978 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1980 remote_mds_nodsh && skip "remote MDS with nodsh"
1981 remote_ost_nodsh && skip "remote OST with nodsh"
1984 rm -f $DIR/$tdir/$tfile
1985 test_mkdir $DIR/$tdir
1987 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1988 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1989 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1991 exhaust_precreations 0 0x80000215
1992 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1993 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1994 $LFS getstripe $DIR/$tdir/$tfile
1998 run_test 27p "append to a truncated file with some full OSTs"
2001 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2002 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2003 remote_mds_nodsh && skip "remote MDS with nodsh"
2004 remote_ost_nodsh && skip "remote OST with nodsh"
2007 rm -f $DIR/$tdir/$tfile
2009 mkdir_on_mdt0 $DIR/$tdir
2010 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
2011 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
2012 error "truncate $DIR/$tdir/$tfile failed"
2013 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
2015 exhaust_all_precreations 0x215
2017 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
2018 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
2022 run_test 27q "append to truncated file with all OSTs full (should error)"
2025 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2026 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2027 remote_mds_nodsh && skip "remote MDS with nodsh"
2028 remote_ost_nodsh && skip "remote OST with nodsh"
2031 rm -f $DIR/$tdir/$tfile
2032 exhaust_precreations 0 0x80000215
2034 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2038 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2040 test_27s() { # bug 10725
2041 test_mkdir $DIR/$tdir
2042 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2043 local stripe_count=0
2044 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2045 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2046 error "stripe width >= 2^32 succeeded" || true
2049 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2051 test_27t() { # bug 10864
2056 $WLFS getstripe $tfile
2059 run_test 27t "check that utils parse path correctly"
2061 test_27u() { # bug 4900
2062 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2063 remote_mds_nodsh && skip "remote MDS with nodsh"
2066 local list=$(comma_list $(mdts_nodes))
2068 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2069 do_nodes $list $LCTL set_param fail_loc=0x139
2070 test_mkdir -p $DIR/$tdir
2071 stack_trap "simple_cleanup_common 1000"
2072 createmany -o $DIR/$tdir/$tfile 1000
2073 do_nodes $list $LCTL set_param fail_loc=0
2075 TLOG=$TMP/$tfile.getstripe
2076 $LFS getstripe $DIR/$tdir > $TLOG
2077 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2078 [[ $OBJS -gt 0 ]] &&
2079 error "$OBJS objects created on OST-0. See $TLOG" ||
2082 run_test 27u "skip object creation on OSC w/o objects"
2084 test_27v() { # bug 4900
2085 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2086 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2087 remote_mds_nodsh && skip "remote MDS with nodsh"
2088 remote_ost_nodsh && skip "remote OST with nodsh"
2090 exhaust_all_precreations 0x215
2093 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2095 touch $DIR/$tdir/$tfile
2096 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2098 for (( i=1; i < OSTCOUNT; i++ )); do
2099 do_facet ost$i lctl set_param fail_loc=0x705
2101 local START=`date +%s`
2102 createmany -o $DIR/$tdir/$tfile 32
2104 local FINISH=`date +%s`
2105 local TIMEOUT=`lctl get_param -n timeout`
2106 local PROCESS=$((FINISH - START))
2107 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2108 error "$FINISH - $START >= $TIMEOUT / 2"
2109 sleep $((TIMEOUT / 2 - PROCESS))
2112 run_test 27v "skip object creation on slow OST"
2114 test_27w() { # bug 10997
2115 test_mkdir $DIR/$tdir
2116 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2117 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2118 error "stripe size $size != 65536" || true
2119 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2120 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2122 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2125 [[ $OSTCOUNT -lt 2 ]] &&
2126 skip_env "skipping multiple stripe count/offset test"
2128 test_mkdir $DIR/$tdir
2129 for i in $(seq 1 $OSTCOUNT); do
2131 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2132 error "setstripe -c $i -i $offset failed"
2133 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2134 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2135 [ $count -ne $i ] && error "stripe count $count != $i" || true
2136 [ $index -ne $offset ] &&
2137 error "stripe offset $index != $offset" || true
2140 run_test 27wa "check $LFS setstripe -c -i options"
2143 remote_ost_nodsh && skip "remote OST with nodsh"
2144 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2147 OFFSET=$(($OSTCOUNT - 1))
2149 local OST=$(ostname_from_index $OSTIDX)
2151 test_mkdir $DIR/$tdir
2152 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2153 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2155 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2156 for i in $(seq 0 $OFFSET); do
2157 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2158 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2159 error "OST0 was degraded but new created file still use it"
2161 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2163 run_test 27x "create files while OST0 is degraded"
2166 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2167 remote_mds_nodsh && skip "remote MDS with nodsh"
2168 remote_ost_nodsh && skip "remote OST with nodsh"
2169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2171 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2172 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2173 osp.$mdtosc.prealloc_last_id)
2174 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2175 osp.$mdtosc.prealloc_next_id)
2176 local fcount=$((last_id - next_id))
2177 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2178 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2180 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2181 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2182 local OST_DEACTIVE_IDX=-1
2187 for OSC in $MDS_OSCS; do
2188 OST=$(osc_to_ost $OSC)
2189 OSTIDX=$(index_from_ostuuid $OST)
2190 if [ $OST_DEACTIVE_IDX == -1 ]; then
2191 OST_DEACTIVE_IDX=$OSTIDX
2193 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2194 echo $OSC "is Deactivated:"
2195 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2199 OSTIDX=$(index_from_ostuuid $OST)
2200 test_mkdir $DIR/$tdir
2201 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2203 for OSC in $MDS_OSCS; do
2204 OST=$(osc_to_ost $OSC)
2205 OSTIDX=$(index_from_ostuuid $OST)
2206 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2207 echo $OST "is degraded:"
2208 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2209 obdfilter.$OST.degraded=1
2214 createmany -o $DIR/$tdir/$tfile $fcount
2216 for OSC in $MDS_OSCS; do
2217 OST=$(osc_to_ost $OSC)
2218 OSTIDX=$(index_from_ostuuid $OST)
2219 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2220 echo $OST "is recovered from degraded:"
2221 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2222 obdfilter.$OST.degraded=0
2224 do_facet $SINGLEMDS lctl --device %$OSC activate
2228 # all osp devices get activated, hence -1 stripe count restored
2229 local stripe_count=0
2231 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2232 # devices get activated.
2234 $LFS setstripe -c -1 $DIR/$tfile
2235 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2237 [ $stripe_count -ne $OSTCOUNT ] &&
2238 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2241 run_test 27y "create files while OST0 is degraded and the rest inactive"
2247 lmm_count=$($LFS getstripe -c $1)
2248 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2249 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2251 local old_ifs="$IFS"
2253 fid=($($LFS path2fid $1))
2256 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2257 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2259 # compare lmm_seq and lu_fid->f_seq
2260 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2261 # compare lmm_object_id and lu_fid->oid
2262 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2264 # check the trusted.fid attribute of the OST objects of the file
2265 local have_obdidx=false
2267 $LFS getstripe $1 | while read obdidx oid hex seq; do
2268 # skip lines up to and including "obdidx"
2269 [ -z "$obdidx" ] && break
2270 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2271 $have_obdidx || continue
2273 local ost=$((obdidx + 1))
2274 local dev=$(ostdevname $ost)
2277 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2279 seq=$(echo $seq | sed -e "s/^0x//g")
2280 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2281 oid_hex=$(echo $oid)
2283 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2285 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2289 # Don't unmount/remount the OSTs if we don't need to do that.
2290 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2291 # update too, until that use mount/ll_decode_filter_fid/mount.
2292 # Re-enable when debugfs will understand new filter_fid.
2294 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2295 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2296 $dev 2>/dev/null" | grep "parent=")
2298 if [ -z "$ff" ]; then
2300 mount_fstype ost$ost
2301 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2302 $(facet_mntpt ost$ost)/$obj_file)
2303 unmount_fstype ost$ost
2304 start ost$ost $dev $OST_MOUNT_OPTS
2308 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2310 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2312 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2313 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2315 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2316 # stripe_size=1048576 component_id=1 component_start=0 \
2317 # component_end=33554432
2318 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2319 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2320 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2322 if grep -q 'stripe=' <<<$ff; then
2323 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2325 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2326 # into f_ver in this case. See comment on ff_parent.
2327 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2330 # compare lmm_seq and filter_fid->ff_parent.f_seq
2331 [ $ff_pseq = $lmm_seq ] ||
2332 error "FF parent SEQ $ff_pseq != $lmm_seq"
2333 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2334 [ $ff_poid = $lmm_oid ] ||
2335 error "FF parent OID $ff_poid != $lmm_oid"
2336 (($ff_pstripe == $stripe_nr)) ||
2337 error "FF stripe $ff_pstripe != $stripe_nr"
2339 stripe_nr=$((stripe_nr + 1))
2340 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2342 if grep -q 'stripe_count=' <<<$ff; then
2343 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2344 -e 's/ .*//' <<<$ff)
2345 [ $lmm_count = $ff_scnt ] ||
2346 error "FF stripe count $lmm_count != $ff_scnt"
2352 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2353 remote_ost_nodsh && skip "remote OST with nodsh"
2355 test_mkdir $DIR/$tdir
2356 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2357 { error "setstripe -c -1 failed"; return 1; }
2358 # We need to send a write to every object to get parent FID info set.
2359 # This _should_ also work for setattr, but does not currently.
2360 # touch $DIR/$tdir/$tfile-1 ||
2361 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2362 { error "dd $tfile-1 failed"; return 2; }
2363 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2364 { error "setstripe -c -1 failed"; return 3; }
2365 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2366 { error "dd $tfile-2 failed"; return 4; }
2368 # make sure write RPCs have been sent to OSTs
2371 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2372 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2374 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2376 test_27A() { # b=19102
2377 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2379 save_layout_restore_at_exit $MOUNT
2380 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2381 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2382 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2383 local default_size=$($LFS getstripe -S $MOUNT)
2384 local default_offset=$($LFS getstripe -i $MOUNT)
2385 local dsize=$(do_facet $SINGLEMDS \
2386 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2387 [ $default_size -eq $dsize ] ||
2388 error "stripe size $default_size != $dsize"
2389 [ $default_offset -eq -1 ] ||
2390 error "stripe offset $default_offset != -1"
2392 run_test 27A "check filesystem-wide default LOV EA values"
2394 test_27B() { # LU-2523
2395 test_mkdir $DIR/$tdir
2396 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2398 # open f1 with O_LOV_DELAY_CREATE
2400 # call setstripe ioctl on open file descriptor for f1
2402 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2406 # open f1 with O_LOV_DELAY_CREATE
2408 # call setstripe ioctl on open file descriptor for f1
2410 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2412 # Allow multiop to fail in imitation of NFS's busted semantics.
2415 run_test 27B "call setstripe on open unlinked file/rename victim"
2417 # 27C family tests full striping and overstriping
2418 test_27Ca() { #LU-2871
2419 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2427 test_mkdir $DIR/$tdir
2429 for i in $(seq 0 $((OSTCOUNT - 1))); do
2430 # set stripe across all OSTs starting from OST$i
2431 $LFS setstripe -i $i -c -1 $tfile$i
2432 # get striping information
2433 ost_idx=($($LFS getstripe $tfile$i |
2434 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2435 echo "OST Index: ${ost_idx[*]}"
2438 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2439 error "${#ost_idx[@]} != $OSTCOUNT"
2441 for index in $(seq 0 $((OSTCOUNT - 1))); do
2443 for j in "${ost_idx[@]}"; do
2444 if [ $index -eq $j ]; then
2450 error "Can not find $index in ${ost_idx[*]}"
2454 run_test 27Ca "check full striping across all OSTs"
2457 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2458 skip "server does not support overstriping"
2459 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2460 skip_env "too many osts, skipping"
2462 test_mkdir -p $DIR/$tdir
2463 local setcount=$(($OSTCOUNT * 2))
2464 [ $setcount -lt 160 ] || large_xattr_enabled ||
2465 skip_env "ea_inode feature disabled"
2467 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2468 error "setstripe failed"
2470 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2471 [ $count -eq $setcount ] ||
2472 error "stripe count $count, should be $setcount"
2474 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2475 error "overstriped should be set in pattern"
2477 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2480 run_test 27Cb "more stripes than OSTs with -C"
2483 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2484 skip "server does not support overstriping"
2485 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2487 test_mkdir -p $DIR/$tdir
2488 local setcount=$(($OSTCOUNT - 1))
2490 [ $setcount -lt 160 ] || large_xattr_enabled ||
2491 skip_env "ea_inode feature disabled"
2493 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2494 error "setstripe failed"
2496 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2497 [ $count -eq $setcount ] ||
2498 error "stripe count $count, should be $setcount"
2500 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2501 error "overstriped should not be set in pattern"
2503 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2506 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2509 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2510 skip "server does not support overstriping"
2511 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2512 large_xattr_enabled || skip_env "ea_inode feature disabled"
2516 test_mkdir -p $DIR/$tdir
2517 local setcount=$LOV_MAX_STRIPE_COUNT
2519 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2520 error "setstripe failed"
2522 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2523 [ $count -eq $setcount ] ||
2524 error "stripe count $count, should be $setcount"
2526 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2527 error "overstriped should be set in pattern"
2529 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2532 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2534 run_test 27Cd "test maximum stripe count"
2537 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2538 skip "server does not support overstriping"
2539 test_mkdir -p $DIR/$tdir
2541 pool_add $TESTNAME || error "Pool creation failed"
2542 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2546 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2547 error "setstripe failed"
2549 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2550 [ $count -eq $setcount ] ||
2551 error "stripe count $count, should be $setcount"
2553 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2554 error "overstriped should be set in pattern"
2556 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2559 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2561 run_test 27Ce "test pool with overstriping"
2564 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2565 skip "server does not support overstriping"
2566 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2567 skip_env "too many osts, skipping"
2569 test_mkdir -p $DIR/$tdir
2571 local setcount=$(($OSTCOUNT * 2))
2572 [ $setcount -lt 160 ] || large_xattr_enabled ||
2573 skip_env "ea_inode feature disabled"
2575 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2576 error "setstripe failed"
2578 echo 1 > $DIR/$tdir/$tfile
2580 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2581 [ $count -eq $setcount ] ||
2582 error "stripe count $count, should be $setcount"
2584 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2585 error "overstriped should be set in pattern"
2587 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2590 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2592 run_test 27Cf "test default inheritance with overstriping"
2595 (( MDS1_VERSION >= $(version_code v2_15_55-80-gd96b98ee6b) )) ||
2596 skip "need MDS version at least v2_15_55-80-gd96b98ee6b for fix"
2598 $LFS setstripe -o 0,$OSTCOUNT $DIR/$tfile
2599 (( $? != 0 )) || error "must be an error for not existent OST#"
2601 run_test 27Cg "test setstripe with wrong OST idx"
2604 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2605 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2606 remote_mds_nodsh && skip "remote MDS with nodsh"
2608 local POOL=${POOL:-testpool}
2610 local last_ost=$(($OSTCOUNT - 1))
2612 local ost_list=$(seq $first_ost $ost_step $last_ost)
2613 local ost_range="$first_ost $last_ost $ost_step"
2615 test_mkdir $DIR/$tdir
2616 pool_add $POOL || error "pool_add failed"
2617 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2620 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2622 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2623 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2624 skip27D+=" -s 30,31"
2625 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2626 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2627 skip27D+=" -s 32,33"
2628 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2630 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2631 error "llapi_layout_test failed"
2633 destroy_test_pools || error "destroy test pools failed"
2635 run_test 27D "validate llapi_layout API"
2637 # Verify that default_easize is increased from its initial value after
2638 # accessing a widely striped file.
2640 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2641 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2642 skip "client does not have LU-3338 fix"
2644 # 72 bytes is the minimum space required to store striping
2645 # information for a file striped across one OST:
2646 # (sizeof(struct lov_user_md_v3) +
2647 # sizeof(struct lov_user_ost_data_v1))
2649 $LCTL set_param -n llite.*.default_easize $min_easize ||
2650 error "lctl set_param failed"
2651 local easize=$($LCTL get_param -n llite.*.default_easize)
2653 [ $easize -eq $min_easize ] ||
2654 error "failed to set default_easize"
2656 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2657 error "setstripe failed"
2658 # In order to ensure stat() call actually talks to MDS we need to
2659 # do something drastic to this file to shake off all lock, e.g.
2660 # rename it (kills lookup lock forcing cache cleaning)
2661 mv $DIR/$tfile $DIR/${tfile}-1
2662 ls -l $DIR/${tfile}-1
2665 easize=$($LCTL get_param -n llite.*.default_easize)
2667 [ $easize -gt $min_easize ] ||
2668 error "default_easize not updated"
2670 run_test 27E "check that default extended attribute size properly increases"
2672 test_27F() { # LU-5346/LU-7975
2673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2674 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2675 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2676 skip "Need MDS version at least 2.8.51"
2677 remote_ost_nodsh && skip "remote OST with nodsh"
2679 test_mkdir $DIR/$tdir
2681 $LFS setstripe -c 2 $DIR/$tdir
2683 # stop all OSTs to reproduce situation for LU-7975 ticket
2684 for num in $(seq $OSTCOUNT); do
2688 # open/create f0 with O_LOV_DELAY_CREATE
2689 # truncate f0 to a non-0 size
2691 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2693 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2694 # open/write it again to force delayed layout creation
2695 cat /etc/hosts > $DIR/$tdir/f0 &
2699 for num in $(seq $OSTCOUNT); do
2700 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2701 error "ost$num failed to start"
2704 wait $catpid || error "cat failed"
2706 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2707 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2708 error "wrong stripecount"
2711 run_test 27F "Client resend delayed layout creation with non-zero size"
2713 test_27G() { #LU-10629
2714 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2715 skip "Need MDS version at least 2.11.51"
2716 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2717 remote_mds_nodsh && skip "remote MDS with nodsh"
2718 local POOL=${POOL:-testpool}
2719 local ostrange="0 0 1"
2721 test_mkdir $DIR/$tdir
2722 touch $DIR/$tdir/$tfile.nopool
2723 pool_add $POOL || error "pool_add failed"
2724 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2725 $LFS setstripe -p $POOL $DIR/$tdir
2727 local pool=$($LFS getstripe -p $DIR/$tdir)
2729 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2730 touch $DIR/$tdir/$tfile.default
2731 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2732 $LFS find $DIR/$tdir -type f --pool $POOL
2733 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2734 [[ "$found" == "2" ]] ||
2735 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2737 $LFS setstripe -d $DIR/$tdir
2739 pool=$($LFS getstripe -p -d $DIR/$tdir)
2741 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2743 run_test 27G "Clear OST pool from stripe"
2746 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2747 skip "Need MDS version newer than 2.11.54"
2748 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2749 test_mkdir $DIR/$tdir
2750 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2751 touch $DIR/$tdir/$tfile
2752 $LFS getstripe -c $DIR/$tdir/$tfile
2753 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2754 error "two-stripe file doesn't have two stripes"
2756 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2757 $LFS getstripe -y $DIR/$tdir/$tfile
2758 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2759 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2760 error "expected l_ost_idx: [02]$ not matched"
2762 # make sure ost list has been cleared
2763 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2764 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2765 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2767 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2769 run_test 27H "Set specific OSTs stripe"
2772 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2773 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2774 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2775 skip "Need MDS version newer than 2.12.52"
2776 local pool=$TESTNAME
2777 local ostrange="1 1 1"
2779 save_layout_restore_at_exit $MOUNT
2780 $LFS setstripe -c 2 -i 0 $MOUNT
2781 pool_add $pool || error "pool_add failed"
2782 pool_add_targets $pool $ostrange ||
2783 error "pool_add_targets failed"
2784 test_mkdir $DIR/$tdir
2785 $LFS setstripe -p $pool $DIR/$tdir
2786 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2787 $LFS getstripe $DIR/$tdir/$tfile
2789 run_test 27I "check that root dir striping does not break parent dir one"
2792 (( $MDS1_VERSION > $(version_code 2.12.51) )) ||
2793 skip "Need MDS version newer than 2.12.51"
2795 # skip basic ops on file with foreign LOV tests on 5.12-6.2 kernels
2796 # until the filemap_read() issue is fixed by v6.2-rc4-61-g5956592ce337
2797 (( $LINUX_VERSION_CODE < $(version_code 5.12.0) ||
2798 $LINUX_VERSION_CODE >= $(version_code 6.2.0) )) ||
2799 skip "Need kernel < 5.12.0 or >= 6.2.0 for filemap_read() fix"
2801 test_mkdir $DIR/$tdir
2802 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2803 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2805 # create foreign file (raw way)
2806 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2807 error "creating $tfile w/ hex flags w/o --foreign should fail"
2809 ! $LFS setstripe --foreign --flags foo \
2810 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2811 error "creating $tfile with '--flags foo' should fail"
2813 ! $LFS setstripe --foreign --flags 0xffffffff \
2814 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2815 error "creating $tfile w/ 0xffffffff flags should fail"
2817 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2818 -t 1 -F 0xda08 || error "create_foreign_file failed"
2820 # verify foreign file (raw way)
2821 parse_foreign_file -f $DIR/$tdir/$tfile |
2822 grep "lov_foreign_magic: 0x0BD70BD0" ||
2823 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2824 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2825 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2826 parse_foreign_file -f $DIR/$tdir/$tfile |
2827 grep "lov_foreign_size: 73" ||
2828 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2829 parse_foreign_file -f $DIR/$tdir/$tfile |
2830 grep "lov_foreign_type: 1" ||
2831 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2832 parse_foreign_file -f $DIR/$tdir/$tfile |
2833 grep "lov_foreign_flags: 0x0000DA08" ||
2834 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2835 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2836 grep "lov_foreign_value: 0x" |
2837 sed -e 's/lov_foreign_value: 0x//')
2838 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2839 [[ $lov = ${lov2// /} ]] ||
2840 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2842 # create foreign file (lfs + API)
2843 $LFS setstripe --foreign=none --flags 0xda08 \
2844 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2845 error "$DIR/$tdir/${tfile}2: create failed"
2847 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2848 grep "lfm_magic:.*0x0BD70BD0" ||
2849 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2850 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2851 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2852 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2853 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2854 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2855 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2856 grep "lfm_flags:.*0x0000DA08" ||
2857 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2858 $LFS getstripe $DIR/$tdir/${tfile}2 |
2859 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2860 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2862 # modify striping should fail
2863 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2864 error "$DIR/$tdir/$tfile: setstripe should fail"
2865 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2866 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2869 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2870 cat $DIR/$tdir/${tfile}2 &&
2871 error "$DIR/$tdir/${tfile}2: read should fail"
2872 cat /etc/passwd > $DIR/$tdir/$tfile &&
2873 error "$DIR/$tdir/$tfile: write should fail"
2874 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2875 error "$DIR/$tdir/${tfile}2: write should fail"
2878 chmod 222 $DIR/$tdir/$tfile ||
2879 error "$DIR/$tdir/$tfile: chmod failed"
2880 chmod 222 $DIR/$tdir/${tfile}2 ||
2881 error "$DIR/$tdir/${tfile}2: chmod failed"
2884 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2885 error "$DIR/$tdir/$tfile: chown failed"
2886 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2887 error "$DIR/$tdir/${tfile}2: chown failed"
2889 # rename should work
2890 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2891 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2892 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2893 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2895 #remove foreign file
2896 rm $DIR/$tdir/${tfile}.new ||
2897 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2898 rm $DIR/$tdir/${tfile}2.new ||
2899 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2901 run_test 27J "basic ops on file with foreign LOV"
2904 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2905 skip "Need MDS version newer than 2.12.49"
2907 test_mkdir $DIR/$tdir
2908 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2909 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2911 # create foreign dir (raw way)
2912 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2913 error "creating $tdir w/ hex flags w/o --foreign should fail"
2915 ! $LFS setdirstripe --foreign --flags foo \
2916 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2917 error "creating $tdir with '--flags foo' should fail"
2919 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2920 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2921 error "creating $tdir w/ 0xffffffff flags should fail"
2923 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2924 error "create_foreign_dir FAILED"
2926 # verify foreign dir (raw way)
2927 parse_foreign_dir -d $DIR/$tdir/$tdir |
2928 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2929 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2930 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2931 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2932 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2933 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2934 parse_foreign_dir -d $DIR/$tdir/$tdir |
2935 grep "lmv_foreign_flags: 55813$" ||
2936 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2937 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2938 grep "lmv_foreign_value: 0x" |
2939 sed 's/lmv_foreign_value: 0x//')
2940 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2942 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2944 # create foreign dir (lfs + API)
2945 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2946 $DIR/$tdir/${tdir}2 ||
2947 error "$DIR/$tdir/${tdir}2: create failed"
2949 $LFS getdirstripe -v $DIR/$tdir/${tdir}2
2951 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2952 grep "lfm_magic:.*0x0CD50CD0" ||
2953 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2954 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2955 # - sizeof(lfm_type) - sizeof(lfm_flags)
2956 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2957 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2958 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2959 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2960 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2961 grep "lfm_flags:.*0x0000DA05" ||
2962 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2963 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2964 grep "lfm_value.*${uuid1}@${uuid2}" ||
2965 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2967 # file create in dir should fail
2968 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
2969 touch $DIR/$tdir/${tdir}2/$tfile &&
2970 error "$DIR/${tdir}2: file create should fail"
2973 chmod 777 $DIR/$tdir/$tdir ||
2974 error "$DIR/$tdir: chmod failed"
2975 chmod 777 $DIR/$tdir/${tdir}2 ||
2976 error "$DIR/${tdir}2: chmod failed"
2979 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2980 error "$DIR/$tdir: chown failed"
2981 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2982 error "$DIR/${tdir}2: chown failed"
2984 # rename should work
2985 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2986 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2987 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2988 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2991 rmdir $DIR/$tdir/${tdir}.new ||
2992 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2993 rmdir $DIR/$tdir/${tdir}2.new ||
2994 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2996 run_test 27K "basic ops on dir with foreign LMV"
2999 remote_mds_nodsh && skip "remote MDS with nodsh"
3001 local POOL=${POOL:-$TESTNAME}
3003 pool_add $POOL || error "pool_add failed"
3005 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
3006 error "pool_list does not contain ${FSNAME}.${POOL}:" \
3007 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
3009 run_test 27L "lfs pool_list gives correct pool name"
3012 (( $MDS1_VERSION >= $(version_code 2.12.57) )) ||
3013 skip "Need MDS version >= than 2.12.57"
3014 remote_mds_nodsh && skip "remote MDS with nodsh"
3015 (( $OSTCOUNT > 1 )) || skip "need > 1 OST"
3017 # Set default striping on directory
3020 local mdts=$(comma_list $(mdts_nodes))
3022 # if we run against a 2.12 server which lacks overstring support
3023 # then the connect_flag will not report overstriping, even if client
3025 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
3026 stripe_opt="-C $setcount"
3027 elif (( $OSTCOUNT >= $setcount )); then
3028 stripe_opt="-c $setcount"
3030 skip "server does not support overstriping"
3033 test_mkdir $DIR/$tdir
3035 # Validate existing append_* params and ensure restore
3036 local pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3037 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3038 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3040 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3041 ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count"
3042 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1"
3044 $LFS setstripe $stripe_opt $DIR/$tdir
3046 echo 1 > $DIR/$tdir/${tfile}.1
3047 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
3048 (( $count == $setcount )) ||
3049 error "(1) stripe count $count, should be $setcount"
3051 local appendcount=$orig_count
3052 echo 1 >> $DIR/$tdir/${tfile}.2_append
3053 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
3054 (( $count == $appendcount )) ||
3055 error "(2)stripe count $count, should be $appendcount for append"
3057 # Disable O_APPEND striping, verify it works
3058 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3060 # Should now get the default striping, which is 4
3062 echo 1 >> $DIR/$tdir/${tfile}.3_append
3063 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3064 (( $count == $setcount )) ||
3065 error "(3) stripe count $count, should be $setcount"
3067 # Try changing the stripe count for append files
3068 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3070 # Append striping is now 2 (directory default is still 4)
3072 echo 1 >> $DIR/$tdir/${tfile}.4_append
3073 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3074 (( $count == $appendcount )) ||
3075 error "(4) stripe count $count, should be $appendcount for append"
3077 # Test append stripe count of -1
3078 # Exercise LU-16872 patch with specific striping, only if MDS has fix
3079 (( $MDS1_VERSION > $(version_code 2.15.56.46) )) &&
3080 $LFS setstripe -o 0,$((OSTCOUNT - 1)) $DIR/$tdir &&
3081 touch $DIR/$tdir/$tfile.specific.{1..128}
3082 stack_trap "rm -f $DIR/$tdir/$tfile.*"
3084 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3085 appendcount=$OSTCOUNT
3086 echo 1 >> $DIR/$tdir/${tfile}.5
3087 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3088 (( $count == $appendcount )) ||
3089 error "(5) stripe count $count, should be $appendcount for append"
3091 # Set append striping back to default of 1
3092 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3094 # Try a new default striping, PFL + DOM
3095 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3097 # Create normal DOM file, DOM returns stripe count == 0
3099 touch $DIR/$tdir/${tfile}.6
3100 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3101 (( $count == $setcount )) ||
3102 error "(6) stripe count $count, should be $setcount"
3106 echo 1 >> $DIR/$tdir/${tfile}.7_append
3107 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3108 (( $count == $appendcount )) ||
3109 error "(7) stripe count $count, should be $appendcount for append"
3111 # Clean up DOM layout
3112 $LFS setstripe -d $DIR/$tdir
3114 save_layout_restore_at_exit $MOUNT
3115 # Now test that append striping works when layout is from root
3116 $LFS setstripe -c 2 $MOUNT
3117 # Make a special directory for this
3118 mkdir $DIR/${tdir}/${tdir}.2
3120 # Verify for normal file
3122 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3123 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3124 (( $count == $setcount )) ||
3125 error "(8) stripe count $count, should be $setcount"
3128 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3129 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3130 (( $count == $appendcount )) ||
3131 error "(9) stripe count $count, should be $appendcount for append"
3133 # Now test O_APPEND striping with pools
3134 pool_add $TESTNAME || error "pool creation failed"
3135 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3136 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3138 echo 1 >> $DIR/$tdir/${tfile}.10_append
3140 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3141 [[ "$pool" == "$TESTNAME" ]] || error "(10) incorrect pool: $pool"
3143 # Check that count is still correct
3145 echo 1 >> $DIR/$tdir/${tfile}.11_append
3146 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3147 (( $count == $appendcount )) ||
3148 error "(11) stripe count $count, should be $appendcount for append"
3150 # Disable O_APPEND stripe count, verify pool works separately
3151 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3153 echo 1 >> $DIR/$tdir/${tfile}.12_append
3155 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3156 [[ "$pool" == "$TESTNAME" ]] || error "(12) incorrect pool: $pool"
3158 # Remove pool setting, verify it's not applied
3159 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3161 echo 1 >> $DIR/$tdir/${tfile}.13_append
3163 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3164 [[ -z "$pool" ]] || error "(13) pool found: $pool"
3166 run_test 27M "test O_APPEND striping"
3169 combined_mgs_mds && skip "needs separate MGS/MDT"
3171 pool_add $TESTNAME || error "pool_add failed"
3172 do_facet mgs "$LCTL pool_list $FSNAME" |
3173 grep -Fx "${FSNAME}.${TESTNAME}" ||
3174 error "lctl pool_list on MGS failed"
3176 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3178 clean_foreign_symlink() {
3180 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3181 for i in $DIR/$tdir/* ; do
3182 $LFS unlink_foreign $i || true
3187 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3188 skip "Need MDS version newer than 2.12.51"
3190 test_mkdir $DIR/$tdir
3191 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3192 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3194 trap clean_foreign_symlink EXIT
3196 # enable foreign_symlink behaviour
3197 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3199 # foreign symlink LOV format is a partial path by default
3201 # create foreign file (lfs + API)
3202 $LFS setstripe --foreign=symlink --flags 0xda05 \
3203 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3204 error "$DIR/$tdir/${tfile}: create failed"
3206 $LFS getstripe -v $DIR/$tdir/${tfile} |
3207 grep "lfm_magic:.*0x0BD70BD0" ||
3208 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3209 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3210 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3211 $LFS getstripe -v $DIR/$tdir/${tfile} |
3212 grep "lfm_flags:.*0x0000DA05" ||
3213 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3214 $LFS getstripe $DIR/$tdir/${tfile} |
3215 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3216 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3218 # modify striping should fail
3219 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3220 error "$DIR/$tdir/$tfile: setstripe should fail"
3222 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3223 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3224 cat /etc/passwd > $DIR/$tdir/$tfile &&
3225 error "$DIR/$tdir/$tfile: write should fail"
3227 # rename should succeed
3228 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3229 error "$DIR/$tdir/$tfile: rename has failed"
3231 #remove foreign_symlink file should fail
3232 rm $DIR/$tdir/${tfile}.new &&
3233 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3236 mkdir /tmp/${uuid1} ||
3237 error "/tmp/${uuid1}: mkdir has failed"
3238 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3239 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3240 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3241 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3242 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3243 #read should succeed now
3244 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3245 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3246 #write should succeed now
3247 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3248 error "$DIR/$tdir/${tfile}.new: write should succeed"
3249 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3250 error "$DIR/$tdir/${tfile}.new: diff has failed"
3251 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3252 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3254 #check that getstripe still works
3255 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3256 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3258 # chmod should still succeed
3259 chmod 644 $DIR/$tdir/${tfile}.new ||
3260 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3262 # chown should still succeed
3263 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3264 error "$DIR/$tdir/${tfile}.new: chown has failed"
3266 # rename should still succeed
3267 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3268 error "$DIR/$tdir/${tfile}.new: rename has failed"
3270 #remove foreign_symlink file should still fail
3271 rm $DIR/$tdir/${tfile} &&
3272 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3274 #use special ioctl() to unlink foreign_symlink file
3275 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3276 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3279 run_test 27O "basic ops on foreign file of symlink type"
3282 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3283 skip "Need MDS version newer than 2.12.49"
3285 test_mkdir $DIR/$tdir
3286 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3287 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3289 trap clean_foreign_symlink EXIT
3291 # enable foreign_symlink behaviour
3292 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3294 # foreign symlink LMV format is a partial path by default
3296 # create foreign dir (lfs + API)
3297 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3298 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3299 error "$DIR/$tdir/${tdir}: create failed"
3301 $LFS getdirstripe -v $DIR/$tdir/${tdir}
3303 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3304 grep "lfm_magic:.*0x0CD50CD0" ||
3305 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3306 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3307 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3308 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3309 grep "lfm_flags:.*0x0000DA05" ||
3310 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3311 $LFS getdirstripe $DIR/$tdir/${tdir} |
3312 grep "lfm_value.*${uuid1}/${uuid2}" ||
3313 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3315 # file create in dir should fail
3316 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3317 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
3319 # rename should succeed
3320 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3321 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3323 #remove foreign_symlink dir should fail
3324 rmdir $DIR/$tdir/${tdir}.new &&
3325 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3328 mkdir -p /tmp/${uuid1}/${uuid2} ||
3329 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3330 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3331 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3332 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3333 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3334 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3335 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3336 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3338 #check that getstripe fails now that foreign_symlink enabled
3339 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3340 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3342 # file create in dir should work now
3343 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3344 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3345 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3346 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3347 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3348 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3350 # chmod should still succeed
3351 chmod 755 $DIR/$tdir/${tdir}.new ||
3352 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3354 # chown should still succeed
3355 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3356 error "$DIR/$tdir/${tdir}.new: chown has failed"
3358 # rename should still succeed
3359 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3360 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3362 #remove foreign_symlink dir should still fail
3363 rmdir $DIR/$tdir/${tdir} &&
3364 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3366 #use special ioctl() to unlink foreign_symlink file
3367 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3368 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3370 #created file should still exist
3371 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3372 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3373 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3374 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3376 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3379 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3380 stack_trap "rm -f $TMP/$tfile*"
3382 test_mkdir $DIR/$tdir-1
3383 test_mkdir $DIR/$tdir-2
3385 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3386 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3388 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3389 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3391 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3392 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3394 # Create some bad symlinks and ensure that we don't loop
3395 # forever or something. These should return ELOOP (40) and
3396 # ENOENT (2) but I don't want to test for that because there's
3397 # always some weirdo architecture that needs to ruin
3398 # everything by defining these error numbers differently.
3400 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3401 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3403 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3404 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3408 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3411 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
3412 skip "need MDS 2.14.55 or later"
3413 (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
3415 local testdir="$DIR/$tdir"
3416 test_mkdir -p $testdir
3417 stack_trap "rm -rf $testdir"
3418 $LFS setstripe -c -1 $testdir || error "setstripe failed"
3420 local f1="$testdir/f1"
3421 touch $f1 || error "failed to touch $f1"
3422 local count=$($LFS getstripe -c $f1)
3423 (( $count == $OSTCOUNT )) || error "wrong stripe count"
3425 do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
3426 (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
3428 local maxcount=$(($OSTCOUNT - 1))
3429 local mdts=$(comma_list $(mdts_nodes))
3430 do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
3431 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
3433 local f2="$testdir/f2"
3434 touch $f2 || error "failed to touch $f2"
3435 local count=$($LFS getstripe -c $f2)
3436 (( $count == $maxcount )) || error "wrong stripe count"
3438 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
3441 [ $(facet_host client) == $(facet_host ost1) ] &&
3442 skip "need ost1 and client on different nodes"
3444 #define OBD_FAIL_OSC_NO_GRANT 0x411
3445 $LCTL set_param fail_loc=0x20000411 fail_val=1
3446 #define OBD_FAIL_OST_ENOSPC 0x215
3447 do_facet ost1 "$LCTL set_param fail_loc=0x80000215"
3448 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3449 $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c ||
3450 error "multiop failed"
3452 run_test 27T "no eio on close on partial write due to enosp"
3455 local dir=$DIR/$tdir
3456 local file=$dir/$tfile
3457 local append_pool=${TESTNAME}-append
3458 local normal_pool=${TESTNAME}-normal
3462 local mdts=$(comma_list $(mdts_nodes))
3464 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
3465 skip "Need MDS version at least 2.15.51 for append pool feature"
3467 # Validate existing append_* params and ensure restore
3468 pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3469 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3470 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3472 stripe_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3473 ((stripe_count == 1)) || error "expected append_stripe_count != 0, got $stripe_count"
3474 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$stripe_count"
3476 pool_add $append_pool || error "pool creation failed"
3477 pool_add_targets $append_pool 0 1 || error "Pool add targets failed"
3479 pool_add $normal_pool || error "pool creation failed"
3480 pool_add_targets $normal_pool 0 1 || error "Pool add targets failed"
3483 $LFS setstripe -E 1M -c 1 -p $normal_pool -E 2M -c 2 -p $normal_pool -E eof -c -1 $dir
3486 $LFS getstripe $file.1
3488 pool=$($LFS getstripe -p $file.1)
3489 [[ "$pool" == "$normal_pool" ]] || error "got pool '$pool', expected '$normal_pool'"
3491 stripe_count2=$($LFS getstripe -c $file.1)
3492 ((stripe_count2 == stripe_count)) ||
3493 error "got stripe_count '$stripe_count2', expected '$stripe_count'"
3495 do_nodes $mdts $LCTL set_param mdd.*.append_pool=$append_pool
3498 $LFS getstripe $file.2
3500 pool=$($LFS getstripe -p $file.2)
3501 [[ "$pool" == "$append_pool" ]] || error "got pool '$pool', expected '$append_pool'"
3503 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3506 $LFS getstripe $file.3
3508 stripe_count2=$($LFS getstripe -c $file.3)
3509 ((stripe_count2 == 2)) || error "got stripe_count '$stripe_count2', expected 2"
3511 run_test 27U "append pool and stripe count work with composite default layout"
3514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3515 (( $OSTCOUNT >= 4 )) || skip_env "needs >= 4 OSTs"
3517 local dir=$DIR/$tdir
3518 local osp_param=osp.$FSNAME-OST0000-osc-MDT0000.max_create_count
3519 local lod_param=lod.$FSNAME-MDT0000-mdtlov.qos_threshold_rr
3520 local saved_max=$(do_facet mds1 $LCTL get_param -n $osp_param)
3521 local saved_qos=$(do_facet mds1 $LCTL get_param -n $lod_param)
3524 stack_trap "do_facet mds1 $LCTL set_param $osp_param=$saved_max"
3526 do_facet mds1 $LCTL set_param $lod_param=0
3527 stack_trap "do_facet mds1 $LCTL set_param $lod_param=$saved_qos"
3529 $LFS setdirstripe --mdt-count=1 --mdt-index=0 $dir
3530 stack_trap "rm -rf $dir"
3532 # exercise race in LU-16981 with deactivating OST while creating a file
3535 do_facet mds1 $LCTL set_param $osp_param=0 > /dev/null
3538 $LCTL set_param $osp_param=$saved_max > /dev/null
3543 stack_trap "kill -9 $pid"
3545 # errors here are OK so ignore them (just don't want to crash)
3546 $LFS setstripe -c -1 $dir/f.{1..200} 2> /dev/null
3550 run_test 27V "creating widely striped file races with deactivating OST"
3552 # createtest also checks that device nodes are created and
3553 # then visible correctly (#2091)
3554 test_28() { # bug 2091
3556 $CREATETEST $DIR/d28/ct || error "createtest failed"
3558 run_test 28 "create/mknod/mkdir with bad file types ============"
3561 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3563 [ $MDS1_VERSION -ge $(version_code 2.14.51) ] && {
3565 stack_trap "restore_opencache"
3568 sync; sleep 1; sync # flush out any dirty pages from previous tests
3575 local locks_orig=$(total_used_locks mdc)
3576 (( $locks_orig != 0 )) || error "No mdc lock count"
3578 local locks_unused_orig=$(total_unused_locks mdc)
3584 local locks_current=$(total_used_locks mdc)
3586 local locks_unused_current=$(total_unused_locks mdc)
3588 if (( $locks_current > $locks_orig )); then
3589 $LCTL set_param -n ldlm.dump_namespaces ""
3590 error "CURRENT: $locks_current > $locks_orig"
3592 if (( $locks_unused_current > $locks_unused_orig )); then
3593 error "UNUSED: $locks_unused_current > $locks_unused_orig"
3596 run_test 29 "IT_GETATTR regression ============================"
3598 test_30a() { # was test_30
3599 cp $(which ls) $DIR || cp /bin/ls $DIR
3600 $DIR/ls / || error "Can't execute binary from lustre"
3603 run_test 30a "execute binary from Lustre (execve) =============="
3606 cp `which ls` $DIR || cp /bin/ls $DIR
3608 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3611 run_test 30b "execute binary from Lustre as non-root ==========="
3613 test_30c() { # b=22376
3614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3616 cp $(which ls) $DIR || cp /bin/ls $DIR
3618 cancel_lru_locks mdc
3619 cancel_lru_locks osc
3620 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3623 run_test 30c "execute binary from Lustre without read perms ===="
3626 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3628 for i in {1..10}; do
3629 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3632 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3633 wait $PID || error "executing dd from Lustre failed"
3639 run_test 30d "execute binary from Lustre while clear locks"
3642 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3643 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3645 run_test 31a "open-unlink file =================================="
3648 touch $DIR/f31 || error "touch $DIR/f31 failed"
3649 ln $DIR/f31 $DIR/f31b || error "ln failed"
3650 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3651 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3653 run_test 31b "unlink file with multiple links while open ======="
3656 touch $DIR/f31 || error "touch $DIR/f31 failed"
3657 ln $DIR/f31 $DIR/f31c || error "ln failed"
3658 multiop_bg_pause $DIR/f31 O_uc ||
3659 error "multiop_bg_pause for $DIR/f31 failed"
3661 $MULTIOP $DIR/f31c Ouc
3662 kill -USR1 $MULTIPID
3665 run_test 31c "open-unlink file with multiple links ============="
3668 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3669 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3671 run_test 31d "remove of open directory ========================="
3673 test_31e() { # bug 2904
3674 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3676 run_test 31e "remove of open non-empty directory ==============="
3678 test_31f() { # bug 4554
3679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3682 test_mkdir $DIR/d31f
3683 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3684 cp /etc/hosts $DIR/d31f
3686 $LFS getstripe $DIR/d31f/hosts
3687 multiop_bg_pause $DIR/d31f D_c || return 1
3690 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3691 test_mkdir $DIR/d31f
3692 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3693 cp /etc/hosts $DIR/d31f
3695 $LFS getstripe $DIR/d31f/hosts
3696 multiop_bg_pause $DIR/d31f D_c || return 1
3699 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3700 wait $MULTIPID || error "first opendir $MULTIPID failed"
3704 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3705 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3708 run_test 31f "remove of open directory with open-unlink file ==="
3711 echo "-- cross directory link --"
3712 test_mkdir -c1 $DIR/${tdir}ga
3713 test_mkdir -c1 $DIR/${tdir}gb
3714 touch $DIR/${tdir}ga/f
3715 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3716 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3717 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3718 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3719 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3721 run_test 31g "cross directory link==============="
3724 echo "-- cross directory link --"
3725 test_mkdir -c1 $DIR/${tdir}
3726 test_mkdir -c1 $DIR/${tdir}/dir
3727 touch $DIR/${tdir}/f
3728 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3729 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3730 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3731 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3732 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3734 run_test 31h "cross directory link under child==============="
3737 echo "-- cross directory link --"
3738 test_mkdir -c1 $DIR/$tdir
3739 test_mkdir -c1 $DIR/$tdir/dir
3740 touch $DIR/$tdir/dir/f
3741 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3742 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3743 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3744 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3745 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3747 run_test 31i "cross directory link under parent==============="
3750 test_mkdir -c1 -p $DIR/$tdir
3751 test_mkdir -c1 -p $DIR/$tdir/dir1
3752 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3753 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3754 link $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "link to the same dir"
3757 run_test 31j "link for directory"
3760 test_mkdir -c1 -p $DIR/$tdir
3762 touch $DIR/$tdir/exist
3763 link $DIR/$tdir/s $DIR/$tdir/t || error "link"
3764 link $DIR/$tdir/s $DIR/$tdir/exist && error "link to exist file"
3765 link $DIR/$tdir/s $DIR/$tdir/s && error "link to the same file"
3766 link $DIR/$tdir/s $DIR/$tdir && error "link to parent dir"
3767 link $DIR/$tdir $DIR/$tdir/s && error "link parent dir to target"
3768 link $DIR/$tdir/not-exist $DIR/$tdir/foo && error "link non-existing to new"
3769 link $DIR/$tdir/not-exist $DIR/$tdir/s && error "link non-existing to exist"
3772 run_test 31k "link to file: the same, non-existing, dir"
3775 local ln_ver=$(ln --version | awk '/coreutils/ { print $4 }')
3777 (( $(version_code $ln_ver) < $(version_code 8.31) )) ||
3778 (( $(version_code $(uname -r)) >= $(version_code 5.18) )) ||
3779 skip "need coreutils < 8.31 or kernel >= 5.18 for ln"
3781 touch $DIR/$tfile || error "create failed"
3782 mkdir $DIR/$tdir || error "mkdir failed"
3783 ln $DIR/$tfile $DIR/$tdir/ || error "ln to '$tdir/' failed"
3785 run_test 31l "link to file: target dir has trailing slash"
3791 touch $DIR/d31m2/exist
3792 link $DIR/d31m/s $DIR/d31m2/t || error "link"
3793 link $DIR/d31m/s $DIR/d31m2/exist && error "link to exist file"
3794 link $DIR/d31m/s $DIR/d31m2 && error "link to parent dir"
3795 link $DIR/d31m2 $DIR/d31m/s && error "link parent dir to target"
3796 link $DIR/d31m/not-exist $DIR/d31m2/foo && error "link non-existing to new"
3797 link $DIR/d31m/not-exist $DIR/d31m2/s && error "link non-existing to exist"
3800 run_test 31m "link to file: the same, non-existing, dir"
3803 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3804 nlink=$(stat --format=%h $DIR/$tfile)
3805 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3807 local cmd="exec $fd<$DIR/$tfile"
3810 trap "eval $cmd" EXIT
3811 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3812 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3813 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3814 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3815 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3818 run_test 31n "check link count of unlinked file"
3821 local tempfile=$(mktemp $1_XXXXXX)
3822 link $tempfile $1 2> /dev/null &&
3823 echo "$BASHPID: link $tempfile to $1 succeeded"
3827 test_31o() { # LU-2901
3828 test_mkdir $DIR/$tdir
3829 for LOOP in $(seq 100); do
3830 rm -f $DIR/$tdir/$tfile*
3831 for THREAD in $(seq 8); do
3832 link_one $DIR/$tdir/$tfile.$LOOP &
3835 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3836 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3837 error "$LINKS duplicate links to $tfile.$LOOP" &&
3841 run_test 31o "duplicate hard links with same filename"
3844 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3846 test_mkdir $DIR/$tdir
3847 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3848 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3850 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3851 error "open unlink test1 failed"
3852 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3853 error "open unlink test2 failed"
3855 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3856 error "test1 still exists"
3857 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3858 error "test2 still exists"
3860 run_test 31p "remove of open striped directory"
3863 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3865 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3866 index=$($LFS getdirstripe -i $DIR/$tdir)
3867 [ $index -eq 3 ] || error "first stripe index $index != 3"
3868 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3869 [ $index -eq 1 ] || error "second stripe index $index != 1"
3871 # when "-c <stripe_count>" is set, the number of MDTs specified after
3872 # "-i" should equal to the stripe count
3873 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3875 run_test 31q "create striped directory on specific MDTs"
3879 touch $DIR/$tfile.target
3880 touch $DIR/$tfile.source
3882 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3883 $LCTL set_param fail_loc=0x1419 fail_val=3
3884 cat $DIR/$tfile.target &
3887 # Guarantee open is waiting before we get here
3889 mv $DIR/$tfile.source $DIR/$tfile.target
3893 if [[ $RC -ne 0 ]]; then
3894 error "open with cat failed, rc=$RC"
3897 run_test 31r "open-rename(replace) race"
3899 cleanup_test32_mount() {
3902 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3903 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3904 losetup -d $loopdev || true
3910 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3912 echo "== more mountpoints and symlinks ================="
3913 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3914 trap cleanup_test32_mount EXIT
3915 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3916 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3917 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3918 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3919 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3920 cleanup_test32_mount
3922 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3925 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3927 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3928 trap cleanup_test32_mount EXIT
3929 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3930 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3931 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3932 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3933 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3934 cleanup_test32_mount
3936 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3939 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3941 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3942 trap cleanup_test32_mount EXIT
3943 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3944 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3945 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3946 test_mkdir -p $DIR/$tdir/d2/test_dir
3947 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3948 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3949 cleanup_test32_mount
3951 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3954 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3956 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3957 trap cleanup_test32_mount EXIT
3958 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3959 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3960 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3961 test_mkdir -p $DIR/$tdir/d2/test_dir
3962 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3963 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3964 cleanup_test32_mount
3966 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3970 test_mkdir -p $DIR/$tdir/tmp
3971 local tmp_dir=$DIR/$tdir/tmp
3972 ln -s $DIR/$tdir $tmp_dir/symlink11
3973 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3974 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3975 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3977 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3981 test_mkdir -p $DIR/$tdir/tmp
3982 local tmp_dir=$DIR/$tdir/tmp
3983 ln -s $DIR/$tdir $tmp_dir/symlink11
3984 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3985 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3986 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3988 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3991 local tmp_dir=$DIR/$tdir/tmp
3992 test_mkdir -p $tmp_dir
3993 test_mkdir $DIR/${tdir}2
3994 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3995 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3996 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3997 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3998 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3999 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
4001 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
4004 rm -fr $DIR/$tdir $DIR/${tdir}2
4005 tmp_dir=$DIR/$tdir/tmp
4006 test_mkdir -p $tmp_dir
4007 test_mkdir $DIR/${tdir}2
4008 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
4009 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
4010 ls $tmp_dir/symlink12 || error "listing symlink12"
4011 ls $DIR/$tdir/symlink02 || error "listing symlink02"
4013 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
4016 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4018 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4019 trap cleanup_test32_mount EXIT
4020 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4021 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4022 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4023 touch $DIR/$tdir/test_file
4024 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
4025 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
4026 cleanup_test32_mount
4028 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
4031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4033 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4034 trap cleanup_test32_mount EXIT
4035 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4036 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4037 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4038 touch $DIR/$tdir/test_file
4039 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
4040 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
4041 cleanup_test32_mount
4043 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
4046 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4049 trap cleanup_test32_mount EXIT
4050 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4051 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4052 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4053 test_mkdir -p $DIR/$tdir/d2
4054 touch $DIR/$tdir/d2/test_file || error "touch failed"
4055 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
4056 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
4057 cleanup_test32_mount
4059 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
4062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4065 trap cleanup_test32_mount EXIT
4066 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4067 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4068 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4069 test_mkdir -p $DIR/$tdir/d2
4070 touch $DIR/$tdir/d2/test_file || error "touch failed"
4071 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
4072 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
4073 cleanup_test32_mount
4075 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
4079 test_mkdir -p $DIR/d32m/tmp
4080 TMP_DIR=$DIR/d32m/tmp
4081 ln -s $DIR $TMP_DIR/symlink11
4082 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4083 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
4084 error "symlink11 not a link"
4085 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
4086 error "symlink01 not a link"
4088 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
4092 test_mkdir -p $DIR/d32n/tmp
4093 TMP_DIR=$DIR/d32n/tmp
4094 ln -s $DIR $TMP_DIR/symlink11
4095 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4096 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
4097 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
4099 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
4103 test_mkdir -p $DIR/d32o/tmp
4104 TMP_DIR=$DIR/d32o/tmp
4105 ln -s $DIR/$tfile $TMP_DIR/symlink12
4106 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4107 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
4108 error "symlink12 not a link"
4109 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
4110 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
4111 error "$DIR/d32o/tmp/symlink12 not file type"
4112 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
4113 error "$DIR/d32o/symlink02 not file type"
4115 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
4125 test_mkdir -p $DIR/d32p/tmp
4127 TMP_DIR=$DIR/d32p/tmp
4129 ln -s $DIR/$tfile $TMP_DIR/symlink12
4131 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4133 cat $DIR/d32p/tmp/symlink12 ||
4134 error "Can't open $DIR/d32p/tmp/symlink12"
4136 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
4139 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
4142 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4144 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4145 trap cleanup_test32_mount EXIT
4146 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4147 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4148 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4149 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4150 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
4151 cleanup_test32_mount
4153 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4156 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4158 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4159 trap cleanup_test32_mount EXIT
4160 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4161 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4162 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4163 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4164 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4165 cleanup_test32_mount
4167 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4172 chmod 444 $DIR/$tfile
4173 chown $RUNAS_ID $DIR/$tfile
4175 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4178 run_test 33aa "write file with mode 444 (should return error)"
4182 test_mkdir $DIR/$tdir
4183 chown $RUNAS_ID $DIR/$tdir
4184 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4185 error "$RUNAS create $tdir/$tfile failed"
4186 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4187 error "open RDWR" || true
4189 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4193 test_mkdir $DIR/$tdir
4194 chown $RUNAS_ID $DIR/$tdir
4195 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4197 run_test 33b "test open file with malformed flags (No panic)"
4200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4201 remote_ost_nodsh && skip "remote OST with nodsh"
4209 test_mkdir $DIR/$tdir
4210 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4213 for ostnum in $(seq $OSTCOUNT); do
4214 # test-framework's OST numbering is one-based, while Lustre's
4216 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4217 # check if at least some write_bytes stats are counted
4218 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4219 obdfilter.$ostname.stats |
4220 awk '/^write_bytes/ {print $7}' )
4221 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4222 if (( ${write_bytes:-0} > 0 )); then
4228 $all_zeros || return 0
4231 echo foo > $DIR/$tdir/bar
4235 # Total up write_bytes after writing. We'd better find non-zeros.
4236 for ostnum in $(seq $OSTCOUNT); do
4237 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4238 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4239 obdfilter/$ostname/stats |
4240 awk '/^write_bytes/ {print $7}' )
4241 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4242 if (( ${write_bytes:-0} > 0 )); then
4249 for ostnum in $(seq $OSTCOUNT); do
4250 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4251 echo "Check write_bytes is in obdfilter.*.stats:"
4252 do_facet ost$ostnum lctl get_param -n \
4253 obdfilter.$ostname.stats
4255 error "OST not keeping write_bytes stats (b=22312)"
4258 run_test 33c "test write_bytes stats"
4261 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4262 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4265 local remote_dir=$DIR/$tdir/remote_dir
4267 test_mkdir $DIR/$tdir
4268 $LFS mkdir -i $MDTIDX $remote_dir ||
4269 error "create remote directory failed"
4271 touch $remote_dir/$tfile
4272 chmod 444 $remote_dir/$tfile
4273 chown $RUNAS_ID $remote_dir/$tfile
4275 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4277 chown $RUNAS_ID $remote_dir
4278 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4279 error "create" || true
4280 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4281 error "open RDWR" || true
4282 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4284 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4287 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4291 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4292 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4293 mkdir $DIR/$tdir/local_dir
4295 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4296 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4297 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4299 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4300 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4302 rmdir $DIR/$tdir/* || error "rmdir failed"
4305 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4306 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4307 mkdir $DIR/$tdir/local_dir
4309 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4310 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4311 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4313 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4314 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4316 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4319 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4320 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4321 mkdir $DIR/$tdir/local_dir
4323 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4324 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4325 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4327 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4328 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4330 run_test 33e "mkdir and striped directory should have same mode"
4334 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4338 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4339 remote_mds_nodsh && skip "remote MDS with nodsh"
4342 chmod go+rwx $DIR/$tdir
4343 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4344 trap cleanup_33f EXIT
4346 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4347 error "cannot create striped directory"
4349 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4350 error "cannot create files in striped directory"
4352 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4353 error "cannot remove files in striped directory"
4355 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4356 error "cannot remove striped directory"
4360 run_test 33f "nonroot user can create, access, and remove a striped directory"
4363 mkdir -p $DIR/$tdir/dir2
4365 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4367 [[ $err =~ "exists" ]] || error "Not exists error"
4369 run_test 33g "nonroot user create already existing root created file"
4375 test_mkdir -c $MDSCOUNT -H $hash_type $DIR/$tdir ||
4376 error "lfs mkdir -H $hash_type $tdir failed"
4377 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4379 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4383 for fname in $DIR/$tdir/$tfile.bak \
4384 $DIR/$tdir/$tfile.SAV \
4385 $DIR/$tdir/$tfile.orig \
4386 $DIR/$tdir/$tfile~; do
4387 touch $fname || error "touch $fname failed"
4388 index2=$($LFS getstripe -m $fname)
4389 (( $index == $index2 )) ||
4390 error "$fname MDT index mismatch $index != $index2"
4394 local patterns=(".$tfile.XXXXXX" "$tfile.XXXXXXXX")
4397 for pattern in ${patterns[*]}; do
4398 echo "pattern $pattern"
4399 fname=$DIR/$tdir/$pattern
4400 for (( i = 0; i < $count; i++ )); do
4401 fname=$(mktemp $DIR/$tdir/$pattern) ||
4402 error "mktemp $DIR/$tdir/$pattern failed"
4403 index2=$($LFS getstripe -m $fname)
4404 (( $index == $index2 )) && continue
4406 failed=$((failed + 1))
4407 echo "$fname MDT index mismatch $index != $index2"
4411 echo "$failed/$count MDT index mismatches, expect ~2-4"
4412 (( failed < 10 )) || error "MDT index mismatch $failed/$count times"
4417 # verify that "crush" is still broken with all files on same MDT,
4418 # crush2 should have about 1/MDSCOUNT files on each MDT, with margin
4419 [[ "$hash_type" == "crush" ]] && expect=$count ||
4420 expect=$((count / MDSCOUNT))
4422 # crush2 doesn't put all-numeric suffixes on the same MDT,
4423 # filename like $tfile.12345678 should *not* be considered temp
4424 for pattern in ${patterns[*]}; do
4425 local base=${pattern%%X*}
4426 local suff=${pattern#$base}
4428 echo "pattern $pattern"
4429 for (( i = 0; i < $count; i++ )); do
4430 fname=$DIR/$tdir/$base$((${suff//X/1} + i))
4431 touch $fname || error "touch $fname failed"
4432 index2=$($LFS getstripe -m $fname)
4433 (( $index != $index2 )) && continue
4439 # the number of "bad" hashes is random, as it depends on the random
4440 # filenames generated by "mktemp". Allow some margin in the results.
4441 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4442 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4443 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4444 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4447 # crush2 doesn't put suffixes with special characters on the same MDT
4448 # filename like $tfile.txt.1234 should *not* be considered temp
4449 for pattern in ${patterns[*]}; do
4450 local base=${pattern%%X*}
4451 local suff=${pattern#$base}
4453 pattern=$base...${suff/XXX}
4454 echo "pattern=$pattern"
4455 for (( i = 0; i < $count; i++ )); do
4456 fname=$(mktemp $DIR/$tdir/$pattern) ||
4457 error "touch $fname failed"
4458 index2=$($LFS getstripe -m $fname)
4459 (( $index != $index2 )) && continue
4465 # the number of "bad" hashes is random, as it depends on the random
4466 # filenames generated by "mktemp". Allow some margin in the results.
4467 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4468 (( same / ${#patterns[*]} <= expect * 9 / 7 &&
4469 same / ${#patterns[*]} > expect * 5 / 7 )) ||
4470 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4474 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4475 (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
4476 skip "Need MDS version at least 2.13.50"
4480 run_test 33h "temp file is located on the same MDT as target (crush)"
4483 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4484 echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
4485 (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
4486 skip "Need MDS version at least 2.15.0 for crush2"
4490 run_test 33hh "temp file is located on the same MDT as target (crush2)"
4494 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4496 local FNAME=$(str_repeat 'f' 250)
4498 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4499 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4504 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4506 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4508 lctl --device %$MDC deactivate
4509 stack_trap "lctl --device %$MDC activate"
4510 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4511 total=$(\ls -l $DIR/$tdir | wc -l)
4512 # "ls -l" will list total in the first line
4513 total=$((total - 1))
4514 (( total + count == 1000 )) ||
4515 error "ls list $total files, $count files on MDT1"
4517 run_test 33i "striped directory can be accessed when one MDT is down"
4520 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4522 mkdir -p $DIR/$tdir/
4524 $LFS setdirstripe -D -i0,1 $DIR/$tdir/striped_dir_a &&
4525 error "setdirstripe -D -i0,1 incorrectly succeeded"
4527 $LFS setdirstripe -D -i0,1 -c1 $DIR/$tdir/striped_dir_b &&
4528 error "setdirstripe -D -i0,1 -c1 incorrectly succeeded"
4530 $LFS setdirstripe -D -i0,1 -c3 $DIR/$tdir/striped_dir_c &&
4531 error "setdirstripe -D -i0,1 -c3 incorrectly succeeded"
4533 $LFS setdirstripe -i0,1 $DIR/$tdir/striped_dir_e ||
4534 error "-D was not specified, but still failed"
4536 run_test 33j "lfs setdirstripe -D -i x,y,x should fail"
4538 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4541 $MCREATE $DIR/f34 || error "mcreate failed"
4542 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4543 error "getstripe failed"
4544 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4545 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4546 error "getstripe failed"
4547 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4548 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4550 run_test 34a "truncate file that has not been opened ==========="
4553 [ ! -f $DIR/f34 ] && test_34a
4554 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4555 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4556 $OPENFILE -f O_RDONLY $DIR/f34
4557 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4558 error "getstripe failed"
4559 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4560 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4562 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4565 [ ! -f $DIR/f34 ] && test_34a
4566 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4567 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4568 $OPENFILE -f O_RDWR $DIR/f34
4569 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4570 error "$LFS getstripe failed"
4571 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4572 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4574 run_test 34c "O_RDWR opening file-with-size works =============="
4577 [ ! -f $DIR/f34 ] && test_34a
4578 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4580 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4581 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4584 run_test 34d "write to sparse file ============================="
4588 $MCREATE $DIR/f34e || error "mcreate failed"
4589 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4590 $CHECKSTAT -s 1000 $DIR/f34e ||
4591 error "Size of $DIR/f34e not equal to 1000 bytes"
4592 $OPENFILE -f O_RDWR $DIR/f34e
4593 $CHECKSTAT -s 1000 $DIR/f34e ||
4594 error "Size of $DIR/f34e not equal to 1000 bytes"
4596 run_test 34e "create objects, some with size and some without =="
4598 test_34f() { # bug 6242, 6243
4599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4603 $MCREATE $DIR/f34f || error "mcreate failed"
4604 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4605 dd if=$DIR/f34f of=$TMP/f34f
4606 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4607 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4608 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4609 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4610 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4612 run_test 34f "read from a file with no objects until EOF ======="
4615 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4617 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4619 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4620 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4621 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4622 cancel_lru_locks osc
4623 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4624 error "wrong size after lock cancel"
4626 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4627 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4628 error "expanding truncate failed"
4629 cancel_lru_locks osc
4630 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4631 error "wrong expanded size after lock cancel"
4633 run_test 34g "truncate long file ==============================="
4636 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4641 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4642 sync # Flush the cache so that multiop below does not block on cache
4643 # flush when getting the group lock
4644 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4647 # Since just timed wait is not good enough, let's do a sync write
4648 # that way we are sure enough time for a roundtrip + processing
4649 # passed + 2 seconds of extra margin.
4650 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4654 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4655 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4659 local nsz=`stat -c %s $DIR/$tfile`
4660 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4662 run_test 34h "ftruncate file under grouplock should not block"
4665 cp /bin/sh $DIR/f35a
4667 chown $RUNAS_ID $DIR/f35a
4668 $RUNAS $DIR/f35a && error || true
4671 run_test 35a "exec file with mode 444 (should return and not leak)"
4675 utime $DIR/f36 || error "utime failed for MDS"
4677 run_test 36a "MDS utime check (mknod, utime)"
4681 utime $DIR/f36 || error "utime failed for OST"
4683 run_test 36b "OST utime check (open, utime)"
4688 chown $RUNAS_ID $DIR/d36
4689 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4691 run_test 36c "non-root MDS utime check (mknod, utime)"
4694 [ ! -d $DIR/d36 ] && test_36c
4695 echo "" > $DIR/d36/f36
4696 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4698 run_test 36d "non-root OST utime check (open, utime)"
4701 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4703 test_mkdir $DIR/$tdir
4704 touch $DIR/$tdir/$tfile
4705 $RUNAS utime $DIR/$tdir/$tfile &&
4706 error "utime worked, expected failure" || true
4708 run_test 36e "utime on non-owned file (should return error)"
4712 local LANG_SAVE=$LANG
4713 local LC_LANG_SAVE=$LC_LANG
4714 export LANG=C LC_LANG=C # for date language
4716 DATESTR="Dec 20 2000"
4717 test_mkdir $DIR/$tdir
4718 lctl set_param fail_loc=$fl
4720 cp /etc/hosts $DIR/$tdir/$tfile
4721 sync & # write RPC generated with "current" inode timestamp, but delayed
4723 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4724 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4725 cancel_lru_locks $OSC
4726 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4728 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4729 echo "BEFORE: $LS_BEFORE" && \
4730 echo "AFTER : $LS_AFTER" && \
4731 echo "WANT : $DATESTR" && \
4732 error "$DIR/$tdir/$tfile timestamps changed" || true
4734 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4738 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4740 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4741 subr_36fh "0x80000214"
4743 run_test 36f "utime on file racing with OST BRW write =========="
4746 remote_ost_nodsh && skip "remote OST with nodsh"
4747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4748 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4749 skip "Need MDS version at least 2.12.51"
4754 local tgt="obdfilter"
4756 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4758 test_mkdir $DIR/$tdir
4759 fmd_max_age=$(do_facet $facet \
4760 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4763 echo "FMD max age: ${fmd_max_age}s"
4764 touch $DIR/$tdir/$tfile
4765 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4766 gawk '{cnt=cnt+$1} END{print cnt}')
4767 echo "FMD before: $fmd"
4769 error "FMD wasn't create by touch"
4770 sleep $((fmd_max_age + 12))
4771 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4772 gawk '{cnt=cnt+$1} END{print cnt}')
4773 echo "FMD after: $fmd"
4775 error "FMD wasn't expired by ping"
4777 run_test 36g "FMD cache expiry ====================="
4780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4782 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4783 subr_36fh "0x80000227"
4785 run_test 36h "utime on file racing with OST BRW write =========="
4788 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4790 test_mkdir $DIR/$tdir
4791 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4793 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4794 local new_mtime=$((mtime + 200))
4796 #change Modify time of striped dir
4797 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4798 error "change mtime failed"
4800 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4802 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4804 run_test 36i "change mtime on striped directory"
4806 # test_37 - duplicate with tests 32q 32r
4809 local file=$DIR/$tfile
4811 openfile -f O_DIRECTORY $file
4814 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4815 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4817 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4819 test_39a() { # was test_39
4821 touch $DIR/${tfile}2
4822 # ls -l $DIR/$tfile $DIR/${tfile}2
4823 # ls -lu $DIR/$tfile $DIR/${tfile}2
4824 # ls -lc $DIR/$tfile $DIR/${tfile}2
4826 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4827 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4829 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4831 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4833 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4834 error "O_TRUNC didn't change timestamps"
4837 run_test 39a "mtime changed on create"
4840 test_mkdir -c1 $DIR/$tdir
4841 cp -p /etc/passwd $DIR/$tdir/fopen
4842 cp -p /etc/passwd $DIR/$tdir/flink
4843 cp -p /etc/passwd $DIR/$tdir/funlink
4844 cp -p /etc/passwd $DIR/$tdir/frename
4845 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4848 echo "aaaaaa" >> $DIR/$tdir/fopen
4849 echo "aaaaaa" >> $DIR/$tdir/flink
4850 echo "aaaaaa" >> $DIR/$tdir/funlink
4851 echo "aaaaaa" >> $DIR/$tdir/frename
4853 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4854 local link_new=`stat -c %Y $DIR/$tdir/flink`
4855 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4856 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4858 cat $DIR/$tdir/fopen > /dev/null
4859 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4860 rm -f $DIR/$tdir/funlink2
4861 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4863 for (( i=0; i < 2; i++ )) ; do
4864 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4865 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4866 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4867 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4869 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4870 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4871 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4872 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4874 cancel_lru_locks $OSC
4875 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4878 run_test 39b "mtime change on open, link, unlink, rename ======"
4880 # this should be set to past
4881 TEST_39_MTIME=`date -d "1 year ago" +%s`
4887 local mtime0=`stat -c %Y $DIR1/$tfile`
4889 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4890 local mtime1=`stat -c %Y $DIR1/$tfile`
4891 [ "$mtime1" = $TEST_39_MTIME ] || \
4892 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4895 echo hello >> $DIR1/$tfile
4897 local mtime2=`stat -c %Y $DIR1/$tfile`
4898 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4899 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4901 mv $DIR1/$tfile $DIR1/$tfile-1
4903 for (( i=0; i < 2; i++ )) ; do
4904 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4905 [ "$mtime2" = "$mtime3" ] || \
4906 error "mtime ($mtime2) changed (to $mtime3) on rename"
4908 cancel_lru_locks $OSC
4909 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4912 run_test 39c "mtime change on rename ==========================="
4916 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4919 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4921 for (( i=0; i < 2; i++ )) ; do
4922 local mtime=`stat -c %Y $DIR1/$tfile`
4923 [ $mtime = $TEST_39_MTIME ] || \
4924 error "mtime($mtime) is not set to $TEST_39_MTIME"
4926 cancel_lru_locks $OSC
4927 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4930 run_test 39d "create, utime, stat =============================="
4934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4937 local mtime1=`stat -c %Y $DIR1/$tfile`
4939 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4941 for (( i=0; i < 2; i++ )) ; do
4942 local mtime2=`stat -c %Y $DIR1/$tfile`
4943 [ $mtime2 = $TEST_39_MTIME ] || \
4944 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4946 cancel_lru_locks $OSC
4947 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4950 run_test 39e "create, stat, utime, stat ========================"
4954 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4957 mtime1=`stat -c %Y $DIR1/$tfile`
4960 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4962 for (( i=0; i < 2; i++ )) ; do
4963 local mtime2=`stat -c %Y $DIR1/$tfile`
4964 [ $mtime2 = $TEST_39_MTIME ] || \
4965 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4967 cancel_lru_locks $OSC
4968 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4971 run_test 39f "create, stat, sleep, utime, stat ================="
4975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4977 echo hello >> $DIR1/$tfile
4978 local mtime1=`stat -c %Y $DIR1/$tfile`
4981 chmod o+r $DIR1/$tfile
4983 for (( i=0; i < 2; i++ )) ; do
4984 local mtime2=`stat -c %Y $DIR1/$tfile`
4985 [ "$mtime1" = "$mtime2" ] || \
4986 error "lost mtime: $mtime2, should be $mtime1"
4988 cancel_lru_locks $OSC
4989 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4992 run_test 39g "write, chmod, stat ==============================="
4996 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5002 echo hello >> $DIR1/$tfile
5003 local mtime1=`stat -c %Y $DIR1/$tfile`
5005 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
5007 if [ "$d1" != "$d2" ]; then
5008 echo "write and touch not within one second"
5010 for (( i=0; i < 2; i++ )) ; do
5011 local mtime2=`stat -c %Y $DIR1/$tfile`
5012 [ "$mtime2" = $TEST_39_MTIME ] || \
5013 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
5015 cancel_lru_locks $OSC
5016 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5020 run_test 39h "write, utime within one second, stat ============="
5023 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5028 echo hello >> $DIR1/$tfile
5029 local mtime1=`stat -c %Y $DIR1/$tfile`
5031 mv $DIR1/$tfile $DIR1/$tfile-1
5033 for (( i=0; i < 2; i++ )) ; do
5034 local mtime2=`stat -c %Y $DIR1/$tfile-1`
5036 [ "$mtime1" = "$mtime2" ] || \
5037 error "lost mtime: $mtime2, should be $mtime1"
5039 cancel_lru_locks $OSC
5040 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5043 run_test 39i "write, rename, stat =============================="
5046 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5048 start_full_debug_logging
5052 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
5053 lctl set_param fail_loc=0x80000412
5054 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
5055 error "multiop failed"
5057 local mtime1=`stat -c %Y $DIR1/$tfile`
5059 mv $DIR1/$tfile $DIR1/$tfile-1
5061 kill -USR1 $multipid
5062 wait $multipid || error "multiop close failed"
5064 for (( i=0; i < 2; i++ )) ; do
5065 local mtime2=`stat -c %Y $DIR1/$tfile-1`
5066 [ "$mtime1" = "$mtime2" ] ||
5067 error "mtime is lost on close: $mtime2, " \
5071 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5073 lctl set_param fail_loc=0
5074 stop_full_debug_logging
5076 run_test 39j "write, rename, close, stat ======================="
5079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5084 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
5086 local mtime1=`stat -c %Y $DIR1/$tfile`
5088 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
5090 kill -USR1 $multipid
5091 wait $multipid || error "multiop close failed"
5093 for (( i=0; i < 2; i++ )) ; do
5094 local mtime2=`stat -c %Y $DIR1/$tfile`
5096 [ "$mtime2" = $TEST_39_MTIME ] || \
5097 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
5100 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5103 run_test 39k "write, utime, close, stat ========================"
5105 # this should be set to future
5106 TEST_39_ATIME=`date -d "1 year" +%s`
5109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5110 remote_mds_nodsh && skip "remote MDS with nodsh"
5112 local atime_diff=$(do_facet $SINGLEMDS \
5113 lctl get_param -n mdd.*MDT0000*.atime_diff)
5115 mkdir_on_mdt0 $DIR/$tdir
5117 # test setting directory atime to future
5118 touch -a -d @$TEST_39_ATIME $DIR/$tdir
5119 local atime=$(stat -c %X $DIR/$tdir)
5120 [ "$atime" = $TEST_39_ATIME ] ||
5121 error "atime is not set to future: $atime, $TEST_39_ATIME"
5123 # test setting directory atime from future to now
5124 local now=$(date +%s)
5125 touch -a -d @$now $DIR/$tdir
5127 atime=$(stat -c %X $DIR/$tdir)
5128 [ "$atime" -eq "$now" ] ||
5129 error "atime is not updated from future: $atime, $now"
5131 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
5134 # test setting directory atime when now > dir atime + atime_diff
5135 local d1=$(date +%s)
5137 local d2=$(date +%s)
5138 cancel_lru_locks mdc
5139 atime=$(stat -c %X $DIR/$tdir)
5140 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5141 error "atime is not updated : $atime, should be $d2"
5143 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
5146 # test not setting directory atime when now < dir atime + atime_diff
5148 cancel_lru_locks mdc
5149 atime=$(stat -c %X $DIR/$tdir)
5150 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5151 error "atime is updated to $atime, should remain $d1<atime<$d2"
5153 do_facet $SINGLEMDS \
5154 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5156 run_test 39l "directory atime update ==========================="
5159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5163 local far_past_mtime=$(date -d "May 29 1953" +%s)
5164 local far_past_atime=$(date -d "Dec 17 1903" +%s)
5166 touch -m -d @$far_past_mtime $DIR1/$tfile
5167 touch -a -d @$far_past_atime $DIR1/$tfile
5169 for (( i=0; i < 2; i++ )) ; do
5170 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
5171 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
5172 error "atime or mtime set incorrectly"
5174 cancel_lru_locks $OSC
5175 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5178 run_test 39m "test atime and mtime before 1970"
5180 test_39n() { # LU-3832
5181 remote_mds_nodsh && skip "remote MDS with nodsh"
5183 local atime_diff=$(do_facet $SINGLEMDS \
5184 lctl get_param -n mdd.*MDT0000*.atime_diff)
5189 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
5192 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
5193 atime0=$(stat -c %X $DIR/$tfile)
5196 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5197 atime1=$(stat -c %X $DIR/$tfile)
5200 cancel_lru_locks mdc
5201 cancel_lru_locks osc
5202 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5203 atime2=$(stat -c %X $DIR/$tfile)
5205 do_facet $SINGLEMDS \
5206 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5208 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
5209 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
5211 run_test 39n "check that O_NOATIME is honored"
5214 TESTDIR=$DIR/$tdir/$tfile
5215 [ -e $TESTDIR ] && rm -rf $TESTDIR
5222 links2=$(stat -c %h .)
5223 [ $(($links1 + 2)) != $links2 ] &&
5224 error "wrong links count $(($links1 + 2)) != $links2"
5226 links3=$(stat -c %h .)
5227 [ $(($links1 + 1)) != $links3 ] &&
5228 error "wrong links count $links1 != $links3"
5231 run_test 39o "directory cached attributes updated after create"
5234 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5237 TESTDIR=$DIR/$tdir/$tdir
5238 [ -e $TESTDIR ] && rm -rf $TESTDIR
5239 test_mkdir -p $TESTDIR
5243 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5244 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5246 links2=$(stat -c %h .)
5247 [ $(($links1 + 2)) != $links2 ] &&
5248 error "wrong links count $(($links1 + 2)) != $links2"
5250 links3=$(stat -c %h .)
5251 [ $(($links1 + 1)) != $links3 ] &&
5252 error "wrong links count $links1 != $links3"
5255 run_test 39p "remote directory cached attributes updated after create ========"
5258 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5259 skip "no atime update on old OST"
5260 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5261 skip_env "ldiskfs only test"
5265 saved_adiff=$(do_facet ost1 \
5266 lctl get_param -n obdfilter.*OST0000.atime_diff)
5267 stack_trap "do_facet ost1 \
5268 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5270 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5272 $LFS setstripe -i 0 $DIR/$tfile
5273 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5274 error "can't write initial file"
5275 cancel_lru_locks osc
5277 # exceed atime_diff and access file
5279 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5280 error "can't udpate atime"
5282 local atime_cli=$(stat -c %X $DIR/$tfile)
5283 echo "client atime: $atime_cli"
5284 # allow atime update to be written to device
5285 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5288 local ostdev=$(ostdevname 1)
5289 local fid=($($LFS getstripe $DIR/$tfile | grep 0x))
5290 local seq=${fid[3]#0x}
5294 if [ $seq == 0 ]; then
5297 oid_hex=${fid[2]#0x}
5299 local objpath="O/$seq/d$(($oid % 32))/$oid_hex"
5300 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5302 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5303 local atime_ost=$(do_facet ost1 "$cmd" |&
5304 awk -F'[: ]' '/atime:/ { print $4 }')
5305 (( atime_cli == atime_ost )) ||
5306 error "atime on client $atime_cli != ost $atime_ost"
5308 run_test 39r "lazy atime update on OST"
5310 test_39q() { # LU-8041
5311 local testdir=$DIR/$tdir
5313 multiop_bg_pause $testdir D_c || error "multiop failed"
5315 cancel_lru_locks mdc
5316 kill -USR1 $multipid
5317 local atime=$(stat -c %X $testdir)
5318 [ "$atime" -ne 0 ] || error "atime is zero"
5320 run_test 39q "close won't zero out atime"
5329 umount_client $MOUNT
5330 mount_client $MOUNT relatime
5332 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer conv=fsync
5333 atime0=$(stat -c %X $DIR/$tfile)
5335 # First read updates atime
5337 cat $DIR/$tfile >/dev/null
5338 atime1=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5340 # Next reads do not update atime
5342 cat $DIR/$tfile >/dev/null
5343 atime2=$(stat -c %X $DIR/$tfile) # (atime = atime0 + 1)
5345 # If mtime is greater than atime, atime is updated
5347 touch -m $DIR/$tfile # (mtime = now)
5349 cat $DIR/$tfile >/dev/null # (atime is updated because atime < mtime)
5350 atime3=$(stat -c %X $DIR/$tfile) # (atime = mtime = atime0 + 3)
5352 # Next reads do not update atime
5354 cat $DIR/$tfile >/dev/null
5355 atime4=$(stat -c %X $DIR/$tfile)
5357 # Remount the client to clear 'relatime' option
5358 remount_client $MOUNT
5360 (( atime0 < atime1 )) ||
5361 error "atime $atime0 should be smaller than $atime1"
5362 (( atime1 == atime2 )) ||
5363 error "atime $atime1 was updated to $atime2"
5364 (( atime1 < atime3 )) || error "atime1 $atime1 != atime3 $atime3"
5365 (( atime3 == atime4 )) || error "atime3 $atime3 != atime4 $atime4"
5367 run_test 39s "relatime is supported"
5370 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5371 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5372 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5373 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5374 error "$tfile is not 4096 bytes in size"
5376 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5380 small_write $DIR/f41 18
5382 run_test 41 "test small file write + fstat ====================="
5384 count_ost_writes() {
5385 lctl get_param -n ${OSC}.*.stats |
5386 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5387 END { printf("%0.0f", writes) }'
5394 BG_DIRTY_RATIO_SAVE=10
5395 MAX_BG_DIRTY_RATIO=25
5399 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5400 # dirty_ratio, dirty_background_ratio
5401 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5402 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5403 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5404 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5406 # if file not here, we are a 2.4 kernel
5407 kill -CONT `pidof kupdated`
5412 # setup the trap first, so someone cannot exit the test at the
5413 # exact wrong time and mess up a machine
5414 trap start_writeback EXIT
5415 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5416 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5417 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5418 sysctl -w vm.dirty_writeback_centisecs=0
5419 sysctl -w vm.dirty_writeback_centisecs=0
5420 # save and increase /proc/sys/vm/dirty_ratio
5421 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5422 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5423 # save and increase /proc/sys/vm/dirty_background_ratio
5424 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5425 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5427 # if file not here, we are a 2.4 kernel
5428 kill -STOP `pidof kupdated`
5432 # ensure that all stripes have some grant before we test client-side cache
5434 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5435 dd if=/dev/zero of=$i bs=4k count=1
5440 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5441 # file truncation, and file removal.
5443 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5446 cancel_lru_locks $OSC
5448 sync; sleep 1; sync # just to be safe
5449 BEFOREWRITES=`count_ost_writes`
5450 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5451 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5452 AFTERWRITES=`count_ost_writes`
5453 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5454 error "$BEFOREWRITES < $AFTERWRITES"
5457 run_test 42a "ensure that we don't flush on close"
5460 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5463 cancel_lru_locks $OSC
5466 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5467 BEFOREWRITES=$(count_ost_writes)
5468 unlink $DIR/f42b || error "unlink $DIR/f42b: $?"
5469 AFTERWRITES=$(count_ost_writes)
5470 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5471 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5473 BEFOREWRITES=$(count_ost_writes)
5474 sync || error "sync: $?"
5475 AFTERWRITES=$(count_ost_writes)
5476 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5477 error "$BEFOREWRITES < $AFTERWRITES on sync"
5479 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5483 run_test 42b "test destroy of file with cached dirty data ======"
5485 # if these tests just want to test the effect of truncation,
5486 # they have to be very careful. consider:
5487 # - the first open gets a {0,EOF}PR lock
5488 # - the first write conflicts and gets a {0, count-1}PW
5489 # - the rest of the writes are under {count,EOF}PW
5490 # - the open for truncate tries to match a {0,EOF}PR
5491 # for the filesize and cancels the PWs.
5492 # any number of fixes (don't get {0,EOF} on open, match
5493 # composite locks, do smarter file size management) fix
5494 # this, but for now we want these tests to verify that
5495 # the cancellation with truncate intent works, so we
5496 # start the file with a full-file pw lock to match against
5497 # until the truncate.
5502 cancel_lru_locks $OSC
5504 # prime the file with 0,EOF PW to match
5508 # now the real test..
5509 dd if=/dev/zero of=$file bs=1024 count=100
5510 BEFOREWRITES=`count_ost_writes`
5511 $TRUNCATE $file $offset
5512 cancel_lru_locks $OSC
5513 AFTERWRITES=`count_ost_writes`
5518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5521 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5522 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5525 run_test 42c "test partial truncate of file with cached dirty data"
5528 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5530 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
5531 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
5532 $LCTL set_param debug=+cache
5535 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5536 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5539 run_test 42d "test complete truncate of file with cached dirty data"
5541 test_42e() { # bug22074
5542 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5544 local TDIR=$DIR/${tdir}e
5545 local pages=16 # hardcoded 16 pages, don't change it.
5546 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5547 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5551 test_mkdir $DIR/${tdir}e
5552 $LFS setstripe -c 1 $TDIR
5553 createmany -o $TDIR/f $files
5555 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5557 # we assume that with $OSTCOUNT files, at least one of them will
5558 # be allocated on OST0.
5559 warmup_files=$((OSTCOUNT * max_dirty_mb))
5560 createmany -o $TDIR/w $warmup_files
5562 # write a large amount of data into one file and sync, to get good
5563 # avail_grant number from OST.
5564 for ((i=0; i<$warmup_files; i++)); do
5565 idx=$($LFS getstripe -i $TDIR/w$i)
5566 [ $idx -ne 0 ] && continue
5567 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5570 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5572 $LCTL get_param $proc_osc0/cur_dirty_bytes
5573 $LCTL get_param $proc_osc0/cur_grant_bytes
5575 # create as much dirty pages as we can while not to trigger the actual
5576 # RPCs directly. but depends on the env, VFS may trigger flush during this
5577 # period, hopefully we are good.
5578 for ((i=0; i<$warmup_files; i++)); do
5579 idx=$($LFS getstripe -i $TDIR/w$i)
5580 [ $idx -ne 0 ] && continue
5581 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5583 $LCTL get_param $proc_osc0/cur_dirty_bytes
5584 $LCTL get_param $proc_osc0/cur_grant_bytes
5586 # perform the real test
5587 $LCTL set_param $proc_osc0/rpc_stats 0
5588 for ((;i<$files; i++)); do
5589 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5590 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5593 $LCTL get_param $proc_osc0/rpc_stats
5596 local have_ppr=false
5597 $LCTL get_param $proc_osc0/rpc_stats |
5598 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5599 # skip lines until we are at the RPC histogram data
5600 [ "$PPR" == "pages" ] && have_ppr=true && continue
5601 $have_ppr || continue
5603 # we only want the percent stat for < 16 pages
5604 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5606 percent=$((percent + WPCT))
5607 if [[ $percent -gt 15 ]]; then
5608 error "less than 16-pages write RPCs" \
5615 run_test 42e "verify sub-RPC writes are not done synchronously"
5617 test_43A() { # was test_43
5618 test_mkdir $DIR/$tdir
5619 cp -p /bin/ls $DIR/$tdir/$tfile
5620 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5622 # give multiop a chance to open
5625 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5627 # Wait for multiop to exit
5630 run_test 43A "execution of file opened for write should return -ETXTBSY"
5633 test_mkdir $DIR/$tdir
5634 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5635 $DIR/$tdir/sleep 60 &
5637 # Make sure exec of $tdir/sleep wins race with truncate
5639 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5642 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5645 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5647 test_mkdir $DIR/$tdir
5648 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5649 $DIR/$tdir/sleep 60 &
5651 # Make sure exec of $tdir/sleep wins race with truncate
5653 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5656 run_test 43b "truncate of file being executed should return -ETXTBSY"
5659 local testdir="$DIR/$tdir"
5662 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5663 ( cd $testdir && md5sum -c )
5665 run_test 43c "md5sum of copy into lustre"
5667 test_44A() { # was test_44
5668 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5670 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5671 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5673 run_test 44A "zero length read from a sparse stripe"
5676 local nstripe=$($LFS getstripe -c -d $DIR)
5677 [ -z "$nstripe" ] && skip "can't get stripe info"
5678 [[ $nstripe -gt $OSTCOUNT ]] &&
5679 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5681 local stride=$($LFS getstripe -S -d $DIR)
5682 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5683 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5686 OFFSETS="0 $((stride/2)) $((stride-1))"
5687 for offset in $OFFSETS; do
5688 for i in $(seq 0 $((nstripe-1))); do
5689 local GLOBALOFFSETS=""
5691 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5692 local myfn=$DIR/d44a-$size
5693 echo "--------writing $myfn at $size"
5694 ll_sparseness_write $myfn $size ||
5695 error "ll_sparseness_write"
5696 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5697 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5698 error "ll_sparseness_verify $GLOBALOFFSETS"
5700 for j in $(seq 0 $((nstripe-1))); do
5702 size=$((((j + $nstripe )*$stride + $offset)))
5703 ll_sparseness_write $myfn $size ||
5704 error "ll_sparseness_write"
5705 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5707 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5708 error "ll_sparseness_verify $GLOBALOFFSETS"
5713 run_test 44a "test sparse pwrite ==============================="
5717 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5723 before=`dirty_osc_total`
5724 echo executing "\"$*\""
5726 after=`dirty_osc_total`
5727 echo before $before, after $after
5730 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5733 # Obtain grants from OST if it supports it
5734 echo blah > ${f}_grant
5737 do_dirty_record "echo blah > $f"
5738 [[ $before -eq $after ]] && error "write wasn't cached"
5739 do_dirty_record "> $f"
5740 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5741 do_dirty_record "echo blah > $f"
5742 [[ $before -eq $after ]] && error "write wasn't cached"
5743 do_dirty_record "sync"
5744 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5745 do_dirty_record "echo blah > $f"
5746 [[ $before -eq $after ]] && error "write wasn't cached"
5747 do_dirty_record "cancel_lru_locks osc"
5748 [[ $before -gt $after ]] ||
5749 error "lock cancellation didn't lower dirty count"
5752 run_test 45 "osc io page accounting ============================"
5754 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5755 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5756 # objects offset and an assert hit when an rpc was built with 1023's mapped
5757 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5759 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5764 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5766 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5767 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5771 run_test 46 "dirtying a previously written page ================"
5773 # test_47 is removed "Device nodes check" is moved to test_28
5775 test_48a() { # bug 2399
5776 [ "$mds1_FSTYPE" = "zfs" ] &&
5777 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5778 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5780 test_mkdir $DIR/$tdir
5782 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5783 test_mkdir $DIR/$tdir
5784 touch foo || error "'touch foo' failed after recreating cwd"
5786 touch .foo || error "'touch .foo' failed after recreating cwd"
5788 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5789 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5790 cd . || error "'cd .' failed after recreating cwd"
5791 mkdir . && error "'mkdir .' worked after recreating cwd"
5792 rmdir . && error "'rmdir .' worked after recreating cwd"
5793 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5794 cd .. || error "'cd ..' failed after recreating cwd"
5796 run_test 48a "Access renamed working dir (should return errors)="
5798 test_48b() { # bug 2399
5800 test_mkdir $DIR/$tdir
5802 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5803 touch foo && error "'touch foo' worked after removing cwd"
5804 mkdir foo && error "'mkdir foo' worked after removing cwd"
5805 touch .foo && error "'touch .foo' worked after removing cwd"
5806 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5807 ls . > /dev/null && error "'ls .' worked after removing cwd"
5808 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5809 mkdir . && error "'mkdir .' worked after removing cwd"
5810 rmdir . && error "'rmdir .' worked after removing cwd"
5811 ln -s . foo && error "'ln -s .' worked after removing cwd"
5812 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5814 run_test 48b "Access removed working dir (should return errors)="
5816 test_48c() { # bug 2350
5817 #lctl set_param debug=-1
5820 test_mkdir -p $DIR/$tdir/dir
5822 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5823 $TRACE touch foo && error "touch foo worked after removing cwd"
5824 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5825 touch .foo && error "touch .foo worked after removing cwd"
5826 mkdir .foo && error "mkdir .foo worked after removing cwd"
5827 $TRACE ls . && error "'ls .' worked after removing cwd"
5828 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5829 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5830 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5831 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5832 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5834 run_test 48c "Access removed working subdir (should return errors)"
5836 test_48d() { # bug 2350
5837 #lctl set_param debug=-1
5840 test_mkdir -p $DIR/$tdir/dir
5842 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5843 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5844 $TRACE touch foo && error "'touch foo' worked after removing parent"
5845 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5846 touch .foo && error "'touch .foo' worked after removing parent"
5847 mkdir .foo && error "mkdir .foo worked after removing parent"
5848 $TRACE ls . && error "'ls .' worked after removing parent"
5849 $TRACE ls .. && error "'ls ..' worked after removing parent"
5850 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5851 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5852 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5855 run_test 48d "Access removed parent subdir (should return errors)"
5857 test_48e() { # bug 4134
5858 #lctl set_param debug=-1
5861 test_mkdir -p $DIR/$tdir/dir
5863 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5864 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5865 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5866 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5867 # On a buggy kernel addition of "touch foo" after cd .. will
5868 # produce kernel oops in lookup_hash_it
5869 touch ../foo && error "'cd ..' worked after recreate parent"
5871 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5873 run_test 48e "Access to recreated parent subdir (should return errors)"
5876 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5877 skip "need MDS >= 2.13.55"
5878 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5879 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5880 skip "needs different host for mdt1 mdt2"
5881 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5883 $LFS mkdir -i0 $DIR/$tdir
5884 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5886 for d in sub1 sub2 sub3; do
5887 #define OBD_FAIL_OSD_REF_DEL 0x19c
5888 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5889 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5892 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5894 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5896 test_49() { # LU-1030
5897 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5898 remote_ost_nodsh && skip "remote OST with nodsh"
5900 # get ost1 size - $FSNAME-OST0000
5901 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5903 # write 800M at maximum
5904 [[ $ost1_size -lt 2 ]] && ost1_size=2
5905 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5907 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5908 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5911 # change max_pages_per_rpc while writing the file
5912 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5913 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5914 # loop until dd process exits
5915 while ps ax -opid | grep -wq $dd_pid; do
5916 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5917 sleep $((RANDOM % 5 + 1))
5919 # restore original max_pages_per_rpc
5920 $LCTL set_param $osc1_mppc=$orig_mppc
5921 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5923 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5927 test_mkdir $DIR/$tdir
5929 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5931 run_test 50 "special situations: /proc symlinks ==============="
5933 test_51a() { # was test_51
5934 # bug 1516 - create an empty entry right after ".." then split dir
5935 test_mkdir -c1 $DIR/$tdir
5936 touch $DIR/$tdir/foo
5937 $MCREATE $DIR/$tdir/bar
5939 createmany -m $DIR/$tdir/longfile 201
5941 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5942 $MCREATE $DIR/$tdir/longfile$FNUM
5947 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5949 run_test 51a "special situations: split htree with empty entry =="
5951 cleanup_print_lfs_df () {
5958 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5960 local dir=$DIR/$tdir
5961 local nrdirs=$((65536 + 100))
5963 # cleanup the directory
5966 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5970 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5971 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5972 [[ $numfree -lt $nrdirs ]] &&
5973 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5975 # need to check free space for the directories as well
5976 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5977 numfree=$(( blkfree / $(fs_inode_ksize) ))
5978 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5980 trap cleanup_print_lfs_df EXIT
5983 createmany -d $dir/d $nrdirs || {
5984 unlinkmany $dir/d $nrdirs
5985 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5989 nrdirs=$(ls -U $dir | wc -l)
5991 # unlink all but 100 subdirectories, then check it still works
5993 local delete=$((nrdirs - left))
5998 # for ldiskfs the nlink count should be 1, but this is OSD specific
5999 # and so this is listed for informational purposes only
6000 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
6001 unlinkmany -d $dir/d $delete ||
6002 error "unlink of first $delete subdirs failed"
6004 echo "nlink between: $(stat -c %h $dir)"
6005 local found=$(ls -U $dir | wc -l)
6006 [ $found -ne $left ] &&
6007 error "can't find subdirs: found only $found, expected $left"
6009 unlinkmany -d $dir/d $delete $left ||
6010 error "unlink of second $left subdirs failed"
6011 # regardless of whether the backing filesystem tracks nlink accurately
6012 # or not, the nlink count shouldn't be more than "." and ".." here
6013 local after=$(stat -c %h $dir)
6014 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
6015 echo "nlink after: $after"
6017 cleanup_print_lfs_df
6019 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
6022 local stripecount=$1
6025 log "create files with stripecount=$stripecount"
6026 $LFS setstripe -C $stripecount $DIR/$tdir
6027 createmany -o $DIR/$tdir/t- $nfiles
6028 $LFS getstripe $DIR/$tdir > $TMP/$tfile
6029 for ((n = 0; n < $OSTCOUNT; n++)); do
6030 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
6031 END { printf("%0.0f", objs) }' $TMP/$tfile)
6032 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
6033 '($1 == '$n') { objs += 1 } \
6034 END { printf("%0.0f", objs) }')
6035 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
6037 unlinkmany $DIR/$tdir/t- $nfiles
6042 local max=6 # allow variance of (1 - $min/$max) = 33% by default
6044 # For some combinations of stripecount and OSTCOUNT current code
6045 # is not ideal, and allocates 50% fewer *first* objects to some OSTs
6046 # than others. Rather than skipping this test entirely, check that
6047 # and keep testing to ensure imbalance does not get worse. LU-15282
6048 (( (OSTCOUNT == 6 && stripecount == 4) ||
6049 (OSTCOUNT == 10 && (stripecount == 4 || stripecount == 8)) ||
6050 (OSTCOUNT == 12 && (stripecount == 8 || stripecount == 9)))) && max=9
6051 for ((nlast=0, n = 1; n < $OSTCOUNT; nlast=n,n++)); do
6052 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
6053 { $LFS df && $LFS df -i &&
6054 error "stripecount=$stripecount: " \
6055 "OST $n has fewer objects vs. OST $nlast " \
6056 "(${objs[$n]} < ${objs[$nlast]} x 4/5)"; }
6057 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
6058 { $LFS df && $LFS df -i &&
6059 error "stripecount=$stripecount: " \
6060 "OST $n has more objects vs. OST $nlast " \
6061 "(${objs[$n]} > ${objs[$nlast]} x 5/4)"; }
6063 (( ${objs0[$n]} > ${objs0[$nlast]} * $min / $max )) ||
6064 { $LFS df && $LFS df -i &&
6065 error "stripecount=$stripecount: " \
6066 "OST $n has fewer #0 objects vs. OST $nlast " \
6067 "(${objs0[$n]} < ${objs0[$nlast]} x $min/$max)"; }
6068 (( ${objs0[$n]} < ${objs0[$nlast]} * $max / $min )) ||
6069 { $LFS df && $LFS df -i &&
6070 error "stripecount=$stripecount: " \
6071 "OST $n has more #0 objects vs. OST $nlast " \
6072 "(${objs0[$n]} > ${objs0[$nlast]} x $max/$min)"; }
6077 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6078 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
6082 local nfiles=$((per_ost * OSTCOUNT))
6083 local mdts=$(comma_list $(mdts_nodes))
6084 local param="osp.*.create_count"
6085 local qos_old=$(do_facet mds1 \
6086 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
6089 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
6090 stack_trap "do_nodes $mdts \
6091 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
6093 test_mkdir $DIR/$tdir
6094 local dirstripes=$(lfs getdirstripe -c $DIR/$tdir)
6095 (( dirstripes > 0 )) || dirstripes=1
6097 # Ensure enough OST objects precreated for tests to pass without
6098 # running out of objects. This is an LOV r-r OST algorithm test,
6099 # not an OST object precreation test.
6100 local old=$(do_facet mds1 "$LCTL get_param -n $param" | head -n 1)
6101 (( old >= nfiles )) ||
6103 local create_count=$((nfiles * OSTCOUNT / dirstripes))
6105 do_nodes $mdts "$LCTL set_param $param=$create_count"
6106 stack_trap "do_nodes $mdts $LCTL set_param $param=$old"
6108 # trigger precreation from all MDTs for all OSTs
6109 for ((i = 0; i < $MDSCOUNT * 2; i++ )); do
6110 $LFS setstripe -c -1 $DIR/$tdir/wide.$i
6114 for ((stripecount = 3; stripecount <= $OSTCOUNT; stripecount++)); do
6115 sleep 8 # allow object precreation to catch up
6116 test_51d_sub $stripecount $nfiles
6119 run_test 51d "check LOV round-robin OST object distribution"
6122 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6123 skip_env "ldiskfs only test"
6126 test_mkdir -c1 $DIR/$tdir
6127 test_mkdir -c1 $DIR/$tdir/d0
6129 touch $DIR/$tdir/d0/foo
6130 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
6131 error "file exceed 65000 nlink limit!"
6132 unlinkmany $DIR/$tdir/d0/f- 65001
6135 run_test 51e "check file nlink limit"
6138 test_mkdir $DIR/$tdir
6141 local ulimit_old=$(ulimit -n)
6142 local spare=20 # number of spare fd's for scripts/libraries, etc.
6143 local mdt=$($LFS getstripe -m $DIR/$tdir)
6144 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
6146 echo "MDT$mdt numfree=$numfree, max=$max"
6147 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
6148 if [ $((numfree + spare)) -gt $ulimit_old ]; then
6149 while ! ulimit -n $((numfree + spare)); do
6150 numfree=$((numfree * 3 / 4))
6152 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
6154 echo "left ulimit at $ulimit_old"
6157 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
6158 unlinkmany $DIR/$tdir/f $numfree
6159 error "create+open $numfree files in $DIR/$tdir failed"
6161 ulimit -n $ulimit_old
6163 # if createmany exits at 120s there will be fewer than $numfree files
6164 unlinkmany $DIR/$tdir/f $numfree || true
6166 run_test 51f "check many open files limit"
6169 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
6170 test_mkdir $DIR/$tdir
6171 touch $DIR/$tdir/foo
6172 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
6173 echo bar >> $DIR/$tdir/foo || error "append bar failed"
6174 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6175 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6176 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6178 echo foo >> $DIR/$tdir/foo || error "append foo failed"
6179 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6180 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
6182 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
6183 cp -r $DIR/$tdir $TMP/
6184 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
6186 run_test 52a "append-only flag test (should return errors)"
6189 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
6190 test_mkdir $DIR/$tdir
6191 touch $DIR/$tdir/foo
6192 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
6193 cat test > $DIR/$tdir/foo && error "cat test worked"
6194 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6195 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6196 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6198 echo foo >> $DIR/$tdir/foo && error "echo worked"
6199 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6200 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
6201 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
6202 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
6204 chattr -i $DIR/$tdir/foo || error "chattr failed"
6206 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
6208 run_test 52b "immutable flag test (should return errors) ======="
6211 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6212 remote_mds_nodsh && skip "remote MDS with nodsh"
6213 remote_ost_nodsh && skip "remote OST with nodsh"
6226 local support_last_seq=true
6228 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
6229 support_last_seq=false
6232 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
6234 for value in $(do_facet $SINGLEMDS \
6235 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
6236 param=$(echo ${value[0]} | cut -d "=" -f1)
6237 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
6239 if $support_last_seq; then
6240 param_seq=$(echo $param |
6241 sed -e s/prealloc_last_id/prealloc_last_seq/g)
6242 mds_last_seq=$(do_facet $SINGLEMDS \
6243 $LCTL get_param -n $param_seq)
6245 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
6247 ostnum=$(index_from_ostuuid ${ostname}_UUID)
6248 node=$(facet_active_host ost$((ostnum+1)))
6249 param="obdfilter.$ostname.last_id"
6250 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
6251 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
6252 ost_last_id=$ost_last
6254 if $support_last_seq; then
6255 ost_last_id=$(echo $ost_last |
6256 awk -F':' '{print $2}' |
6258 ost_last_seq=$(echo $ost_last |
6259 awk -F':' '{print $1}')
6260 [[ $ost_last_seq = $mds_last_seq ]] || continue
6263 if [[ $ost_last_id != $mds_last ]]; then
6264 error "$ost_last_id != $mds_last"
6271 $found || error "can not match last_seq/last_id for $mdtosc"
6274 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
6277 LANG=C perl -MSocket -e ';' || skip "no Socket perl module installed"
6279 LANG=C $SOCKETSERVER $DIR/socket ||
6280 error "$SOCKETSERVER $DIR/socket failed: $?"
6281 LANG=C $SOCKETCLIENT $DIR/socket ||
6282 error "$SOCKETCLIENT $DIR/socket failed: $?"
6283 unlink $DIR/socket || error "unlink $DIR/socket failed: $?"
6285 run_test 54a "unix domain socket test =========================="
6291 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
6293 run_test 54b "char device works in lustre ======================"
6296 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
6297 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
6298 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
6300 for i in $(seq 3 7); do
6301 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
6310 loopdev="$DIR/loop54c"
6313 $UMOUNT $DIR/$tdir || rc=$?
6314 losetup -d $loopdev || true
6315 losetup -d $LOOPDEV || true
6316 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
6321 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6323 loopdev="$DIR/loop54c"
6326 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
6327 trap cleanup_54c EXIT
6328 mknod $loopdev b 7 $LOOPNUM
6329 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
6330 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
6331 losetup $loopdev $DIR/$tfile ||
6332 error "can't set up $loopdev for $DIR/$tfile"
6333 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
6334 test_mkdir $DIR/$tdir
6335 mount -t ext2 $loopdev $DIR/$tdir ||
6336 error "error mounting $loopdev on $DIR/$tdir"
6337 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6340 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6344 run_test 54c "block device works in lustre ====================="
6347 local pipe="$DIR/$tfile.pipe"
6348 local string="aaaaaa"
6351 echo -n "$string" > $pipe &
6352 local result=$(cat $pipe)
6353 [[ "$result" == "$string" ]] || error "$result != $string"
6355 run_test 54d "fifo device works in lustre ======================"
6360 cp -aL /dev/console $f
6361 echo $string > $f || error "echo $string to $f failed"
6363 run_test 54e "console/tty device works in lustre ======================"
6366 local dev_path="/sys/kernel/debug/lustre/devices"
6368 load_module obdclass/obd_test verbose=2 || error "load_module failed"
6370 # This must be run in iteractive mode, since attach and setup
6372 eval "$LCTL <<-EOF || error 'OBD device creation failed'
6373 attach obd_test obd_name obd_uuid
6378 cat "$dev_path" | tail -n 10
6380 $LCTL --device "obd_name" cleanup
6381 $LCTL --device "obd_name" detach
6383 dmesg | tail -n 25 | grep "Lustre: OBD:.*FAIL" &&
6384 error "OBD unit test failed"
6386 rmmod -v obd_test ||
6387 error "rmmod failed (may trigger a failure in a later test)"
6389 run_test 55a "OBD device life cycle unit tests"
6392 local dev_path="/sys/kernel/debug/lustre/devices"
6393 local dev_count="$(wc -l $dev_path | awk '{print $1}')"
6395 # Set up a large number of devices, using the number
6396 # that can be set up in about a minute (based on prior
6397 # testing). We don't want to run this test forever.
6398 local num_dev_to_create="$(( 24000 - $dev_count))"
6400 load_module obdclass/obd_test || error "load_module failed"
6402 local start=$SECONDS
6404 # This must be run in iteractive mode, since attach and setup
6406 for ((i = 1; i <= num_dev_to_create; i++)); do
6407 echo "attach obd_test obd_name_$i obd_uuid_$i"
6408 echo "setup obd_test_$i"
6409 done | $LCTL || error "OBD device creation failed"
6411 echo "Load time: $((SECONDS - start))"
6413 cat "$dev_path" | tail -n 10
6415 for ((i = 1; i <= num_dev_to_create; i++)); do
6416 echo "--device obd_name_$i cleanup"
6417 echo "--device obd_name_$i detach"
6418 done | $LCTL || error "OBD device cleanup failed"
6420 echo "Unload time: $((SECONDS - start))"
6422 rmmod -v obd_test ||
6423 error "rmmod failed (may trigger a failure in a later test)"
6425 run_test 55b "Load and unload max OBD devices"
6430 local dir=$DIR/$tdir
6433 test_mkdir -p $dir/dir
6434 for i in $(seq $numfiles); do
6436 touch $dir/dir/file$i
6439 local numcomp=$($LFS getstripe --component-count $dir)
6441 [[ $numcomp == 0 ]] && numcomp=1
6443 # test lfs getstripe with --recursive
6444 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6446 [[ $filenum -eq $((numfiles * 2)) ]] ||
6447 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6448 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6449 [[ $filenum -eq $numfiles ]] ||
6450 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6451 echo "$LFS getstripe showed obdidx or l_ost_idx"
6453 # test lfs getstripe with file instead of dir
6454 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6455 [[ $filenum -eq 1 ]] ||
6456 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6457 echo "$LFS getstripe file1 passed"
6459 #test lfs getstripe with --verbose
6460 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6461 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6462 error "$LFS getstripe --verbose $dir: "\
6463 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6464 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6465 error "$LFS getstripe $dir: showed lmm_magic"
6467 #test lfs getstripe with -v prints lmm_fid
6468 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6469 local countfids=$((numdirs + numfiles * numcomp))
6470 [[ $filenum -eq $countfids ]] ||
6471 error "$LFS getstripe -v $dir: "\
6472 "got $filenum want $countfids lmm_fid"
6473 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6474 error "$LFS getstripe $dir: showed lmm_fid by default"
6475 echo "$LFS getstripe --verbose passed"
6477 #check for FID information
6478 local fid1=$($LFS getstripe --fid $dir/file1)
6479 local fid2=$($LFS getstripe --verbose $dir/file1 |
6480 awk '/lmm_fid: / { print $2; exit; }')
6481 local fid3=$($LFS path2fid $dir/file1)
6483 [ "$fid1" != "$fid2" ] &&
6484 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6485 [ "$fid1" != "$fid3" ] &&
6486 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6487 echo "$LFS getstripe --fid passed"
6489 #test lfs getstripe with --obd
6490 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6491 error "$LFS getstripe --obd wrong_uuid: should return error"
6493 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6496 local obduuid=$(ostuuid_from_index $ostidx)
6497 local found=$($LFS getstripe -r --obd $obduuid $dir |
6498 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6500 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6501 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6503 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6506 [[ $found -eq $filenum ]] ||
6507 error "$LFS getstripe --obd: found $found expect $filenum"
6508 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6509 sed '/^[ ]*'${ostidx}'[ ]/d' |
6510 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6511 error "$LFS getstripe --obd: should not show file on other obd"
6512 echo "$LFS getstripe --obd passed"
6514 run_test 56a "check $LFS getstripe"
6517 local dir=$DIR/$tdir
6521 for i in $(seq $numdirs); do
6522 test_mkdir $dir/dir$i
6525 # test lfs getdirstripe default mode is non-recursion, which is
6526 # different from lfs getstripe
6527 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6529 [[ $dircnt -eq 1 ]] ||
6530 error "$LFS getdirstripe: found $dircnt, not 1"
6531 dircnt=$($LFS getdirstripe --recursive $dir |
6532 grep -c lmv_stripe_count)
6533 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6534 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6536 run_test 56b "check $LFS getdirstripe"
6539 verify_yaml_available || skip_env "YAML verification not installed"
6540 local output_file=$DIR/$tfile.out
6542 $LFS getdirstripe -v -D -y $DIR 1> $output_file
6545 cat $output_file | verify_yaml || error "layout is not valid YAML"
6547 run_test 56bb "check $LFS getdirstripe layout is YAML"
6550 remote_ost_nodsh && skip "remote OST with nodsh"
6553 local ost_name=$(ostname_from_index $ost_idx)
6554 local old_status=$(ost_dev_status $ost_idx)
6555 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6557 [[ -z "$old_status" ]] ||
6558 skip_env "OST $ost_name is in $old_status status"
6560 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6561 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6562 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6563 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6564 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6565 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6568 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6569 error "$LFS df -v showing inactive devices"
6572 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6574 [[ "$new_status" =~ "D" ]] ||
6575 error "$ost_name status is '$new_status', missing 'D'"
6576 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6577 [[ "$new_status" =~ "N" ]] ||
6578 error "$ost_name status is '$new_status', missing 'N'"
6580 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6581 [[ "$new_status" =~ "f" ]] ||
6582 error "$ost_name status is '$new_status', missing 'f'"
6585 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6586 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6587 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6588 [[ -z "$p" ]] && restore_lustre_params < $p || true
6591 new_status=$(ost_dev_status $ost_idx)
6592 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6593 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6594 # can't check 'f' as devices may actually be on flash
6596 run_test 56c "check 'lfs df' showing device status"
6599 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6600 local osts=$($LFS df -v $MOUNT | grep -c OST)
6604 (( mdts == MDSCOUNT )) ||
6605 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6606 (( osts == OSTCOUNT )) ||
6607 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6609 run_test 56d "'lfs df -v' prints only configured devices"
6612 err_enoent=2 # No such file or directory
6613 err_eopnotsupp=95 # Operation not supported
6615 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6616 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6618 # Check for handling of path not exists
6619 output=$($LFS df $enoent_mnt 2>&1)
6622 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6623 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6624 error "expect failure $err_enoent, not $ret"
6626 # Check for handling of non-Lustre FS
6627 output=$($LFS df $notsup_mnt)
6630 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6631 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6632 error "expect success $err_eopnotsupp, not $ret"
6634 # Check for multiple LustreFS argument
6635 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6638 [[ $output -eq 3 && $ret -eq 0 ]] ||
6639 error "expect success 3, not $output, rc = $ret"
6641 # Check for correct non-Lustre FS handling among multiple
6643 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6644 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6647 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6648 error "expect success 2, not $output, rc = $ret"
6650 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6655 local local_tdir="$1"
6656 local local_numfiles="$2"
6657 local local_numdirs="$3"
6658 local dir_params="$4"
6659 local dir_stripe_params="$5"
6661 if [ ! -d "$local_tdir" ] ; then
6662 test_mkdir -p $dir_stripe_params $local_tdir
6663 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6664 for i in $(seq $local_numfiles) ; do
6665 touch $local_tdir/file$i
6667 for i in $(seq $local_numdirs) ; do
6668 test_mkdir $dir_stripe_params $local_tdir/dir$i
6669 for j in $(seq $local_numfiles) ; do
6670 touch $local_tdir/dir$i/file$j
6676 setup_56_special() {
6678 local local_numfiles=$2
6679 local local_numdirs=$3
6681 setup_56 $local_tdir $local_numfiles $local_numdirs
6683 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6684 for i in $(seq $local_numfiles) ; do
6685 mknod $local_tdir/loop${i}b b 7 $i
6686 mknod $local_tdir/null${i}c c 1 3
6687 ln -s $local_tdir/file1 $local_tdir/link${i}
6689 for i in $(seq $local_numdirs) ; do
6690 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6691 mknod $local_tdir/dir$i/null${i}c c 1 3
6692 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6698 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6699 local expected=$(($NUMDIRS + 2))
6701 setup_56 $dir $NUMFILES $NUMDIRS
6703 # test lfs find with -name
6704 for i in $(seq $NUMFILES) ; do
6705 local nums=$($LFS find -name "*$i" $dir | wc -l)
6707 [ $nums -eq $expected ] ||
6708 error "lfs find -name '*$i' $dir wrong: "\
6709 "found $nums, expected $expected"
6712 run_test 56g "check lfs find -name"
6715 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6716 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6718 setup_56 $dir $NUMFILES $NUMDIRS
6720 # test lfs find with ! -name
6721 for i in $(seq $NUMFILES) ; do
6722 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6724 [ $nums -eq $expected ] ||
6725 error "lfs find ! -name '*$i' $dir wrong: "\
6726 "found $nums, expected $expected"
6729 run_test 56h "check lfs find ! -name"
6732 local dir=$DIR/$tdir
6736 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6739 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6741 run_test 56i "check 'lfs find -ost UUID' skips directories"
6744 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6746 setup_56_special $dir $NUMFILES $NUMDIRS
6748 local expected=$((NUMDIRS + 1))
6749 local cmd="$LFS find -type d $dir"
6750 local nums=$($cmd | wc -l)
6752 [ $nums -eq $expected ] ||
6753 error "'$cmd' wrong: found $nums, expected $expected"
6755 run_test 56j "check lfs find -type d"
6758 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6760 setup_56_special $dir $NUMFILES $NUMDIRS
6762 local expected=$(((NUMDIRS + 1) * NUMFILES))
6763 local cmd="$LFS find -type f $dir"
6764 local nums=$($cmd | wc -l)
6766 [ $nums -eq $expected ] ||
6767 error "'$cmd' wrong: found $nums, expected $expected"
6769 run_test 56k "check lfs find -type f"
6772 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6774 setup_56_special $dir $NUMFILES $NUMDIRS
6776 local expected=$((NUMDIRS + NUMFILES))
6777 local cmd="$LFS find -type b $dir"
6778 local nums=$($cmd | wc -l)
6780 [ $nums -eq $expected ] ||
6781 error "'$cmd' wrong: found $nums, expected $expected"
6783 run_test 56l "check lfs find -type b"
6786 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6788 setup_56_special $dir $NUMFILES $NUMDIRS
6790 local expected=$((NUMDIRS + NUMFILES))
6791 local cmd="$LFS find -type c $dir"
6792 local nums=$($cmd | wc -l)
6793 [ $nums -eq $expected ] ||
6794 error "'$cmd' wrong: found $nums, expected $expected"
6796 run_test 56m "check lfs find -type c"
6799 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6800 setup_56_special $dir $NUMFILES $NUMDIRS
6802 local expected=$((NUMDIRS + NUMFILES))
6803 local cmd="$LFS find -type l $dir"
6804 local nums=$($cmd | wc -l)
6806 [ $nums -eq $expected ] ||
6807 error "'$cmd' wrong: found $nums, expected $expected"
6809 run_test 56n "check lfs find -type l"
6812 local dir=$DIR/$tdir
6814 setup_56 $dir $NUMFILES $NUMDIRS
6815 utime $dir/file1 > /dev/null || error "utime (1)"
6816 utime $dir/file2 > /dev/null || error "utime (2)"
6817 utime $dir/dir1 > /dev/null || error "utime (3)"
6818 utime $dir/dir2 > /dev/null || error "utime (4)"
6819 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6820 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6823 local nums=$($LFS find -mtime +0 $dir | wc -l)
6825 [ $nums -eq $expected ] ||
6826 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6829 cmd="$LFS find -mtime 0 $dir"
6830 nums=$($cmd | wc -l)
6831 [ $nums -eq $expected ] ||
6832 error "'$cmd' wrong: found $nums, expected $expected"
6834 run_test 56o "check lfs find -mtime for old files"
6837 local dir=$DIR/$tdir
6841 # just to make sure there is something that won't be found
6843 touch $dir/$tfile.now
6845 for age in year week day hour min; do
6846 count=$((count + 1))
6848 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6849 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6850 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6852 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6853 local nums=$($cmd | wc -l)
6854 [ $nums -eq $expected ] ||
6855 error "'$cmd' wrong: found $nums, expected $expected"
6857 cmd="$LFS find $dir -atime $count${age:0:1}"
6858 nums=$($cmd | wc -l)
6859 [ $nums -eq $expected ] ||
6860 error "'$cmd' wrong: found $nums, expected $expected"
6864 cmd="$LFS find $dir -ctime +1s -type f"
6865 nums=$($cmd | wc -l)
6866 (( $nums == $count * 2 + 1)) ||
6867 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6869 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6871 test_newerXY_base() {
6874 local dir=$DIR/$tdir
6878 if [ $y == "t" ]; then
6879 if [ $x == "b" ]; then
6880 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6882 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6885 ref=$DIR/$tfile.newer.$x$y
6886 touch $ref || error "touch $ref failed"
6889 echo "before = $ref"
6891 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6893 if [ $y == "t" ]; then
6894 if [ $x == "b" ]; then
6895 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6897 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6900 negref=$DIR/$tfile.negnewer.$x$y
6901 touch $negref || error "touch $negref failed"
6904 echo "after = $negref"
6905 local cmd="$LFS find $dir -newer$x$y $ref"
6906 local nums=$(eval $cmd | wc -l)
6907 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6909 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6910 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6912 cmd="$LFS find $dir ! -newer$x$y $negref"
6913 nums=$(eval $cmd | wc -l)
6914 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6915 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6917 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6918 nums=$(eval $cmd | wc -l)
6919 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6920 error "'$cmd' wrong: found $nums between, expected $expected"; }
6926 test_newerXY_base "a" "a"
6927 test_newerXY_base "a" "m"
6928 test_newerXY_base "a" "c"
6929 test_newerXY_base "m" "a"
6930 test_newerXY_base "m" "m"
6931 test_newerXY_base "m" "c"
6932 test_newerXY_base "c" "a"
6933 test_newerXY_base "c" "m"
6934 test_newerXY_base "c" "c"
6936 test_newerXY_base "a" "t"
6937 test_newerXY_base "m" "t"
6938 test_newerXY_base "c" "t"
6940 (( $MDS1_VERSION >= $(version_code v2_13_53-145-g186b97e68a) &&
6941 $CLIENT_VERSION >= $(version_code v2_13_53-145-g186b97e68a) )) ||
6942 { echo "btime needs v2_13_53-145-g186b97e68a"; return 0; }
6944 test_newerXY_base "b" "b"
6945 test_newerXY_base "b" "t"
6947 run_test 56oc "check lfs find -newerXY work"
6950 (( $MDS1_VERSION >= $(version_code v2_13_53-145-g186b97e68a) )) ||
6951 skip "btime unsupported on MDS < v2_13_53-145-g186b97e68a"
6953 (( $CLIENT_VERSION >= $(version_code v2_13_53-145-g186b97e68a) )) ||
6954 skip "btime unsupported on clients < v2_13_53-145-g186b97e68a"
6956 local dir=$DIR/$tdir
6957 local ref=$DIR/$tfile.ref
6958 local negref=$DIR/$tfile.negref
6960 mkdir $dir || error "mkdir $dir failed"
6961 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6962 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6963 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6964 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6965 touch $ref || error "touch $ref failed"
6966 # sleep 3 seconds at least
6969 local before=$(do_facet mds1 date +%s)
6970 local skew=$(($(date +%s) - before + 1))
6972 if (( skew < 0 && skew > -5 )); then
6973 sleep $((0 - skew + 1))
6977 # Set the dir stripe params to limit files all on MDT0,
6978 # otherwise we need to calc the max clock skew between
6979 # the client and MDTs.
6980 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6982 touch $negref || error "touch $negref failed"
6984 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6985 local nums=$($cmd | wc -l)
6986 local expected=$(((NUMFILES + 1) * NUMDIRS))
6988 [ $nums -eq $expected ] ||
6989 error "'$cmd' wrong: found $nums, expected $expected"
6991 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6992 nums=$($cmd | wc -l)
6993 expected=$((NUMFILES + 1))
6994 [ $nums -eq $expected ] ||
6995 error "'$cmd' wrong: found $nums, expected $expected"
6997 [ $skew -lt 0 ] && return
6999 local after=$(do_facet mds1 date +%s)
7000 local age=$((after - before + 1 + skew))
7002 cmd="$LFS find $dir -btime -${age}s -type f"
7003 nums=$($cmd | wc -l)
7004 expected=$(((NUMFILES + 1) * NUMDIRS))
7006 echo "Clock skew between client and server: $skew, age:$age"
7007 [ $nums -eq $expected ] ||
7008 error "'$cmd' wrong: found $nums, expected $expected"
7010 expected=$(($NUMDIRS + 1))
7011 cmd="$LFS find $dir -btime -${age}s -type d"
7012 nums=$($cmd | wc -l)
7013 [ $nums -eq $expected ] ||
7014 error "'$cmd' wrong: found $nums, expected $expected"
7015 rm -f $ref $negref || error "Failed to remove $ref $negref"
7017 run_test 56od "check lfs find -btime with units"
7020 [ $RUNAS_ID -eq $UID ] &&
7021 skip_env "RUNAS_ID = UID = $UID -- skipping"
7023 local dir=$DIR/$tdir
7025 setup_56 $dir $NUMFILES $NUMDIRS
7026 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
7028 local expected=$NUMFILES
7029 local cmd="$LFS find -uid $RUNAS_ID $dir"
7030 local nums=$($cmd | wc -l)
7032 [ $nums -eq $expected ] ||
7033 error "'$cmd' wrong: found $nums, expected $expected"
7035 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
7036 cmd="$LFS find ! -uid $RUNAS_ID $dir"
7037 nums=$($cmd | wc -l)
7038 [ $nums -eq $expected ] ||
7039 error "'$cmd' wrong: found $nums, expected $expected"
7041 run_test 56p "check lfs find -uid and ! -uid"
7044 [ $RUNAS_ID -eq $UID ] &&
7045 skip_env "RUNAS_ID = UID = $UID -- skipping"
7047 local dir=$DIR/$tdir
7049 setup_56 $dir $NUMFILES $NUMDIRS
7050 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
7052 local expected=$NUMFILES
7053 local cmd="$LFS find -gid $RUNAS_GID $dir"
7054 local nums=$($cmd | wc -l)
7056 [ $nums -eq $expected ] ||
7057 error "'$cmd' wrong: found $nums, expected $expected"
7059 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
7060 cmd="$LFS find ! -gid $RUNAS_GID $dir"
7061 nums=$($cmd | wc -l)
7062 [ $nums -eq $expected ] ||
7063 error "'$cmd' wrong: found $nums, expected $expected"
7065 run_test 56q "check lfs find -gid and ! -gid"
7068 local dir=$DIR/$tdir
7070 setup_56 $dir $NUMFILES $NUMDIRS
7073 local cmd="$LFS find -size 0 -type f -lazy $dir"
7074 local nums=$($cmd | wc -l)
7076 [ $nums -eq $expected ] ||
7077 error "'$cmd' wrong: found $nums, expected $expected"
7078 cmd="$LFS find -size 0 -type f $dir"
7079 nums=$($cmd | wc -l)
7080 [ $nums -eq $expected ] ||
7081 error "'$cmd' wrong: found $nums, expected $expected"
7084 cmd="$LFS find ! -size 0 -type f -lazy $dir"
7085 nums=$($cmd | wc -l)
7086 [ $nums -eq $expected ] ||
7087 error "'$cmd' wrong: found $nums, expected $expected"
7088 cmd="$LFS find ! -size 0 -type f $dir"
7089 nums=$($cmd | wc -l)
7090 [ $nums -eq $expected ] ||
7091 error "'$cmd' wrong: found $nums, expected $expected"
7093 echo "test" > $dir/$tfile
7094 echo "test2" > $dir/$tfile.2 && sync
7096 cmd="$LFS find -size 5 -type f -lazy $dir"
7097 nums=$($cmd | wc -l)
7098 [ $nums -eq $expected ] ||
7099 error "'$cmd' wrong: found $nums, expected $expected"
7100 cmd="$LFS find -size 5 -type f $dir"
7101 nums=$($cmd | wc -l)
7102 [ $nums -eq $expected ] ||
7103 error "'$cmd' wrong: found $nums, expected $expected"
7106 cmd="$LFS find -size +5 -type f -lazy $dir"
7107 nums=$($cmd | wc -l)
7108 [ $nums -eq $expected ] ||
7109 error "'$cmd' wrong: found $nums, expected $expected"
7110 cmd="$LFS find -size +5 -type f $dir"
7111 nums=$($cmd | wc -l)
7112 [ $nums -eq $expected ] ||
7113 error "'$cmd' wrong: found $nums, expected $expected"
7116 cmd="$LFS find -size +0 -type f -lazy $dir"
7117 nums=$($cmd | wc -l)
7118 [ $nums -eq $expected ] ||
7119 error "'$cmd' wrong: found $nums, expected $expected"
7120 cmd="$LFS find -size +0 -type f $dir"
7121 nums=$($cmd | wc -l)
7122 [ $nums -eq $expected ] ||
7123 error "'$cmd' wrong: found $nums, expected $expected"
7126 cmd="$LFS find ! -size -5 -type f -lazy $dir"
7127 nums=$($cmd | wc -l)
7128 [ $nums -eq $expected ] ||
7129 error "'$cmd' wrong: found $nums, expected $expected"
7130 cmd="$LFS find ! -size -5 -type f $dir"
7131 nums=$($cmd | wc -l)
7132 [ $nums -eq $expected ] ||
7133 error "'$cmd' wrong: found $nums, expected $expected"
7136 cmd="$LFS find -size -5 -type f -lazy $dir"
7137 nums=$($cmd | wc -l)
7138 [ $nums -eq $expected ] ||
7139 error "'$cmd' wrong: found $nums, expected $expected"
7140 cmd="$LFS find -size -5 -type f $dir"
7141 nums=$($cmd | wc -l)
7142 [ $nums -eq $expected ] ||
7143 error "'$cmd' wrong: found $nums, expected $expected"
7145 run_test 56r "check lfs find -size works"
7152 cancel_lru_locks $OSC
7154 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7155 local nums=$($cmd | wc -l)
7157 [ $nums -eq $expected ] ||
7158 error "'$cmd' wrong: found $nums, expected $expected"
7160 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
7162 if (( rpcs_before + glimpses != rpcs_after )); then
7163 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
7164 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
7166 if [[ $glimpses == 0 ]]; then
7167 error "'$cmd' should not send glimpse RPCs to OST"
7169 error "'$cmd' should send $glimpses glimpse RPCs to OST"
7175 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
7176 skip "MDS < 2.12.58 doesn't return LSOM data"
7177 local dir=$DIR/$tdir
7178 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
7180 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
7182 # statahead_agl may cause extra glimpse which confuses results. LU-13017
7183 $LCTL set_param -n llite.*.statahead_agl=0
7184 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
7186 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7187 # open and close all files to ensure LSOM is updated
7188 cancel_lru_locks $OSC
7189 find $dir -type f | xargs cat > /dev/null
7191 # expect_found glimpse_rpcs command_to_run
7192 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
7193 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
7194 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
7195 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
7197 echo "test" > $dir/$tfile
7198 echo "test2" > $dir/$tfile.2 && sync
7199 cancel_lru_locks $OSC
7200 cat $dir/$tfile $dir/$tfile.2 > /dev/null
7202 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
7203 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
7204 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
7205 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
7207 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
7208 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
7209 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
7210 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
7211 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
7212 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
7214 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
7217 local dir=$DIR/$tdir
7218 local tmp=$TMP/$tfile.log
7221 test_mkdir -p $dir || error "failed to mkdir $dir"
7222 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
7223 error "failed to setstripe $dir/$tfile"
7224 mdt_idx=$($LFS getdirstripe -i $dir)
7225 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
7227 stack_trap "rm -f $tmp" EXIT
7228 $LFS find --size +100K --ost 0 $dir |& tee $tmp
7229 ! grep -q obd_uuid $tmp ||
7230 error "failed to find --size +100K --ost 0 $dir"
7231 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
7232 ! grep -q obd_uuid $tmp ||
7233 error "failed to find --size +100K --mdt $mdt_idx $dir"
7235 run_test 56rb "check lfs find --size --ost/--mdt works"
7238 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
7239 local dir=$DIR/$tdir
7242 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
7243 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
7244 (( $MDSCOUNT > 2 )) &&
7245 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
7246 mkdir $dir/$tdir-{1..10}
7247 touch $dir/$tfile-{1..10}
7249 found=$($LFS find $dir --mdt-count 2 | wc -l)
7251 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
7253 found=$($LFS find $dir -T +1 | wc -l)
7254 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
7255 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
7257 found=$($LFS find $dir --mdt-hash all_char | wc -l)
7259 (( $found == $expect )) || error "found $found all_char, expect $expect"
7261 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
7262 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
7263 (( $found == $expect )) || error "found $found all_char, expect $expect"
7265 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
7268 local dir=$DIR/$tdir
7273 mkfifo $dir/fifo || error "failed to create fifo file"
7274 $LFS find $dir -t p --printf "%p %y %LP\n" ||
7275 error "should not fail even cannot get projid from pipe file"
7276 found=$($LFS find $dir -t p --printf "%y")
7277 [[ "p" == $found ]] || error "found $found, expect p"
7279 mknod $dir/chardev c 1 5 ||
7280 error "failed to create character device file"
7281 $LFS find $dir -t c --printf "%p %y %LP\n" ||
7282 error "should not fail even cannot get projid from chardev file"
7283 found=$($LFS find $dir -t c --printf "%y")
7284 [[ "c" == $found ]] || error "found $found, expect c"
7286 found=$($LFS find $dir ! -type d --printf "%p %y %LP\n" | wc -l)
7287 (( found == 2 )) || error "unable to list all files"
7289 run_test 56rd "check lfs find --printf special files"
7291 test_56s() { # LU-611 #LU-9369
7292 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
7294 local dir=$DIR/$tdir
7295 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
7297 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7298 for i in $(seq $NUMDIRS); do
7299 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
7302 local expected=$NUMDIRS
7303 local cmd="$LFS find -c $OSTCOUNT $dir"
7304 local nums=$($cmd | wc -l)
7306 [ $nums -eq $expected ] || {
7307 $LFS getstripe -R $dir
7308 error "'$cmd' wrong: found $nums, expected $expected"
7311 expected=$((NUMDIRS + onestripe))
7312 cmd="$LFS find -stripe-count +0 -type f $dir"
7313 nums=$($cmd | wc -l)
7314 [ $nums -eq $expected ] || {
7315 $LFS getstripe -R $dir
7316 error "'$cmd' wrong: found $nums, expected $expected"
7320 cmd="$LFS find -stripe-count 1 -type f $dir"
7321 nums=$($cmd | wc -l)
7322 [ $nums -eq $expected ] || {
7323 $LFS getstripe -R $dir
7324 error "'$cmd' wrong: found $nums, expected $expected"
7327 cmd="$LFS find -stripe-count -2 -type f $dir"
7328 nums=$($cmd | wc -l)
7329 [ $nums -eq $expected ] || {
7330 $LFS getstripe -R $dir
7331 error "'$cmd' wrong: found $nums, expected $expected"
7335 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
7336 nums=$($cmd | wc -l)
7337 [ $nums -eq $expected ] || {
7338 $LFS getstripe -R $dir
7339 error "'$cmd' wrong: found $nums, expected $expected"
7342 run_test 56s "check lfs find -stripe-count works"
7344 test_56t() { # LU-611 #LU-9369
7345 local dir=$DIR/$tdir
7347 setup_56 $dir 0 $NUMDIRS
7348 for i in $(seq $NUMDIRS); do
7349 $LFS setstripe -S 8M $dir/dir$i/$tfile
7352 local expected=$NUMDIRS
7353 local cmd="$LFS find -S 8M $dir"
7354 local nums=$($cmd | wc -l)
7356 [ $nums -eq $expected ] || {
7357 $LFS getstripe -R $dir
7358 error "'$cmd' wrong: found $nums, expected $expected"
7362 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
7364 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
7366 expected=$(((NUMDIRS + 1) * NUMFILES))
7367 cmd="$LFS find -stripe-size 512k -type f $dir"
7368 nums=$($cmd | wc -l)
7369 [ $nums -eq $expected ] ||
7370 error "'$cmd' wrong: found $nums, expected $expected"
7372 cmd="$LFS find -stripe-size +320k -type f $dir"
7373 nums=$($cmd | wc -l)
7374 [ $nums -eq $expected ] ||
7375 error "'$cmd' wrong: found $nums, expected $expected"
7377 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
7378 cmd="$LFS find -stripe-size +200k -type f $dir"
7379 nums=$($cmd | wc -l)
7380 [ $nums -eq $expected ] ||
7381 error "'$cmd' wrong: found $nums, expected $expected"
7383 cmd="$LFS find -stripe-size -640k -type f $dir"
7384 nums=$($cmd | wc -l)
7385 [ $nums -eq $expected ] ||
7386 error "'$cmd' wrong: found $nums, expected $expected"
7389 cmd="$LFS find -stripe-size 256k -type f $dir"
7390 nums=$($cmd | wc -l)
7391 [ $nums -eq $expected ] ||
7392 error "'$cmd' wrong: found $nums, expected $expected"
7394 cmd="$LFS find -stripe-size -320k -type f $dir"
7395 nums=$($cmd | wc -l)
7396 [ $nums -eq $expected ] ||
7397 error "'$cmd' wrong: found $nums, expected $expected"
7400 cmd="$LFS find -stripe-size 1024k -type f $dir"
7401 nums=$($cmd | wc -l)
7402 [ $nums -eq $expected ] ||
7403 error "'$cmd' wrong: found $nums, expected $expected"
7405 run_test 56t "check lfs find -stripe-size works"
7407 test_56u() { # LU-611
7408 local dir=$DIR/$tdir
7410 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
7412 if [[ $OSTCOUNT -gt 1 ]]; then
7413 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
7419 local expected=$(((NUMDIRS + 1) * NUMFILES))
7420 local cmd="$LFS find -stripe-index 0 -type f $dir"
7421 local nums=$($cmd | wc -l)
7423 [ $nums -eq $expected ] ||
7424 error "'$cmd' wrong: found $nums, expected $expected"
7427 cmd="$LFS find -stripe-index 1 -type f $dir"
7428 nums=$($cmd | wc -l)
7429 [ $nums -eq $expected ] ||
7430 error "'$cmd' wrong: found $nums, expected $expected"
7432 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7433 nums=$($cmd | wc -l)
7434 [ $nums -eq $expected ] ||
7435 error "'$cmd' wrong: found $nums, expected $expected"
7438 # This should produce an error and not return any files
7439 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7440 nums=$($cmd 2>/dev/null | wc -l)
7441 [ $nums -eq $expected ] ||
7442 error "'$cmd' wrong: found $nums, expected $expected"
7444 if [[ $OSTCOUNT -gt 1 ]]; then
7445 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7446 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7447 nums=$($cmd | wc -l)
7448 [ $nums -eq $expected ] ||
7449 error "'$cmd' wrong: found $nums, expected $expected"
7452 run_test 56u "check lfs find -stripe-index works"
7456 local dir=$DIR/$tdir
7458 setup_56 $dir $NUMFILES $NUMDIRS
7460 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7461 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7463 for file in $($LFS find -m $UUID $dir); do
7464 file_midx=$($LFS getstripe -m $file)
7465 [ $file_midx -eq $mdt_idx ] ||
7466 error "lfs find -m $UUID != getstripe -m $file_midx"
7469 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7472 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7473 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7475 local dir=$DIR/$tdir
7477 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7478 stack_trap "rm -rf $dir"
7480 local stripe_size=$($LFS getstripe -S -d $dir) ||
7481 error "$LFS getstripe -S -d $dir failed"
7482 stripe_size=${stripe_size%% *}
7484 local file_size=$((stripe_size * OSTCOUNT))
7485 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7486 local required_space=$((file_num * file_size))
7487 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7489 (( free_space >= required_space / 1024 )) ||
7490 skip_env "need $required_space, have $free_space kbytes"
7493 local dd_count=$((file_size / dd_bs))
7495 # write data into the files
7500 for ((i = 1; i <= NUMFILES; i++ )); do
7502 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7503 error "write data into $file failed"
7505 for ((i = 1; i <= NUMDIRS; i++ )); do
7506 for ((j = 1; j <= NUMFILES; j++ )); do
7507 file=$dir/dir$i/file$j
7508 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7509 error "write data into $file failed"
7513 # $LFS_MIGRATE will fail if hard link migration is unsupported
7514 if (( MDS1_VERSION > $(version_code 2.5.55) )); then
7515 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7516 error "creating links to $dir/dir1/file1 failed"
7521 (( OSTCOUNT <= 1 )) || expected=$((OSTCOUNT - 1))
7524 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7527 eval $cmd || error "$cmd failed"
7529 check_stripe_count $dir/file1 $expected
7531 if (( $MDS1_VERSION >= $(version_code 2.6.90) )); then
7532 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7533 # OST 1 if it is on OST 0. This file is small enough to
7534 # be on only one stripe.
7535 file=$dir/migr_1_ost
7536 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7537 error "write data into $file failed"
7538 local obdidx=$($LFS getstripe -i $file)
7539 local oldmd5=$(md5sum $file)
7542 (( obdidx != 0 )) || newobdidx=1
7543 cmd="$LFS migrate -i $newobdidx $file"
7545 eval $cmd || error "$cmd failed"
7547 local realobdix=$($LFS getstripe -i $file)
7548 local newmd5=$(md5sum $file)
7550 (( $newobdidx == $realobdix )) ||
7551 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
7552 [[ "$oldmd5" == "$newmd5" ]] ||
7553 error "md5sum differ: $oldmd5, $newmd5"
7557 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7559 eval $cmd || error "$cmd failed"
7561 for (( j = 1; j <= NUMFILES; j++ )); do
7562 check_stripe_count $dir/dir1/file$j $expected
7565 # lfs_migrate works with lfs find
7566 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7567 $LFS_MIGRATE -y -c $expected"
7569 eval $cmd || error "$cmd failed"
7571 for (( i = 2; i <= NUMFILES; i++ )); do
7572 check_stripe_count $dir/file$i $expected
7574 for (( i = 2; i <= NUMDIRS; i++ )); do
7575 for (( j = 1; j <= NUMFILES; j++ )); do
7576 check_stripe_count $dir/dir$i/file$j $expected
7580 run_test 56wa "check lfs_migrate -c stripe_count works"
7583 local file1=$DIR/$tdir/file1
7584 local create_pool=false
7585 local initial_pool=$($LFS getstripe -p $DIR)
7589 echo -n "Creating test dir..."
7590 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7593 echo -n "Creating test file..."
7594 touch $file1 || error "cannot create file"
7597 echo -n "Detecting existing pools..."
7598 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7600 if [ ${#pool_list[@]} -gt 0 ]; then
7601 echo "${pool_list[@]}"
7602 for thispool in "${pool_list[@]}"; do
7603 if [[ -z "$initial_pool" ||
7604 "$initial_pool" != "$thispool" ]]; then
7606 echo "Using existing pool '$pool'"
7611 echo "none detected."
7613 if [ -z "$pool" ]; then
7614 pool=${POOL:-testpool}
7615 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7616 echo -n "Creating pool '$pool'..."
7618 pool_add $pool &> /dev/null ||
7619 error "pool_add failed"
7622 echo -n "Adding target to pool..."
7623 pool_add_targets $pool 0 0 1 &> /dev/null ||
7624 error "pool_add_targets failed"
7628 echo -n "Setting pool using -p option..."
7629 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7630 error "migrate failed rc = $?"
7633 echo -n "Verifying test file is in pool after migrating..."
7634 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7635 error "file was not migrated to pool $pool"
7638 echo -n "Removing test file from pool '$pool'..."
7639 # "lfs migrate $file" won't remove the file from the pool
7640 # until some striping information is changed.
7641 $LFS migrate -c 1 $file1 &> /dev/null ||
7642 error "cannot remove from pool"
7643 [ "$($LFS getstripe -p $file1)" ] &&
7644 error "pool still set"
7647 echo -n "Setting pool using --pool option..."
7648 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7649 error "migrate failed rc = $?"
7654 if $create_pool; then
7655 destroy_test_pools 2> /dev/null ||
7656 error "destroy test pools failed"
7659 run_test 56wb "check lfs_migrate pool support"
7662 local file1="$DIR/$tdir/$tfile"
7672 echo -n "Creating test dir..."
7673 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7674 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7675 error "cannot set stripe by '-S 1M -c 1'"
7678 echo -n "Setting initial stripe for test file..."
7679 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7680 error "cannot set stripe"
7681 cur_ssize=$($LFS getstripe -S "$file1")
7682 (( cur_ssize == 524288 )) || error "setstripe -S $cur_ssize != 524288"
7685 dd if=/dev/urandom of=$file1 bs=1M count=12 || error "dd $file1 failed"
7686 stack_trap "rm -f $file1"
7687 md5="$(md5sum $file1)"
7689 # File currently set to -S 512K -c 1
7691 # Ensure -c and -S options are rejected when -R is set
7692 echo -n "Verifying incompatible options are detected..."
7693 $LFS_MIGRATE -R -c 1 "$file1" &&
7694 error "incompatible -R and -c options not detected"
7695 $LFS_MIGRATE -R -S 1M "$file1" &&
7696 error "incompatible -R and -S options not detected"
7697 $LFS_MIGRATE -R -p pool "$file1" &&
7698 error "incompatible -R and -p options not detected"
7699 $LFS_MIGRATE -R -E eof -c 1 "$file1" &&
7700 error "incompatible -R and -E options not detected"
7701 $LFS_MIGRATE -R -A "$file1" &&
7702 error "incompatible -R and -A options not detected"
7703 $LFS_MIGRATE -A -c 1 "$file1" &&
7704 error "incompatible -A and -c options not detected"
7705 $LFS_MIGRATE -A -S 1M "$file1" &&
7706 error "incompatible -A and -S options not detected"
7707 $LFS_MIGRATE -A -p pool "$file1" &&
7708 error "incompatible -A and -p options not detected"
7709 $LFS_MIGRATE -A -E eof -c 1 "$file1" &&
7710 error "incompatible -A and -E options not detected"
7713 # Ensure unrecognized options are passed through to 'lfs migrate'
7714 echo -n "Verifying -S option is passed through to lfs migrate..."
7715 $LFS_MIGRATE -y -S 1M "$file1" || error "migration failed"
7716 cur_ssize=$($LFS getstripe -S "$file1")
7717 (( cur_ssize == 1048576 )) || error "migrate -S $cur_ssize != 1048576"
7718 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (1)"
7721 # File currently set to -S 1M -c 1
7723 # Ensure long options are supported
7724 echo -n "Verifying long options supported..."
7725 $LFS_MIGRATE --non-block "$file1" ||
7726 error "long option without argument not supported"
7727 $LFS_MIGRATE --stripe-size 512K "$file1" ||
7728 error "long option with argument not supported"
7729 cur_ssize=$($LFS getstripe -S "$file1")
7730 (( cur_ssize == 524288 )) ||
7731 error "migrate --stripe-size $cur_ssize != 524288"
7732 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (2)"
7735 # File currently set to -S 512K -c 1
7737 if (( OSTCOUNT > 1 )); then
7738 echo -n "Verifying explicit stripe count can be set..."
7739 $LFS_MIGRATE -c 2 "$file1" || error "migrate failed"
7740 cur_scount=$($LFS getstripe -c "$file1")
7741 (( cur_scount == 2 )) || error "migrate -c $cur_scount != 2"
7742 [[ "$(md5sum $file1)" == "$md5" ]] ||
7743 error "file data has changed (3)"
7747 # File currently set to -S 512K -c 1 or -S 512K -c 2
7749 # Ensure parent striping is used if -R is set, and no stripe
7750 # count or size is specified
7751 echo -n "Setting stripe for parent directory..."
7752 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7753 error "cannot set stripe '-S 2M -c 1'"
7754 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (4)"
7757 echo -n "Verifying restripe option uses parent stripe settings..."
7758 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7759 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7760 $LFS_MIGRATE -R "$file1" || error "migrate failed"
7761 cur_ssize=$($LFS getstripe -S "$file1")
7762 (( cur_ssize == parent_ssize )) ||
7763 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7764 cur_scount=$($LFS getstripe -c "$file1")
7765 (( cur_scount == parent_scount )) ||
7766 error "migrate -R stripe_count $cur_scount != $parent_scount"
7767 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (5)"
7770 # File currently set to -S 1M -c 1
7772 # Ensure striping is preserved if -R is not set, and no stripe
7773 # count or size is specified
7774 echo -n "Verifying striping size preserved when not specified..."
7775 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7776 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7777 error "cannot set stripe on parent directory"
7778 $LFS_MIGRATE "$file1" || error "migrate failed"
7779 cur_ssize=$($LFS getstripe -S "$file1")
7780 (( cur_ssize == orig_ssize )) ||
7781 error "migrate by default $cur_ssize != $orig_ssize"
7782 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (6)"
7785 # Ensure file name properly detected when final option has no argument
7786 echo -n "Verifying file name properly detected..."
7787 $LFS_MIGRATE "$file1" ||
7788 error "file name interpreted as option argument"
7789 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (7)"
7792 # Ensure PFL arguments are passed through properly
7793 echo -n "Verifying PFL options passed through..."
7794 new_scount=$(((OSTCOUNT + 1) / 2))
7795 $LFS_MIGRATE -E 1M -c 1 -E 16M -c $new_scount -E eof -c -1 "$file1" ||
7796 error "migrate PFL arguments failed"
7797 cur_comp=$($LFS getstripe --comp-count $file1)
7798 (( cur_comp == 3 )) || error "component count '$cur_comp' != 3"
7799 cur_scount=$($LFS getstripe --stripe-count $file1)
7800 (( cur_scount == new_scount)) ||
7801 error "PFL stripe count $cur_scount != $new_scount"
7802 [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (8)"
7805 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7808 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
7810 local file1=$DIR/$tdir/$tfile
7812 echo -n "Creating test dir..."
7813 test_mkdir $DIR/$tdir || error "cannot create dir"
7816 echo -n "Creating test file..."
7817 echo "$tfile" > $file1
7820 # Ensure 'lfs migrate' will fail by using a non-existent option,
7821 # and make sure rsync is not called to recover
7822 echo -n "Make sure --no-rsync option works..."
7823 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7824 grep -q 'refusing to fall back to rsync' ||
7825 error "rsync was called with --no-rsync set"
7828 # Ensure rsync is called without trying 'lfs migrate' first
7829 echo -n "Make sure --rsync option works..."
7830 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7831 grep -q 'falling back to rsync' &&
7832 error "lfs migrate was called with --rsync set"
7835 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7841 test_mkdir $td || error "cannot create $td"
7842 touch $tf || error "cannot touch $tf"
7844 echo -n "Make sure --non-direct|-D works..."
7845 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7846 grep -q "lfs migrate --non-direct" ||
7847 error "--non-direct option cannot work correctly"
7848 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7849 grep -q "lfs migrate -D" ||
7850 error "-D option cannot work correctly"
7853 run_test 56we "check lfs_migrate --non-direct|-D support"
7856 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7857 check_swap_layouts_support
7859 local dir=$DIR/$tdir
7860 local ref1=/etc/passwd
7861 local file1=$dir/file1
7863 test_mkdir $dir || error "creating dir $dir"
7864 $LFS setstripe -c 2 $file1
7866 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7867 stripe=$($LFS getstripe -c $file1)
7868 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7869 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7874 run_test 56x "lfs migration support"
7877 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7878 check_swap_layouts_support
7880 local dir=$DIR/$tdir/$testnum
7884 local ref1=/etc/passwd
7885 local file1=$dir/file1
7887 $LFS setstripe -c 2 $file1
7889 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7891 local stripe=$($LFS getstripe -c $file1)
7893 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7894 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7899 run_test 56xa "lfs migration --block support"
7901 check_migrate_links() {
7902 [[ "$1" == "--rsync" ]] && local opts="--rsync -y" && shift
7904 local file1="$dir/file1"
7908 local total_count=$(($begin + $count - 1))
7909 local symlink_count=10
7912 if [ ! -f "$file1" ]; then
7913 echo -n "creating initial file..."
7914 $LFS setstripe -c 1 -S "512k" "$file1" ||
7915 error "cannot setstripe initial file"
7918 echo -n "creating symlinks..."
7919 for s in $(seq 1 $symlink_count); do
7920 ln -s "$file1" "$dir/slink$s" ||
7921 error "cannot create symlinks"
7925 echo -n "creating nonlinked files..."
7926 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7927 error "cannot create nonlinked files"
7932 if [ ! -f "$dir/file$total_count" ]; then
7933 echo -n "creating hard links $begin:$total_count..."
7934 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7935 /dev/null || error "cannot create hard links"
7939 echo -n "checking number of hard links listed in xattrs..."
7940 local fid=$($LFS getstripe -F "$file1")
7941 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7944 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7945 skip "hard link list has unexpected size, skipping test"
7947 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7948 error "link names should exceed xattrs size"
7951 echo -n "migrating files..."
7952 local migrate_out=$($runas $LFS_MIGRATE $opts -S '1m' $dir)
7954 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7957 # make sure all links have been properly migrated
7958 echo -n "verifying files..."
7959 fid=$($LFS getstripe -F "$file1") ||
7960 error "cannot get fid for file $file1"
7961 for i in $(seq 2 $total_count); do
7962 local fid2=$($LFS getstripe -F $dir/file$i)
7964 [ "$fid2" == "$fid" ] ||
7965 error "migrated hard link has mismatched FID"
7968 # make sure hard links were properly detected, and migration was
7969 # performed only once for the entire link set; nonlinked files should
7971 local actual=$(grep -c 'done' <<< "$migrate_out")
7972 local expected=$(($uniq_count + 1))
7974 [ "$actual" -eq "$expected" ] ||
7975 error "hard links individually migrated ($actual != $expected)"
7977 # make sure the correct number of hard links are present
7978 local hardlinks=$(stat -c '%h' "$file1")
7980 [ $hardlinks -eq $total_count ] ||
7981 error "num hard links $hardlinks != $total_count"
7988 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7989 skip "Need MDS version at least 2.10.55"
7991 local dir="$DIR/$tdir"
7993 test_mkdir "$dir" || error "cannot create dir $dir"
7995 echo "testing lfs migrate mode when all links fit within xattrs"
7996 check_migrate_links "$dir" 2 99
7998 echo "testing rsync mode when all links fit within xattrs"
7999 check_migrate_links --rsync "$dir" 2 99
8001 echo "testing lfs migrate mode when all links do not fit within xattrs"
8002 check_migrate_links "$dir" 101 100
8004 echo "testing rsync mode when all links do not fit within xattrs"
8005 check_migrate_links --rsync "$dir" 101 100
8007 chown -R $RUNAS_ID $dir
8008 echo "testing non-root lfs migrate mode when not all links are in xattr"
8009 check_migrate_links "$dir" 101 100 "$RUNAS"
8014 run_test 56xb "lfs migration hard link support"
8017 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8019 local dir="$DIR/$tdir"
8021 test_mkdir "$dir" || error "cannot create dir $dir"
8023 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
8024 echo -n "Setting initial stripe for 20MB test file..."
8025 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
8026 error "cannot setstripe 20MB file"
8028 echo -n "Sizing 20MB test file..."
8029 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
8031 echo -n "Verifying small file autostripe count is 1..."
8032 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
8033 error "cannot migrate 20MB file"
8034 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
8035 error "cannot get stripe for $dir/20mb"
8036 [ $stripe_count -eq 1 ] ||
8037 error "unexpected stripe count $stripe_count for 20MB file"
8041 # Test 2: File is small enough to fit within the available space on
8042 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
8043 # have at least an additional 1KB for each desired stripe for test 3
8044 echo -n "Setting stripe for 1GB test file..."
8045 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
8047 echo -n "Sizing 1GB test file..."
8048 # File size is 1GB + 3KB
8049 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
8052 # need at least 512MB per OST for 1GB file to fit in 2 stripes
8053 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
8054 if (( avail > 524288 * OSTCOUNT )); then
8055 echo -n "Migrating 1GB file..."
8056 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
8057 error "cannot migrate 1GB file"
8059 echo -n "Verifying autostripe count is sqrt(n) + 1..."
8060 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
8061 error "cannot getstripe for 1GB file"
8062 [ $stripe_count -eq 2 ] ||
8063 error "unexpected stripe count $stripe_count != 2"
8067 # Test 3: File is too large to fit within the available space on
8068 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
8069 if [ $OSTCOUNT -ge 3 ]; then
8070 # The required available space is calculated as
8071 # file size (1GB + 3KB) / OST count (3).
8072 local kb_per_ost=349526
8074 echo -n "Migrating 1GB file with limit..."
8075 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
8076 error "cannot migrate 1GB file with limit"
8079 stripe_count=$($LFS getstripe -c "$dir/1gb")
8080 echo -n "Verifying 1GB autostripe count with limited space..."
8081 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
8082 error "unexpected stripe count $stripe_count (min 3)"
8089 run_test 56xc "lfs migration autostripe"
8092 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8094 local dir=$DIR/$tdir
8095 local f_mgrt=$dir/$tfile.mgrt
8096 local f_yaml=$dir/$tfile.yaml
8097 local f_copy=$dir/$tfile.copy
8098 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
8099 local layout_copy="-c 2 -S 2M -i 1"
8100 local yamlfile=$dir/yamlfile
8101 local layout_before;
8104 test_mkdir "$dir" || error "cannot create dir $dir"
8105 stack_trap "rm -rf $dir"
8106 $LFS setstripe $layout_yaml $f_yaml ||
8107 error "cannot setstripe $f_yaml with layout $layout_yaml"
8108 $LFS getstripe --yaml $f_yaml > $yamlfile
8109 $LFS setstripe $layout_copy $f_copy ||
8110 error "cannot setstripe $f_copy with layout $layout_copy"
8112 dd if=/dev/zero of=$f_mgrt bs=1M count=4
8114 # 1. test option --yaml
8115 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
8116 error "cannot migrate $f_mgrt with --yaml $yamlfile"
8117 layout_before=$(get_layout_param $f_yaml)
8118 layout_after=$(get_layout_param $f_mgrt)
8119 [ "$layout_after" == "$layout_before" ] ||
8120 error "lfs_migrate --yaml: $layout_after != $layout_before"
8122 # 2. test option --copy
8123 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
8124 error "cannot migrate $f_mgrt with --copy $f_copy"
8125 layout_before=$(SKIP_INDEX=yes get_layout_param $f_copy)
8126 layout_after=$(SKIP_INDEX=yes get_layout_param $f_mgrt)
8127 [ "$layout_after" == "$layout_before" ] ||
8128 error "lfs_migrate --copy: $layout_after != $layout_before"
8130 run_test 56xd "check lfs_migrate --yaml and --copy support"
8133 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8135 local dir=$DIR/$tdir
8136 local f_comp=$dir/$tfile
8137 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
8138 local layout_before=""
8139 local layout_after=""
8141 test_mkdir "$dir" || error "cannot create dir $dir"
8142 stack_trap "rm -rf $dir"
8143 $LFS setstripe $layout $f_comp ||
8144 error "cannot setstripe $f_comp with layout $layout"
8145 layout_before=$(SKIP_INDEX=yes get_layout_param $f_comp)
8146 dd if=/dev/zero of=$f_comp bs=1M count=4
8148 # 1. migrate a comp layout file by lfs_migrate
8149 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
8150 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
8151 [ "$layout_before" == "$layout_after" ] ||
8152 error "lfs_migrate: $layout_before != $layout_after"
8154 # 2. migrate a comp layout file by lfs migrate
8155 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
8156 layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
8157 [ "$layout_before" == "$layout_after" ] ||
8158 error "lfs migrate: $layout_before != $layout_after"
8160 run_test 56xe "migrate a composite layout file"
8163 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
8165 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
8166 skip "Need server version at least 2.13.53"
8168 local dir=$DIR/$tdir
8169 local f_comp=$dir/$tfile
8170 local layout="-E 1M -c1 -E -1 -c2"
8174 test_mkdir "$dir" || error "cannot create dir $dir"
8175 stack_trap "rm -rf $dir"
8176 $LFS setstripe $layout $f_comp ||
8177 error "cannot setstripe $f_comp with layout $layout"
8178 fid_before=$($LFS getstripe --fid $f_comp)
8179 dd if=/dev/zero of=$f_comp bs=1M count=4
8181 # 1. migrate a comp layout file to a comp layout
8182 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
8183 fid_after=$($LFS getstripe --fid $f_comp)
8184 [ "$fid_before" == "$fid_after" ] ||
8185 error "comp-to-comp migrate: $fid_before != $fid_after"
8187 # 2. migrate a comp layout file to a plain layout
8188 $LFS migrate -c2 $f_comp ||
8189 error "cannot migrate $f_comp by lfs migrate"
8190 fid_after=$($LFS getstripe --fid $f_comp)
8191 [ "$fid_before" == "$fid_after" ] ||
8192 error "comp-to-plain migrate: $fid_before != $fid_after"
8194 # 3. migrate a plain layout file to a comp layout
8195 $LFS migrate $layout $f_comp ||
8196 error "cannot migrate $f_comp by lfs migrate"
8197 fid_after=$($LFS getstripe --fid $f_comp)
8198 [ "$fid_before" == "$fid_after" ] ||
8199 error "plain-to-comp migrate: $fid_before != $fid_after"
8201 run_test 56xf "FID is not lost during migration of a composite layout file"
8203 check_file_ost_range() {
8210 file_range=($($LFS getstripe -y "$file" |
8211 awk '/l_ost_idx:/ { print $NF }'))
8213 if [[ "${#file_range[@]}" = 0 ]]; then
8214 echo "No osts found for $file"
8218 for idx in "${file_range[@]}"; do
8219 [[ " $range " =~ " $idx " ]] ||
8227 local stripe_opt="$1"
8230 local pool_ostidx="$(seq $* | tr '\n' ' ')"
8232 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
8233 error "Fail to migrate $tfile on $pool"
8234 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
8235 error "$tfile is not in pool $pool"
8236 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
8237 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
8241 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8242 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
8243 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
8244 skip "Need MDS version newer than 2.14.52"
8246 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
8247 local -a pool_ranges=("0 0" "1 1" "0 1")
8250 for i in "${!pool_names[@]}"; do
8251 pool_add ${pool_names[$i]} ||
8252 error "pool_add failed (pool: ${pool_names[$i]})"
8253 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
8254 error "pool_add_targets failed (pool: ${pool_names[$i]})"
8257 # init the file to migrate
8258 $LFS setstripe -c1 -i1 $DIR/$tfile ||
8259 error "Unable to create $tfile on OST1"
8260 stack_trap "rm -f $DIR/$tfile"
8261 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
8262 error "Unable to write on $tfile"
8264 echo "1. migrate $tfile on pool ${pool_names[0]}"
8265 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
8267 echo "2. migrate $tfile on pool ${pool_names[2]}"
8268 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
8270 echo "3. migrate $tfile on pool ${pool_names[1]}"
8271 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
8273 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
8274 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
8278 destroy_test_pools ||
8279 error "pool_destroy failed"
8281 run_test 56xg "lfs migrate pool support"
8284 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8287 local file1=$DIR/$tfile
8288 local tmp1=$TMP/$tfile.tmp
8290 $LFS setstripe -c 2 $file1
8292 stack_trap "rm -f $file1 $tmp1"
8293 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8294 error "error creating $tmp1"
8298 local start=$SECONDS
8300 $LFS migrate --stats --stats-interval=1 -W 1M -c 1 $file1 ||
8301 error "migrate failed rc = $?"
8303 local elapsed=$((SECONDS - start))
8305 # with 1MB/s, elapsed should equal size_mb
8306 (( elapsed >= size_mb * 95 / 100 )) ||
8307 error "'lfs migrate -W' too fast ($elapsed < 0.95 * $size_mb)?"
8309 (( elapsed <= size_mb * 120 / 100 )) ||
8310 error_not_in_vm "'lfs migrate -W' slow ($elapsed > 1.2 * $size_mb)"
8312 (( elapsed <= size_mb * 350 / 100 )) ||
8313 error "'lfs migrate -W' too slow in VM ($elapsed > 3.5 * $size_mb)"
8315 stripe=$($LFS getstripe -c $file1)
8316 (( $stripe == 1 )) || error "stripe of $file1 is $stripe != 1"
8317 cmp $file1 $tmp1 || error "content mismatch $file1 differs from $tmp1"
8319 # Clean up file (since it is multiple MB)
8322 run_test 56xh "lfs migrate bandwidth limitation support"
8325 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8326 verify_yaml_available || skip_env "YAML verification not installed"
8329 local file1=$DIR/$tfile.1
8330 local file2=$DIR/$tfile.2
8331 local file3=$DIR/$tfile.3
8332 local output_file=$DIR/$tfile.out
8333 local tmp1=$TMP/$tfile.tmp
8335 $LFS setstripe -c 2 $file1
8336 $LFS setstripe -c 2 $file2
8337 $LFS setstripe -c 2 $file3
8339 stack_trap "rm -f $file1 $file2 $file3 $tmp1 $output_file"
8340 dd if=/dev/urandom of=$tmp1 bs=1M count=$size_mb ||
8341 error "error creating $tmp1"
8347 $LFS migrate --stats --stats-interval=1 \
8348 -c 1 $file1 $file2 $file3 1> $output_file ||
8349 error "migrate failed rc = $?"
8352 cat $output_file | verify_yaml || error "rename_stats is not valid YAML"
8354 # Clean up file (since it is multiple MB)
8355 rm -f $file1 $file2 $file3 $tmp1 $output_file
8357 run_test 56xi "lfs migrate stats support"
8359 test_56xj() { # LU-16571 "lfs migrate -b" can cause thread starvation on OSS
8360 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8362 local file=$DIR/$tfile
8363 local linkdir=$DIR/$tdir
8365 test_mkdir $linkdir || error "fail to create $linkdir"
8366 $LFS setstripe -i 0 -c 1 -S1M $file
8367 stack_trap "rm -rf $file $linkdir"
8368 dd if=/dev/urandom of=$file bs=1M count=10 ||
8369 error "fail to create $file"
8376 thread_max=$(do_facet ost1 "$LCTL get_param -n ost.OSS.ost.threads_max")
8377 cpts=$(do_facet ost1 "$LCTL get_param -n cpu_partition_table | wc -l")
8378 (( nlinks = thread_max * 3 / 2 / cpts))
8380 echo "create $nlinks hard links of $file"
8381 createmany -l $file $linkdir/link $nlinks
8383 # Parallel migrates (should not block)
8385 for ((i = 0; i < nlinks; i++)); do
8386 echo $linkdir/link$i
8387 done | xargs -n1 -P $nlinks $LFS migrate -c2
8390 stripe_count=$($LFS getstripe -c $file) ||
8391 error "fail to get stripe count on $file"
8393 ((stripe_count == 2)) ||
8394 error "fail to migrate $file (stripe_count = $stripe_count)"
8396 run_test 56xj "lfs migrate -b should not cause starvation of threads on OSS"
8399 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8402 local file1=$DIR/$tfile
8404 stack_trap "rm -f $file1"
8405 $LFS setstripe -c 1 $file1
8406 dd if=/dev/zero of=$file1 bs=1M count=$size_mb ||
8407 error "error creating $file1"
8408 $LFS mirror extend -N $file1 || error "can't mirror"
8409 dd if=/dev/zero of=$file1 bs=4k count=1 conv=notrunc ||
8411 $LFS getstripe $file1 | grep stale ||
8412 error "one component must be stale"
8414 local start=$SECONDS
8415 $LFS mirror resync --stats --stats-interval=1 -W 1M $file1 ||
8416 error "migrate failed rc = $?"
8417 local elapsed=$((SECONDS - start))
8418 $LFS getstripe $file1 | grep stale &&
8419 error "all components must be sync"
8421 # with 1MB/s, elapsed should equal size_mb
8422 (( elapsed >= size_mb * 95 / 100 )) ||
8423 error "'lfs mirror resync -W' too fast ($elapsed < 0.95 * $size_mb)?"
8425 (( elapsed <= size_mb * 120 / 100 )) ||
8426 error_not_in_vm "'lfs mirror resync -W' slow ($elapsed > 1.2 * $size_mb)"
8428 (( elapsed <= size_mb * 350 / 100 )) ||
8429 error "'lfs mirror resync -W' too slow in VM ($elapsed > 3.5 * $size_mb)"
8431 run_test 56xk "lfs mirror resync bandwidth limitation support"
8434 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
8435 verify_yaml_available || skip_env "YAML verification not installed"
8438 local file1=$DIR/$tfile.1
8439 local output_file=$DIR/$tfile.out
8441 stack_trap "rm -f $file1"
8442 $LFS setstripe -c 1 $file1
8443 dd if=/dev/zero of=$file1 bs=1M count=$size_mb ||
8444 error "error creating $file1"
8445 $LFS mirror extend -N $file1 || error "can't mirror"
8446 dd if=/dev/zero of=$file1 bs=4k count=1 conv=notrunc ||
8448 $LFS getstripe $file1 | grep stale ||
8449 error "one component must be stale"
8450 $LFS getstripe $file1
8452 $LFS mirror resync --stats --stats-interval=1 $file1 >$output_file ||
8453 error "resync failed rc = $?"
8454 $LFS getstripe $file1 | grep stale &&
8455 error "all components must be sync"
8458 cat $output_file | verify_yaml || error "stats is not valid YAML"
8460 run_test 56xl "lfs mirror resync stats support"
8463 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
8464 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
8467 local dir=$DIR/$tdir
8471 test_mkdir -p $dir || error "creating dir $dir"
8472 touch $f1 || error "creating std file $f1"
8473 $MULTIOP $f2 H2c || error "creating released file $f2"
8475 # a directory can be raid0, so ask only for files
8476 res=$($LFS find $dir -L raid0 -type f | wc -l)
8477 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
8479 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
8480 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
8482 # only files can be released, so no need to force file search
8483 res=$($LFS find $dir -L released)
8484 [[ $res == $f2 ]] || error "search released: found $res != $f2"
8486 res=$($LFS find $dir -type f \! -L released)
8487 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
8489 run_test 56y "lfs find -L raid0|released"
8491 test_56z() { # LU-4824
8492 # This checks to make sure 'lfs find' continues after errors
8493 # There are two classes of errors that should be caught:
8494 # - If multiple paths are provided, all should be searched even if one
8496 # - If errors are encountered during the search, it should not terminate
8498 local dir=$DIR/$tdir
8502 for i in d{0..9}; do
8504 touch $dir/$i/$tfile
8506 $LFS find $DIR/non_existent_dir $dir &&
8507 error "$LFS find did not return an error"
8508 # Make a directory unsearchable. This should NOT be the last entry in
8509 # directory order. Arbitrarily pick the 6th entry
8510 chmod 700 $($LFS find $dir -type d | sed '6!d')
8512 $RUNAS $LFS find $DIR/non_existent $dir
8513 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
8515 # The user should be able to see 10 directories and 9 files
8516 (( count == 19 )) ||
8517 error "$LFS find found $count != 19 entries after error"
8519 run_test 56z "lfs find should continue after an error"
8521 test_56aa() { # LU-5937
8522 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
8524 local dir=$DIR/$tdir
8527 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
8529 createmany -o $dir/striped_dir/${tfile}- 1024
8530 local dirs=$($LFS find --size +8k $dir/)
8532 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
8534 run_test 56aa "lfs find --size under striped dir"
8536 test_56ab() { # LU-10705
8537 test_mkdir $DIR/$tdir
8538 dd if=/dev/urandom of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
8539 dd if=/dev/urandom of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
8540 dd if=/dev/urandom of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
8541 # Flush writes to ensure valid blocks. Need to be more thorough for
8542 # ZFS, since blocks are not allocated/returned to client immediately.
8544 wait_zfs_commit ost1 2
8545 cancel_lru_locks osc
8548 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
8550 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
8552 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
8553 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
8555 rm -f $DIR/$tdir/$tfile.[123]
8557 run_test 56ab "lfs find --blocks"
8561 local dir="$DIR/$tdir"
8562 local perms=(001 002 003 004 005 006 007
8563 010 020 030 040 050 060 070
8564 100 200 300 400 500 600 700
8565 111 222 333 444 555 666 777)
8566 local perm_minus=(8 8 4 8 4 4 2
8570 local perm_slash=(8 8 12 8 12 12 14
8573 16 16 24 16 24 24 28)
8576 for perm in ${perms[*]}; do
8577 touch "$dir/$tfile.$perm"
8578 chmod $perm "$dir/$tfile.$perm"
8581 for ((i = 0; i < ${#perms[*]}; i++)); do
8582 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
8584 error "lfs find -perm ${perms[i]}:"\
8587 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
8588 (( $num == ${perm_minus[i]} )) ||
8589 error "lfs find -perm -${perms[i]}:"\
8590 "$num != ${perm_minus[i]}"
8592 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
8593 (( $num == ${perm_slash[i]} )) ||
8594 error "lfs find -perm /${perms[i]}:"\
8595 "$num != ${perm_slash[i]}"
8598 run_test 56aca "check lfs find -perm with octal representation"
8601 local dir=$DIR/$tdir
8602 # p is the permission of write and execute for user, group and other
8603 # without the umask. It is used to test +wx.
8604 local p=$(printf "%o" "$((0333 & ~$(umask)))")
8605 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
8606 local symbolic=(+t a+t u+t g+t o+t
8612 o=r,ug+o,u+w u=r,a+u,u+w
8613 g=r,ugo=g,u+w u+x,+X +X
8614 u+x,u+X u+X u+x,g+X o+r,+X
8618 for perm in ${perms[*]}; do
8619 touch "$dir/$tfile.$perm"
8620 chmod $perm "$dir/$tfile.$perm"
8623 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
8624 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
8627 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8630 run_test 56acb "check lfs find -perm with symbolic representation"
8633 local dir=$DIR/$tdir
8634 local tests="17777 787 789 abcd
8635 ug=uu ug=a ug=gu uo=ou urw
8639 for err in $tests; do
8640 if $LFS find $dir -perm $err 2>/dev/null; then
8641 error "lfs find -perm $err: parsing should have failed"
8645 run_test 56acc "check parsing error for lfs find -perm"
8648 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8649 skip "Need MDS version at least 2.10.50"
8651 # Create composite files with one component
8652 local dir=$DIR/$tdir
8654 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8655 # Create composite files with three components
8656 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8657 # LU-16904 Create plain layout files
8658 lfs setstripe -c 1 $dir/$tfile-{1..10}
8660 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8662 [[ $nfiles == 10 ]] ||
8663 error "lfs find -E 1M found $nfiles != 10 files"
8665 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8666 [[ $nfiles == 25 ]] ||
8667 error "lfs find ! -E 1M found $nfiles != 25 files"
8669 # All files have a component that starts at 0
8670 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8671 [[ $nfiles == 35 ]] ||
8672 error "lfs find --component-start 0 - $nfiles != 35 files"
8674 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8675 [[ $nfiles == 15 ]] ||
8676 error "lfs find --component-start 2M - $nfiles != 15 files"
8678 # All files created here have a componenet that does not starts at 2M
8679 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8680 [[ $nfiles == 35 ]] ||
8681 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8683 # Find files with a specified number of components
8684 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8685 [[ $nfiles == 15 ]] ||
8686 error "lfs find --component-count 3 - $nfiles != 15 files"
8688 # Remember non-composite files have a component count of zero
8689 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8690 [[ $nfiles == 10 ]] ||
8691 error "lfs find --component-count 0 - $nfiles != 10 files"
8693 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8694 [[ $nfiles == 20 ]] ||
8695 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8697 # All files have a flag called "init"
8698 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8699 [[ $nfiles == 35 ]] ||
8700 error "lfs find --component-flags init - $nfiles != 35 files"
8702 # Multi-component files will have a component not initialized
8703 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8704 [[ $nfiles == 15 ]] ||
8705 error "lfs find !--component-flags init - $nfiles != 15 files"
8710 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8713 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8714 skip "Need MDS version at least 2.10.57"
8724 # create mirrored directories and mirrored files
8725 mkdir $td || error "mkdir $td failed"
8726 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8727 createmany -o $tf- 10 || error "create $tf- failed"
8729 for i in $(seq 2); do
8731 mkdir $dir || error "mkdir $dir failed"
8732 $LFS mirror create -N$((3 + i)) $dir ||
8733 error "create mirrored dir $dir failed"
8734 createmany -o $dir/$tfile- 10 ||
8735 error "create $dir/$tfile- failed"
8738 # change the states of some mirrored files
8740 for i in $(seq 2); do
8742 for j in $(seq 4 9); do
8743 echo foo > $dir/$tfile-$j
8747 # find mirrored files with specific mirror count
8748 cmd="$LFS find --mirror-count 3 --type f $td"
8749 nfiles=$($cmd | wc -l)
8750 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8752 cmd="$LFS find ! --mirror-count 3 --type f $td"
8753 nfiles=$($cmd | wc -l)
8754 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8756 cmd="$LFS find --mirror-count +2 --type f $td"
8757 nfiles=$($cmd | wc -l)
8758 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8760 cmd="$LFS find --mirror-count -6 --type f $td"
8761 nfiles=$($cmd | wc -l)
8762 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8764 # find mirrored files with specific file state
8765 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8766 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8768 cmd="$LFS find --mirror-state=ro --type f $td"
8769 nfiles=$($cmd | wc -l)
8770 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8772 cmd="$LFS find ! --mirror-state=ro --type f $td"
8773 nfiles=$($cmd | wc -l)
8774 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8776 cmd="$LFS find --mirror-state=wp --type f $td"
8777 nfiles=$($cmd | wc -l)
8778 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8780 cmd="$LFS find ! --mirror-state=sp --type f $td"
8781 nfiles=$($cmd | wc -l)
8782 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8784 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8786 test_56da() { # LU-14179
8787 local path=$DIR/$tdir
8792 local longdir=$(str_repeat 'a' 255)
8794 for i in {1..15}; do
8801 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8806 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8809 touch $(str_repeat 'f' 255)
8811 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8812 error "lfs find reported an error"
8816 run_test 56da "test lfs find with long paths"
8818 test_56ea() { #LU-10378
8819 local path=$DIR/$tdir
8820 local pool=$TESTNAME
8823 pool_add $pool || error "pool_add $pool failed"
8824 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8825 error "adding targets to $pool failed"
8827 # Set default pool on directory before creating file
8828 mkdir $path || error "mkdir $path failed"
8829 $LFS setstripe -p $pool $path ||
8830 error "set OST pool on $pool failed"
8831 touch $path/$tfile || error "touch $path/$tfile failed"
8833 # Compare basic file attributes from -printf and stat
8834 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G %n")
8835 local attr_stat=$(stat -c "%X %Y %Z %u %g %h" $path/$tfile)
8837 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8838 error "Attrs from lfs find and stat don't match"
8840 # Compare Lustre attributes from lfs find and lfs getstripe
8841 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8842 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8843 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8844 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8845 local fpool=$($LFS getstripe --pool $path/$tfile)
8846 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8848 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8849 error "Attrs from lfs find and lfs getstripe don't match"
8851 # Verify behavior for unknown escape/format sequences
8852 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8854 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8855 error "Escape/format codes don't match"
8857 run_test 56ea "test lfs find -printf option"
8860 local dir=$DIR/$tdir
8861 local subdir_1=$dir/subdir_1
8863 test_mkdir -p $subdir_1
8864 ln -s subdir_1 $dir/link_1
8866 $LFS getstripe $dir | grep "^$dir/link_1$" -A1 ||
8867 error "symlink is not followed"
8869 $LFS getstripe --no-follow $dir |
8870 grep "^$dir/link_1 has no stripe info$" ||
8871 error "symlink should not have stripe info"
8874 ln -s testfile $dir/file_link_2
8876 $LFS getstripe $dir | grep "^$dir/file_link_2$" -A1 ||
8877 error "symlink is not followed"
8879 $LFS getstripe --no-follow $dir |
8880 grep "^$dir/file_link_2 has no stripe info$" ||
8881 error "symlink should not have stripe info"
8883 run_test 56eb "check lfs getstripe on symlink"
8886 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8887 local dir=$DIR/$tdir
8888 local srcfile=$dir/srcfile
8889 local srcyaml=$dir/srcyaml
8890 local destfile=$dir/destfile
8894 $LFS setstripe -i 1 $srcfile
8895 $LFS getstripe --hex-idx --yaml $srcfile > $srcyaml
8896 # if the setstripe yaml parsing fails for any reason, the command can
8897 # randomly assign the correct OST index, leading to an erroneous
8898 # success. but the chance of false success is low enough that a
8899 # regression should still be quickly caught.
8900 $LFS setstripe --yaml=$srcyaml $destfile
8902 local srcindex=$($LFS getstripe -i $srcfile)
8903 local destindex=$($LFS getstripe -i $destfile)
8905 if [[ ! $srcindex -eq $destindex ]]; then
8906 error "setstripe did not set OST index correctly"
8909 run_test 56ec "check lfs getstripe,setstripe --hex --yaml"
8912 local dir=$DIR/$tdir
8913 local subdir=$dir/subdir
8914 local file1=$dir/$tfile
8915 local file2=$dir/$tfile\2
8916 local link=$dir/$tfile-link
8920 $LFS setdirstripe -c1 $subdir
8925 nfiles=$($LFS find --links 1 $dir | wc -l)
8926 (( $nfiles == 1 )) ||
8927 error "lfs find --links expected 1 file, got $nfiles"
8929 nfiles=$($LFS find --type f --links 2 $dir | wc -l)
8930 (( $nfiles == 2 )) ||
8931 error "lfs find --links expected 2 files, got $nfiles"
8933 nfiles=$($LFS find --type d --links 2 $dir | wc -l)
8934 (( $nfiles == 1 )) ||
8935 error "lfs find --links expected 1 directory, got $nfiles"
8937 run_test 56eda "check lfs find --links"
8940 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
8942 local dir=$DIR/$tdir
8943 local stripedir=$dir/stripedir
8948 $LFS setdirstripe -c2 $stripedir
8950 $LFS getdirstripe $stripedir
8952 nfiles=$($LFS find --type d --links 2 $stripedir | wc -l)
8953 (( $nfiles == 1 )) ||
8954 error "lfs find --links expected 1 directory, got $nfiles"
8956 run_test 56edb "check lfs find --links for directory striped on multiple MDTs"
8959 local dir=$DIR/$tdir
8972 nfiles=$($LFS find $dir1 $dir2 ! -type d | wc -l)
8973 (( $nfiles == 2 )) ||
8974 error "(1) lfs find expected 2 files, got $nfiles"
8976 nfiles=$($LFS find $dir1 $dir2 -type f | wc -l)
8977 (( $nfiles == 2 )) ||
8978 error "(2) lfs find expected 2 files, got $nfiles"
8980 nfiles=$($LFS find -type f $dir1 $dir2 | wc -l)
8981 (( $nfiles == 2 )) ||
8982 error "(3) lfs find expected 2 files, got $nfiles"
8984 run_test 56ef "lfs find with multiple paths"
8987 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8988 # note test will not do anything if MDS is not local
8989 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8990 skip_env "ldiskfs only test"
8992 remote_mds_nodsh && skip "remote MDS with nodsh"
8994 local MNTDEV="osd*.*MDT*.mntdev"
8995 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8996 [ -z "$DEV" ] && error "can't access $MNTDEV"
8997 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8998 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8999 error "can't access $DEV"
9000 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
9001 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
9005 run_test 57a "verify MDS filesystem created with large inodes =="
9008 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9009 if [ "$mds1_FSTYPE" != ldiskfs ]; then
9010 skip_env "ldiskfs only test"
9012 remote_mds_nodsh && skip "remote MDS with nodsh"
9014 local dir=$DIR/$tdir
9017 local fileN=$dir/f$filecount
9019 rm -rf $dir || error "removing $dir"
9021 local mdtidx=$($LFS getstripe -m $dir)
9022 local mdtname=MDT$(printf %04x $mdtidx)
9023 local facet=mds$((mdtidx + 1))
9025 echo "mcreating $filecount files"
9026 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
9028 # verify that files do not have EAs yet
9029 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
9030 error "$file1 has an EA"
9031 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
9032 error "$fileN has an EA"
9036 df $dir #make sure we get new statfs data
9037 local mdsfree=$(do_facet $facet \
9038 lctl get_param -n osd*.*$mdtname.kbytesfree)
9039 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
9042 echo "opening files to create objects/EAs"
9043 for file in $(seq -f $dir/f%g 1 $filecount); do
9044 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
9045 error "opening $file"
9048 # verify that files have EAs now
9049 $LFS getstripe -y $file1 | grep -q "l_ost_idx" ||
9050 error "$file1 missing EA"
9051 $LFS getstripe -y $fileN | grep -q "l_ost_idx" ||
9052 error "$fileN missing EA"
9054 sleep 1 #make sure we get new statfs data
9056 local mdsfree2=$(do_facet $facet \
9057 lctl get_param -n osd*.*$mdtname.kbytesfree)
9058 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
9060 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
9061 if [ "$mdsfree" != "$mdsfree2" ]; then
9062 error "MDC before $mdcfree != after $mdcfree2"
9064 echo "MDC before $mdcfree != after $mdcfree2"
9065 echo "unable to confirm if MDS has large inodes"
9070 run_test 57b "default LOV EAs are stored inside large inodes ==="
9073 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9074 [ -z "$(which wiretest 2>/dev/null)" ] &&
9075 skip_env "could not find wiretest"
9079 run_test 58 "verify cross-platform wire constants =============="
9082 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9084 echo "touch 130 files"
9085 createmany -o $DIR/f59- 130
9087 unlinkmany $DIR/f59- 130
9089 # wait for commitment of removal
9090 wait_delete_completed
9092 run_test 59 "verify cancellation of llog records async ========="
9094 TEST60_HEAD="test_60 run $RANDOM"
9096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9097 remote_mgs_nodsh && skip "remote MGS with nodsh"
9098 do_facet mgs "! which run-llog.sh &> /dev/null" &&
9099 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
9100 skip_env "missing subtest run-llog.sh"
9102 log "$TEST60_HEAD - from kernel mode"
9103 do_facet mgs "$LCTL dk > /dev/null"
9104 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
9105 do_facet mgs $LCTL dk > $TMP/$tfile
9107 # LU-6388: test llog_reader
9108 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
9109 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
9110 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
9111 skip_env "missing llog_reader"
9112 local fstype=$(facet_fstype mgs)
9113 [ $fstype != ldiskfs -a $fstype != zfs ] &&
9114 skip_env "Only for ldiskfs or zfs type mgs"
9116 local mntpt=$(facet_mntpt mgs)
9117 local mgsdev=$(mgsdevname 1)
9129 #get fid and record list
9130 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
9132 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
9134 #remount mgs as ldiskfs or zfs type
9135 stop mgs || error "stop mgs failed"
9136 mount_fstype mgs || error "remount mgs failed"
9137 for ((i = 0; i < ${#fid_list[@]}; i++)); do
9140 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
9141 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
9146 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
9148 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
9150 echo "obj_file is $obj_file"
9151 do_facet mgs $llog_reader $obj_file
9153 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
9154 awk '{ print $3 }' | sed -e "s/^type=//g")
9155 if [ $rec_type != $rec ]; then
9156 echo "FAILED test_60a wrong record type $rec_type," \
9162 #check obj path if record type is LLOG_LOGID_MAGIC
9163 if [ "$rec" == "1064553b" ]; then
9164 path=$(do_facet mgs $llog_reader $obj_file |
9165 grep "path=" | awk '{ print $NF }' |
9166 sed -e "s/^path=//g")
9167 if [ $obj_file != $mntpt/$path ]; then
9168 echo "FAILED test_60a wrong obj path" \
9169 "$montpt/$path, should be $obj_file"
9176 #restart mgs before "error", otherwise it will block the next test
9177 stop mgs || error "stop mgs failed"
9178 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
9179 $pass || error "test failed, see FAILED test_60a messages for specifics"
9181 run_test 60a "llog_test run from kernel module and test llog_reader"
9183 test_60b() { # bug 6411
9184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9187 LLOG_COUNT=$(do_facet mgs dmesg |
9188 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
9189 /llog_[a-z]*.c:[0-9]/ {
9201 [[ $LLOG_COUNT -gt 120 ]] &&
9202 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
9204 run_test 60b "limit repeated messages from CERROR/CWARN"
9207 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9209 echo "create 5000 files"
9210 createmany -o $DIR/f60c- 5000
9211 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
9212 lctl set_param fail_loc=0x80000137
9213 unlinkmany $DIR/f60c- 5000
9214 lctl set_param fail_loc=0
9216 run_test 60c "unlink file when mds full"
9219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9221 SAVEPRINTK=$(lctl get_param -n printk)
9222 # verify "lctl mark" is even working"
9223 MESSAGE="test message ID $RANDOM $$"
9224 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
9225 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
9227 lctl set_param printk=0 || error "set lnet.printk failed"
9228 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
9229 MESSAGE="new test message ID $RANDOM $$"
9230 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
9231 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
9232 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
9234 lctl set_param -n printk="$SAVEPRINTK"
9236 run_test 60d "test printk console message masking"
9239 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9240 remote_mds_nodsh && skip "remote MDS with nodsh"
9243 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
9244 do_facet mds1 lctl set_param fail_loc=0x15b
9247 run_test 60e "no space while new llog is being created"
9250 local old_path=$($LCTL get_param -n debug_path)
9252 stack_trap "$LCTL set_param debug_path=$old_path"
9253 stack_trap "rm -f $TMP/$tfile*"
9254 rm -f $TMP/$tfile* 2> /dev/null
9255 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9256 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
9257 test_mkdir $DIR/$tdir
9258 # retry in case the open is cached and not released
9259 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
9260 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
9264 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
9266 run_test 60f "change debug_path works"
9272 test_mkdir -c $MDSCOUNT $DIR/$tdir
9277 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
9278 -c $MDSCOUNT $DIR/$tdir/subdir$index \
9280 mkdir $DIR/$tdir/subdir$index 2>/dev/null
9281 rmdir $DIR/$tdir/subdir$index 2>/dev/null
9282 index=$((index + 1))
9288 for i in {0..100}; do
9289 # define OBD_FAIL_OSD_TXN_START 0x19a
9290 local index=$((i % MDSCOUNT + 1))
9292 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
9299 for i in $(seq $MDSCOUNT); do
9300 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
9303 mkdir $DIR/$tdir/new || error "mkdir failed"
9304 rmdir $DIR/$tdir/new || error "rmdir failed"
9306 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
9308 for i in $(seq $MDSCOUNT); do
9309 wait_update_facet mds$i "$LCTL get_param -n \
9310 mdd.$(facet_svc mds$i).lfsck_namespace |
9311 awk '/^status/ { print \\\$2 }'" "completed"
9315 rm -rf $DIR/$tdir || error "rmdir failed"
9317 run_test 60g "transaction abort won't cause MDT hung"
9320 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
9321 skip "Need MDS version at least 2.12.52"
9322 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
9326 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
9327 #define OBD_FAIL_MDS_STRIPE_FID 0x189
9328 for fail_loc in 0x80000188 0x80000189; do
9329 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
9330 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
9331 error "mkdir $dir-$fail_loc failed"
9332 for i in {0..10}; do
9333 # create may fail on missing stripe
9334 echo $i > $DIR/$tdir-$fail_loc/$i
9336 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
9337 error "getdirstripe $tdir-$fail_loc failed"
9338 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
9339 error "migrate $tdir-$fail_loc failed"
9340 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
9341 error "getdirstripe $tdir-$fail_loc failed"
9342 pushd $DIR/$tdir-$fail_loc
9344 echo $f | cmp $f - || error "$f data mismatch"
9347 rm -rf $DIR/$tdir-$fail_loc
9350 run_test 60h "striped directory with missing stripes can be accessed"
9352 function t60i_load() {
9354 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
9355 $LCTL set_param fail_loc=0x131c fail_val=1
9356 for ((i=0; i<5000; i++)); do
9357 touch $DIR/$tdir/f$i
9362 changelog_register || error "changelog_register failed"
9363 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
9364 changelog_users $SINGLEMDS | grep -q $cl_user ||
9365 error "User $cl_user not found in changelog_users"
9366 changelog_chmask "ALL"
9369 for((i=0; i<100; i++)); do
9370 changelog_dump >/dev/null ||
9371 error "can't read changelog"
9375 changelog_deregister || error "changelog_deregister failed"
9376 $LCTL set_param fail_loc=0
9378 run_test 60i "llog: new record vs reader race"
9381 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
9382 skip "need MDS version at least 2.15.50"
9383 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9384 remote_mds_nodsh && skip "remote MDS with nodsh"
9385 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
9387 changelog_users $SINGLEMDS | grep "^cl" &&
9388 skip "active changelog user"
9390 local llog_reader=$(do_facet $SINGLEMDS "which llog_reader 2> /dev/null")
9392 [[ -z $(do_facet $SINGLEMDS ls -d $llog_reader 2> /dev/null) ]] &&
9393 skip_env "missing llog_reader"
9395 mkdir_on_mdt0 $DIR/$tdir
9397 local f=$DIR/$tdir/$tfile
9402 changelog_register || error "cannot register changelog user"
9404 # set changelog_mask to ALL
9405 changelog_chmask "ALL"
9408 createmany -o ${f}- 100 || error "createmany failed as $RUNAS_ID"
9409 unlinkmany ${f}- 100 || error "unlinkmany failed"
9411 tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
9412 mdt_dev=$(facet_device $SINGLEMDS)
9414 do_facet $SINGLEMDS sync
9415 plain=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump changelog_catalog \
9416 $tmpfile' $mdt_dev; $llog_reader $tmpfile" |
9417 awk '{match($0,"path=([^ ]+)",a)}END{print a[1]}')
9419 stack_trap "do_facet $SINGLEMDS rm -f $tmpfile"
9421 # if $tmpfile is not on EXT3 filesystem for some reason
9422 [[ ${plain:0:1} == 'O' ]] ||
9423 skip "path $plain is not in 'O/1/d<n>/<n>' format"
9425 size=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'dump $plain $tmpfile' \
9426 $mdt_dev; stat -c %s $tmpfile")
9427 echo "Truncate llog from $size to $((size - size % 8192))"
9428 size=$((size - size % 8192))
9429 do_facet $SINGLEMDS $TRUNCATE $tmpfile $size
9430 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9431 grep -c 'in bitmap only')
9432 (( $errs > 0 )) || error "llog_reader didn't find lost records"
9434 size=$((size - 9000))
9435 echo "Corrupt llog in the middle at $size"
9436 do_facet $SINGLEMDS dd if=/dev/urandom of=$tmpfile bs=1 seek=$size \
9437 count=333 conv=notrunc
9438 errs=$(do_facet $SINGLEMDS "$llog_reader $tmpfile" |
9439 grep -c 'next chunk')
9440 (( $errs > 0 )) || error "llog_reader didn't skip bad chunk"
9442 run_test 60j "llog_reader reports corruptions"
9445 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9448 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
9449 cancel_lru_locks osc
9450 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
9453 run_test 61a "mmap() writes don't make sync hang ================"
9456 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
9458 run_test 61b "mmap() of unstriped file is successful"
9460 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
9461 # Though this test is irrelevant anymore, it helped to reveal some
9462 # other grant bugs (LU-4482), let's keep it.
9463 test_63a() { # was test_63
9464 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9466 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
9468 for i in `seq 10` ; do
9469 dd if=/dev/zero of=$DIR/f63 bs=8k &
9475 rm -f $DIR/f63 || true
9477 run_test 63a "Verify oig_wait interruption does not crash ======="
9479 # bug 2248 - async write errors didn't return to application on sync
9480 # bug 3677 - async write errors left page locked
9482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9485 lctl set_param debug=-1
9487 # ensure we have a grant to do async writes
9488 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
9491 sync # sync lest earlier test intercept the fail_loc
9493 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9494 lctl set_param fail_loc=0x80000406
9495 $MULTIOP $DIR/$tfile Owy && \
9496 error "sync didn't return ENOMEM"
9497 sync; sleep 2; sync # do a real sync this time to flush page
9498 lctl get_param -n llite.*.dump_page_cache | grep locked && \
9499 error "locked page left in cache after async error" || true
9502 run_test 63b "async write errors should be returned to fsync ==="
9505 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9508 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
9510 run_test 64a "verify filter grant calculations (in kernel) ====="
9513 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9515 bash oos.sh $MOUNT || error "oos.sh failed: $?"
9517 run_test 64b "check out-of-space detection on client"
9520 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
9522 run_test 64c "verify grant shrink"
9528 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
9531 # this does exactly what osc_request.c:osc_announce_cached() does in
9532 # order to calculate max amount of grants to ask from server
9536 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
9537 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
9539 ((rpc_in_flight++));
9540 nrpages=$((nrpages * rpc_in_flight))
9542 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
9544 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
9546 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
9547 local undirty=$((nrpages * PAGE_SIZE))
9549 local max_extent_pages
9550 max_extent_pages=$(import_param $tgt grant_max_extent_size)
9551 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
9552 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
9553 local grant_extent_tax
9554 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9556 undirty=$((undirty + nrextents * grant_extent_tax))
9561 # this is size of unit for grant allocation. It should be equal to
9562 # what tgt_grant.c:tgt_grant_chunk() calculates
9566 local grant_extent_tax
9568 max_brw_size=$(import_param $tgt max_brw_size)
9570 grant_extent_tax=$(import_param $tgt grant_extent_tax)
9572 echo $(((max_brw_size + grant_extent_tax) * 2))
9576 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
9577 skip "OST < 2.10.55 doesn't limit grants enough"
9579 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
9581 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
9582 skip "no grant_param connect flag"
9584 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9586 $LCTL set_param -n -n debug="$OLDDEBUG" || true
9587 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9590 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
9591 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
9593 $LFS setstripe $DIR/$tfile -i 0 -c 1
9594 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
9597 while kill -0 $ddpid; do
9598 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9600 if [[ $cur_grant -gt $max_cur_granted ]]; then
9602 error "cur_grant $cur_grant > $max_cur_granted"
9608 run_test 64d "check grant limit exceed"
9614 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
9616 ((cur_grants == expected)) ||
9617 error "$msg: grants mismatch: $cur_grants, expected $expected"
9621 echo $((($1 + $2 - 1) & ~($2 - 1)))
9625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9626 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
9627 skip "Need OSS version at least 2.11.56"
9629 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9630 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9631 $LCTL set_param debug=+cache
9633 # Remount client to reset grant
9634 remount_client $MOUNT || error "failed to remount client"
9635 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9637 local init_grants=$(import_param $osc_tgt initial_grant)
9639 check_grants $osc_tgt $init_grants "init grants"
9641 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9642 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9643 local gbs=$(import_param $osc_tgt grant_block_size)
9645 # write random number of bytes from max_brw_size / 4 to max_brw_size
9646 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9647 # align for direct io
9648 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9649 # round to grant consumption unit
9650 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9652 local grants=$((wb_round_up + extent_tax))
9654 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9655 stack_trap "rm -f $DIR/$tfile"
9657 # define OBD_FAIL_TGT_NO_GRANT 0x725
9658 # make the server not grant more back
9659 do_facet ost1 $LCTL set_param fail_loc=0x725
9660 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
9662 do_facet ost1 $LCTL set_param fail_loc=0
9664 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
9666 rm -f $DIR/$tfile || error "rm failed"
9668 # Remount client to reset grant
9669 remount_client $MOUNT || error "failed to remount client"
9670 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9672 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9674 # define OBD_FAIL_TGT_NO_GRANT 0x725
9675 # make the server not grant more back
9676 do_facet ost1 $LCTL set_param fail_loc=0x725
9677 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
9678 do_facet ost1 $LCTL set_param fail_loc=0
9680 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
9682 run_test 64e "check grant consumption (no grant allocation)"
9685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9687 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
9688 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
9689 $LCTL set_param debug=+cache
9691 # Remount client to reset grant
9692 remount_client $MOUNT || error "failed to remount client"
9693 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9695 local init_grants=$(import_param $osc_tgt initial_grant)
9696 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9697 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9698 local gbs=$(import_param $osc_tgt grant_block_size)
9699 local chunk=$(grant_chunk $osc_tgt)
9701 # write random number of bytes from max_brw_size / 4 to max_brw_size
9702 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9703 # align for direct io
9704 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9705 # round to grant consumption unit
9706 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9708 local grants=$((wb_round_up + extent_tax))
9710 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9711 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
9712 error "error writing to $DIR/$tfile"
9714 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9715 "direct io with grant allocation"
9717 rm -f $DIR/$tfile || error "rm failed"
9719 # Remount client to reset grant
9720 remount_client $MOUNT || error "failed to remount client"
9721 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9723 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9725 # Testing that buffered IO consumes grant on the client
9727 # Delay the RPC on the server so it's guaranteed to not complete even
9728 # if the RPC is sent from the client
9729 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
9730 $LCTL set_param fail_loc=0x50a fail_val=3
9731 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 conv=notrunc ||
9732 error "error writing to $DIR/$tfile with buffered IO"
9734 check_grants $osc_tgt $((init_grants - grants)) \
9735 "buffered io, not write rpc"
9737 # Clear the fail loc and do a sync on the client
9738 $LCTL set_param fail_loc=0 fail_val=0
9741 # RPC is now known to have sent
9742 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9743 "buffered io, one RPC"
9745 run_test 64f "check grant consumption (with grant allocation)"
9748 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
9749 skip "Need MDS version at least 2.14.56"
9751 local mdts=$(comma_list $(mdts_nodes))
9753 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
9755 stack_trap "$LCTL set_param $old"
9757 # generate dirty pages and increase dirty granted on MDT
9758 stack_trap "rm -f $DIR/$tfile-*"
9759 for (( i = 0; i < 10; i++)); do
9760 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
9761 error "can't set stripe"
9762 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
9764 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
9765 $LFS getstripe $DIR/$tfile-$i
9766 error "not DoM file"
9773 # wait until grant shrink reset grant dirty on MDTs
9774 for ((i = 0; i < 120; i++)); do
9775 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9776 awk '{sum=sum+$1} END {print sum}')
9777 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
9778 echo "$grant_dirty grants, $vm_dirty pages"
9779 (( grant_dirty + vm_dirty == 0 )) && break
9780 (( i == 3 )) && sync &&
9781 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
9785 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9786 awk '{sum=sum+$1} END {print sum}')
9787 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
9789 run_test 64g "grant shrink on MDT"
9792 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9793 skip "need OST at least 2.14.56 to avoid grant shrink on read"
9795 local instance=$($LFS getname -i $DIR)
9796 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9797 local num_exps=$(do_facet ost1 \
9798 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
9799 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9800 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
9801 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9803 # 10MiB is for file to be written, max_brw_size * 16 *
9804 # num_exps is space reserve so that tgt_grant_shrink() decided
9806 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
9807 (( avail * 1024 < expect )) &&
9808 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
9810 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
9811 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
9812 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
9813 $LCTL set_param osc.*OST0000*.grant_shrink=1
9814 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
9816 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9817 stack_trap "rm -f $DIR/$tfile"
9818 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
9820 # drop cache so that coming read would do rpc
9821 cancel_lru_locks osc
9823 # shrink interval is set to 10, pause for 7 seconds so that
9824 # grant thread did not wake up yet but coming read entered
9825 # shrink mode for rpc (osc_should_shrink_grant())
9828 declare -a cur_grant_bytes
9829 declare -a tot_granted
9830 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9831 tot_granted[0]=$(do_facet ost1 \
9832 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9834 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9836 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9837 tot_granted[1]=$(do_facet ost1 \
9838 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9840 # grant change should be equal on both sides
9841 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9842 tot_granted[0] - tot_granted[1])) ||
9843 error "grant change mismatch, " \
9844 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9845 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9847 run_test 64h "grant shrink on read"
9850 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9851 skip "need OST at least 2.14.56 to avoid grant shrink on replay"
9853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9854 remote_ost_nodsh && skip "remote OSTs with nodsh"
9856 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9857 stack_trap "rm -f $DIR/$tfile"
9859 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9861 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9862 local instance=$($LFS getname -i $DIR)
9864 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9865 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9867 # shrink grants and simulate rpc loss
9868 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9869 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9870 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9874 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9876 local testid=$(echo $TESTNAME | tr '_' ' ')
9878 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9879 grep "GRANT, real grant" &&
9880 error "client has more grants then it owns" || true
9882 run_test 64i "shrink on reconnect"
9884 # bug 1414 - set/get directories' stripe info
9886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9888 test_mkdir $DIR/$tdir
9890 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9892 run_test 65a "directory with no stripe info"
9895 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9897 test_mkdir $DIR/$tdir
9898 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9900 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9903 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9905 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9909 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9911 test_mkdir $DIR/$tdir
9912 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9914 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9915 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9917 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9919 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9922 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9924 test_mkdir $DIR/$tdir
9925 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9926 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9928 if [[ $STRIPECOUNT -le 0 ]]; then
9930 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9931 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9932 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9934 sc=$(($STRIPECOUNT - 1))
9936 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9937 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9938 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9939 error "lverify failed"
9941 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9944 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9946 # LU-16904 delete layout when root is set as PFL layout
9947 save_layout_restore_at_exit $MOUNT
9948 $LFS setstripe -d $MOUNT || error "setstripe failed"
9950 test_mkdir $DIR/$tdir
9952 $LFS setstripe $DIR/$tdir || error "setstripe"
9953 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9954 error "no stripe info failed"
9956 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9958 run_test 65e "directory setstripe defaults"
9961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9963 test_mkdir $DIR/${tdir}f
9964 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9965 error "setstripe succeeded" || true
9967 run_test 65f "dir setstripe permission (should return error) ==="
9970 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9972 # LU-16904 delete layout when root is set as PFL layout
9973 save_layout_restore_at_exit $MOUNT
9974 $LFS setstripe -d $MOUNT || error "setstripe failed"
9976 test_mkdir $DIR/$tdir
9977 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9979 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9980 error "setstripe -S failed"
9981 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9982 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9983 error "delete default stripe failed"
9985 run_test 65g "directory setstripe -d"
9988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9990 test_mkdir $DIR/$tdir
9991 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9993 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9994 error "setstripe -S failed"
9995 test_mkdir $DIR/$tdir/dd1
9996 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9997 error "stripe info inherit failed"
9999 run_test 65h "directory stripe info inherit ===================="
10002 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10004 save_layout_restore_at_exit $MOUNT
10006 # bug6367: set non-default striping on root directory
10007 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
10009 # bug12836: getstripe on -1 default directory striping
10010 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
10012 # bug12836: getstripe -v on -1 default directory striping
10013 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
10015 # bug12836: new find on -1 default directory striping
10016 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
10018 run_test 65i "various tests to set root directory striping"
10020 test_65j() { # bug6367
10021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10025 # if we aren't already remounting for each test, do so for this test
10026 if [ "$I_MOUNTED" = "yes" ]; then
10027 cleanup || error "failed to unmount"
10031 save_layout_restore_at_exit $MOUNT
10033 $LFS setstripe -d $MOUNT || error "setstripe failed"
10035 run_test 65j "set default striping on root directory (bug 6367)="
10039 wait_delete_completed
10040 do_facet $SINGLEMDS "lctl set_param -n \
10041 osp.$ost*MDT0000.max_create_count=$max_count"
10042 do_facet $SINGLEMDS "lctl set_param -n \
10043 osp.$ost*MDT0000.create_count=$count"
10044 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
10045 echo $INACTIVE_OSC "is Activate"
10047 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
10050 test_65k() { # bug11679
10051 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10052 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10053 remote_mds_nodsh && skip "remote MDS with nodsh"
10055 local disable_precreate=true
10056 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
10057 disable_precreate=false
10059 echo "Check OST status: "
10060 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
10061 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
10063 for OSC in $MDS_OSCS; do
10064 echo $OSC "is active"
10065 do_facet $SINGLEMDS lctl --device %$OSC activate
10068 for INACTIVE_OSC in $MDS_OSCS; do
10069 local ost=$(osc_to_ost $INACTIVE_OSC)
10070 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
10071 lov.*md*.target_obd |
10072 awk -F: /$ost/'{ print $1 }' | head -n 1)
10074 mkdir -p $DIR/$tdir
10075 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
10076 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
10078 echo "Deactivate: " $INACTIVE_OSC
10079 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
10081 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
10082 osp.$ost*MDT0000.create_count")
10083 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
10084 osp.$ost*MDT0000.max_create_count")
10085 $disable_precreate &&
10086 do_facet $SINGLEMDS "lctl set_param -n \
10087 osp.$ost*MDT0000.max_create_count=0"
10089 for idx in $(seq 0 $((OSTCOUNT - 1))); do
10090 [ -f $DIR/$tdir/$idx ] && continue
10091 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
10092 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
10094 error "setstripe $idx should succeed"; }
10095 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
10097 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
10100 do_facet $SINGLEMDS "lctl set_param -n \
10101 osp.$ost*MDT0000.max_create_count=$max_count"
10102 do_facet $SINGLEMDS "lctl set_param -n \
10103 osp.$ost*MDT0000.create_count=$count"
10104 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
10105 echo $INACTIVE_OSC "is Activate"
10107 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
10110 run_test 65k "validate manual striping works properly with deactivated OSCs"
10112 test_65l() { # bug 12836
10113 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10115 test_mkdir -p $DIR/$tdir/test_dir
10116 $LFS setstripe -c -1 $DIR/$tdir/test_dir
10117 $LFS find -mtime -1 $DIR/$tdir >/dev/null
10119 run_test 65l "lfs find on -1 stripe dir ========================"
10122 local layout=$(save_layout $MOUNT)
10123 $RUNAS $LFS setstripe -c 2 $MOUNT && {
10124 restore_layout $MOUNT $layout
10125 error "setstripe should fail by non-root users"
10129 run_test 65m "normal user can't set filesystem default stripe"
10132 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
10133 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
10134 skip "Need MDS version at least 2.12.50"
10135 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
10137 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
10138 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
10139 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
10141 save_layout_restore_at_exit $MOUNT
10143 # new subdirectory under root directory should not inherit
10144 # the default layout from root
10145 # LU-16904 check if the root is set as PFL layout
10146 local numcomp=$($LFS getstripe --component-count $MOUNT)
10148 if [[ $numcomp -eq 0 ]]; then
10149 local dir1=$MOUNT/$tdir-1
10150 mkdir $dir1 || error "mkdir $dir1 failed"
10151 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
10152 error "$dir1 shouldn't have LOV EA"
10155 # delete the default layout on root directory
10156 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
10158 local dir2=$MOUNT/$tdir-2
10159 mkdir $dir2 || error "mkdir $dir2 failed"
10160 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
10161 error "$dir2 shouldn't have LOV EA"
10163 # set a new striping pattern on root directory
10164 local def_stripe_size=$($LFS getstripe -S $MOUNT)
10165 local new_def_stripe_size=$((def_stripe_size * 2))
10166 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
10167 error "set stripe size on $MOUNT failed"
10169 # new file created in $dir2 should inherit the new stripe size from
10170 # the filesystem default
10171 local file2=$dir2/$tfile-2
10172 touch $file2 || error "touch $file2 failed"
10174 local file2_stripe_size=$($LFS getstripe -S $file2)
10175 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
10177 echo "file2_stripe_size: '$file2_stripe_size'"
10178 echo "new_def_stripe_size: '$new_def_stripe_size'"
10179 error "$file2 didn't inherit stripe size $new_def_stripe_size"
10182 local dir3=$MOUNT/$tdir-3
10183 mkdir $dir3 || error "mkdir $dir3 failed"
10184 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
10185 # the root layout, which is the actual default layout that will be used
10186 # when new files are created in $dir3.
10187 local dir3_layout=$(get_layout_param $dir3)
10188 local root_dir_layout=$(get_layout_param $MOUNT)
10189 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
10191 echo "dir3_layout: '$dir3_layout'"
10192 echo "root_dir_layout: '$root_dir_layout'"
10193 error "$dir3 should show the default layout from $MOUNT"
10196 # set OST pool on root directory
10197 local pool=$TESTNAME
10198 pool_add $pool || error "add $pool failed"
10199 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
10200 error "add targets to $pool failed"
10202 $LFS setstripe -p $pool $MOUNT ||
10203 error "set OST pool on $MOUNT failed"
10205 # new file created in $dir3 should inherit the pool from
10206 # the filesystem default
10207 local file3=$dir3/$tfile-3
10208 touch $file3 || error "touch $file3 failed"
10210 local file3_pool=$($LFS getstripe -p $file3)
10211 [[ "$file3_pool" = "$pool" ]] ||
10212 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
10214 local dir4=$MOUNT/$tdir-4
10215 mkdir $dir4 || error "mkdir $dir4 failed"
10216 local dir4_layout=$(get_layout_param $dir4)
10217 root_dir_layout=$(get_layout_param $MOUNT)
10218 echo "$LFS getstripe -d $dir4"
10219 $LFS getstripe -d $dir4
10220 echo "$LFS getstripe -d $MOUNT"
10221 $LFS getstripe -d $MOUNT
10222 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
10224 echo "dir4_layout: '$dir4_layout'"
10225 echo "root_dir_layout: '$root_dir_layout'"
10226 error "$dir4 should show the default layout from $MOUNT"
10229 # new file created in $dir4 should inherit the pool from
10230 # the filesystem default
10231 local file4=$dir4/$tfile-4
10232 touch $file4 || error "touch $file4 failed"
10234 local file4_pool=$($LFS getstripe -p $file4)
10235 [[ "$file4_pool" = "$pool" ]] ||
10236 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
10238 # new subdirectory under non-root directory should inherit
10239 # the default layout from its parent directory
10240 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
10241 error "set directory layout on $dir4 failed"
10243 local dir5=$dir4/$tdir-5
10244 mkdir $dir5 || error "mkdir $dir5 failed"
10246 dir4_layout=$(get_layout_param $dir4)
10247 local dir5_layout=$(get_layout_param $dir5)
10248 [[ "$dir4_layout" = "$dir5_layout" ]] ||
10250 echo "dir4_layout: '$dir4_layout'"
10251 echo "dir5_layout: '$dir5_layout'"
10252 error "$dir5 should inherit the default layout from $dir4"
10255 # though subdir under ROOT doesn't inherit default layout, but
10256 # its sub dir/file should be created with default layout.
10257 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
10258 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
10259 skip "Need MDS version at least 2.12.59"
10261 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
10262 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
10263 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
10265 if [ $default_lmv_hash == "none" ]; then
10266 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
10268 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
10269 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
10272 $LFS setdirstripe -D -c 2 $MOUNT ||
10273 error "setdirstripe -D -c 2 failed"
10274 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
10275 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
10276 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
10278 # $dir4 layout includes pool
10279 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
10280 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
10281 error "pool lost on setstripe"
10282 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
10283 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
10284 error "pool lost on compound layout setstripe"
10286 run_test 65n "don't inherit default layout from root for new subdirectories"
10289 (( $MDS1_VERSION >= $(version_code 2.14.57) )) ||
10290 skip "need MDS version at least 2.14.57"
10292 # set OST pool on root directory
10293 local pool=$TESTNAME
10295 pool_add $pool || error "add $pool failed"
10296 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
10297 error "add targets to $pool failed"
10299 local dir1=$MOUNT/$tdir
10301 mkdir $dir1 || error "mkdir $dir1 failed"
10303 # set a new striping pattern on root directory
10304 local def_stripe_size=$($LFS getstripe -S $MOUNT)
10306 $LFS setstripe -p $pool $dir1 ||
10307 error "set directory layout on $dir1 failed"
10309 # $dir1 layout includes pool
10310 $LFS setstripe -S $((def_stripe_size * 2)) $dir1
10311 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
10312 error "pool lost on setstripe"
10313 $LFS setstripe -E 1M -L mdt -E -1 -c 1 $dir1
10314 $LFS getstripe $dir1
10315 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
10316 error "pool lost on compound layout setstripe"
10318 $LFS setdirstripe -i 0 -c 2 $dir1/dir2 ||
10319 error "setdirstripe failed on sub-dir with inherited pool"
10320 $LFS getstripe $dir1/dir2
10321 [[ "$pool" = $($LFS getstripe -p -d $dir1/dir2) ]] ||
10322 error "pool lost on compound layout setdirstripe"
10324 $LFS setstripe -E -1 -c 1 $dir1
10325 $LFS getstripe -d $dir1
10326 [[ "$pool" = $($LFS getstripe -p -d $dir1) ]] ||
10327 error "pool lost on setstripe"
10329 run_test 65o "pool inheritance for mdt component"
10331 test_65p () { # LU-16152
10332 local src_dir=$DIR/$tdir/src_dir
10333 local dst_dir=$DIR/$tdir/dst_dir
10334 local yaml_file=$DIR/$tdir/layout.yaml
10337 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
10338 skip "Need at least version 2.15.51"
10340 test_mkdir -p $src_dir
10341 $LFS setstripe -E 2048M -c 4 -E EOF -c 8 $src_dir ||
10342 error "failed to setstripe"
10343 $LFS getstripe --yaml -d $src_dir > $yaml_file ||
10344 error "failed to getstripe"
10346 test_mkdir -p $dst_dir
10347 $LFS setstripe --yaml $yaml_file $dst_dir ||
10348 error "failed to setstripe with yaml file"
10349 border=$($LFS getstripe -d $dst_dir |
10350 awk '/lcme_extent.e_end:/ { print $2; exit; }') ||
10351 error "failed to getstripe"
10353 # 2048M is 0x80000000, or 2147483648
10354 (( $border == 2147483648 )) ||
10355 error "failed to handle huge number in yaml layout"
10357 run_test 65p "setstripe with yaml file and huge number"
10359 test_65p () { # LU-16194
10360 local src_dir=$DIR/$tdir/src_dir
10362 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
10363 skip "Need at least version 2.15.51"
10365 test_mkdir -p $src_dir
10366 # 8E is 0x8000 0000 0000 0000, which is negative as s64
10367 $LFS setstripe -E 8E -c 4 -E EOF -c 8 $src_dir &&
10368 error "should fail if extent start/end >=8E"
10370 # EOF should work as before
10371 $LFS setstripe -E 8M -c 4 -E EOF -c 8 $src_dir ||
10372 error "failed to setstripe normally"
10374 run_test 65p "setstripe with >=8E offset should fail"
10376 # bug 2543 - update blocks count on client
10378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10380 local COUNT=${COUNT:-8}
10381 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
10382 sync; sync_all_data; sync; sync_all_data
10383 cancel_lru_locks osc
10384 local BLOCKS=$(ls -s --block-size=1k $DIR/f66 | awk '{ print $1 }')
10385 (( BLOCKS >= COUNT )) || error "$DIR/f66 blocks $BLOCKS < $COUNT"
10387 run_test 66 "update inode blocks count on client ==============="
10390 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
10394 swapon -s | awk '($1 == "'$1'") { print $4 }'
10397 # bug5265, obdfilter oa2dentry return -ENOENT
10398 # #define OBD_FAIL_SRV_ENOENT 0x217
10400 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10401 remote_ost_nodsh && skip "remote OST with nodsh"
10404 $LFS setstripe -c 1 -i 0 $f
10405 stack_trap "rm -f $f ${f}.2"
10407 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
10409 do_facet ost1 lctl set_param fail_loc=0x217
10410 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
10411 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
10413 do_facet ost1 lctl set_param fail_loc=0
10414 $DIRECTIO write $f 0 2 || error "write error"
10416 cancel_lru_locks osc
10417 $DIRECTIO read $f 0 1 || error "read error"
10419 do_facet ost1 lctl set_param fail_loc=0x217
10420 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
10422 do_facet ost1 lctl set_param fail_loc=0
10424 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
10427 test_mkdir $DIR/$tdir
10428 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
10429 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
10431 run_test 71 "Running dbench on lustre (don't segment fault) ===="
10433 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
10434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10435 [ "$RUNAS_ID" = "$UID" ] &&
10436 skip_env "RUNAS_ID = UID = $UID -- skipping"
10437 # Check that testing environment is properly set up. Skip if not
10438 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
10439 skip_env "User $RUNAS_ID does not exist - skipping"
10442 chmod 777 $DIR/$tfile
10443 chmod ug+s $DIR/$tfile
10444 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
10445 error "$RUNAS dd $DIR/$tfile failed"
10446 # See if we are still setuid/sgid
10447 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10448 error "S/gid is not dropped on write"
10449 # Now test that MDS is updated too
10450 cancel_lru_locks mdc
10451 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
10452 error "S/gid is not dropped on MDS"
10455 run_test 72a "Test that remove suid works properly (bug5695) ===="
10457 test_72b() { # bug 24226 -- keep mode setting when size is not changing
10460 [ "$RUNAS_ID" = "$UID" ] &&
10461 skip_env "RUNAS_ID = UID = $UID -- skipping"
10462 [ "$RUNAS_ID" -eq 0 ] &&
10463 skip_env "RUNAS_ID = 0 -- skipping"
10464 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10465 # Check that testing environment is properly set up. Skip if not
10466 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
10467 skip_env "User $RUNAS_ID does not exist - skipping"
10469 touch $DIR/${tfile}-f{g,u}
10470 test_mkdir $DIR/${tfile}-dg
10471 test_mkdir $DIR/${tfile}-du
10472 chmod 770 $DIR/${tfile}-{f,d}{g,u}
10473 chmod g+s $DIR/${tfile}-{f,d}g
10474 chmod u+s $DIR/${tfile}-{f,d}u
10475 for perm in 777 2777 4777; do
10476 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
10477 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
10478 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
10479 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
10483 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
10485 # bug 3462 - multiple simultaneous MDC requests
10487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10489 test_mkdir $DIR/d73-1
10490 test_mkdir $DIR/d73-2
10491 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
10494 lctl set_param fail_loc=0x80000129
10495 $MULTIOP $DIR/d73-1/f73-2 Oc &
10497 lctl set_param fail_loc=0
10499 $MULTIOP $DIR/d73-2/f73-3 Oc &
10503 wait $pid1 || return 1
10507 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
10508 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
10509 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
10513 run_test 73 "multiple MDC requests (should not deadlock)"
10515 test_74a() { # bug 6149, 6184
10516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10519 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10521 # very important to OR with CFS_FAIL_ONCE (0x80000000) -- otherwise it
10522 # will spin in a tight reconnection loop
10523 $LCTL set_param fail_loc=0x8000030e
10524 # get any lock that won't be difficult - lookup works.
10526 $LCTL set_param fail_loc=0
10530 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
10532 test_74b() { # bug 13310
10533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10535 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
10537 # very important to OR with CFS_FAIL_ONCE (0x80000000) -- otherwise it
10538 # will spin in a tight reconnection loop
10539 $LCTL set_param fail_loc=0x8000030e
10540 # get a "difficult" lock
10542 $LCTL set_param fail_loc=0
10546 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
10549 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10551 #define OBD_FAIL_LDLM_NEW_LOCK
10552 $LCTL set_param fail_loc=0x319
10553 touch $DIR/$tfile && error "touch successful"
10554 $LCTL set_param fail_loc=0
10557 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
10559 slab_lic=/sys/kernel/slab/lustre_inode_cache
10561 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
10562 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
10563 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
10566 test_76a() { # Now for b=20433, added originally in b=1443
10567 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10569 cancel_lru_locks osc
10570 # there may be some slab objects cached per core
10571 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
10572 local before=$(num_objects)
10573 local count=$((512 * cpus))
10574 [ "$SLOW" = "no" ] && count=$((128 * cpus))
10575 local margin=$((count / 10))
10576 if [[ -f $slab_lic/aliases ]]; then
10577 local aliases=$(cat $slab_lic/aliases)
10578 (( aliases > 0 )) && margin=$((margin * aliases))
10581 echo "before slab objects: $before"
10582 for i in $(seq $count); do
10586 cancel_lru_locks osc
10587 local after=$(num_objects)
10588 echo "created: $count, after slab objects: $after"
10589 # shared slab counts are not very accurate, allow significant margin
10590 # the main goal is that the cache growth is not permanently > $count
10591 while (( after > before + margin )); do
10593 after=$(num_objects)
10595 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10596 if (( wait > 60 )); then
10597 error "inode slab grew from $before+$margin to $after"
10601 run_test 76a "confirm clients recycle inodes properly ===="
10604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10605 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
10608 local before=$(num_objects)
10610 for i in $(seq $count); do
10615 local after=$(num_objects)
10618 while (( after > before )); do
10620 after=$(num_objects)
10622 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
10623 if (( wait > 60 )); then
10624 error "inode slab grew from $before to $after"
10628 echo "slab objects before: $before, after: $after"
10630 run_test 76b "confirm clients recycle directory inodes properly ===="
10632 export ORIG_CSUM=""
10635 # Note: in sptlrpc modes which enable its own bulk checksum, the
10636 # original crc32_le bulk checksum will be automatically disabled,
10637 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
10638 # will be checked by sptlrpc code against sptlrpc bulk checksum.
10639 # In this case set_checksums() will not be no-op, because sptlrpc
10640 # bulk checksum will be enabled all through the test.
10642 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
10643 lctl set_param -n osc.*.checksums $1
10647 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10648 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
10649 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
10650 tr -d [] | head -n1)}
10651 set_checksum_type()
10653 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
10655 log "set checksum type to $1, rc = $rc"
10659 get_osc_checksum_type()
10661 # arugment 1: OST name, like OST0000
10663 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
10664 sed 's/.*\[\(.*\)\].*/\1/g')
10666 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
10667 echo $checksum_type
10670 F77_TMP=$TMP/f77-temp
10673 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
10674 error "error writing to $F77_TMP"
10677 test_77a() { # bug 10889
10678 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10679 $GSS && skip_env "could not run with gss"
10681 [ ! -f $F77_TMP ] && setup_f77
10683 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
10687 run_test 77a "normal checksum read/write operation"
10689 test_77b() { # bug 10889
10690 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10691 $GSS && skip_env "could not run with gss"
10693 [ ! -f $F77_TMP ] && setup_f77
10694 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10695 $LCTL set_param fail_loc=0x80000409
10698 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10699 error "dd error: $?"
10700 $LCTL set_param fail_loc=0
10702 for algo in $CKSUM_TYPES; do
10703 cancel_lru_locks osc
10704 set_checksum_type $algo
10705 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10706 $LCTL set_param fail_loc=0x80000408
10707 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
10708 $LCTL set_param fail_loc=0
10711 set_checksum_type $ORIG_CSUM_TYPE
10714 run_test 77b "checksum error on client write, read"
10719 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
10721 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
10722 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
10723 $check_ost && [ -n "$ost_file_prefix" ] &&
10724 do_facet ost1 rm -f ${ost_file_prefix}\*
10728 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10729 $GSS && skip_env "could not run with gss"
10730 remote_ost_nodsh && skip "remote OST with nodsh"
10733 local osc_file_prefix
10735 local check_ost=false
10736 local ost_file_prefix
10742 # ensure corruption will occur on first OSS/OST
10743 $LFS setstripe -i 0 $DIR/$tfile
10745 [ ! -f $F77_TMP ] && setup_f77
10746 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
10747 error "dd write error: $?"
10748 fid=$($LFS path2fid $DIR/$tfile)
10750 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
10753 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
10754 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
10756 echo "OSS do not support bulk pages dump upon error"
10759 osc_file_prefix=$($LCTL get_param -n debug_path)
10760 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
10762 trap cleanup_77c EXIT
10765 # enable bulk pages dump upon error on Client
10766 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
10767 # enable bulk pages dump upon error on OSS
10769 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
10771 # flush Client cache to allow next read to reach OSS
10772 cancel_lru_locks osc
10774 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10775 $LCTL set_param fail_loc=0x80000408
10776 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
10777 $LCTL set_param fail_loc=0
10781 # check cksum dump on Client
10782 osc_file=$(ls ${osc_file_prefix}*)
10783 [ -n "$osc_file" ] || error "no checksum dump file on Client"
10784 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
10785 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
10786 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
10787 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
10789 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
10790 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10791 error "dump content does not match on Client"
10793 $check_ost || skip "No need to check cksum dump on OSS"
10795 # check cksum dump on OSS
10796 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
10797 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
10798 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
10799 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
10800 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10801 error "dump content does not match on OSS"
10805 run_test 77c "checksum error on client read with debug"
10807 test_77d() { # bug 10889
10808 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10809 $GSS && skip_env "could not run with gss"
10811 stack_trap "rm -f $DIR/$tfile"
10812 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10813 $LCTL set_param fail_loc=0x80000409
10815 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10816 error "direct write: rc=$?"
10817 $LCTL set_param fail_loc=0
10820 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10821 $LCTL set_param fail_loc=0x80000408
10823 cancel_lru_locks osc
10824 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10825 error "direct read: rc=$?"
10826 $LCTL set_param fail_loc=0
10829 run_test 77d "checksum error on OST direct write, read"
10831 test_77f() { # bug 10889
10832 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10833 $GSS && skip_env "could not run with gss"
10836 stack_trap "rm -f $DIR/$tfile"
10837 for algo in $CKSUM_TYPES; do
10838 cancel_lru_locks osc
10839 set_checksum_type $algo
10840 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10841 $LCTL set_param fail_loc=0x409
10842 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
10843 error "direct write succeeded"
10844 $LCTL set_param fail_loc=0
10846 set_checksum_type $ORIG_CSUM_TYPE
10849 run_test 77f "repeat checksum error on write (expect error)"
10851 test_77g() { # bug 10889
10852 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10853 $GSS && skip_env "could not run with gss"
10854 remote_ost_nodsh && skip "remote OST with nodsh"
10856 [ ! -f $F77_TMP ] && setup_f77
10858 local file=$DIR/$tfile
10859 stack_trap "rm -f $file" EXIT
10861 $LFS setstripe -c 1 -i 0 $file
10862 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
10863 do_facet ost1 lctl set_param fail_loc=0x8000021a
10865 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
10866 error "write error: rc=$?"
10867 do_facet ost1 lctl set_param fail_loc=0
10870 cancel_lru_locks osc
10871 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
10872 do_facet ost1 lctl set_param fail_loc=0x8000021b
10874 cmp $F77_TMP $file || error "file compare failed"
10875 do_facet ost1 lctl set_param fail_loc=0
10878 run_test 77g "checksum error on OST write, read"
10880 test_77k() { # LU-10906
10881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10882 $GSS && skip_env "could not run with gss"
10884 local cksum_param="osc.$FSNAME*.checksums"
10885 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
10889 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
10890 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
10891 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
10894 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
10895 error "failed to set checksum=$i on MGS"
10896 wait_update $HOSTNAME "$get_checksum" $i
10898 echo "remount client, checksum should be $i"
10899 remount_client $MOUNT || error "failed to remount client"
10900 checksum=$(eval $get_checksum)
10901 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10903 # remove persistent param to avoid races with checksum mountopt below
10904 do_facet mgs $LCTL set_param -P -d $cksum_param ||
10905 error "failed to delete checksum on MGS"
10907 for opt in "checksum" "nochecksum"; do
10908 #remount with mount option
10909 echo "remount client with option $opt, checksum should be $i"
10910 umount_client $MOUNT || error "failed to umount client"
10911 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
10912 error "failed to mount client with option '$opt'"
10913 checksum=$(eval $get_checksum)
10914 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10918 remount_client $MOUNT || error "failed to remount client"
10920 run_test 77k "enable/disable checksum correctly"
10923 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10924 $GSS && skip_env "could not run with gss"
10927 stack_trap "set_checksums $ORIG_CSUM" EXIT
10928 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10930 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10932 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10933 for algo in $CKSUM_TYPES; do
10934 set_checksum_type $algo || error "fail to set checksum type $algo"
10935 osc_algo=$(get_osc_checksum_type OST0000)
10936 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10938 # no locks, no reqs to let the connection idle
10939 cancel_lru_locks osc
10940 lru_resize_disable osc
10941 wait_osc_import_state client ost1 IDLE
10943 # ensure ost1 is connected
10944 stat $DIR/$tfile >/dev/null || error "can't stat"
10945 wait_osc_import_state client ost1 FULL
10947 osc_algo=$(get_osc_checksum_type OST0000)
10948 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10952 run_test 77l "preferred checksum type is remembered after reconnected"
10954 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10959 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10960 skip "Need at least version 2.14.52"
10961 local param=checksum_speed
10963 $LCTL get_param $param || error "reading $param failed"
10965 csum_speeds=$($LCTL get_param -n $param)
10967 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10968 error "known checksum types are missing"
10970 run_test 77m "Verify checksum_speed is correctly read"
10972 check_filefrag_77n() {
10977 while read extidx a b start end rest; do
10978 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10979 nr_ext=$(( $nr_ext + 1 ))
10980 starts+=( ${start%..} )
10983 done < <( filefrag -sv $1 )
10985 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10990 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10993 $TRUNCATE $DIR/$tfile 0
10994 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10995 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10996 check_filefrag_77n $DIR/$tfile ||
10997 skip "$tfile blocks not contiguous around hole"
11000 stack_trap "set_checksums $ORIG_CSUM" EXIT
11001 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
11002 stack_trap "rm -f $DIR/$tfile"
11004 for algo in $CKSUM_TYPES; do
11005 if [[ "$algo" =~ ^t10 ]]; then
11006 set_checksum_type $algo ||
11007 error "fail to set checksum type $algo"
11008 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
11009 error "fail to read $tfile with $algo"
11015 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
11018 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
11019 skip "Need MDS version at least 2.14.55"
11020 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
11021 skip "Need OST version at least 2.14.55"
11022 local ofd=obdfilter
11025 # print OST checksum_type
11026 echo "$ofd.$FSNAME-*.checksum_type:"
11027 do_nodes $(comma_list $(osts_nodes)) \
11028 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
11030 # print MDT checksum_type
11031 echo "$mdt.$FSNAME-*.checksum_type:"
11032 do_nodes $(comma_list $(mdts_nodes)) \
11033 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
11035 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
11036 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
11038 (( $o_count == $OSTCOUNT )) ||
11039 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
11041 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
11042 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
11044 (( $m_count == $MDSCOUNT )) ||
11045 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
11047 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
11049 cleanup_test_78() {
11054 test_78() { # bug 10901
11055 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11056 remote_ost || skip_env "local OST"
11059 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
11060 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
11061 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
11062 echo "MemTotal: $MEMTOTAL"
11064 # reserve 256MB of memory for the kernel and other running processes,
11065 # and then take 1/2 of the remaining memory for the read/write buffers.
11066 if [ $MEMTOTAL -gt 512 ] ;then
11067 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
11069 # for those poor memory-starved high-end clusters...
11070 MEMTOTAL=$((MEMTOTAL / 2))
11072 echo "Mem to use for directio: $MEMTOTAL"
11074 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
11075 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
11076 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
11077 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
11079 echo "Smallest OST: $SMALLESTOST"
11080 [[ $SMALLESTOST -lt 10240 ]] &&
11081 skip "too small OSTSIZE, useless to run large O_DIRECT test"
11083 trap cleanup_test_78 EXIT
11085 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
11086 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
11088 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
11089 echo "File size: $F78SIZE"
11090 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
11091 for i in $(seq 1 $NSEQ); do
11092 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
11093 echo directIO rdwr round $i of $NSEQ
11094 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
11099 run_test 78 "handle large O_DIRECT writes correctly ============"
11101 test_79() { # bug 12743
11102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11104 wait_delete_completed
11106 BKTOTAL=$(calc_osc_kbytes kbytestotal)
11107 BKFREE=$(calc_osc_kbytes kbytesfree)
11108 BKAVAIL=$(calc_osc_kbytes kbytesavail)
11110 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
11111 DFTOTAL=`echo $STRING | cut -d, -f1`
11112 DFUSED=`echo $STRING | cut -d, -f2`
11113 DFAVAIL=`echo $STRING | cut -d, -f3`
11114 DFFREE=$(($DFTOTAL - $DFUSED))
11116 ALLOWANCE=$((64 * $OSTCOUNT))
11118 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
11119 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
11120 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
11122 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
11123 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
11124 error "df free($DFFREE) mismatch OST free($BKFREE)"
11126 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
11127 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
11128 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
11131 run_test 79 "df report consistency check ======================="
11133 test_80() { # bug 10718
11134 remote_ost_nodsh && skip "remote OST with nodsh"
11135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11137 # relax strong synchronous semantics for slow backends like ZFS
11138 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
11139 local soc="obdfilter.*.sync_lock_cancel"
11140 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
11142 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
11143 if [ -z "$save" ]; then
11144 soc="obdfilter.*.sync_on_lock_cancel"
11145 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
11148 if [ "$save" != "never" ]; then
11149 local hosts=$(comma_list $(osts_nodes))
11151 do_nodes $hosts $LCTL set_param $soc=never
11152 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
11156 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
11157 sync; sleep 1; sync
11158 local before=$(date +%s)
11159 cancel_lru_locks osc
11160 local after=$(date +%s)
11161 local diff=$((after - before))
11162 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
11166 run_test 80 "Page eviction is equally fast at high offsets too"
11168 test_81a() { # LU-456
11169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11170 remote_ost_nodsh && skip "remote OST with nodsh"
11172 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
11173 # MUST OR with the CFS_FAIL_ONCE (0x80000000)
11174 do_facet ost1 lctl set_param fail_loc=0x80000228
11176 # write should trigger a retry and success
11177 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11178 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11180 if [ $RC -ne 0 ] ; then
11181 error "write should success, but failed for $RC"
11184 run_test 81a "OST should retry write when get -ENOSPC ==============="
11186 test_81b() { # LU-456
11187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11188 remote_ost_nodsh && skip "remote OST with nodsh"
11190 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
11191 # Don't OR with the CFS_FAIL_ONCE (0x80000000)
11192 do_facet ost1 lctl set_param fail_loc=0x228
11194 # write should retry several times and return -ENOSPC finally
11195 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11196 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11199 if [ $RC -ne $ENOSPC ] ; then
11200 error "dd should fail for -ENOSPC, but succeed."
11203 run_test 81b "OST should return -ENOSPC when retry still fails ======="
11206 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
11208 test_mkdir $DIR/$tdir.cvsroot
11209 chown $RUNAS_ID $DIR/$tdir.cvsroot
11212 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
11215 # some versions of cvs import exit(1) when asked to import links or
11216 # files they can't read. ignore those files.
11217 local toignore=$(find . -type l -printf '-I %f\n' -o \
11218 ! -perm /4 -printf '-I %f\n')
11219 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
11220 $tdir.reposname vtag rtag
11223 test_mkdir $DIR/$tdir.reposname
11224 chown $RUNAS_ID $DIR/$tdir.reposname
11225 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
11227 cd $DIR/$tdir.reposname
11229 $RUNAS cvs add -m 'addmsg' foo99
11231 $RUNAS cvs commit -m 'nomsg' foo99
11232 rm -fr $DIR/$tdir.cvsroot
11234 run_test 99 "cvs strange file/directory operations"
11237 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11238 [[ "$NETTYPE" =~ tcp ]] ||
11239 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
11240 [[ -n "$(type -p ss)" ]] || skip_env "ss not available"
11241 remote_ost_nodsh && skip "remote OST with nodsh"
11242 remote_mds_nodsh && skip "remote MDS with nodsh"
11243 remote_servers || skip "useless for local single node setup"
11245 ss -tna | ( rc=1; while read STATE SND RCV LOCAL REMOTE STAT; do
11246 [[ "${REMOTE/*:/}" == "$ACCEPTOR_PORT" ]] || continue
11249 if (( ${LOCAL/*:/} >= 1024 )); then
11250 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
11252 error "local: ${LOCAL/*:/} > 1024 remote: ${REMOTE/*:/}"
11255 (( $rc == 0 )) || error "privileged port not found" )
11257 run_test 100 "check local port using privileged port"
11259 function get_named_value()
11263 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
11267 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11272 local cache_limit=32
11274 $LCTL set_param -n osc.*-osc*.rpc_stats=0
11275 $LCTL set_param -n llite.*.read_ahead_stats=0
11276 local max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11277 awk '/^max_cached_mb/ { print $2 }')
11278 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$max_cached_mb"
11279 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
11282 # randomly read 10000 of 64K chunks from file 3x 32MB in size
11284 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
11285 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
11288 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
11289 get_named_value 'read.but.discarded'); do
11290 discard=$(($discard + $s))
11293 $LCTL get_param osc.*-osc*.rpc_stats
11294 $LCTL get_param llite.*.read_ahead_stats
11296 # Discard is generally zero, but sometimes a few random reads line up
11297 # and trigger larger readahead, which is wasted & leads to discards.
11298 if [[ $(($discard)) -gt $nreads ]]; then
11299 error "too many ($discard) discarded pages"
11301 rm -f $DIR/$tfile || true
11303 run_test 101a "check read-ahead for random reads"
11305 setup_test101bc() {
11306 test_mkdir $DIR/$tdir
11308 local FILE_LENGTH=$2
11311 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
11313 local list=$(comma_list $(osts_nodes))
11314 set_osd_param $list '' read_cache_enable 0
11315 set_osd_param $list '' writethrough_cache_enable 0
11317 trap cleanup_test101bc EXIT
11318 # prepare the read-ahead file
11319 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
11321 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
11322 count=$FILE_SIZE_MB 2> /dev/null
11326 cleanup_test101bc() {
11331 local list=$(comma_list $(osts_nodes))
11332 set_osd_param $list '' read_cache_enable 1
11333 set_osd_param $list '' writethrough_cache_enable 1
11338 local stripe_size=$2
11339 local stride_length=$((stripe_size / read_size))
11340 local stride_width=$((stride_length * OSTCOUNT))
11341 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
11342 (stride_width - stride_length) ))
11343 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
11344 get_named_value 'read.but.discarded' | calc_sum)
11346 if [[ $discard -gt $discard_limit ]]; then
11347 $LCTL get_param llite.*.read_ahead_stats
11348 error "($discard limit ${discard_limit}) discarded pages with size (${read_size})"
11350 echo "Read-ahead success for size ${read_size}"
11355 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11356 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11358 local STRIPE_SIZE=1048576
11359 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
11361 if [ $SLOW == "yes" ]; then
11362 local FILE_LENGTH=$((STRIDE_SIZE * 64))
11364 local FILE_LENGTH=$((STRIDE_SIZE * 8))
11367 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
11369 # prepare the read-ahead file
11370 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
11371 cancel_lru_locks osc
11372 for BIDX in 2 4 8 16 32 64 128 256
11374 local BSIZE=$((BIDX*4096))
11375 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
11376 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
11377 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
11378 $LCTL set_param -n llite.*.read_ahead_stats=0
11379 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
11380 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
11381 cancel_lru_locks osc
11382 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
11387 run_test 101b "check stride-io mode read-ahead ================="
11390 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11392 local STRIPE_SIZE=1048576
11393 local FILE_LENGTH=$((STRIPE_SIZE*100))
11396 local osc_rpc_stats
11398 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
11400 cancel_lru_locks osc
11401 $LCTL set_param osc.*.rpc_stats=0
11402 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
11403 $LCTL get_param osc.*.rpc_stats
11404 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
11405 local stats=$($LCTL get_param -n $osc_rpc_stats)
11406 local lines=$(echo "$stats" | awk 'END {print NR;}')
11409 if [ $lines -le 20 ]; then
11410 echo "continue debug"
11413 for size in 1 2 4 8; do
11414 local rpc=$(echo "$stats" |
11415 awk '($1 == "'$size':") {print $2; exit; }')
11416 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
11417 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
11419 echo "$osc_rpc_stats check passed!"
11424 run_test 101c "check stripe_size aligned read-ahead"
11427 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11429 local file=$DIR/$tfile
11430 local sz_MB=${FILESIZE_101d:-80}
11431 local ra_MB=${READAHEAD_MB:-40}
11433 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
11434 [ $free_MB -lt $sz_MB ] &&
11435 skip "Need free space ${sz_MB}M, have ${free_MB}M"
11437 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
11438 $LFS setstripe -c -1 $file || error "setstripe failed"
11440 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
11441 echo Cancel LRU locks on lustre client to flush the client cache
11442 cancel_lru_locks osc
11444 echo Disable read-ahead
11445 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11446 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11447 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
11448 $LCTL get_param -n llite.*.max_read_ahead_mb
11450 echo "Reading the test file $file with read-ahead disabled"
11451 local sz_KB=$((sz_MB * 1024 / 4))
11452 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
11453 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
11454 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11455 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11457 echo "Cancel LRU locks on lustre client to flush the client cache"
11458 cancel_lru_locks osc
11459 echo Enable read-ahead with ${ra_MB}MB
11460 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
11462 echo "Reading the test file $file with read-ahead enabled"
11463 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
11464 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
11466 echo "read-ahead disabled time read $raOFF"
11467 echo "read-ahead enabled time read $raON"
11470 wait_delete_completed
11472 # use awk for this check instead of bash because it handles decimals
11473 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
11474 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
11476 run_test 101d "file read with and without read-ahead enabled"
11479 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11481 local file=$DIR/$tfile
11482 local size_KB=500 #KB
11486 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
11487 local need_KB=$((count * size_KB))
11488 [[ $free_KB -le $need_KB ]] &&
11489 skip_env "Need free space $need_KB, have $free_KB"
11491 echo "Creating $count ${size_KB}K test files"
11492 for ((i = 0; i < $count; i++)); do
11493 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
11496 echo "Cancel LRU locks on lustre client to flush the client cache"
11497 cancel_lru_locks $OSC
11499 echo "Reset readahead stats"
11500 $LCTL set_param -n llite.*.read_ahead_stats=0
11502 for ((i = 0; i < $count; i++)); do
11503 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
11506 $LCTL get_param llite.*.max_cached_mb
11507 $LCTL get_param llite.*.read_ahead_stats
11508 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11509 get_named_value 'misses' | calc_sum)
11511 for ((i = 0; i < $count; i++)); do
11512 rm -rf $file.$i 2>/dev/null
11515 #10000 means 20% reads are missing in readahead
11516 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
11518 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
11521 which iozone || skip_env "no iozone installed"
11523 local old_debug=$($LCTL get_param debug)
11524 old_debug=${old_debug#*=}
11525 $LCTL set_param debug="reada mmap"
11527 # create a test file
11528 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
11530 echo Cancel LRU locks on lustre client to flush the client cache
11531 cancel_lru_locks osc
11533 echo Reset readahead stats
11534 $LCTL set_param -n llite.*.read_ahead_stats=0
11536 echo mmap read the file with small block size
11537 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
11540 echo checking missing pages
11541 $LCTL get_param llite.*.read_ahead_stats
11542 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11543 get_named_value 'misses' | calc_sum)
11545 $LCTL set_param debug="$old_debug"
11546 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
11549 run_test 101f "check mmap read performance"
11551 test_101g_brw_size_test() {
11553 local pages=$((mb * 1048576 / PAGE_SIZE))
11554 local file=$DIR/$tfile
11556 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
11557 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
11558 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
11559 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
11563 stack_trap "rm -f $file" EXIT
11564 $LCTL set_param -n osc.*.rpc_stats=0
11566 # 10 RPCs should be enough for the test
11568 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
11569 { error "dd write ${mb} MB blocks failed"; return 3; }
11570 cancel_lru_locks osc
11571 dd of=/dev/null if=$file bs=${mb}M count=$count ||
11572 { error "dd write ${mb} MB blocks failed"; return 4; }
11574 # calculate number of full-sized read and write RPCs
11575 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
11576 sed -n '/pages per rpc/,/^$/p' |
11577 awk '/'$pages':/ { reads += $2; writes += $6 }; \
11578 END { print reads,writes }'))
11579 # allow one extra full-sized read RPC for async readahead
11580 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
11581 { error "${rpcs[0]} != $count read RPCs"; return 5; }
11582 [[ ${rpcs[1]} == $count ]] ||
11583 { error "${rpcs[1]} != $count write RPCs"; return 6; }
11587 remote_ost_nodsh && skip "remote OST with nodsh"
11590 local osts=$(get_facets OST)
11591 local list=$(comma_list $(osts_nodes))
11592 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11593 local brw_size="obdfilter.*.brw_size"
11595 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11597 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
11599 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
11600 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
11601 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
11602 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
11603 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
11604 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
11606 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
11609 if [[ $orig_mb -lt 16 ]]; then
11610 save_lustre_params $osts "$brw_size" > $p
11611 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
11612 error "set 16MB RPC size failed"
11614 echo "remount client to enable new RPC size"
11615 remount_client $MOUNT || error "remount_client failed"
11618 test_101g_brw_size_test 16 || error "16MB RPC test failed"
11619 # should be able to set brw_size=12, but no rpc_stats for that
11620 test_101g_brw_size_test 8 || error "8MB RPC test failed"
11623 test_101g_brw_size_test 4 || error "4MB RPC test failed"
11625 if [[ $orig_mb -lt 16 ]]; then
11626 restore_lustre_params < $p
11627 remount_client $MOUNT || error "remount_client restore failed"
11630 rm -f $p $DIR/$tfile
11632 run_test 101g "Big bulk(4/16 MiB) readahead"
11635 $LFS setstripe -i 0 -c 1 $DIR/$tfile
11637 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
11638 error "dd 70M file failed"
11639 echo Cancel LRU locks on lustre client to flush the client cache
11640 cancel_lru_locks osc
11642 echo "Reset readahead stats"
11643 $LCTL set_param -n llite.*.read_ahead_stats 0
11645 echo "Read 10M of data but cross 64M bundary"
11646 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
11647 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11648 get_named_value 'misses' | calc_sum)
11649 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
11650 rm -f $p $DIR/$tfile
11652 run_test 101h "Readahead should cover current read window"
11655 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
11656 error "dd 10M file failed"
11658 local max_per_file_mb=$($LCTL get_param -n \
11659 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
11660 cancel_lru_locks osc
11661 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
11662 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
11663 error "set max_read_ahead_per_file_mb to 1 failed"
11665 echo "Reset readahead stats"
11666 $LCTL set_param llite.*.read_ahead_stats=0
11668 dd if=$DIR/$tfile of=/dev/null bs=2M
11670 $LCTL get_param llite.*.read_ahead_stats
11671 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11672 awk '/misses/ { print $2 }')
11673 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
11676 run_test 101i "allow current readahead to exceed reservation"
11679 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
11680 error "setstripe $DIR/$tfile failed"
11681 local file_size=$((1048576 * 16))
11682 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
11683 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
11685 echo Disable read-ahead
11686 $LCTL set_param -n llite.*.max_read_ahead_mb=0
11688 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
11689 for blk in $PAGE_SIZE 1048576 $file_size; do
11690 cancel_lru_locks osc
11691 echo "Reset readahead stats"
11692 $LCTL set_param -n llite.*.read_ahead_stats=0
11693 local count=$(($file_size / $blk))
11694 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
11695 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
11696 get_named_value 'failed.to.fast.read' | calc_sum)
11697 $LCTL get_param -n llite.*.read_ahead_stats
11698 [ $miss -eq $count ] || error "expected $count got $miss"
11701 rm -f $p $DIR/$tfile
11703 run_test 101j "A complete read block should be submitted when no RA"
11705 test_readahead_base() {
11706 local file=$DIR/$tfile
11712 $LCTL set_param -n llite.*.read_ahead_stats=0
11713 # The first page is not accounted into readahead
11714 ramax=$(((size + PAGE_SIZE - 1) / PAGE_SIZE - 1))
11715 iosz=$(((size + 1048575) / 1048576 * 1048576))
11716 echo "Test readahead: size=$size ramax=$ramx iosz=$iosz"
11718 $LCTL mark "Test readahead: size=$size ramax=$ramx iosz=$iosz"
11719 fallocate -l $size $file || error "failed to fallocate $file"
11720 cancel_lru_locks osc
11721 $MULTIOP $file or${iosz}c || error "failed to read $file"
11722 $LCTL get_param -n llite.*.read_ahead_stats
11723 ranum=$($LCTL get_param -n llite.*.read_ahead_stats |
11724 awk '/readahead.pages/ { print $7 }' | calc_sum)
11725 (( $ranum <= $ramax )) ||
11726 error "read-ahead pages is $ranum more than $ramax"
11727 rm -rf $file || error "failed to remove $file"
11732 local file=$DIR/$tfile
11738 check_set_fallocate_or_skip
11739 stack_trap "rm -f $file" EXIT
11741 test_readahead_base 4096
11743 # file size: 16K = 16384
11744 test_readahead_base 16384
11745 test_readahead_base 16385
11746 test_readahead_base 16383
11748 # file size: 1M + 1 = 1048576 + 1
11749 test_readahead_base 1048577
11750 # file size: 1M + 16K
11751 test_readahead_base $((1048576 + 16384))
11753 # file size: stripe_size * (stripe_count - 1) + 16K
11754 $LFS setstripe -c -1 $file || error "failed to setstripe $file"
11755 test_readahead_base $((1048576 * (OSTCOUNT - 1) + 16384))
11756 # file size: stripe_size * stripe_count + 16K
11757 $LFS setstripe -c -1 $file || error "failed to setstripe $file"
11758 test_readahead_base $((1048576 * OSTCOUNT + 16384))
11759 # file size: 2 * stripe_size * stripe_count + 16K
11760 $LFS setstripe -c -1 $file || error "failed to setstripe $file"
11761 test_readahead_base $((2 * 1048576 * OSTCOUNT + 16384))
11763 run_test 101m "read ahead for small file and last stripe of the file"
11766 test_mkdir $DIR/$tdir
11767 chown $RUNAS_ID $DIR/$tdir
11770 STRIPE_COUNT=$OSTCOUNT
11771 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
11773 trap cleanup_test102 EXIT
11775 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
11777 for num in 1 2 3 4; do
11778 for count in $(seq 1 $STRIPE_COUNT); do
11779 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
11780 local size=`expr $STRIPE_SIZE \* $num`
11781 local file=file"$num-$idx-$count"
11782 $1 $LFS setstripe -S $size -i $idx -c $count $file
11788 $1 tar cf $TMP/f102.tar $tdir --xattrs
11791 cleanup_test102() {
11793 rm -f $TMP/f102.tar
11794 rm -rf $DIR/d0.sanity/d102
11798 [ "$UID" != 0 ] && skip "must run as root"
11799 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
11800 skip_env "must have user_xattr"
11802 [ -z "$(which setfattr 2>/dev/null)" ] &&
11803 skip_env "could not find setfattr"
11805 local testfile=$DIR/$tfile
11808 echo "set/get xattr..."
11809 setfattr -n trusted.name1 -v value1 $testfile ||
11810 error "setfattr -n trusted.name1=value1 $testfile failed"
11811 getfattr -n trusted.name1 $testfile 2> /dev/null |
11812 grep "trusted.name1=.value1" ||
11813 error "$testfile missing trusted.name1=value1"
11815 setfattr -n user.author1 -v author1 $testfile ||
11816 error "setfattr -n user.author1=author1 $testfile failed"
11817 getfattr -n user.author1 $testfile 2> /dev/null |
11818 grep "user.author1=.author1" ||
11819 error "$testfile missing trusted.author1=author1"
11821 echo "listxattr..."
11822 setfattr -n trusted.name2 -v value2 $testfile ||
11823 error "$testfile unable to set trusted.name2"
11824 setfattr -n trusted.name3 -v value3 $testfile ||
11825 error "$testfile unable to set trusted.name3"
11826 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
11827 grep "trusted.name" | wc -l) -eq 3 ] ||
11828 error "$testfile missing 3 trusted.name xattrs"
11830 setfattr -n user.author2 -v author2 $testfile ||
11831 error "$testfile unable to set user.author2"
11832 setfattr -n user.author3 -v author3 $testfile ||
11833 error "$testfile unable to set user.author3"
11834 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
11835 grep "user.author" | wc -l) -eq 3 ] ||
11836 error "$testfile missing 3 user.author xattrs"
11838 echo "remove xattr..."
11839 setfattr -x trusted.name1 $testfile ||
11840 error "$testfile error deleting trusted.name1"
11841 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
11842 error "$testfile did not delete trusted.name1 xattr"
11844 setfattr -x user.author1 $testfile ||
11845 error "$testfile error deleting user.author1"
11846 echo "set lustre special xattr ..."
11847 $LFS setstripe -c1 $testfile
11848 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
11849 awk -F "=" '/trusted.lov/ { print $2 }' )
11850 setfattr -n "trusted.lov" -v $lovea $testfile ||
11851 error "$testfile doesn't ignore setting trusted.lov again"
11852 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
11853 error "$testfile allow setting invalid trusted.lov"
11856 run_test 102a "user xattr test =================================="
11858 check_102b_layout() {
11860 local testfile=$DIR/$tfile
11862 echo "test layout '$layout'"
11863 $LFS setstripe $layout $testfile || error "setstripe failed"
11864 $LFS getstripe -y $testfile
11866 echo "get/set/list trusted.lov xattr ..." # b=10930
11867 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
11868 [[ "$value" =~ "trusted.lov" ]] ||
11869 error "can't get trusted.lov from $testfile"
11870 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
11871 error "getstripe failed"
11873 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
11875 value=$(cut -d= -f2 <<<$value)
11876 # LU-13168: truncated xattr should fail if short lov_user_md header
11877 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
11878 lens="${#value}" || lens="$(seq 4 2 ${#value})"
11879 for len in $lens; do
11880 echo "setfattr $len $testfile.2"
11881 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
11882 [ $len -lt 66 ] && error "short xattr len=$len worked"
11884 local stripe_size=$($LFS getstripe -S $testfile.2)
11885 local stripe_count=$($LFS getstripe -c $testfile.2)
11886 [[ $stripe_size -eq 65536 ]] ||
11887 error "stripe size $stripe_size != 65536"
11888 [[ $stripe_count -eq $stripe_count_orig ]] ||
11889 error "stripe count $stripe_count != $stripe_count_orig"
11890 rm $testfile $testfile.2
11894 [ -z "$(which setfattr 2>/dev/null)" ] &&
11895 skip_env "could not find setfattr"
11896 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11898 # check plain layout
11899 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
11901 # and also check composite layout
11902 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
11905 run_test 102b "getfattr/setfattr for trusted.lov EAs"
11908 [ -z "$(which setfattr 2>/dev/null)" ] &&
11909 skip_env "could not find setfattr"
11910 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11912 # b10930: get/set/list lustre.lov xattr
11913 echo "get/set/list lustre.lov xattr ..."
11914 test_mkdir $DIR/$tdir
11915 chown $RUNAS_ID $DIR/$tdir
11916 local testfile=$DIR/$tdir/$tfile
11917 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
11918 error "setstripe failed"
11919 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
11920 error "getstripe failed"
11921 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
11922 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
11924 local testfile2=${testfile}2
11925 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
11926 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
11928 $RUNAS $MCREATE $testfile2
11929 $RUNAS setfattr -n lustre.lov -v $value $testfile2
11930 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
11931 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
11932 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
11933 [ $stripe_count -eq $STRIPECOUNT ] ||
11934 error "stripe count $stripe_count != $STRIPECOUNT"
11936 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
11938 compare_stripe_info1() {
11939 local stripe_index_all_zero=true
11941 for num in 1 2 3 4; do
11942 for count in $(seq 1 $STRIPE_COUNT); do
11943 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
11944 local size=$((STRIPE_SIZE * num))
11945 local file=file"$num-$offset-$count"
11946 stripe_size=$($LFS getstripe -S $PWD/$file)
11947 [[ $stripe_size -ne $size ]] &&
11948 error "$file: size $stripe_size != $size"
11949 stripe_count=$($LFS getstripe -c $PWD/$file)
11950 # allow fewer stripes to be created, ORI-601
11951 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
11952 error "$file: count $stripe_count != $count"
11953 stripe_index=$($LFS getstripe -i $PWD/$file)
11954 [[ $stripe_index -ne 0 ]] &&
11955 stripe_index_all_zero=false
11959 $stripe_index_all_zero &&
11960 error "all files are being extracted starting from OST index 0"
11964 have_xattrs_include() {
11965 tar --help | grep -q xattrs-include &&
11966 echo --xattrs-include="lustre.*"
11970 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11971 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11973 XINC=$(have_xattrs_include)
11975 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11976 cd $DIR/$tdir/$tdir
11977 compare_stripe_info1
11979 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11982 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11983 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11985 XINC=$(have_xattrs_include)
11987 test_mkdir $DIR/$tdir.restore
11989 tar cf - --xattrs $tdir | tar xf - \
11990 -C $DIR/$tdir.restore --xattrs $XINC
11991 cd $DIR/$tdir.restore/$tdir
11992 compare_stripe_info1
11994 run_test 102f "tar copy files, not keep osts"
11997 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11998 skip "must have user_xattr"
11999 [ -z "$(which setfattr 2>/dev/null)" ] &&
12000 skip_env "could not find setfattr"
12001 [ -z "$(which getfattr 2>/dev/null)" ] &&
12002 skip_env "could not find getfattr"
12004 local xsize=${1:-1024} # in bytes
12005 local file=$DIR/$tfile
12006 local value="$(generate_string $xsize)"
12007 local xbig=trusted.big
12011 log "save $xbig on $file"
12012 if [ -z "$toobig" ]
12014 setfattr -n $xbig -v $value $file ||
12015 error "saving $xbig on $file failed"
12017 setfattr -n $xbig -v $value $file &&
12018 error "saving $xbig on $file succeeded"
12022 local orig=$(get_xattr_value $xbig $file)
12023 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
12025 local xsml=trusted.sml
12026 log "save $xsml on $file"
12027 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
12029 local new=$(get_xattr_value $xbig $file)
12030 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
12032 log "grow $xsml on $file"
12033 setfattr -n $xsml -v "$value" $file ||
12034 error "growing $xsml on $file failed"
12036 new=$(get_xattr_value $xbig $file)
12037 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
12038 log "$xbig still valid after growing $xsml"
12043 test_102h() { # bug 15777
12046 run_test 102h "grow xattr from inside inode to external block"
12049 large_xattr_enabled || skip_env "ea_inode feature disabled"
12051 echo "setting xattr of max xattr size: $(max_xattr_size)"
12052 grow_xattr $(max_xattr_size)
12054 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
12055 echo "This should fail:"
12056 grow_xattr $(($(max_xattr_size) + 10)) 1
12058 run_test 102ha "grow xattr from inside inode to external inode"
12060 test_102i() { # bug 17038
12061 [ -z "$(which getfattr 2>/dev/null)" ] &&
12062 skip "could not find getfattr"
12065 ln -s $DIR/$tfile $DIR/${tfile}link
12066 getfattr -n trusted.lov $DIR/$tfile ||
12067 error "lgetxattr on $DIR/$tfile failed"
12068 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
12069 grep -i "no such attr" ||
12070 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
12071 rm -f $DIR/$tfile $DIR/${tfile}link
12073 run_test 102i "lgetxattr test on symbolic link ============"
12076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12077 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12079 XINC=$(have_xattrs_include)
12080 setup_test102 "$RUNAS"
12081 chown $RUNAS_ID $DIR/$tdir
12082 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
12083 cd $DIR/$tdir/$tdir
12084 compare_stripe_info1 "$RUNAS"
12086 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
12089 [ -z "$(which setfattr 2>/dev/null)" ] &&
12090 skip "could not find setfattr"
12093 # b22187 just check that does not crash for regular file.
12094 setfattr -n trusted.lov $DIR/$tfile
12095 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
12096 local test_kdir=$DIR/$tdir
12097 test_mkdir $test_kdir
12098 local default_size=$($LFS getstripe -S $test_kdir)
12099 local default_count=$($LFS getstripe -c $test_kdir)
12100 local default_offset=$($LFS getstripe -i $test_kdir)
12101 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
12102 error 'dir setstripe failed'
12103 setfattr -n trusted.lov $test_kdir
12104 local stripe_size=$($LFS getstripe -S $test_kdir)
12105 local stripe_count=$($LFS getstripe -c $test_kdir)
12106 local stripe_offset=$($LFS getstripe -i $test_kdir)
12107 [ $stripe_size -eq $default_size ] ||
12108 error "stripe size $stripe_size != $default_size"
12109 [ $stripe_count -eq $default_count ] ||
12110 error "stripe count $stripe_count != $default_count"
12111 [ $stripe_offset -eq $default_offset ] ||
12112 error "stripe offset $stripe_offset != $default_offset"
12113 rm -rf $DIR/$tfile $test_kdir
12115 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
12118 [ -z "$(which getfattr 2>/dev/null)" ] &&
12119 skip "could not find getfattr"
12121 # LU-532 trusted. xattr is invisible to non-root
12122 local testfile=$DIR/$tfile
12126 echo "listxattr as user..."
12127 chown $RUNAS_ID $testfile
12128 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
12129 grep -q "trusted" &&
12130 error "$testfile trusted xattrs are user visible"
12134 run_test 102l "listxattr size test =================================="
12136 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
12137 local path=$DIR/$tfile
12140 listxattr_size_check $path || error "listattr_size_check $path failed"
12142 run_test 102m "Ensure listxattr fails on small bufffer ========"
12146 getxattr() { # getxattr path name
12147 # Return the base64 encoding of the value of xattr name on path.
12151 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
12153 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
12155 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
12157 getfattr --absolute-names --encoding=base64 --name=$name $path |
12158 awk -F= -v name=$name '$1 == name {
12159 print substr($0, index($0, "=") + 1);
12163 test_102n() { # LU-4101 mdt: protect internal xattrs
12164 [ -z "$(which setfattr 2>/dev/null)" ] &&
12165 skip "could not find setfattr"
12166 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
12168 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
12171 local file0=$DIR/$tfile.0
12172 local file1=$DIR/$tfile.1
12173 local xattr0=$TMP/$tfile.0
12174 local xattr1=$TMP/$tfile.1
12175 local namelist="lov lma lmv link fid version som hsm"
12179 rm -rf $file0 $file1 $xattr0 $xattr1
12180 touch $file0 $file1
12182 # Get 'before' xattrs of $file1.
12183 getfattr --absolute-names --dump --match=- $file1 > $xattr0
12185 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
12186 namelist+=" lfsck_namespace"
12187 for name in $namelist; do
12188 # Try to copy xattr from $file0 to $file1.
12189 value=$(getxattr $file0 trusted.$name 2> /dev/null)
12191 setfattr --name=trusted.$name --value="$value" $file1 ||
12192 error "setxattr 'trusted.$name' failed"
12194 # Try to set a garbage xattr.
12195 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
12197 if [[ x$name == "xlov" ]]; then
12198 setfattr --name=trusted.lov --value="$value" $file1 &&
12199 error "setxattr invalid 'trusted.lov' success"
12201 setfattr --name=trusted.$name --value="$value" $file1 ||
12202 error "setxattr invalid 'trusted.$name' failed"
12205 # Try to remove the xattr from $file1. We don't care if this
12206 # appears to succeed or fail, we just don't want there to be
12207 # any changes or crashes.
12208 setfattr --remove=$trusted.$name $file1 2> /dev/null
12211 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
12214 # Try to copy xattr from $file0 to $file1.
12215 value=$(getxattr $file0 trusted.$name 2> /dev/null)
12217 setfattr --name=trusted.$name --value="$value" $file1 ||
12218 error "setxattr 'trusted.$name' failed"
12220 # Try to set a garbage xattr.
12221 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
12223 setfattr --name=trusted.$name --value="$value" $file1 ||
12224 error "setxattr 'trusted.$name' failed"
12226 # Try to remove the xattr from $file1. We don't care if this
12227 # appears to succeed or fail, we just don't want there to be
12228 # any changes or crashes.
12229 setfattr --remove=$trusted.$name $file1 2> /dev/null
12232 # Get 'after' xattrs of file1.
12233 getfattr --absolute-names --dump --match=- $file1 > $xattr1
12235 if ! diff $xattr0 $xattr1; then
12236 error "before and after xattrs of '$file1' differ"
12239 rm -rf $file0 $file1 $xattr0 $xattr1
12243 run_test 102n "silently ignore setxattr on internal trusted xattrs"
12245 test_102p() { # LU-4703 setxattr did not check ownership
12246 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
12247 skip "MDS needs to be at least 2.5.56"
12249 local testfile=$DIR/$tfile
12253 echo "setfacl as user..."
12254 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
12255 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
12257 echo "setfattr as user..."
12258 setfacl -m "u:$RUNAS_ID:---" $testfile
12259 $RUNAS setfattr -x system.posix_acl_access $testfile
12260 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
12262 run_test 102p "check setxattr(2) correctly fails without permission"
12265 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
12266 skip "MDS needs to be at least 2.6.92"
12268 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
12270 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
12273 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
12274 skip "MDS needs to be at least 2.6.93"
12276 touch $DIR/$tfile || error "touch"
12277 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
12278 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
12279 rm $DIR/$tfile || error "rm"
12282 mkdir -p $DIR/$tdir || error "mkdir"
12283 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
12284 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
12285 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
12286 error "$testfile error deleting user.author1"
12287 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
12288 grep "user.$(basename $tdir)" &&
12289 error "$tdir did not delete user.$(basename $tdir)"
12290 rmdir $DIR/$tdir || error "rmdir"
12293 test_mkdir $DIR/$tdir
12294 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
12295 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
12296 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
12297 error "$testfile error deleting user.author1"
12298 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
12299 grep "user.$(basename $tdir)" &&
12300 error "$tdir did not delete user.$(basename $tdir)"
12301 rmdir $DIR/$tdir || error "rm striped dir"
12303 run_test 102r "set EAs with empty values"
12306 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
12307 skip "MDS needs to be at least 2.11.52"
12309 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12311 save_lustre_params client "llite.*.xattr_cache" > $save
12313 for cache in 0 1; do
12314 lctl set_param llite.*.xattr_cache=$cache
12317 touch $DIR/$tfile || error "touch"
12318 for prefix in lustre security system trusted user; do
12319 # Note getxattr() may fail with 'Operation not
12320 # supported' or 'No such attribute' depending
12321 # on prefix and cache.
12322 getfattr -n $prefix.n102s $DIR/$tfile &&
12323 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
12327 restore_lustre_params < $save
12329 run_test 102s "getting nonexistent xattrs should fail"
12332 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
12333 skip "MDS needs to be at least 2.11.52"
12335 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12337 save_lustre_params client "llite.*.xattr_cache" > $save
12339 for cache in 0 1; do
12340 lctl set_param llite.*.xattr_cache=$cache
12342 for buf_size in 0 256; do
12344 touch $DIR/$tfile || error "touch"
12345 setfattr -n user.multiop $DIR/$tfile
12346 $MULTIOP $DIR/$tfile oa$buf_size ||
12347 error "cannot get zero length xattr value (buf_size = $buf_size)"
12351 restore_lustre_params < $save
12353 run_test 102t "zero length xattr values handled correctly"
12357 local test=$LUSTRE/tests/acl/$1.test
12358 local tmp=$(mktemp -t $1-XXXXXX).test
12366 local sedusers="-e s/bin/$bin/g -e s/daemon/$dmn/g"
12367 local sedgroups="-e s/:users/:$grp/g"
12368 [[ -z "$nbd" ]] || sedusers+=" -e s/nobody/$nbd/g"
12370 sed $sedusers $sedgroups < $test > $tmp
12371 stack_trap "rm -f $tmp"
12372 [[ -s $tmp ]] || error "sed failed to create test script"
12374 echo "performing $1 with bin='$bin' daemon='$dmn' users='$grp'..."
12375 $LUSTRE/tests/acl/run $tmp || error "run_acl_subtest '$1' failed"
12379 [ "$UID" != 0 ] && skip "must run as root"
12380 $GSS && skip_env "could not run under gss"
12381 [[ "$(lctl get_param -n mdc.*-mdc-*.connect_flags)" =~ "acl" ]] ||
12382 skip_env "must have acl enabled"
12383 which setfacl || skip_env "could not find setfacl"
12384 remote_mds_nodsh && skip "remote MDS with nodsh"
12386 local mdts=$(comma_list $(mdts_nodes))
12387 local saved=$(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.job_xattr)
12389 [[ -z "$saved" ]] || do_nodes $mdts $LCTL set_param mdt.*.job_xattr=NONE
12390 stack_trap "[[ -z \"$saved\" ]] || \
12391 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=$saved" EXIT
12393 ACLBIN=${ACLBIN:-"bin"}
12394 ACLDMN=${ACLDMN:-"daemon"}
12395 ACLGRP=${ACLGRP:-"users"}
12396 ACLNBD=${ACLNBD:-"nobody"}
12399 [[ "$(id -u $ACLBIN)" != "$(do_facet mds1 id -u $ACLBIN)" ]]; then
12400 echo "bad 'bin' user '$ACLBIN', using '$USER0'"
12402 if ! id $ACLBIN ; then
12404 skip_env "can't find suitable ACL 'bin' $ACLBIN"
12407 if ! id $ACLDMN || (( $(id -u $ACLDMN) < $(id -u $ACLBIN) )) ||
12408 [[ "$(id -u $ACLDMN)" != "$(do_facet mds1 id -u $ACLDMN)" ]]; then
12409 echo "bad 'daemon' user '$ACLDMN', using '$USER1'"
12411 if ! id $ACLDMN ; then
12413 skip_env "can't find suitable ACL 'daemon' $ACLDMN"
12416 if ! getent group $ACLGRP; then
12417 echo "missing 'users' group '$ACLGRP', using '$TSTUSR'"
12419 if ! getent group $ACLGRP; then
12420 echo "cannot find group '$ACLGRP', adding it"
12422 add_group 60000 $ACLGRP
12426 local bingid=$(getent group $ACLBIN | cut -d: -f 3)
12427 local dmngid=$(getent group $ACLDMN | cut -d: -f 3)
12428 local grpgid=$(getent group $ACLGRP | cut -d: -f 3)
12430 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
12431 echo "group '$ACLGRP' has low gid=$grpgid, use '$TSTUSR'"
12433 if ! getent group $ACLGRP; then
12434 echo "cannot find group '$ACLGRP', adding it"
12436 add_group 60000 $ACLGRP
12438 grpgid=$(getent group $ACLGRP | cut -d: -f 3)
12439 if (( $bingid > $grpgid || $dmngid > $grpgid )); then
12441 skip_env "$ACLGRP gid=$grpgid less than $bingid|$dmngid"
12445 gpasswd -a $ACLDMN $ACLBIN ||
12446 error "setting client group failed" # LU-5641
12447 do_facet mds1 gpasswd -a $ACLDMN $ACLBIN ||
12448 error "setting MDS group failed" # LU-5641
12450 declare -a identity_old
12452 for ((num = 1; num <= $MDSCOUNT; num++)); do
12453 switch_identity $num true || identity_old[$num]=$?
12456 SAVE_UMASK=$(umask)
12458 mkdir -p $DIR/$tdir
12461 run_acl_subtest cp $ACLBIN $ACLDMN $ACLGRP
12462 run_acl_subtest getfacl-noacl $ACLBIN $ACLDMN $ACLGRP
12463 run_acl_subtest misc $ACLBIN $ACLDMN $ACLGRP
12464 run_acl_subtest permissions $ACLBIN $ACLDMN $ACLGRP
12465 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
12466 # CentOS7- uses nobody=99, while newer distros use nobody=65534
12467 if ! id -u $ACLNBD ||
12468 (( $(id -u nobody) != $(do_facet mds1 id -u nobody) )); then
12470 if ! id -u $ACLNBD; then
12474 if [[ -n "$ACLNBD" ]] && ! getent group $ACLNBD; then
12475 add_group $(id -u $ACLNBD) $ACLNBD
12476 if ! getent group $ACLNBD; then
12480 if (( $MDS1_VERSION > $(version_code 2.8.55) )) &&
12481 [[ -n "$ACLNBD" ]] && which setfattr; then
12482 run_acl_subtest permissions_xattr \
12483 $ACLBIN $ACLDMN $ACLGRP $ACLNBD
12484 elif [[ -z "$ACLNBD" ]]; then
12485 echo "skip 'permission_xattr' test - missing 'nobody' user/grp"
12487 echo "skip 'permission_xattr' test - missing setfattr command"
12489 run_acl_subtest setfacl $ACLBIN $ACLDMN $ACLGRP
12491 # inheritance test got from HP
12492 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
12493 chmod +x make-tree || error "chmod +x failed"
12494 run_acl_subtest inheritance $ACLBIN $ACLDMN $ACLGRP
12497 echo "LU-974 ignore umask when acl is enabled..."
12498 run_acl_subtest 974 $ACLBIN $ACLDMN $ACLGRP
12499 if [ $MDSCOUNT -ge 2 ]; then
12500 run_acl_subtest 974_remote $ACLBIN $ACLDMN $ACLGRP
12503 echo "LU-2561 newly created file is same size as directory..."
12504 if [ "$mds1_FSTYPE" != "zfs" ]; then
12505 run_acl_subtest 2561 $ACLBIN $ACLDMN $ACLGRP
12507 run_acl_subtest 2561_zfs $ACLBIN $ACLDMN $ACLGRP
12510 run_acl_subtest 4924 $ACLBIN $ACLDMN $ACLGRP
12515 for ((num = 1; num <= $MDSCOUNT; num++)); do
12516 if [[ "${identity_old[$num]}" == 1 ]]; then
12517 switch_identity $num false || identity_old[$num]=$?
12521 run_test 103a "acl test"
12527 stack_trap "rm -f $DIR/$tfile.*"
12528 for U in {0..511}; do
12530 local O=$(printf "%04o" $U)
12532 umask $(printf "%04o" $((511 ^ $O)))
12533 $LFS setstripe -c 1 $DIR/$tfile.s$O
12534 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
12536 (( $S == ($O & 0666) )) ||
12537 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
12539 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
12540 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
12541 (( $S == ($O & 0666) )) ||
12542 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
12544 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
12545 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
12546 (( $S == ($O & 0666) )) ||
12547 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
12548 rm -f $DIR/$tfile.[smp]$0
12552 # limit the concurrently running threads to 64. LU-11878
12553 local idx=$((U % 64))
12554 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
12559 run_test 103b "umask lfs setstripe"
12562 mkdir -p $DIR/$tdir
12563 cp -rp $DIR/$tdir $DIR/$tdir.bak
12565 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
12566 error "$DIR/$tdir shouldn't contain default ACL"
12567 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
12568 error "$DIR/$tdir.bak shouldn't contain default ACL"
12571 run_test 103c "'cp -rp' won't set empty acl"
12576 local saved_debug=$($LCTL get_param -n debug)
12578 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
12579 skip "MDS needs to be at least 2.14.52"
12581 large_xattr_enabled || skip_env "ea_inode feature disabled"
12583 mkdir -p $DIR/$tdir
12584 # add big LOV EA to cause reply buffer overflow earlier
12585 $LFS setstripe -C 1000 $DIR/$tdir
12586 lctl set_param mdc.*-mdc*.stats=clear
12588 $LCTL set_param debug=0
12589 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
12590 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
12592 # add a large number of default ACLs (expect 8000+ for 2.13+)
12593 for U in {2..7000}; do
12594 setfacl -d -m user:$U:rwx $DIR/$tdir ||
12595 error "Able to add just $U default ACLs"
12597 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
12598 echo "$numacl default ACLs created"
12600 stat $DIR/$tdir || error "Cannot stat directory"
12601 # check file creation
12602 touch $DIR/$tdir/$tfile ||
12603 error "failed to create $tfile with $numacl default ACLs"
12604 stat $DIR/$tdir/$tfile || error "Cannot stat file"
12605 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12606 echo "$fileacl ACLs were inherited"
12607 (( $fileacl == $numacl )) ||
12608 error "Not all default ACLs were inherited: $numacl != $fileacl"
12609 # check that new ACLs creation adds new ACLs to inherited ACLs
12610 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
12611 error "Cannot set new ACL"
12612 numacl=$((numacl + 1))
12613 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12614 (( $fileacl == $numacl )) ||
12615 error "failed to add new ACL: $fileacl != $numacl as expected"
12616 # adds more ACLs to a file to reach their maximum at 8000+
12618 for U in {20000..25000}; do
12619 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
12620 numacl=$((numacl + 1))
12622 echo "Added $numacl more ACLs to the file"
12623 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
12624 echo "Total $fileacl ACLs in file"
12625 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
12626 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
12627 rmdir $DIR/$tdir || error "Cannot remove directory"
12629 run_test 103e "inheritance of big amount of default ACLs"
12632 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
12633 skip "MDS needs to be at least 2.14.51"
12635 large_xattr_enabled || skip_env "ea_inode feature disabled"
12637 # enable changelog to consume more internal MDD buffers
12640 mkdir -p $DIR/$tdir
12642 $LFS setstripe -C 1000 $DIR/$tdir
12643 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
12644 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
12645 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
12646 rmdir $DIR/$tdir || error "Cannot remove directory"
12648 run_test 103f "changelog doesn't interfere with default ACLs buffers"
12651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12654 lfs df || error "lfs df failed"
12655 lfs df -ih || error "lfs df -ih failed"
12656 lfs df -h $DIR || error "lfs df -h $DIR failed"
12657 lfs df -i $DIR || error "lfs df -i $DIR failed"
12658 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
12659 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
12661 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
12662 lctl --device %$OSC deactivate
12663 lfs df || error "lfs df with deactivated OSC failed"
12664 lctl --device %$OSC activate
12665 # wait the osc back to normal
12666 wait_osc_import_ready client ost
12668 lfs df || error "lfs df with reactivated OSC failed"
12671 run_test 104a "lfs df [-ih] [path] test ========================="
12674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12675 [ $RUNAS_ID -eq $UID ] &&
12676 skip_env "RUNAS_ID = UID = $UID -- skipping"
12678 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
12679 grep "Permission denied" | wc -l)))
12680 if [ $denied_cnt -ne 0 ]; then
12681 error "lfs check servers test failed"
12684 run_test 104b "$RUNAS lfs check servers test ===================="
12687 # Verify $1 is within range of $2.
12688 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
12689 # $1 is <= 2% of $2. Else Fail.
12692 # Strip all units (M, G, T)
12693 actual=$(echo $1 | tr -d A-Z)
12694 expect=$(echo $2 | tr -d A-Z)
12696 expect_lo=$(($expect * 98 / 100)) # 2% below
12697 expect_hi=$(($expect * 102 / 100)) # 2% above
12699 # permit 2% drift above and below
12700 (( $actual >= $expect_lo && $actual <= $expect_hi ))
12704 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12705 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
12707 local ost_param="osd-zfs.$FSNAME-OST0000."
12708 local mdt_param="osd-zfs.$FSNAME-MDT0000."
12709 local ofacets=$(get_facets OST)
12710 local mfacets=$(get_facets MDS)
12711 local saved_ost_blocks=
12712 local saved_mdt_blocks=
12714 echo "Before recordsize change"
12715 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
12716 df=($(df -h | grep "$MOUNT"$))
12719 echo "lfs output : ${lfs_df[*]}"
12720 echo "df output : ${df[*]}"
12722 for facet in ${ofacets//,/ }; do
12723 if [ -z $saved_ost_blocks ]; then
12724 saved_ost_blocks=$(do_facet $facet \
12725 lctl get_param -n $ost_param.blocksize)
12726 echo "OST Blocksize: $saved_ost_blocks"
12728 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12729 do_facet $facet zfs set recordsize=32768 $ost
12732 # BS too small. Sufficient for functional testing.
12733 for facet in ${mfacets//,/ }; do
12734 if [ -z $saved_mdt_blocks ]; then
12735 saved_mdt_blocks=$(do_facet $facet \
12736 lctl get_param -n $mdt_param.blocksize)
12737 echo "MDT Blocksize: $saved_mdt_blocks"
12739 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12740 do_facet $facet zfs set recordsize=32768 $mdt
12743 # Give new values chance to reflect change
12746 echo "After recordsize change"
12747 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
12748 df_after=($(df -h | grep "$MOUNT"$))
12751 echo "lfs output : ${lfs_df_after[*]}"
12752 echo "df output : ${df_after[*]}"
12755 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
12756 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
12757 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
12758 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
12759 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
12760 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
12763 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
12764 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
12765 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
12766 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
12767 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
12768 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
12770 # Restore MDT recordize back to original
12771 for facet in ${mfacets//,/ }; do
12772 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
12773 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
12776 # Restore OST recordize back to original
12777 for facet in ${ofacets//,/ }; do
12778 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
12779 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
12784 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
12787 (( $RUNAS_ID != $UID )) ||
12788 skip_env "RUNAS_ID = UID = $UID -- skipping"
12790 (( $CLIENT_VERSION >= $(version_code 2.15.51) )) ||
12791 skip "lustre version doesn't support lctl dl with non-root"
12793 # debugfs only allows root users to access files, so the
12794 # previous move of the "devices" file to debugfs broke
12795 # "lctl dl" for non-root users. The LU-9680 Netlink
12796 # interface again allows non-root users to list devices.
12797 [ "$($RUNAS $LCTL dl | wc -l)" -ge 3 ] ||
12798 error "lctl dl doesn't work for non root"
12800 ost_count="$($RUNAS $LCTL dl | grep $FSNAME-OST* | wc -l)"
12801 [ "$ost_count" -eq $OSTCOUNT ] ||
12802 error "lctl dl reports wrong number of OST devices"
12804 mdt_count="$($RUNAS $LCTL dl | grep $FSNAME-MDT* | wc -l)"
12805 [ "$mdt_count" -eq $MDSCOUNT ] ||
12806 error "lctl dl reports wrong number of MDT devices"
12808 run_test 104d "$RUNAS lctl dl test"
12811 # doesn't work on 2.4 kernels
12813 if $(flock_is_enabled); then
12814 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
12816 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
12820 run_test 105a "flock when mounted without -o flock test ========"
12824 if $(flock_is_enabled); then
12825 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
12827 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
12831 run_test 105b "fcntl when mounted without -o flock test ========"
12835 if $(flock_is_enabled); then
12836 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
12838 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
12842 run_test 105c "lockf when mounted without -o flock test"
12844 test_105d() { # bug 15924
12845 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12847 test_mkdir $DIR/$tdir
12848 flock_is_enabled || skip_env "mount w/o flock enabled"
12849 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
12850 $LCTL set_param fail_loc=0x80000315
12851 flocks_test 2 $DIR/$tdir
12853 run_test 105d "flock race (should not freeze) ========"
12855 test_105e() { # bug 22660 && 22040
12856 flock_is_enabled || skip_env "mount w/o flock enabled"
12859 flocks_test 3 $DIR/$tfile
12861 run_test 105e "Two conflicting flocks from same process"
12863 test_106() { #bug 10921
12864 test_mkdir $DIR/$tdir
12865 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
12866 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
12868 run_test 106 "attempt exec of dir followed by chown of that dir"
12871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12879 local save_pattern=$(sysctl -n kernel.core_pattern)
12880 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
12881 sysctl -w kernel.core_pattern=$file
12882 sysctl -w kernel.core_uses_pid=0
12884 ulimit -c unlimited
12890 kill -s 11 $SLEEPPID
12892 if [ -e $file ]; then
12893 size=`stat -c%s $file`
12894 [ $size -eq 0 ] && error "Fail to create core file $file"
12896 error "Fail to create core file $file"
12899 sysctl -w kernel.core_pattern=$save_pattern
12900 sysctl -w kernel.core_uses_pid=$save_uses_pid
12903 run_test 107 "Coredump on SIG"
12906 test_mkdir $DIR/$tdir
12907 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
12908 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
12909 error "mkdir with 256 char should fail, but did not"
12910 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
12911 error "create with 255 char failed"
12912 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
12913 error "create with 256 char should fail, but did not"
12918 run_test 110 "filename length checking"
12920 test_116a() { # was previously test_116()
12921 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12922 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12923 remote_mds_nodsh && skip "remote MDS with nodsh"
12925 echo -n "Free space priority "
12926 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
12931 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
12932 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
12933 stack_trap simple_cleanup_common
12935 # Check if we need to generate uneven OSTs
12936 test_mkdir -p $DIR/$tdir/OST${MINI}
12937 local FILL=$((MINV / 4))
12938 local DIFF=$((MAXV - MINV))
12939 local DIFF2=$((DIFF * 100 / MINV))
12941 local threshold=$(do_facet $SINGLEMDS \
12942 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
12943 threshold=${threshold%%%}
12944 echo -n "Check for uneven OSTs: "
12945 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
12947 if [[ $DIFF2 -gt $threshold ]]; then
12949 echo "Don't need to fill OST$MINI"
12951 # generate uneven OSTs. Write 2% over the QOS threshold value
12953 DIFF=$((threshold - DIFF2 + 2))
12954 DIFF2=$((MINV * DIFF / 100))
12955 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
12956 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
12957 error "setstripe failed"
12958 DIFF=$((DIFF2 / 2048))
12960 while [ $i -lt $DIFF ]; do
12962 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
12963 bs=2M count=1 2>/dev/null
12972 DIFF=$((MAXV - MINV))
12973 DIFF2=$((DIFF * 100 / MINV))
12974 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12975 if [ $DIFF2 -gt $threshold ]; then
12978 skip "QOS imbalance criteria not met"
12986 # now fill using QOS
12987 $LFS setstripe -c 1 $DIR/$tdir
12988 FILL=$((FILL / 200))
12989 if [ $FILL -gt 600 ]; then
12992 echo "writing $FILL files to QOS-assigned OSTs"
12994 while [ $i -lt $FILL ]; do
12996 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12997 count=1 2>/dev/null
13000 echo "wrote $i 200k files"
13004 echo "Note: free space may not be updated, so measurements might be off"
13006 DIFF2=$((MAXV - MINV))
13007 echo "free space delta: orig $DIFF final $DIFF2"
13008 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
13009 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
13010 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
13011 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
13012 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
13013 if [[ $DIFF -gt 0 ]]; then
13014 FILL=$((DIFF2 * 100 / DIFF - 100))
13015 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
13018 # Figure out which files were written where
13019 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
13020 awk '/'$MINI1': / {print $2; exit}')
13022 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
13023 echo "$MINC files created on smaller OST $MINI1"
13024 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
13025 awk '/'$MAXI1': / {print $2; exit}')
13027 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
13028 echo "$MAXC files created on larger OST $MAXI1"
13029 if [[ $MINC -gt 0 ]]; then
13030 FILL=$((MAXC * 100 / MINC - 100))
13031 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
13033 [[ $MAXC -gt $MINC ]] ||
13034 error_ignore LU-9 "stripe QOS didn't balance free space"
13036 run_test 116a "stripe QOS: free space balance ==================="
13038 test_116b() { # LU-2093
13039 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13040 remote_mds_nodsh && skip "remote MDS with nodsh"
13042 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
13043 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
13044 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
13045 [ -z "$old_rr" ] && skip "no QOS"
13046 do_facet $SINGLEMDS lctl set_param \
13047 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
13048 mkdir -p $DIR/$tdir
13049 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
13050 createmany -o $DIR/$tdir/f- 20 || error "can't create"
13051 do_facet $SINGLEMDS lctl set_param fail_loc=0
13053 do_facet $SINGLEMDS lctl set_param \
13054 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
13056 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
13058 test_117() # bug 10891
13060 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13062 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
13063 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
13064 lctl set_param fail_loc=0x21e
13065 > $DIR/$tfile || error "truncate failed"
13066 lctl set_param fail_loc=0
13067 echo "Truncate succeeded."
13070 run_test 117 "verify osd extend =========="
13072 NO_SLOW_RESENDCOUNT=4
13073 export OLD_RESENDCOUNT=""
13074 set_resend_count () {
13075 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
13076 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
13077 lctl set_param -n $PROC_RESENDCOUNT $1
13078 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
13081 # for reduce test_118* time (b=14842)
13082 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
13084 # Reset async IO behavior after error case
13086 FILE=$DIR/reset_async
13088 # Ensure all OSCs are cleared
13089 $LFS setstripe -c -1 $FILE
13090 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
13095 test_118a() #bug 11710
13097 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13101 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13102 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13103 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13105 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13106 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13111 run_test 118a "verify O_SYNC works =========="
13115 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13116 remote_ost_nodsh && skip "remote OST with nodsh"
13120 #define OBD_FAIL_SRV_ENOENT 0x217
13121 set_nodes_failloc "$(osts_nodes)" 0x217
13122 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13124 set_nodes_failloc "$(osts_nodes)" 0
13125 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13126 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13129 if [[ $RC -eq 0 ]]; then
13130 error "Must return error due to dropped pages, rc=$RC"
13134 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13135 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13139 echo "Dirty pages not leaked on ENOENT"
13141 # Due to the above error the OSC will issue all RPCs syncronously
13142 # until a subsequent RPC completes successfully without error.
13143 $MULTIOP $DIR/$tfile Ow4096yc
13148 run_test 118b "Reclaim dirty pages on fatal error =========="
13152 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13154 # for 118c, restore the original resend count, LU-1940
13155 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
13156 set_resend_count $OLD_RESENDCOUNT
13157 remote_ost_nodsh && skip "remote OST with nodsh"
13161 #define OBD_FAIL_OST_EROFS 0x216
13162 set_nodes_failloc "$(osts_nodes)" 0x216
13164 # multiop should block due to fsync until pages are written
13165 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
13169 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
13170 error "Multiop failed to block on fsync, pid=$MULTIPID"
13173 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13175 if [[ $WRITEBACK -eq 0 ]]; then
13176 error "No page in writeback, writeback=$WRITEBACK"
13179 set_nodes_failloc "$(osts_nodes)" 0
13182 if [[ $RC -ne 0 ]]; then
13183 error "Multiop fsync failed, rc=$RC"
13186 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13187 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13189 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13190 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13194 echo "Dirty pages flushed via fsync on EROFS"
13197 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
13199 # continue to use small resend count to reduce test_118* time (b=14842)
13200 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
13204 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13205 remote_ost_nodsh && skip "remote OST with nodsh"
13209 #define OBD_FAIL_OST_BRW_PAUSE_BULK
13210 set_nodes_failloc "$(osts_nodes)" 0x214
13211 # multiop should block due to fsync until pages are written
13212 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
13216 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
13217 error "Multiop failed to block on fsync, pid=$MULTIPID"
13220 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13222 if [[ $WRITEBACK -eq 0 ]]; then
13223 error "No page in writeback, writeback=$WRITEBACK"
13226 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
13227 set_nodes_failloc "$(osts_nodes)" 0
13229 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13230 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13232 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13233 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13237 echo "Dirty pages gaurenteed flushed via fsync"
13240 run_test 118d "Fsync validation inject a delay of the bulk =========="
13243 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13247 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
13248 lctl set_param fail_loc=0x8000040a
13250 # Should simulate EINVAL error which is fatal
13251 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13253 if [[ $RC -eq 0 ]]; then
13254 error "Must return error due to dropped pages, rc=$RC"
13257 lctl set_param fail_loc=0x0
13259 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13260 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13261 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13263 if [[ $LOCKED -ne 0 ]]; then
13264 error "Locked pages remain in cache, locked=$LOCKED"
13267 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13268 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13272 echo "No pages locked after fsync"
13277 run_test 118f "Simulate unrecoverable OSC side error =========="
13280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13284 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
13285 lctl set_param fail_loc=0x406
13287 # simulate local -ENOMEM
13288 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13291 lctl set_param fail_loc=0
13292 if [[ $RC -eq 0 ]]; then
13293 error "Must return error due to dropped pages, rc=$RC"
13296 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13297 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13298 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13300 if [[ $LOCKED -ne 0 ]]; then
13301 error "Locked pages remain in cache, locked=$LOCKED"
13304 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13305 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13309 echo "No pages locked after fsync"
13314 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
13317 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13318 remote_ost_nodsh && skip "remote OST with nodsh"
13322 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13323 set_nodes_failloc "$(osts_nodes)" 0x20e
13324 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
13325 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13328 set_nodes_failloc "$(osts_nodes)" 0
13329 if [[ $RC -eq 0 ]]; then
13330 error "Must return error due to dropped pages, rc=$RC"
13333 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13334 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13335 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
13337 if [[ $LOCKED -ne 0 ]]; then
13338 error "Locked pages remain in cache, locked=$LOCKED"
13341 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13342 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13346 echo "No pages locked after fsync"
13350 run_test 118h "Verify timeout in handling recoverables errors =========="
13352 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
13355 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13356 remote_ost_nodsh && skip "remote OST with nodsh"
13360 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13361 set_nodes_failloc "$(osts_nodes)" 0x20e
13363 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
13364 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
13367 set_nodes_failloc "$(osts_nodes)" 0
13371 if [[ $RC -ne 0 ]]; then
13372 error "got error, but should be not, rc=$RC"
13375 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13376 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13377 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13378 if [[ $LOCKED -ne 0 ]]; then
13379 error "Locked pages remain in cache, locked=$LOCKED"
13382 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13383 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13387 echo "No pages locked after fsync"
13391 run_test 118i "Fix error before timeout in recoverable error =========="
13393 [ "$SLOW" = "no" ] && set_resend_count 4
13396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13397 remote_ost_nodsh && skip "remote OST with nodsh"
13401 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
13402 set_nodes_failloc "$(osts_nodes)" 0x220
13404 # return -EIO from OST
13405 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
13407 set_nodes_failloc "$(osts_nodes)" 0x0
13408 if [[ $RC -eq 0 ]]; then
13409 error "Must return error due to dropped pages, rc=$RC"
13412 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
13413 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
13414 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
13415 if [[ $LOCKED -ne 0 ]]; then
13416 error "Locked pages remain in cache, locked=$LOCKED"
13419 # in recoverable error on OST we want resend and stay until it finished
13420 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
13421 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
13425 echo "No pages locked after fsync"
13429 run_test 118j "Simulate unrecoverable OST side error =========="
13433 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13434 remote_ost_nodsh && skip "remote OSTs with nodsh"
13436 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
13437 set_nodes_failloc "$(osts_nodes)" 0x20e
13438 test_mkdir $DIR/$tdir
13440 for ((i=0;i<10;i++)); do
13441 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
13442 error "dd to $DIR/$tdir/$tfile-$i failed" )&
13449 set_nodes_failloc "$(osts_nodes)" 0
13452 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
13454 test_118l() # LU-646
13456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13458 test_mkdir $DIR/$tdir
13459 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
13462 run_test 118l "fsync dir"
13464 test_118m() # LU-3066
13466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13468 test_mkdir $DIR/$tdir
13469 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
13472 run_test 118m "fdatasync dir ========="
13474 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
13481 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13482 remote_ost_nodsh && skip "remote OSTs with nodsh"
13484 # Sleep to avoid a cached response.
13485 #define OBD_STATFS_CACHE_SECONDS 1
13488 # Inject a 10 second delay in the OST_STATFS handler.
13489 #define OBD_FAIL_OST_STATFS_DELAY 0x242
13490 set_nodes_failloc "$(osts_nodes)" 0x242
13493 stat --file-system $MOUNT > /dev/null
13496 set_nodes_failloc "$(osts_nodes)" 0
13498 if ((end - begin > 20)); then
13499 error "statfs took $((end - begin)) seconds, expected 10"
13502 run_test 118n "statfs() sends OST_STATFS requests in parallel"
13504 test_119a() # bug 11737
13506 BSIZE=$((512 * 1024))
13507 directio write $DIR/$tfile 0 1 $BSIZE
13508 # We ask to read two blocks, which is more than a file size.
13509 # directio will indicate an error when requested and actual
13510 # sizes aren't equeal (a normal situation in this case) and
13511 # print actual read amount.
13512 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
13513 if [ "$NOB" != "$BSIZE" ]; then
13514 error "read $NOB bytes instead of $BSIZE"
13518 run_test 119a "Short directIO read must return actual read amount"
13520 test_119b() # bug 11737
13522 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13524 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
13525 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
13527 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
13528 error "direct read failed"
13531 run_test 119b "Sparse directIO read must return actual read amount"
13533 test_119c() # bug 13099
13536 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
13537 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
13540 run_test 119c "Testing for direct read hitting hole"
13542 # Note: test 119d was removed, skipping 119d for new tests to avoid polluting
13543 # Maloo test history
13547 (( $MDS1_VERSION >= $(version_code 2.15.58) )) ||
13548 skip "Need server version at least 2.15.58"
13549 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13551 local stripe_size=$((1024 * 1024)) #1 MiB
13552 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13553 local file_size=$((25 * stripe_size))
13556 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13557 stack_trap "rm -f $DIR/$tfile*"
13559 # Just a bit bigger than the largest size in the test set below
13560 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13561 error "buffered i/o to create file failed"
13563 # trivial test of unaligned DIO
13564 dd if=$DIR/$tfile.1 bs=4095 of=$DIR/$tfile.2 count=4 \
13565 iflag=direct oflag=direct ||
13566 error "trivial unaligned dio failed"
13568 # Test of disabling unaligned DIO support
13569 $LCTL set_param llite.*.unaligned_dio=0
13570 stack_trap "$LCTL set_param llite.*.unaligned_dio=1"
13571 echo "testing disabling unaligned DIO - 'invalid argument' expected:"
13572 dd if=$DIR/$tfile.1 bs=1024 of=$DIR/$tfile.2 count=4 \
13573 iflag=direct oflag=direct &&
13574 error "unaligned dio succeeded when disabled"
13575 $LCTL set_param llite.*.unaligned_dio=1
13577 # Clean up before next part of test
13578 rm -f $DIR/$tfile.2
13580 if zfs_or_rotational; then
13581 # DIO on ZFS can take up to 2 seconds per IO
13582 # rotational is better, but still slow.
13583 # Limit testing on those media to larger sizes
13584 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13585 $((stripe_size + 1024))"
13587 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13588 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13589 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13590 $((stripe_size - 1)) $stripe_size \
13591 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13592 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13595 for bs in $bsizes; do
13596 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13597 echo "Read/write with DIO at size $bs"
13598 # Read and write with DIO from source to dest
13599 dd if=$DIR/$tfile.1 bs=$bs of=$DIR/$tfile.2 \
13600 iflag=direct oflag=direct ||
13603 ls -la $DIR/$tfile.1 $DIR/$tfile.2
13604 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13605 error "size incorrect, file copy read/write bsize: $bs"
13606 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13607 error "files differ, bsize $bs"
13608 rm -f $DIR/$tfile.2
13611 run_test 119e "Basic tests of dio read and write at various sizes"
13615 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13617 local stripe_size=$((1024 * 1024)) #1 MiB
13618 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13619 local file_size=$((25 * stripe_size))
13622 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13623 stack_trap "rm -f $DIR/$tfile*"
13625 # Just a bit bigger than the largest size in the test set below
13626 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13627 error "buffered i/o to create file failed"
13629 if zfs_or_rotational; then
13630 # DIO on ZFS can take up to 2 seconds per IO
13631 # rotational is better, but still slow.
13632 # Limit testing on those media to larger sizes
13633 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13634 $((stripe_size + 1024))"
13636 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13637 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13638 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13639 $((stripe_size - 1)) $stripe_size \
13640 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13641 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13644 for bs in $bsizes; do
13645 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13646 # Read and write with DIO from source to dest in two
13647 # threads - should give correct copy of file
13650 dd if=$DIR/$tfile.1 bs=$bs of=$DIR/$tfile.2 iflag=direct \
13651 oflag=direct conv=notrunc &
13653 # Note block size is different here for a more interesting race
13654 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
13655 iflag=direct oflag=direct conv=notrunc &
13661 if (( rc1 != 0 )); then
13662 error "dio copy 1 w/bsize $bs failed: $rc1"
13664 if (( rc2 != 0 )); then
13665 error "dio copy 2 w/bsize $bs failed: $rc2"
13669 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13670 error "size incorrect, file copy read/write bsize: $bs"
13671 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13672 error "files differ, bsize $bs"
13673 rm -f $DIR/$tfile.2
13676 run_test 119f "dio vs dio race"
13680 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13682 local stripe_size=$((1024 * 1024)) #1 MiB
13683 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13684 local file_size=$((25 * stripe_size))
13687 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13688 stack_trap "rm -f $DIR/$tfile*"
13690 # Just a bit bigger than the largest size in the test set below
13691 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13692 error "buffered i/o to create file failed"
13694 if zfs_or_rotational; then
13695 # DIO on ZFS can take up to 2 seconds per IO
13696 # rotational is better, but still slow.
13697 # Limit testing on those media to larger sizes
13698 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13699 $((stripe_size + 1024))"
13701 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13702 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13703 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13704 $((stripe_size - 1)) $stripe_size \
13705 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13706 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13709 for bs in $bsizes; do
13710 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13712 dd if=$DIR/$tfile.1 bs=$bs of=$DIR/$tfile.2 iflag=direct \
13713 oflag=direct conv=notrunc &
13715 # Buffered I/O with similar but not the same block size
13716 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 &
13722 if (( rc1 != 0 )); then
13723 error "dio copy 1 w/bsize $bs failed: $rc1"
13725 if (( rc2 != 0 )); then
13726 error "buffered copy 2 w/bsize $bs failed: $rc2"
13729 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13730 error "size incorrect"
13731 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13732 error "files differ, bsize $bs"
13733 rm -f $DIR/$tfile.2
13736 run_test 119g "dio vs buffered I/O race"
13740 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13742 local stripe_size=$((1024 * 1024)) #1 MiB
13743 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13744 local file_size=$((25 * stripe_size))
13747 stack_trap "rm -f $DIR/$tfile.*"
13749 if zfs_or_rotational; then
13750 # DIO on ZFS can take up to 2 seconds per IO
13751 # rotational is better, but still slow.
13752 # Limit testing on those media to larger sizes
13753 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13754 $((stripe_size + 1024))"
13756 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13757 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13758 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13759 $((stripe_size - 1)) $stripe_size \
13760 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13761 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13764 for bs in $bsizes; do
13765 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13766 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13767 echo "unaligned writes of blocksize: $bs"
13768 # Write a file with unaligned DIO and regular DIO, and compare
13770 # with 'u', multiop randomly unaligns the io from the buffer
13771 $MULTIOP $DIR/$tfile.1 \
13772 oO_CREAT:O_RDWR:O_DIRECT:wu${bs}wu${bs}wu${bs}wu${bs}wu${bs} ||
13773 error "multiop memory unaligned write failed, $bs"
13774 $MULTIOP $DIR/$tfile.2 \
13775 oO_CREAT:O_RDWR:O_DIRECT:w${bs}w${bs}w${bs}w${bs}w${bs} ||
13776 error "multiop memory aligned write failed, $bs"
13778 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13779 error "files differ, bsize $bs"
13780 rm -f $DIR/$tfile.*
13783 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13784 dd if=/dev/zero bs=$((stripe_size * 5)) of=$DIR/$tfile.1 count=5 ||
13785 error "dd to create source file for read failed"
13787 # Just a few quick tests to make sure unaligned DIO reads don't crash
13788 for bs in $bsizes; do
13790 echo "unaligned reads of blocksize: $bs"
13791 # with 'u', multiop randomly unaligns the io from the buffer
13792 $MULTIOP $DIR/$tfile.1 \
13793 oO_CREAT:O_RDWR:O_DIRECT:ru${bs}ru${bs}ru${bs}ru${bs}ru${bs} ||
13794 error "multiop memory unaligned read failed, $bs"
13799 run_test 119h "basic tests of memory unaligned dio"
13801 # aiocp with the '-a' option makes testing memory unaligned aio trivial
13804 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
13805 which aiocp || skip_env "no aiocp installed"
13807 local stripe_size=$((1024 * 1024)) #1 MiB
13808 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
13809 local file_size=$((25 * stripe_size))
13812 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
13813 stack_trap "rm -f $DIR/$tfile.*"
13815 # Just a bit bigger than the largest size in the test set below
13816 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
13817 error "buffered i/o to create file failed"
13819 if zfs_or_rotational; then
13820 # DIO on ZFS can take up to 2 seconds per IO
13821 # rotational is better, but still slow.
13822 # Limit testing on those media to larger sizes
13823 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
13824 $((stripe_size + 1024))"
13826 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
13827 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
13828 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
13829 $((stripe_size - 1)) $stripe_size \
13830 $((stripe_size + 1)) $((stripe_size * 3/2)) \
13831 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
13834 # Do page aligned and NOT page aligned AIO
13835 for align in 8 512 $((PAGE_SIZE)); do
13836 # Deliberately includes a few aligned sizes
13837 for bs in $bsizes; do
13838 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
13840 echo "bs: $bs, align: $align, file_size $file_size"
13841 aiocp -a $align -b $bs -s $file_size -f O_DIRECT \
13842 $DIR/$tfile.1 $DIR/$tfile.2 ||
13843 error "unaligned aio failed, bs: $bs, align: $align"
13845 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
13846 error "size incorrect"
13847 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
13848 error "files differ"
13849 rm -f $DIR/$tfile.2
13853 run_test 119i "test unaligned aio at varying sizes"
13856 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13857 remote_mds_nodsh && skip "remote MDS with nodsh"
13858 test_mkdir -i0 -c1 $DIR/$tdir
13859 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13860 skip_env "no early lock cancel on server"
13862 lru_resize_disable mdc
13863 lru_resize_disable osc
13864 cancel_lru_locks mdc
13865 # asynchronous object destroy at MDT could cause bl ast to client
13866 cancel_lru_locks osc
13868 stat $DIR/$tdir > /dev/null
13869 can1=$(do_facet mds1 \
13870 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13871 awk '/ldlm_cancel/ {print $2}')
13872 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13873 awk '/ldlm_bl_callback/ {print $2}')
13874 test_mkdir -i0 -c1 $DIR/$tdir/d1
13875 can2=$(do_facet mds1 \
13876 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13877 awk '/ldlm_cancel/ {print $2}')
13878 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13879 awk '/ldlm_bl_callback/ {print $2}')
13880 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13881 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13882 lru_resize_enable mdc
13883 lru_resize_enable osc
13885 run_test 120a "Early Lock Cancel: mkdir test"
13888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13889 remote_mds_nodsh && skip "remote MDS with nodsh"
13890 test_mkdir $DIR/$tdir
13891 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13892 skip_env "no early lock cancel on server"
13894 lru_resize_disable mdc
13895 lru_resize_disable osc
13896 cancel_lru_locks mdc
13897 stat $DIR/$tdir > /dev/null
13898 can1=$(do_facet $SINGLEMDS \
13899 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13900 awk '/ldlm_cancel/ {print $2}')
13901 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13902 awk '/ldlm_bl_callback/ {print $2}')
13903 touch $DIR/$tdir/f1
13904 can2=$(do_facet $SINGLEMDS \
13905 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13906 awk '/ldlm_cancel/ {print $2}')
13907 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13908 awk '/ldlm_bl_callback/ {print $2}')
13909 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13910 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13911 lru_resize_enable mdc
13912 lru_resize_enable osc
13914 run_test 120b "Early Lock Cancel: create test"
13917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13918 remote_mds_nodsh && skip "remote MDS with nodsh"
13919 test_mkdir -i0 -c1 $DIR/$tdir
13920 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13921 skip "no early lock cancel on server"
13923 lru_resize_disable mdc
13924 lru_resize_disable osc
13925 test_mkdir -i0 -c1 $DIR/$tdir/d1
13926 test_mkdir -i0 -c1 $DIR/$tdir/d2
13927 touch $DIR/$tdir/d1/f1
13928 cancel_lru_locks mdc
13929 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
13930 can1=$(do_facet mds1 \
13931 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13932 awk '/ldlm_cancel/ {print $2}')
13933 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13934 awk '/ldlm_bl_callback/ {print $2}')
13935 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
13936 can2=$(do_facet mds1 \
13937 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13938 awk '/ldlm_cancel/ {print $2}')
13939 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13940 awk '/ldlm_bl_callback/ {print $2}')
13941 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13942 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13943 lru_resize_enable mdc
13944 lru_resize_enable osc
13946 run_test 120c "Early Lock Cancel: link test"
13949 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13950 remote_mds_nodsh && skip "remote MDS with nodsh"
13951 test_mkdir -i0 -c1 $DIR/$tdir
13952 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13953 skip_env "no early lock cancel on server"
13955 lru_resize_disable mdc
13956 lru_resize_disable osc
13958 cancel_lru_locks mdc
13959 stat $DIR/$tdir > /dev/null
13960 can1=$(do_facet mds1 \
13961 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13962 awk '/ldlm_cancel/ {print $2}')
13963 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13964 awk '/ldlm_bl_callback/ {print $2}')
13965 chmod a+x $DIR/$tdir
13966 can2=$(do_facet mds1 \
13967 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13968 awk '/ldlm_cancel/ {print $2}')
13969 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13970 awk '/ldlm_bl_callback/ {print $2}')
13971 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
13972 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
13973 lru_resize_enable mdc
13974 lru_resize_enable osc
13976 run_test 120d "Early Lock Cancel: setattr test"
13979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13980 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
13981 skip_env "no early lock cancel on server"
13982 remote_mds_nodsh && skip "remote MDS with nodsh"
13984 local dlmtrace_set=false
13986 test_mkdir -i0 -c1 $DIR/$tdir
13987 lru_resize_disable mdc
13988 lru_resize_disable osc
13989 ! $LCTL get_param debug | grep -q dlmtrace &&
13990 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
13991 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
13992 cancel_lru_locks mdc
13993 cancel_lru_locks osc
13994 dd if=$DIR/$tdir/f1 of=/dev/null
13995 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
13996 # XXX client can not do early lock cancel of OST lock
13997 # during unlink (LU-4206), so cancel osc lock now.
13999 cancel_lru_locks osc
14000 can1=$(do_facet mds1 \
14001 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14002 awk '/ldlm_cancel/ {print $2}')
14003 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14004 awk '/ldlm_bl_callback/ {print $2}')
14005 unlink $DIR/$tdir/f1
14007 can2=$(do_facet mds1 \
14008 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14009 awk '/ldlm_cancel/ {print $2}')
14010 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14011 awk '/ldlm_bl_callback/ {print $2}')
14012 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
14013 $LCTL dk $TMP/cancel.debug.txt
14014 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
14015 $LCTL dk $TMP/blocking.debug.txt
14016 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
14017 lru_resize_enable mdc
14018 lru_resize_enable osc
14020 run_test 120e "Early Lock Cancel: unlink test"
14023 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14024 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
14025 skip_env "no early lock cancel on server"
14026 remote_mds_nodsh && skip "remote MDS with nodsh"
14028 test_mkdir -i0 -c1 $DIR/$tdir
14029 lru_resize_disable mdc
14030 lru_resize_disable osc
14031 test_mkdir -i0 -c1 $DIR/$tdir/d1
14032 test_mkdir -i0 -c1 $DIR/$tdir/d2
14033 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
14034 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
14035 cancel_lru_locks mdc
14036 cancel_lru_locks osc
14037 dd if=$DIR/$tdir/d1/f1 of=/dev/null
14038 dd if=$DIR/$tdir/d2/f2 of=/dev/null
14039 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
14040 # XXX client can not do early lock cancel of OST lock
14041 # during rename (LU-4206), so cancel osc lock now.
14043 cancel_lru_locks osc
14044 can1=$(do_facet mds1 \
14045 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14046 awk '/ldlm_cancel/ {print $2}')
14047 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14048 awk '/ldlm_bl_callback/ {print $2}')
14049 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
14051 can2=$(do_facet mds1 \
14052 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14053 awk '/ldlm_cancel/ {print $2}')
14054 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14055 awk '/ldlm_bl_callback/ {print $2}')
14056 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
14057 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
14058 lru_resize_enable mdc
14059 lru_resize_enable osc
14061 run_test 120f "Early Lock Cancel: rename test"
14064 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14065 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
14066 skip_env "no early lock cancel on server"
14067 remote_mds_nodsh && skip "remote MDS with nodsh"
14069 lru_resize_disable mdc
14070 lru_resize_disable osc
14072 echo create $count files
14073 test_mkdir $DIR/$tdir
14074 cancel_lru_locks mdc
14075 cancel_lru_locks osc
14078 can0=$(do_facet $SINGLEMDS \
14079 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14080 awk '/ldlm_cancel/ {print $2}')
14081 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14082 awk '/ldlm_bl_callback/ {print $2}')
14083 createmany -o $DIR/$tdir/f $count
14085 can1=$(do_facet $SINGLEMDS \
14086 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14087 awk '/ldlm_cancel/ {print $2}')
14088 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14089 awk '/ldlm_bl_callback/ {print $2}')
14091 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
14092 echo rm $count files
14095 can2=$(do_facet $SINGLEMDS \
14096 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
14097 awk '/ldlm_cancel/ {print $2}')
14098 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
14099 awk '/ldlm_bl_callback/ {print $2}')
14101 echo total: $count removes in $((t2-t1))
14102 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
14104 # wait for commitment of removal
14105 lru_resize_enable mdc
14106 lru_resize_enable osc
14108 run_test 120g "Early Lock Cancel: performance test"
14110 test_121() { #bug #10589
14111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14114 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
14115 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
14116 lctl set_param fail_loc=0x310
14117 cancel_lru_locks osc > /dev/null
14118 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
14119 lctl set_param fail_loc=0
14120 [[ $reads -eq $writes ]] ||
14121 error "read $reads blocks, must be $writes blocks"
14123 run_test 121 "read cancel race ========="
14125 test_123a_base() { # was test 123, statahead(bug 11401)
14128 ost_set_temp_seq_width_all $DATA_SEQ_MAX_WIDTH
14131 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
14132 log "testing UP system. Performance may be lower than expected."
14135 running_in_vm && SLOWOK=1
14137 $LCTL set_param mdc.*.batch_stats=0
14140 test_mkdir $DIR/$tdir
14141 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
14142 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
14144 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
14145 createmany -o $DIR/$tdir/$tfile $j $((i - j))
14147 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
14148 lctl set_param -n llite.*.statahead_max 0
14149 lctl get_param llite.*.statahead_max
14150 cancel_lru_locks mdc
14151 cancel_lru_locks osc
14153 time $lsx $DIR/$tdir | wc -l
14155 delta=$((etime - stime))
14156 log "$lsx $i files without statahead: $delta sec"
14157 lctl set_param llite.*.statahead_max=$max
14159 swrong=$(lctl get_param -n llite.*.statahead_stats |
14160 awk '/statahead.wrong:/ { print $NF }')
14161 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
14162 cancel_lru_locks mdc
14163 cancel_lru_locks osc
14165 time $lsx $DIR/$tdir | wc -l
14167 delta_sa=$((etime - stime))
14168 log "$lsx $i files with statahead: $delta_sa sec"
14169 lctl get_param -n llite.*.statahead_stats
14170 ewrong=$(lctl get_param -n llite.*.statahead_stats |
14171 awk '/statahead.wrong:/ { print $NF }')
14173 [[ $swrong -lt $ewrong ]] &&
14174 log "statahead was stopped, maybe too many locks held!"
14175 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
14177 if (( $delta_sa*100 > $delta*105 && $delta_sa > $delta+2)); then
14178 max=$(lctl get_param -n llite.*.statahead_max |
14180 lctl set_param -n llite.*.statahead_max 0
14181 lctl get_param llite.*.statahead_max
14182 cancel_lru_locks mdc
14183 cancel_lru_locks osc
14185 time $lsx $DIR/$tdir | wc -l
14187 delta=$((etime - stime))
14188 log "$lsx $i files again without statahead: $delta sec"
14189 lctl set_param llite.*.statahead_max=$max
14190 if (( $delta_sa*100 > delta*105 && delta_sa > delta+2 )); then
14191 if [ $SLOWOK -eq 0 ]; then
14192 error "$lsx $i files is slower with statahead!"
14194 log "$lsx $i files is slower with statahead!"
14200 [ $delta -gt 20 ] && break
14201 [ $delta -gt 8 ] && MULT=$((50 / delta))
14202 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
14210 delta=$((etime - stime))
14211 log "rm -r $DIR/$tdir/: $delta seconds"
14213 lctl get_param -n llite.*.statahead_stats
14214 $LCTL get_param mdc.*.batch_stats
14218 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14220 test_123a_base "ls -l"
14222 run_test 123aa "verify statahead work"
14225 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14227 statx_supported || skip_env "Test must be statx() syscall supported"
14229 test_123a_base "$STATX -l"
14231 run_test 123ab "verify statahead work by using statx"
14234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14236 statx_supported || skip_env "Test must be statx() syscall supported"
14243 cancel_lru_locks $OSC
14244 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
14245 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
14246 awk '/agl.total:/ { print $NF }')
14247 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
14248 test_123a_base "$STATX --cached=always -D"
14249 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
14250 awk '/agl.total:/ { print $NF }')
14251 [ $agl_before -eq $agl_after ] ||
14252 error "Should not trigger AGL thread - $agl_before:$agl_after"
14253 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
14254 [ $rpcs_after -eq $rpcs_before ] ||
14255 error "$STATX should not send glimpse RPCs to $OSC"
14257 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
14259 test_batch_statahead() {
14267 echo -e "\nbatching: statahead_max=$max statahead_batch_max=$batch_max"
14268 $LCTL set_param mdc.*.batch_stats=0
14269 $LCTL set_param llite.*.statahead_max=$max
14270 $LCTL set_param llite.*.statahead_batch_max=$batch_max
14271 # Verify that batched statahead is faster than one without statahead
14272 test_123a_base "ls -l"
14274 stack_trap "rm -rf $DIR/$tdir" EXIT
14275 mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
14276 createmany -o $DIR/$tdir/$tfile $num || error "failed to create files"
14278 # unbatched statahead
14279 $LCTL set_param llite.*.statahead_batch_max=0
14280 $LCTL set_param llite.*.statahead_stats=clear
14281 $LCTL set_param mdc.*.stats=clear
14282 cancel_lru_locks mdc
14283 cancel_lru_locks osc
14284 time ls -l $DIR/$tdir | wc -l
14285 unbatch_rpcs=$(calc_stats mdc.*.stats ldlm_ibits_enqueue)
14287 hit_total=$($LCTL get_param -n llite.*.statahead_stats |
14288 awk '/hit.total:/ { print $NF }')
14289 # hit ratio should be larger than 75% (7500).
14290 (( $hit_total > 7500 )) ||
14291 error "unbatched statahead hit count ($hit_total) is too low"
14293 # batched statahead
14294 $LCTL set_param llite.*.statahead_batch_max=$batch_max
14295 $LCTL set_param llite.*.statahead_stats=clear
14296 $LCTL set_param mdc.*.batch_stats=clear
14297 $LCTL set_param mdc.*.stats=clear
14298 cancel_lru_locks mdc
14299 cancel_lru_locks osc
14300 time ls -l $DIR/$tdir | wc -l
14301 batch_rpcs=$(calc_stats mdc.*.stats mds_batch)
14302 # wait for statahead thread to quit and update statahead stats
14304 hit_total=$($LCTL get_param -n llite.*.statahead_stats |
14305 awk '/hit.total:/ { print $NF }')
14306 # hit ratio should be larger than 75% (7500).
14307 (( $hit_total > 7500 )) ||
14308 error "batched statahead hit count ($hit_total) is too low"
14310 echo "unbatched RPCs: $unbatch_rpcs, batched RPCs: $batch_rpcs"
14311 (( $unbatch_rpcs > $batch_rpcs )) ||
14312 error "batched statahead does not reduce RPC count"
14313 $LCTL get_param mdc.*.batch_stats
14317 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14319 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
14320 skip "Need server version at least 2.15.53"
14325 max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
14326 batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
14328 stack_trap "$LCTL set_param llite.*.statahead_max=$max" EXIT
14329 stack_trap "$LCTL set_param llite.*.statahead_batch_max=$batch_max" EXIT
14331 test_batch_statahead 32 32
14332 test_batch_statahead 2048 256
14334 run_test 123ad "Verify batching statahead works correctly"
14336 test_123b () { # statahead(bug 15027)
14337 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14339 test_mkdir $DIR/$tdir
14340 createmany -o $DIR/$tdir/$tfile-%d 1000
14342 cancel_lru_locks mdc
14343 cancel_lru_locks osc
14345 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
14346 lctl set_param fail_loc=0x80000803
14347 ls -lR $DIR/$tdir > /dev/null
14349 lctl set_param fail_loc=0x0
14350 lctl get_param -n llite.*.statahead_stats
14355 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
14358 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
14360 test_mkdir -i 0 -c 1 $DIR/$tdir.0
14361 test_mkdir -i 1 -c 1 $DIR/$tdir.1
14362 touch $DIR/$tdir.1/{1..3}
14363 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
14365 remount_client $MOUNT
14367 $MULTIOP $DIR/$tdir.0 Q
14369 # let statahead to complete
14370 ls -l $DIR/$tdir.0 > /dev/null
14372 testid=$(echo $TESTNAME | tr '_' ' ')
14373 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
14374 error "statahead warning" || true
14376 run_test 123c "Can not initialize inode warning on DNE statahead"
14383 test_mkdir -c -1 $DIR/$tdir || error "test_mkdir $DIR/$tdir failed"
14384 $LFS setdirstripe -D -c $MDSCOUNT $DIR/$tdir ||
14385 error "setdirstripe $DIR/$tdir failed"
14386 createmany -d $DIR/$tdir/$tfile $num || error "createmany $num failed"
14387 remount_client $MOUNT
14388 $LCTL get_param llite.*.statahead_max
14389 $LCTL set_param llite.*.statahead_stats=0 ||
14390 error "clear statahead_stats failed"
14391 swrong=$(lctl get_param -n llite.*.statahead_stats |
14392 awk '/statahead.wrong:/ { print $NF }')
14393 ls -l $DIR/$tdir || error "ls -l $DIR/$tdir failed"
14394 # wait for statahead thread finished to update hit/miss stats.
14396 $LCTL get_param -n llite.*.statahead_stats
14397 ewrong=$(lctl get_param -n llite.*.statahead_stats |
14398 awk '/statahead.wrong:/ { print $NF }')
14399 (( $swrong == $ewrong )) ||
14400 log "statahead was stopped, maybe too many locks held!"
14402 run_test 123d "Statahead on striped directories works correctly"
14407 local dir=$DIR/$tdir
14409 mkdir $dir || error "mkdir $dir failed"
14410 $LFS setstripe -C 32 $dir || error "setstripe $dir failed"
14411 stack_trap "rm -rf $dir"
14413 touch $dir/$tfile.{0..1000} || error "touch 1000 files failed"
14415 max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
14416 batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
14417 stack_trap "$LCTL set_param llite.*.statahead_max=$max" EXIT
14418 stack_trap "$LCTL set_param llite.*.statahead_batch_max=$batch_max" EXIT
14420 $LCTL set_param llite.*.statahead_max=2048
14421 $LCTL set_param llite.*.statahead_batch_max=1024
14424 $LCTL get_param mdc.*.batch_stats
14425 $LCTL get_param llite.*.statahead_*
14427 run_test 123e "statahead with large wide striping"
14432 local dir=$DIR/$tdir
14434 mkdir $dir || error "mkdir $dir failed"
14435 $LFS setstripe -C 1000 $dir || error "setstripe $dir failed"
14436 stack_trap "rm -rf $dir"
14438 touch $dir/$tfile.{0..200} || error "touch 200 files failed"
14440 max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
14441 batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
14443 $LCTL set_param llite.*.statahead_max=64
14444 $LCTL set_param llite.*.statahead_batch_max=64
14447 lctl get_param mdc.*.batch_stats
14448 lctl get_param llite.*.statahead_*
14450 $LCTL set_param llite.*.statahead_max=$max
14451 $LCTL set_param llite.*.statahead_batch_max=$batch_max
14453 run_test 123f "Retry mechanism with large wide striping files"
14456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14457 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14458 skip_env "no lru resize on server"
14462 test_mkdir $DIR/$tdir
14464 log "create $NR files at $DIR/$tdir"
14465 createmany -o $DIR/$tdir/f $NR ||
14466 error "failed to create $NR files in $DIR/$tdir"
14468 cancel_lru_locks mdc
14469 ls -l $DIR/$tdir > /dev/null
14473 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
14474 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
14475 LRU_SIZE=$($LCTL get_param -n $PARAM)
14476 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
14477 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
14479 log "NS=$(basename $NSDIR)"
14484 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
14485 skip "Not enough cached locks created!"
14487 log "LRU=$LRU_SIZE"
14491 # We know that lru resize allows one client to hold $LIMIT locks
14492 # for 10h. After that locks begin to be killed by client.
14494 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
14496 if [ $LIMIT -lt $LRU_SIZE ]; then
14497 skip "Limit is too small $LIMIT"
14500 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
14501 # killing locks. Some time was spent for creating locks. This means
14502 # that up to the moment of sleep finish we must have killed some of
14503 # them (10-100 locks). This depends on how fast ther were created.
14504 # Many of them were touched in almost the same moment and thus will
14505 # be killed in groups.
14506 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
14508 # Use $LRU_SIZE_B here to take into account real number of locks
14509 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
14510 local LRU_SIZE_B=$LRU_SIZE
14512 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
14513 log "OLD_LVF=$OLD_LVF"
14514 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
14516 # Let's make sure that we really have some margin. Client checks
14517 # cached locks every 10 sec.
14518 SLEEP=$((SLEEP+20))
14519 log "Sleep ${SLEEP} sec"
14521 while ((SEC<$SLEEP)); do
14525 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
14526 echo -n "$LRU_SIZE"
14529 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
14530 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
14532 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
14533 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
14534 unlinkmany $DIR/$tdir/f $NR
14538 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
14539 log "unlink $NR files at $DIR/$tdir"
14540 unlinkmany $DIR/$tdir/f $NR
14542 run_test 124a "lru resize ======================================="
14544 get_max_pool_limit()
14546 local limit=$($LCTL get_param \
14547 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
14549 for l in $limit; do
14550 if [[ $l -gt $max ]]; then
14558 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14559 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14560 skip_env "no lru resize on server"
14562 LIMIT=$(get_max_pool_limit)
14564 NR=$(($(default_lru_size)*20))
14565 if [[ $NR -gt $LIMIT ]]; then
14566 log "Limit lock number by $LIMIT locks"
14570 IFree=$(mdsrate_inodes_available)
14571 if [ $IFree -lt $NR ]; then
14572 log "Limit lock number by $IFree inodes"
14576 lru_resize_disable mdc
14577 test_mkdir -p $DIR/$tdir/disable_lru_resize
14579 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
14580 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
14581 cancel_lru_locks mdc
14584 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
14587 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
14590 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
14594 nolruresize_delta=$((etime-stime))
14595 log "ls -la time: $nolruresize_delta seconds"
14596 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
14597 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
14599 lru_resize_enable mdc
14600 test_mkdir -p $DIR/$tdir/enable_lru_resize
14602 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
14603 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
14604 cancel_lru_locks mdc
14607 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
14610 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
14613 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
14617 lruresize_delta=$((etime-stime))
14618 log "ls -la time: $lruresize_delta seconds"
14619 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
14621 if [ $lruresize_delta -gt $nolruresize_delta ]; then
14622 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
14623 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
14624 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
14626 log "lru resize performs the same with no lru resize"
14628 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
14630 run_test 124b "lru resize (performance test) ======================="
14633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14634 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14635 skip_env "no lru resize on server"
14637 # cache ununsed locks on client
14639 cancel_lru_locks mdc
14640 test_mkdir $DIR/$tdir
14641 createmany -o $DIR/$tdir/f $nr ||
14642 error "failed to create $nr files in $DIR/$tdir"
14643 ls -l $DIR/$tdir > /dev/null
14645 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14646 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14647 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
14648 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
14649 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
14651 # set lru_max_age to 1 sec
14652 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
14653 echo "sleep $((recalc_p * 2)) seconds..."
14654 sleep $((recalc_p * 2))
14656 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
14657 # restore lru_max_age
14658 $LCTL set_param -n $nsdir.lru_max_age $max_age
14659 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
14660 unlinkmany $DIR/$tdir/f $nr
14662 run_test 124c "LRUR cancel very aged locks"
14665 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14666 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
14667 skip_env "no lru resize on server"
14669 # cache ununsed locks on client
14672 lru_resize_disable mdc
14673 stack_trap "lru_resize_enable mdc" EXIT
14675 cancel_lru_locks mdc
14677 # asynchronous object destroy at MDT could cause bl ast to client
14678 test_mkdir $DIR/$tdir
14679 createmany -o $DIR/$tdir/f $nr ||
14680 error "failed to create $nr files in $DIR/$tdir"
14681 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
14683 ls -l $DIR/$tdir > /dev/null
14685 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14686 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14687 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
14688 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
14690 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
14692 # set lru_max_age to 1 sec
14693 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
14694 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
14696 echo "sleep $((recalc_p * 2)) seconds..."
14697 sleep $((recalc_p * 2))
14699 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
14701 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
14703 run_test 124d "cancel very aged locks if lru-resize disabled"
14705 test_125() { # 13358
14706 $LCTL get_param -n llite.*.client_type | grep -q local ||
14707 skip "must run as local client"
14708 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
14709 skip_env "must have acl enabled"
14710 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
14711 id $USER0 || skip_env "missing user $USER0"
14713 test_mkdir $DIR/$tdir
14714 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
14715 setfacl -R -m u:$USER0:rwx $DIR/$tdir ||
14716 error "setfacl $DIR/$tdir failed"
14717 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
14719 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
14721 test_126() { # bug 12829/13455
14722 $GSS && skip_env "must run as gss disabled"
14723 $LCTL get_param -n llite.*.client_type | grep -q local ||
14724 skip "must run as local client"
14725 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
14727 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
14728 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
14730 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
14732 run_test 126 "check that the fsgid provided by the client is taken into account"
14734 test_127a() { # bug 15521
14735 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14736 local name count samp unit min max sum sumsq
14737 local tmpfile=$TMP/$tfile.tmp
14739 # enable stats header if it is disabled
14740 $LCTL set_param enable_stats_header=1
14742 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
14743 echo "stats before reset"
14744 stack_trap "rm -f $tmpfile"
14745 local now=$(date +%s)
14747 $LCTL get_param osc.*.stats | tee $tmpfile
14749 local snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
14750 local start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
14751 local elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
14752 local uptime=$(awk '{ print $1 }' /proc/uptime)
14754 # snapshot_time should match POSIX epoch time, allow some delta for VMs
14755 (( ${snapshot_time%\.*} >= $now - 5 &&
14756 ${snapshot_time%\.*} <= $now + 5 )) ||
14757 error "snapshot_time=$snapshot_time != now=$now"
14758 # elapsed _should_ be from mount, but at least less than uptime
14759 (( ${elapsed%\.*} < ${uptime%\.*} )) ||
14760 error "elapsed=$elapsed > uptime=$uptime"
14761 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
14762 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
14763 error "elapsed=$elapsed != $snapshot_time - $start_time"
14765 $LCTL set_param osc.*.stats=0
14766 local reset=$(date +%s)
14767 local fsize=$((2048 * 1024))
14769 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
14770 cancel_lru_locks osc
14771 dd if=$DIR/$tfile of=/dev/null bs=$fsize
14774 $LCTL get_param osc.*0000-osc-*.stats > $tmpfile
14775 while read name count samp unit min max sum sumsq; do
14776 [[ "$samp" == "samples" ]] || continue
14778 echo "got name=$name count=$count unit=$unit min=$min max=$max"
14779 [ ! $min ] && error "Missing min value for $name proc entry"
14780 eval $name=$count || error "Wrong proc format"
14783 read_bytes|write_bytes)
14784 [[ "$unit" =~ "bytes" ]] ||
14785 error "unit is not 'bytes': $unit"
14786 (( $min >= 4096 )) || error "min is too small: $min"
14787 (( $min <= $fsize )) || error "min is too big: $min"
14788 (( $max >= 4096 )) || error "max is too small: $max"
14789 (( $max <= $fsize )) || error "max is too big: $max"
14790 (( $sum == $fsize )) || error "sum is wrong: $sum"
14791 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
14792 error "sumsquare is too small: $sumsq"
14793 (( $sumsq <= $fsize * $fsize )) ||
14794 error "sumsquare is too big: $sumsq"
14796 ost_read|ost_write)
14797 [[ "$unit" =~ "usec" ]] ||
14798 error "unit is not 'usec': $unit"
14804 #check that we actually got some stats
14805 [ "$read_bytes" ] || error "Missing read_bytes stats"
14806 [ "$write_bytes" ] || error "Missing write_bytes stats"
14807 [ "$read_bytes" != 0 ] || error "no read done"
14808 [ "$write_bytes" != 0 ] || error "no write done"
14810 snapshot_time=$(awk '/snapshot_time/ { print $2; exit }' $tmpfile)
14811 start_time=$(awk '/start_time/ { print $2; exit }' $tmpfile)
14812 elapsed=$(awk '/elapsed_time/ { print $2; exit }' $tmpfile)
14814 # snapshot_time should match POSIX epoch time, allow some delta for VMs
14815 (( ${snapshot_time%\.*} >= $now - 5 &&
14816 ${snapshot_time%\.*} <= $now + 5 )) ||
14817 error "reset snapshot_time=$snapshot_time != now=$now"
14818 # elapsed should be from time of stats reset
14819 (( ${elapsed%\.*} >= $now - $reset - 2 &&
14820 ${elapsed%\.*} <= $now - $reset + 2 )) ||
14821 error "reset elapsed=$elapsed > $now - $reset"
14822 (( ${snapshot_time%\.*} - ${start_time%\.*} >= ${elapsed%\.*} - 2 &&
14823 ${snapshot_time%\.*} - ${start_time%\.*} <= ${elapsed%\.*} + 2 )) ||
14824 error "reset elapsed=$elapsed != $snapshot_time - $start_time"
14826 run_test 127a "verify the client stats are sane"
14828 test_127b() { # bug LU-333
14829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14830 local name count samp unit min max sum sumsq
14832 echo "stats before reset"
14833 $LCTL get_param llite.*.stats
14834 $LCTL set_param llite.*.stats=0
14836 # perform 2 reads and writes so MAX is different from SUM.
14837 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
14838 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
14839 cancel_lru_locks osc
14840 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
14841 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
14843 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
14844 stack_trap "rm -f $TMP/$tfile.tmp"
14845 while read name count samp unit min max sum sumsq; do
14846 echo "got name=$name count=$count unit=$unit min=$min max=$max"
14847 eval $name=$count || error "Wrong proc format"
14850 read_bytes|write_bytes)
14851 [[ "$unit" =~ "bytes" ]] ||
14852 error "unit is not 'bytes': $unit"
14853 (( $count == 2 )) || error "count is not 2: $count"
14854 (( $min == $PAGE_SIZE )) ||
14855 error "min is not $PAGE_SIZE: $min"
14856 (( $max == $PAGE_SIZE )) ||
14857 error "max is not $PAGE_SIZE: $max"
14858 (( $sum == $PAGE_SIZE * 2 )) ||
14859 error "sum is not $((PAGE_SIZE * 2)): $sum"
14862 [[ "$unit" =~ "usec" ]] ||
14863 error "unit is not 'usec': $unit"
14867 done < $TMP/$tfile.tmp
14869 #check that we actually got some stats
14870 [ "$read_bytes" ] || error "Missing read_bytes stats"
14871 [ "$write_bytes" ] || error "Missing write_bytes stats"
14872 [ "$read_bytes" != 0 ] || error "no read done"
14873 [ "$write_bytes" != 0 ] || error "no write done"
14875 run_test 127b "verify the llite client stats are sane"
14877 test_127c() { # LU-12394
14878 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
14885 $LCTL set_param llite.*.extents_stats=1
14886 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
14888 # Use two stripes so there is enough space in default config
14889 $LFS setstripe -c 2 $DIR/$tfile
14891 # Extent stats start at 0-4K and go in power of two buckets
14892 # LL_HIST_START = 12 --> 2^12 = 4K
14893 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
14894 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
14896 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
14898 # Write and read, 2x each, second time at a non-zero offset
14899 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
14900 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
14901 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
14902 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
14906 $LCTL get_param llite.*.extents_stats
14909 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
14911 local bucket=$($LCTL get_param -n llite.*.extents_stats |
14913 reads=$(echo $bucket | awk '{print $5}')
14914 writes=$(echo $bucket | awk '{print $9}')
14915 [ "$reads" -eq $count ] ||
14916 error "$reads reads in < $bsize bucket, expect $count"
14917 [ "$writes" -eq $count ] ||
14918 error "$writes writes in < $bsize bucket, expect $count"
14921 # Test mmap write and read
14922 $LCTL set_param llite.*.extents_stats=c
14924 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
14925 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
14926 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
14928 $LCTL get_param llite.*.extents_stats
14930 count=$(((size*1024) / PAGE_SIZE))
14932 bsize=$((2 * PAGE_SIZE / 1024))K
14934 bucket=$($LCTL get_param -n llite.*.extents_stats |
14936 reads=$(echo $bucket | awk '{print $5}')
14937 writes=$(echo $bucket | awk '{print $9}')
14938 # mmap writes fault in the page first, creating an additonal read
14939 [ "$reads" -eq $((2 * count)) ] ||
14940 error "$reads reads in < $bsize bucket, expect $count"
14941 [ "$writes" -eq $count ] ||
14942 error "$writes writes in < $bsize bucket, expect $count"
14944 run_test 127c "test llite extent stats with regular & mmap i/o"
14946 test_128() { # bug 15212
14948 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
14953 result=$(grep error $TMP/$tfile.log)
14954 rm -f $DIR/$tfile $TMP/$tfile.log
14955 [ -z "$result" ] ||
14956 error "consecutive find's under interactive lfs failed"
14958 run_test 128 "interactive lfs for 2 consecutive find's"
14960 set_dir_limits () {
14965 local ldproc=/proc/fs/ldiskfs
14966 local facets=$(get_facets MDS)
14968 for facet in ${facets//,/ }; do
14969 canondev=$(ldiskfs_canon \
14970 *.$(convert_facet2label $facet).mntdev $facet)
14971 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
14972 ldproc=/sys/fs/ldiskfs
14973 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
14974 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
14978 check_mds_dmesg() {
14979 local facets=$(get_facets MDS)
14980 for facet in ${facets//,/ }; do
14981 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
14987 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14988 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
14989 skip "Need MDS version with at least 2.5.56"
14990 if [ "$mds1_FSTYPE" != ldiskfs ]; then
14991 skip_env "ldiskfs only test"
14993 remote_mds_nodsh && skip "remote MDS with nodsh"
14996 local has_warning=false
14999 mkdir -p $DIR/$tdir
15001 # block size of mds1
15002 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
15003 set_dir_limits $maxsize $((maxsize * 6 / 8))
15004 stack_trap "set_dir_limits 0 0"
15005 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
15006 local dirsize=$(stat -c%s "$DIR/$tdir")
15008 while (( $dirsize <= $maxsize )); do
15009 $MCREATE $DIR/$tdir/file_base_$nfiles
15011 # check two errors:
15012 # ENOSPC for ext4 max_dir_size, which has been used since
15013 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
15014 if (( rc == ENOSPC )); then
15016 echo "rc=$rc returned as expected after $nfiles files"
15018 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
15019 error "create failed w/o dir size limit"
15021 # messages may be rate limited if test is run repeatedly
15022 check_mds_dmesg '"is approaching max"' ||
15023 echo "warning message should be output"
15024 check_mds_dmesg '"has reached max"' ||
15025 echo "reached message should be output"
15027 dirsize=$(stat -c%s "$DIR/$tdir")
15029 [[ $dirsize -ge $maxsize ]] && return 0
15030 error "dirsize $dirsize < $maxsize after $nfiles files"
15031 elif (( rc != 0 )); then
15034 nfiles=$((nfiles + 1))
15035 dirsize=$(stat -c%s "$DIR/$tdir")
15038 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
15040 run_test 129 "test directory size limit ========================"
15050 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
15051 [[ -z "$filefrag_op" ]] || skip_env "filefrag does not support FIEMAP"
15053 trap cleanup_130 EXIT RETURN
15055 local fm_file=$DIR/$tfile
15056 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
15057 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
15058 error "dd failed for $fm_file"
15060 # LU-1795: test filefrag/FIEMAP once, even if unsupported on ZFS
15061 filefrag -ves $fm_file
15063 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15064 skip "LU-1941: FIEMAP unimplemented on ZFS"
15065 (( $rc == 0 )) || error "filefrag $fm_file failed"
15067 filefrag_op=$(filefrag -ve -k $fm_file |
15068 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15069 local lun=$($LFS getstripe -i $fm_file)
15071 local start_blk=$(echo $filefrag_op | cut -d: -f2 | cut -d. -f1)
15074 for line in $filefrag_op; do
15075 local frag_lun=$(echo $line | cut -d: -f5)
15076 local ext_len=$(echo $line | cut -d: -f4)
15078 if (( $frag_lun != $lun )); then
15079 error "FIEMAP on 1-stripe file($fm_file) failed"
15082 (( tot_len += ext_len ))
15085 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
15086 error "FIEMAP on 1-stripe file($fm_file) failed"
15090 echo "FIEMAP on single striped file succeeded"
15092 run_test 130a "FIEMAP (1-stripe file)"
15095 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
15097 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15098 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15099 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15100 skip "LU-1941: FIEMAP unimplemented on ZFS"
15102 trap cleanup_130 EXIT RETURN
15104 local fm_file=$DIR/$tfile
15105 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
15106 error "setstripe on $fm_file"
15108 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
15109 error "dd failed on $fm_file"
15111 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15112 filefrag_op=$(filefrag -ve -k $fm_file |
15113 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15115 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
15116 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15122 for line in $filefrag_op; do
15123 local frag_lun=$(echo $line | cut -d: -f5 |
15124 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15125 local ext_len=$(echo $line | cut -d: -f4)
15126 if (( $frag_lun != $last_lun )); then
15127 if (( tot_len != 1024 )); then
15128 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
15131 (( num_luns += 1 ))
15135 (( tot_len += ext_len ))
15138 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
15139 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
15143 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
15145 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
15148 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
15150 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15151 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15152 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15153 skip "LU-1941: FIEMAP unimplemented on ZFS"
15155 trap cleanup_130 EXIT RETURN
15157 local fm_file=$DIR/$tfile
15158 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
15160 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
15161 error "dd failed on $fm_file"
15163 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15164 filefrag_op=$(filefrag -ve -k $fm_file |
15165 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15167 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
15168 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15173 for line in $filefrag_op; do
15174 local frag_lun=$(echo $line | cut -d: -f5 |
15175 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15176 local ext_len=$(echo $line | cut -d: -f4)
15177 if (( $frag_lun != $last_lun )); then
15178 local logical=$(echo $line | cut -d: -f2 | cut -d. -f1)
15179 if (( logical != 512 )); then
15180 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
15183 if (( tot_len != 512 )); then
15184 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
15187 (( num_luns += 1 ))
15191 (( tot_len += ext_len ))
15194 if (( num_luns != 2 || tot_len != 512 )); then
15195 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
15199 echo "FIEMAP on 2-stripe file with hole succeeded"
15201 run_test 130c "FIEMAP (2-stripe file with hole)"
15204 (( $OSTCOUNT >= 3 )) || skip "needs >= 3 OSTs"
15206 filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15207 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15208 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15209 skip "LU-1941: FIEMAP unimplemented on ZFS"
15211 trap cleanup_130 EXIT RETURN
15213 local fm_file=$DIR/$tfile
15214 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
15215 error "setstripe on $fm_file"
15217 local actual_stripe_count=$($LFS getstripe -c $fm_file)
15218 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
15219 error "dd failed on $fm_file"
15221 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15222 filefrag_op=$(filefrag -ve -k $fm_file |
15223 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15225 local last_lun=$(echo $filefrag_op | cut -d: -f5 |
15226 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15231 for line in $filefrag_op; do
15232 local frag_lun=$(echo $line | cut -d: -f5 |
15233 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
15234 local ext_len=$(echo $line | cut -d: -f4)
15235 if (( $frag_lun != $last_lun )); then
15236 if (( tot_len != 1024 )); then
15237 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
15240 (( num_luns += 1 ))
15244 (( tot_len += ext_len ))
15247 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
15248 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
15252 echo "FIEMAP on N-stripe file succeeded"
15254 run_test 130d "FIEMAP (N-stripe file)"
15257 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
15259 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15260 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15261 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15262 skip "LU-1941: FIEMAP unimplemented on ZFS"
15264 trap cleanup_130 EXIT RETURN
15266 local fm_file=$DIR/$tfile
15267 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
15268 stack_trap "rm -f $fm_file"
15271 local expected_len=$(( (num_blks / 2) * 64 ))
15272 for ((i = 0; i < $num_blks; i++)); do
15273 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
15274 conv=notrunc > /dev/null 2>&1
15277 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15278 filefrag_op=$(filefrag -ve -k $fm_file |
15279 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
15281 local last_lun=$(echo $filefrag_op | cut -d: -f5)
15286 for line in $filefrag_op; do
15287 local frag_lun=$(echo $line | cut -d: -f5)
15288 local ext_len=$(echo $line | cut -d: -f4)
15289 if (( $frag_lun != $last_lun )); then
15290 if (( tot_len != $expected_len )); then
15291 error "OST$last_lun $tot_len != $expected_len"
15293 (( num_luns += 1 ))
15297 (( tot_len += ext_len ))
15300 if (( num_luns != 2 || tot_len != $expected_len )); then
15301 error "OST$last_lun $num_luns != 2, $tot_len != $expected_len"
15304 echo "FIEMAP with continuation calls succeeded"
15306 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
15309 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15310 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15311 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15312 skip "LU-1941: FIEMAP unimplemented on ZFS"
15314 local fm_file=$DIR/$tfile
15315 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
15316 error "multiop create with lov_delay_create on $fm_file"
15318 filefrag -ves $fm_file || error "filefrag $fm_file failed"
15319 filefrag_extents=$(filefrag -vek $fm_file |
15320 awk '/extents? found/ { print $2 }')
15321 if (( $filefrag_extents != 0 )); then
15322 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
15327 run_test 130f "FIEMAP (unstriped file)"
15330 (( $MDS1_VERSION >= $(version_code 2.12.53) )) ||
15331 skip "Need MDS version with at least 2.12.53 for overstriping"
15332 local filefrag_op=$(filefrag -l 2>&1 | grep "invalid option")
15333 [[ -z "$filefrag_op" ]] || skip_env "filefrag missing logical ordering"
15334 [[ "$ost1_FSTYPE" != "zfs" ]] ||
15335 skip "LU-1941: FIEMAP unimplemented on ZFS"
15337 local file=$DIR/$tfile
15338 local nr=$((OSTCOUNT * 100))
15340 $LFS setstripe -C $nr -S1M $file ||
15341 error "failed to setstripe -C $nr $file"
15343 stack_trap "rm -f $file"
15344 dd if=/dev/zero of=$file count=$nr bs=1M
15346 nr=$($LFS getstripe -c $file)
15348 local extents=$(filefrag -v $file |
15349 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
15351 echo "filefrag list $extents extents in file with stripecount $nr"
15352 if (( extents < nr )); then
15353 $LFS getstripe $file
15355 error "filefrag printed $extents < $nr extents"
15358 run_test 130g "FIEMAP (overstripe file)"
15360 # Test for writev/readv
15362 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
15363 error "writev test failed"
15364 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
15365 error "readv failed"
15368 run_test 131a "test iov's crossing stripe boundary for writev/readv"
15371 local fsize=$((524288 + 1048576 + 1572864))
15372 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
15373 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
15374 error "append writev test failed"
15376 ((fsize += 1572864 + 1048576))
15377 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
15378 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
15379 error "append writev test failed"
15382 run_test 131b "test append writev"
15385 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
15388 run_test 131c "test read/write on file w/o objects"
15391 rwv -f $DIR/$tfile -w -n 1 1572864
15392 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
15393 if [ "$NOB" != 1572864 ]; then
15394 error "Short read filed: read $NOB bytes instead of 1572864"
15398 run_test 131d "test short read"
15401 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
15402 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
15403 error "read hitting hole failed"
15406 run_test 131e "test read hitting hole"
15414 # open 11 samples [usecs] 468 4793 13658 35791898
15416 mds*) res=($(do_facet $facet \
15417 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op"))
15419 ost*) res=($(do_facet $facet \
15420 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op"))
15422 *) error "Wrong facet '$facet'" ;;
15424 [[ -n "$res" ]] || error "counter for $op on $facet not incremented"
15425 # if $want is zero, it means any stat increment is ok.
15426 if (( $want > 0 )); then
15427 local count=${res[1]}
15429 if (( $count != $want )); then
15430 if [[ $facet =~ "mds" ]]; then
15431 do_nodes $(comma_list $(mdts_nodes)) \
15432 $LCTL get_param mdt.*.md_stats
15434 do_nodes $(comma_list $(osts-nodes)) \
15435 $LCTL get_param obdfilter.*.stats
15437 error "The $op counter on $facet is $count, not $want"
15443 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15444 remote_ost_nodsh && skip "remote OST with nodsh"
15445 remote_mds_nodsh && skip "remote MDS with nodsh"
15446 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
15447 skip_env "MDS doesn't support rename stats"
15449 local testdir=$DIR/${tdir}/stats_testdir
15451 mkdir -p $DIR/${tdir}
15454 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15455 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
15457 # verify mdt stats first.
15458 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
15459 check_stats $SINGLEMDS "mkdir" 1
15461 # clear "open" from "lfs mkdir" above
15462 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15463 touch ${testdir}/${tfile} || error "touch failed"
15464 check_stats $SINGLEMDS "open" 1
15465 check_stats $SINGLEMDS "close" 1
15466 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
15467 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
15468 check_stats $SINGLEMDS "mknod" 2
15470 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
15471 check_stats $SINGLEMDS "unlink" 1
15472 rm -f ${testdir}/${tfile} || error "file remove failed"
15473 check_stats $SINGLEMDS "unlink" 2
15475 # remove working dir and check mdt stats again.
15476 rmdir ${testdir} || error "rmdir failed"
15477 check_stats $SINGLEMDS "rmdir" 1
15479 local testdir1=$DIR/${tdir}/stats_testdir1
15480 mkdir_on_mdt0 -p ${testdir}
15481 mkdir_on_mdt0 -p ${testdir1}
15482 touch ${testdir1}/test1
15483 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
15484 check_stats $SINGLEMDS "crossdir_rename" 1
15486 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
15487 check_stats $SINGLEMDS "samedir_rename" 1
15489 rm -rf $DIR/${tdir}
15491 run_test 133a "Verifying MDT stats ========================================"
15496 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15497 remote_ost_nodsh && skip "remote OST with nodsh"
15498 remote_mds_nodsh && skip "remote MDS with nodsh"
15500 local testdir=$DIR/${tdir}/stats_testdir
15502 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15503 mkdir_on_mdt0 ${testdir} || error "mkdir_on_mdt0 failed"
15504 touch ${testdir}/${tfile} || error "touch failed"
15505 cancel_lru_locks mdc
15508 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15509 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
15511 # extra mdt stats verification.
15512 chmod 444 ${testdir}/${tfile} || error "chmod failed"
15513 check_stats $SINGLEMDS "setattr" 1
15514 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15515 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
15517 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
15518 check_stats $SINGLEMDS "getattr" 1
15520 rm -rf $DIR/${tdir}
15522 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
15523 # so the check below is not reliable
15524 [ $MDSCOUNT -eq 1 ] || return 0
15526 # Sleep to avoid a cached response.
15527 #define OBD_STATFS_CACHE_SECONDS 1
15529 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15530 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
15531 $LFS df || error "lfs failed"
15532 check_stats $SINGLEMDS "statfs" 1
15534 # check aggregated statfs (LU-10018)
15535 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
15537 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
15540 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15541 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
15543 check_stats $SINGLEMDS "statfs" 1
15545 # We want to check that the client didn't send OST_STATFS to
15546 # ost1 but the MDT also uses OST_STATFS for precreate. So some
15547 # extra care is needed here.
15548 if remote_mds; then
15549 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
15550 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
15552 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
15553 [ "$res" ] && error "OST got STATFS"
15558 run_test 133b "Verifying extra MDT stats =================================="
15561 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15562 remote_ost_nodsh && skip "remote OST with nodsh"
15563 remote_mds_nodsh && skip "remote MDS with nodsh"
15565 local testdir=$DIR/$tdir/stats_testdir
15567 test_mkdir -p $testdir
15569 # verify obdfilter stats.
15570 $LFS setstripe -c 1 -i 0 $testdir/$tfile
15572 cancel_lru_locks osc
15573 wait_delete_completed
15576 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
15577 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
15579 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
15582 cancel_lru_locks osc
15583 check_stats ost1 "write" 1
15585 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
15586 check_stats ost1 "read" 1
15588 > $testdir/$tfile || error "truncate failed"
15589 check_stats ost1 "punch" 1
15591 rm -f $testdir/$tfile || error "file remove failed"
15592 wait_delete_completed
15593 check_stats ost1 "destroy" 1
15597 run_test 133c "Verifying OST stats ========================================"
15604 while [ $value -ge 2 ]; do
15609 if [ $orig -gt $order ]; then
15617 local size=('K' 'M' 'G' 'T');
15619 local size_string=$value
15621 while [ $value -ge 1024 ]; do
15622 if [ $i -gt 3 ]; then
15623 #T is the biggest unit we get here, if that is bigger,
15625 size_string=${value}T
15628 value=$((value >> 10))
15629 if [ $value -lt 1024 ]; then
15630 size_string=${value}${size[$i]}
15639 get_rename_size() {
15641 local context=${2:-.}
15642 local sample=$(do_facet $SINGLEMDS $LCTL \
15643 get_param mdt.$FSNAME-MDT0000.rename_stats |
15644 grep -A1 $context |
15645 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
15650 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15651 remote_ost_nodsh && skip "remote OST with nodsh"
15652 remote_mds_nodsh && skip "remote MDS with nodsh"
15653 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
15654 skip_env "MDS doesn't support rename stats"
15656 local testdir1=$DIR/${tdir}/stats_testdir1
15657 local testdir2=$DIR/${tdir}/stats_testdir2
15658 mkdir -p $DIR/${tdir} || error "mkdir $tdir failed"
15660 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
15662 mkdir_on_mdt0 ${testdir1} || error "mkdir $testdir1 failed"
15663 mkdir_on_mdt0 ${testdir2} || error "mkdir $testdir2 failed"
15665 createmany -o $testdir1/test 512 || error "createmany failed"
15667 # check samedir rename size
15668 mv ${testdir1}/test0 ${testdir1}/test_0
15670 local testdir1_size=$(ls -l $DIR/${tdir} |
15671 awk '/stats_testdir1/ {print $5}')
15672 local testdir2_size=$(ls -l $DIR/${tdir} |
15673 awk '/stats_testdir2/ {print $5}')
15675 testdir1_size=$(order_2 $testdir1_size)
15676 testdir2_size=$(order_2 $testdir2_size)
15678 testdir1_size=$(size_in_KMGT $testdir1_size)
15679 testdir2_size=$(size_in_KMGT $testdir2_size)
15681 echo "source rename dir size: ${testdir1_size}"
15682 echo "target rename dir size: ${testdir2_size}"
15684 local cmd="do_facet $SINGLEMDS $LCTL "
15685 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
15687 eval $cmd || error "$cmd failed"
15688 local samedir=$($cmd | grep 'same_dir')
15689 local same_sample=$(get_rename_size $testdir1_size)
15690 [ -z "$samedir" ] && error "samedir_rename_size count error"
15691 [[ $same_sample -eq 1 ]] ||
15692 error "samedir_rename_size error $same_sample"
15693 echo "Check same dir rename stats success"
15695 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
15697 # check crossdir rename size
15698 mv ${testdir1}/test_0 ${testdir2}/test_0
15700 testdir1_size=$(ls -l $DIR/${tdir} |
15701 awk '/stats_testdir1/ {print $5}')
15702 testdir2_size=$(ls -l $DIR/${tdir} |
15703 awk '/stats_testdir2/ {print $5}')
15705 testdir1_size=$(order_2 $testdir1_size)
15706 testdir2_size=$(order_2 $testdir2_size)
15708 testdir1_size=$(size_in_KMGT $testdir1_size)
15709 testdir2_size=$(size_in_KMGT $testdir2_size)
15711 echo "source rename dir size: ${testdir1_size}"
15712 echo "target rename dir size: ${testdir2_size}"
15714 eval $cmd || error "$cmd failed"
15715 local crossdir=$($cmd | grep 'crossdir')
15716 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
15717 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
15718 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
15719 [[ $src_sample -eq 1 ]] ||
15720 error "crossdir_rename_size error $src_sample"
15721 [[ $tgt_sample -eq 1 ]] ||
15722 error "crossdir_rename_size error $tgt_sample"
15723 echo "Check cross dir rename stats success"
15724 rm -rf $DIR/${tdir}
15726 run_test 133d "Verifying rename_stats ========================================"
15729 remote_mds_nodsh && skip "remote MDS with nodsh"
15730 remote_ost_nodsh && skip "remote OST with nodsh"
15731 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15733 local testdir=$DIR/${tdir}/stats_testdir
15734 local ctr f0 f1 bs=32768 count=42 sum
15736 mkdir -p ${testdir} || error "mkdir failed"
15738 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
15740 for ctr in {write,read}_bytes; do
15742 cancel_lru_locks osc
15744 do_facet ost1 $LCTL set_param -n \
15745 "obdfilter.*.exports.clear=clear"
15747 if [ $ctr = write_bytes ]; then
15749 f1=${testdir}/${tfile}
15751 f0=${testdir}/${tfile}
15755 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
15758 cancel_lru_locks osc
15760 sum=$(do_facet ost1 $LCTL get_param \
15761 "obdfilter.*.exports.*.stats" |
15762 awk -v ctr=$ctr 'BEGIN { sum = 0 }
15763 $1 == ctr { sum += $7 }
15764 END { printf("%0.0f", sum) }')
15766 if ((sum != bs * count)); then
15767 error "Bad $ctr sum, expected $((bs * count)), got $sum"
15771 rm -rf $DIR/${tdir}
15773 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
15776 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
15777 skip "too old lustre for get_param -R ($facet_ver)"
15779 # verifying readability.
15780 $LCTL get_param -R '*' &> /dev/null
15782 # Verifing writability with badarea_io.
15783 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
15784 local skipped_params='force_lbug|changelog_mask|daemon_file'
15785 $LCTL list_param -FR '*' | grep '=' | tr -d = |
15786 egrep -v "$skipped_params" |
15787 xargs -n 1 find $proc_dirs -name |
15788 xargs -n 1 badarea_io ||
15789 error "client badarea_io failed"
15791 # remount the FS in case writes/reads /proc break the FS
15792 cleanup || error "failed to unmount"
15793 setup || error "failed to setup"
15795 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
15798 remote_mds_nodsh && skip "remote MDS with nodsh"
15799 remote_ost_nodsh && skip "remote OST with nodsh"
15801 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
15802 local proc_dirs_str=$(eval echo $proc_dirs)
15803 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
15805 for facet in mds1 ost1; do
15806 local facet_ver=$(lustre_version_code $facet)
15807 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
15808 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
15810 log "$facet: too old lustre for get_param -R"
15812 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
15813 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
15814 tr -d = | egrep -v $skipped_params |
15815 xargs -n 1 find $proc_dirs_str -name |
15816 xargs -n 1 badarea_io" ||
15817 error "$facet badarea_io failed"
15819 skip_noexit "$facet: too old lustre for get_param -R"
15823 # remount the FS in case writes/reads /proc break the FS
15824 cleanup || error "failed to unmount"
15825 setup || error "failed to setup"
15827 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
15830 remote_mds_nodsh && skip "remote MDS with nodsh"
15831 remote_ost_nodsh && skip "remote OST with nodsh"
15832 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
15833 skip "Need MDS version at least 2.9.54"
15836 for facet in client mds1 ost1; do
15837 # Get the list of files that are missing the terminating newline
15838 local plist=$(do_facet $facet
15839 $LCTL list_param -FR '*' | grep '=' | tr -d =)
15841 for ent in $plist; do
15842 local missing=$(do_facet $facet $LCTL get_param $ent \|\
15843 awk -v FS='\v' -v RS='\v\v' \
15844 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
15845 print FILENAME}'" 2>/dev/null)
15846 [ -z $missing ] || {
15847 do_facet $facet $LCTL get_param $ent | od -An -tx1
15848 error "file does not end with newline: $facet-$ent"
15853 run_test 133h "Proc files should end with newlines"
15856 remote_mds_nodsh && skip "remote MDS with nodsh"
15857 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
15858 skip "Need MDS version at least 2.7.54"
15860 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
15861 cancel_lru_locks mdc
15863 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
15864 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
15865 [ $unused -eq 0 ] || error "$unused locks are not cleared"
15868 createmany -o $DIR/$tdir/f $nr ||
15869 error "failed to create $nr files in $DIR/$tdir"
15870 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
15872 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
15873 do_facet mds1 $LCTL set_param fail_loc=0x327
15874 do_facet mds1 $LCTL set_param fail_val=500
15877 echo "sleep 10 seconds ..."
15879 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
15881 do_facet mds1 $LCTL set_param fail_loc=0
15882 do_facet mds1 $LCTL set_param fail_val=0
15883 [ $lck_cnt -lt $unused ] ||
15884 error "No locks reclaimed, before:$unused, after:$lck_cnt"
15887 unlinkmany $DIR/$tdir/f $nr
15889 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
15892 remote_mds_nodsh && skip "remote MDS with nodsh"
15893 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
15894 skip "Need MDS version at least 2.7.54"
15896 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
15897 cancel_lru_locks mdc
15899 local low_wm=$(do_facet mds1 $LCTL get_param -n \
15900 ldlm.lock_reclaim_threshold_mb)
15901 # disable reclaim temporarily
15902 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
15904 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
15905 do_facet mds1 $LCTL set_param fail_loc=0x328
15906 do_facet mds1 $LCTL set_param fail_val=500
15908 $LCTL set_param debug=+trace
15911 createmany -o $DIR/$tdir/f $nr &
15912 local create_pid=$!
15914 echo "Sleep $TIMEOUT seconds ..."
15916 if ! ps -p $create_pid > /dev/null 2>&1; then
15917 do_facet mds1 $LCTL set_param fail_loc=0
15918 do_facet mds1 $LCTL set_param fail_val=0
15919 do_facet mds1 $LCTL set_param \
15920 ldlm.lock_reclaim_threshold_mb=${low_wm}m
15921 error "createmany finished incorrectly!"
15923 do_facet mds1 $LCTL set_param fail_loc=0
15924 do_facet mds1 $LCTL set_param fail_val=0
15925 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
15926 wait $create_pid || return 1
15928 unlinkmany $DIR/$tdir/f $nr
15930 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
15933 remote_mds_nodsh && skip "remote MDS with nodsh"
15934 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15935 skip "Need MDS version at least 2.13.50"
15938 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
15940 #define OBD_FAIL_PLAIN_RECORDS 0x1319
15941 #set only one record at plain llog
15942 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
15944 ost_set_temp_seq_width_all $DATA_SEQ_MAX_WIDTH
15946 #fill already existed plain llog each 64767
15947 #wrapping whole catalog
15948 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
15950 createmany -o $DIR/$tdir/$tfile_ 64700
15951 for (( i = 0; i < 64700; i = i + 2 ))
15953 rm $DIR/$tdir/$tfile_$i &
15954 rm $DIR/$tdir/$tfile_$((i + 1)) &
15959 #waiting osp synchronization
15960 wait_delete_completed
15962 run_test 135 "Race catalog processing"
15965 remote_mds_nodsh && skip "remote MDS with nodsh"
15966 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
15967 skip "Need MDS version at least 2.13.50"
15970 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
15971 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
15972 #set only one record at plain llog
15973 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
15974 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
15976 ost_set_temp_seq_width_all $DATA_SEQ_MAX_WIDTH
15978 #fill already existed 2 plain llogs each 64767
15979 #wrapping whole catalog
15980 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
15981 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
15982 wait_delete_completed
15984 createmany -o $DIR/$tdir/$tfile_ 10
15987 do_facet $SINGLEMDS $LCTL set_param fail_val=3
15988 for (( i = 0; i < 10; i = i + 3 ))
15990 rm $DIR/$tdir/$tfile_$i &
15991 rm $DIR/$tdir/$tfile_$((i + 1)) &
15995 rm $DIR/$tdir/$tfile_$((i + 2)) &
15998 #waiting osp synchronization
15999 wait_delete_completed
16001 run_test 136 "Race catalog processing 2"
16003 test_140() { #bug-17379
16004 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16006 test_mkdir $DIR/$tdir
16007 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
16008 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
16010 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
16011 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
16013 while i=$((i + 1)); do
16015 cd $i || error "Changing to $i"
16016 ln -s ../stat stat || error "Creating stat symlink"
16017 # Read the symlink until ELOOP present,
16018 # not LBUGing the system is considered success,
16019 # we didn't overrun the stack.
16020 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
16021 if [ $ret -ne 0 ]; then
16022 if [ $ret -eq 40 ]; then
16025 error "Open stat symlink"
16031 echo "The symlink depth = $i"
16032 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
16033 error "Invalid symlink depth"
16035 # Test recursive symlink
16036 ln -s symlink_self symlink_self
16037 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
16038 echo "open symlink_self returns $ret"
16039 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
16041 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
16044 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16046 local TF="$TMP/$tfile"
16048 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16049 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
16051 cancel_lru_locks $OSC
16052 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
16053 remount_client $MOUNT
16055 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
16058 $TRUNCATE $DIR/$tfile 6000
16059 cancel_lru_locks $OSC
16060 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
16063 echo "12345" >>$DIR/$tfile
16064 cancel_lru_locks $OSC
16065 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
16068 echo "12345" >>$DIR/$tfile
16069 cancel_lru_locks $OSC
16070 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
16072 run_test 150a "truncate/append tests"
16075 check_set_fallocate_or_skip
16079 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16080 out=$(check_fallocate $DIR/$tfile 2>&1) ||
16081 skip_eopnotsupp "$out|check_fallocate failed"
16083 run_test 150b "Verify fallocate (prealloc) functionality"
16086 check_set_fallocate_or_skip
16089 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16090 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
16092 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
16093 # precomputed md5sum for 20MB of zeroes
16094 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
16095 local sum=($(md5sum $DIR/$tfile))
16097 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
16099 check_set_fallocate 1
16102 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
16103 sum=($(md5sum $DIR/$tfile))
16105 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
16107 run_test 150bb "Verify fallocate modes both zero space"
16110 check_set_fallocate_or_skip
16111 local striping="-c2"
16113 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16114 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
16115 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
16116 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
16117 local want=$((OSTCOUNT * 1048576))
16119 # Must allocate all requested space, not more than 5% extra
16120 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
16121 error "bytes $bytes is not $want"
16125 echo "verify fallocate on PFL file"
16127 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
16129 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
16130 error "Create $DIR/$tfile failed"
16131 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
16132 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
16133 want=$((512 * 1048576))
16135 # Must allocate all requested space, not more than 5% extra
16136 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
16137 error "bytes $bytes is not $want"
16139 run_test 150c "Verify fallocate Size and Blocks"
16142 check_set_fallocate_or_skip
16143 local striping="-c2"
16145 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
16147 stack_trap "rm -f $DIR/$tdir; wait_delete_completed"
16148 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
16149 error "setstripe failed"
16150 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
16151 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
16152 local want=$((OSTCOUNT * 1048576))
16154 # Must allocate all requested space, not more than 5% extra
16155 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
16156 error "bytes $bytes is not $want"
16158 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
16161 check_set_fallocate_or_skip
16165 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16166 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
16167 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
16169 # Find OST with Minimum Size
16170 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
16171 sort -un | head -1)
16173 # Get 100MB per OST of the available space to reduce run time
16174 # else 60% of the available space if we are running SLOW tests
16175 if [ $SLOW == "no" ]; then
16176 local space=$((1024 * 100 * OSTCOUNT))
16178 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
16181 fallocate -l${space}k $DIR/$tfile ||
16182 error "fallocate ${space}k $DIR/$tfile failed"
16183 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
16185 # get size immediately after fallocate. This should be correctly
16187 local size=$(stat -c '%s' $DIR/$tfile)
16188 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
16190 # Sleep for a while for statfs to get updated. And not pull from cache.
16193 echo "df after fallocate:"
16196 (( size / 1024 == space )) || error "size $size != requested $space"
16197 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
16198 error "used $used < space $space"
16200 rm $DIR/$tfile || error "rm failed"
16202 wait_delete_completed
16204 echo "df after unlink:"
16207 run_test 150e "Verify 60% of available OST space consumed by fallocate"
16212 local want_size_before=20480 # in bytes
16213 local want_blocks_before=40 # 512 sized blocks
16214 local want_blocks_after=24 # 512 sized blocks
16215 local length=$(((want_blocks_before - want_blocks_after) * 512))
16217 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
16218 skip "need at least 2.14.0 for fallocate punch"
16220 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
16221 skip "LU-14160: punch mode is not implemented on OSD ZFS"
16224 check_set_fallocate_or_skip
16225 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16227 [[ "x$DOM" == "xyes" ]] &&
16228 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
16230 echo "Verify fallocate punch: Range within the file range"
16231 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
16232 error "dd failed for bs 4096 and count 5"
16234 # Call fallocate with punch range which is within the file range
16235 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
16236 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
16237 # client must see changes immediately after fallocate
16238 size=$(stat -c '%s' $DIR/$tfile)
16239 blocks=$(stat -c '%b' $DIR/$tfile)
16241 # Verify punch worked.
16242 (( blocks == want_blocks_after )) ||
16243 error "punch failed: blocks $blocks != $want_blocks_after"
16245 (( size == want_size_before )) ||
16246 error "punch failed: size $size != $want_size_before"
16248 # Verify there is hole in file
16249 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
16250 # precomputed md5sum
16251 local expect="4a9a834a2db02452929c0a348273b4aa"
16253 cksum=($(md5sum $DIR/$tfile))
16254 [[ "${cksum[0]}" == "$expect" ]] ||
16255 error "unexpected MD5SUM after punch: ${cksum[0]}"
16257 # Start second sub-case for fallocate punch.
16258 echo "Verify fallocate punch: Range overlapping and less than blocksize"
16259 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
16260 error "dd failed for bs 4096 and count 5"
16262 # Punch range less than block size will have no change in block count
16263 want_blocks_after=40 # 512 sized blocks
16265 # Punch overlaps two blocks and less than blocksize
16266 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
16267 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
16268 size=$(stat -c '%s' $DIR/$tfile)
16269 blocks=$(stat -c '%b' $DIR/$tfile)
16271 # Verify punch worked.
16272 (( blocks == want_blocks_after )) ||
16273 error "punch failed: blocks $blocks != $want_blocks_after"
16275 (( size == want_size_before )) ||
16276 error "punch failed: size $size != $want_size_before"
16278 # Verify if range is really zero'ed out. We expect Zeros.
16279 # precomputed md5sum
16280 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
16281 cksum=($(md5sum $DIR/$tfile))
16282 [[ "${cksum[0]}" == "$expect" ]] ||
16283 error "unexpected MD5SUM after punch: ${cksum[0]}"
16285 run_test 150f "Verify fallocate punch functionality"
16293 local BS=4096 # Block size in bytes
16295 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
16296 skip "need at least 2.14.0 for fallocate punch"
16298 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
16299 skip "LU-14160: punch mode is not implemented on OSD ZFS"
16302 check_set_fallocate_or_skip
16303 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
16305 if [[ "x$DOM" == "xyes" ]]; then
16306 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
16307 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
16309 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
16310 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
16313 # Get 100MB per OST of the available space to reduce run time
16314 # else 60% of the available space if we are running SLOW tests
16315 if [ $SLOW == "no" ]; then
16316 space=$((1024 * 100 * OSTCOUNT))
16318 # Find OST with Minimum Size
16319 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
16320 sort -un | head -1)
16321 echo "min size OST: $space"
16322 space=$(((space * 60)/100 * OSTCOUNT))
16324 # space in 1k units, round to 4k blocks
16325 local blkcount=$((space * 1024 / $BS))
16327 echo "Verify fallocate punch: Very large Range"
16328 fallocate -l${space}k $DIR/$tfile ||
16329 error "fallocate ${space}k $DIR/$tfile failed"
16330 # write 1M at the end, start and in the middle
16331 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
16332 error "dd failed: bs $BS count 256"
16333 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
16334 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
16335 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
16336 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
16339 size=$(stat -c '%s' $DIR/$tfile)
16341 # gather punch length.
16342 local punch_size=$((size - (BS * 2)))
16344 echo "punch_size = $punch_size"
16345 echo "size - punch_size: $((size - punch_size))"
16346 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
16348 # Call fallocate to punch all except 2 blocks. We leave the
16349 # first and the last block
16350 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
16351 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
16352 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
16354 size_after=$(stat -c '%s' $DIR/$tfile)
16355 blocks_after=$(stat -c '%b' $DIR/$tfile)
16357 # Verify punch worked.
16358 # Size should be kept
16359 (( size == size_after )) ||
16360 error "punch failed: size $size != $size_after"
16362 # two 4k data blocks to remain plus possible 1 extra extent block
16363 (( blocks_after <= ((BS / 512) * 3) )) ||
16364 error "too many blocks remains: $blocks_after"
16366 # Verify that file has hole between the first and the last blocks
16367 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
16368 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
16370 echo "Hole at [$hole_start, $hole_end)"
16371 (( hole_start == BS )) ||
16372 error "no hole at offset $BS after punch"
16374 (( hole_end == BS + punch_size )) ||
16375 error "data at offset $hole_end < $((BS + punch_size))"
16377 run_test 150g "Verify fallocate punch on large range"
16380 local file=$DIR/$tfile
16383 check_set_fallocate_or_skip
16384 statx_supported || skip_env "Test must be statx() syscall supported"
16386 # fallocate() does not update the size information on the MDT
16387 fallocate -l 16K $file || error "failed to fallocate $file"
16388 cancel_lru_locks $OSC
16389 # STATX with cached-always mode will not send glimpse RPCs to OST,
16390 # it uses the caching attrs on the client side as much as possible.
16391 size=$($STATX --cached=always -c %s $file)
16392 [ $size == 16384 ] ||
16393 error "size after fallocate() is $size, expected 16384"
16395 run_test 150h "Verify extend fallocate updates the file size"
16397 #LU-2902 roc_hit was not able to read all values from lproc
16398 function roc_hit_init() {
16399 local list=$(comma_list $(osts_nodes))
16400 local dir=$DIR/$tdir-check
16401 local file=$dir/$tfile
16407 #use setstripe to do a write to every ost
16408 for i in $(seq 0 $((OSTCOUNT-1))); do
16409 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
16410 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
16411 idx=$(printf %04x $i)
16412 BEFORE=$(get_osd_param $list *OST*$idx stats |
16413 awk '$1 == "cache_access" {sum += $7}
16414 END { printf("%0.0f", sum) }')
16416 cancel_lru_locks osc
16417 cat $file >/dev/null
16419 AFTER=$(get_osd_param $list *OST*$idx stats |
16420 awk '$1 == "cache_access" {sum += $7}
16421 END { printf("%0.0f", sum) }')
16423 echo BEFORE:$BEFORE AFTER:$AFTER
16424 if ! let "AFTER - BEFORE == 4"; then
16426 error "roc_hit is not safe to use"
16434 function roc_hit() {
16435 local list=$(comma_list $(osts_nodes))
16436 echo $(get_osd_param $list '' stats |
16437 awk '$1 == "cache_hit" {sum += $7}
16438 END { printf("%0.0f", sum) }')
16441 function set_cache() {
16444 if [ "$2" == "off" ]; then
16447 local list=$(comma_list $(osts_nodes))
16448 set_osd_param $list '' $1_cache_enable $on
16450 cancel_lru_locks osc
16454 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16455 remote_ost_nodsh && skip "remote OST with nodsh"
16456 (( CLIENT_VERSION == OST1_VERSION )) ||
16457 skip "LU-13081: no interop testing for OSS cache"
16460 local list=$(comma_list $(osts_nodes))
16462 # check whether obdfilter is cache capable at all
16463 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
16464 skip "not cache-capable obdfilter"
16467 # check cache is enabled on all obdfilters
16468 if get_osd_param $list '' read_cache_enable | grep 0; then
16469 skip "oss cache is disabled"
16472 set_osd_param $list '' writethrough_cache_enable 1
16474 # check write cache is enabled on all obdfilters
16475 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
16476 skip "oss write cache is NOT enabled"
16481 #define OBD_FAIL_OBD_NO_LRU 0x609
16482 do_nodes $list $LCTL set_param fail_loc=0x609
16484 # pages should be in the case right after write
16485 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
16488 local BEFORE=$(roc_hit)
16489 cancel_lru_locks osc
16490 cat $DIR/$tfile >/dev/null
16491 local AFTER=$(roc_hit)
16493 do_nodes $list $LCTL set_param fail_loc=0
16495 if ! let "AFTER - BEFORE == CPAGES"; then
16496 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
16499 cancel_lru_locks osc
16500 # invalidates OST cache
16501 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
16502 set_osd_param $list '' read_cache_enable 0
16503 cat $DIR/$tfile >/dev/null
16505 # now data shouldn't be found in the cache
16507 cancel_lru_locks osc
16508 cat $DIR/$tfile >/dev/null
16510 if let "AFTER - BEFORE != 0"; then
16511 error "IN CACHE: before: $BEFORE, after: $AFTER"
16514 set_osd_param $list '' read_cache_enable 1
16517 run_test 151 "test cache on oss and controls ==============================="
16520 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16522 local TF="$TMP/$tfile"
16524 # simulate ENOMEM during write
16525 #define OBD_FAIL_OST_NOMEM 0x226
16526 lctl set_param fail_loc=0x80000226
16527 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
16529 sync || error "sync failed"
16530 lctl set_param fail_loc=0
16532 # discard client's cache
16533 cancel_lru_locks osc
16535 # simulate ENOMEM during read
16536 lctl set_param fail_loc=0x80000226
16537 cmp $TF $DIR/$tfile || error "cmp failed"
16538 lctl set_param fail_loc=0
16542 run_test 152 "test read/write with enomem ============================"
16545 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
16547 run_test 153 "test if fdatasync does not crash ======================="
16549 dot_lustre_fid_permission_check() {
16551 local ffid=$MOUNT/.lustre/fid/$fid
16554 echo "stat fid $fid"
16555 stat $ffid || error "stat $ffid failed."
16556 echo "touch fid $fid"
16557 touch $ffid || error "touch $ffid failed."
16558 echo "write to fid $fid"
16559 cat /etc/hosts > $ffid || error "write $ffid failed."
16560 echo "read fid $fid"
16561 diff /etc/hosts $ffid || error "read $ffid failed."
16562 echo "append write to fid $fid"
16563 cat /etc/hosts >> $ffid || error "append write $ffid failed."
16564 echo "rename fid $fid"
16565 mv $ffid $test_dir/$tfile.1 &&
16566 error "rename $ffid to $tfile.1 should fail."
16567 touch $test_dir/$tfile.1
16568 mv $test_dir/$tfile.1 $ffid &&
16569 error "rename $tfile.1 to $ffid should fail."
16570 rm -f $test_dir/$tfile.1
16571 echo "truncate fid $fid"
16572 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
16573 echo "link fid $fid"
16574 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
16575 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
16576 id $USER0 || skip_env "missing user $USER0"
16577 echo "setfacl fid $fid"
16578 setfacl -R -m u:$USER0:rwx $ffid ||
16579 error "setfacl $ffid failed"
16580 echo "getfacl fid $fid"
16581 getfacl $ffid || error "getfacl $ffid failed."
16583 echo "unlink fid $fid"
16584 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
16585 echo "mknod fid $fid"
16586 mknod $ffid c 1 3 && error "mknod $ffid should fail."
16588 fid=[0xf00000400:0x1:0x0]
16589 ffid=$MOUNT/.lustre/fid/$fid
16591 echo "stat non-exist fid $fid"
16592 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
16593 echo "write to non-exist fid $fid"
16594 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
16595 echo "link new fid $fid"
16596 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
16598 mkdir -p $test_dir/$tdir
16599 touch $test_dir/$tdir/$tfile
16600 fid=$($LFS path2fid $test_dir/$tdir)
16603 error "error: could not get fid for $test_dir/$dir/$tfile."
16605 ffid=$MOUNT/.lustre/fid/$fid
16608 ls $ffid || error "ls $ffid failed."
16609 echo "touch $fid/$tfile.1"
16610 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
16612 echo "touch $MOUNT/.lustre/fid/$tfile"
16613 touch $MOUNT/.lustre/fid/$tfile && \
16614 error "touch $MOUNT/.lustre/fid/$tfile should fail."
16616 echo "setxattr to $MOUNT/.lustre/fid"
16617 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
16619 echo "listxattr for $MOUNT/.lustre/fid"
16620 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
16622 echo "delxattr from $MOUNT/.lustre/fid"
16623 setfattr -x trusted.name1 $MOUNT/.lustre/fid
16625 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
16626 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
16627 error "touch invalid fid should fail."
16629 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
16630 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
16631 error "touch non-normal fid should fail."
16633 echo "rename $tdir to $MOUNT/.lustre/fid"
16634 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
16635 error "rename to $MOUNT/.lustre/fid should fail."
16637 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
16639 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
16640 local new_obf_mode=777
16642 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
16643 chmod $new_obf_mode $DIR/.lustre/fid ||
16644 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
16646 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
16647 [ $obf_mode -eq $new_obf_mode ] ||
16648 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
16650 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
16651 chmod $old_obf_mode $DIR/.lustre/fid ||
16652 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
16655 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
16656 fid=$($LFS path2fid $test_dir/$tfile-2)
16658 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
16660 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
16661 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
16662 error "create lov data thru .lustre failed"
16664 echo "cp /etc/passwd $test_dir/$tfile-2"
16665 cp /etc/passwd $test_dir/$tfile-2 ||
16666 error "copy to $test_dir/$tfile-2 failed."
16667 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
16668 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
16669 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
16671 rm -rf $test_dir/tfile.lnk
16672 rm -rf $test_dir/$tfile-2
16676 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
16677 skip "Need MDS version at least 2.4.1"
16679 local tf=$DIR/$tfile
16682 local fid=$($LFS path2fid $tf)
16683 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
16685 # check that we get the same pathname back
16688 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
16689 echo "$rootpath $fid"
16690 found=$($LFS fid2path $rootpath "$fid")
16691 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
16692 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
16695 # check wrong root path format
16696 rootpath=$MOUNT"_wrong"
16697 found=$($LFS fid2path $rootpath "$fid")
16698 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
16700 run_test 154A "lfs path2fid and fid2path basic checks"
16703 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
16704 skip "Need MDS version at least 2.4.1"
16706 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
16707 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
16708 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
16709 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
16711 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
16712 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
16714 # check that we get the same pathname
16715 echo "PFID: $PFID, name: $name"
16716 local FOUND=$($LFS fid2path $MOUNT "$PFID")
16717 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
16718 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
16719 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
16721 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
16723 run_test 154B "verify the ll_decode_linkea tool"
16726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16727 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16728 (( $MDS1_VERSION >= $(version_code 2.2.51) )) ||
16729 skip "Need MDS version at least 2.2.51"
16730 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
16732 cp /etc/hosts $DIR/$tfile
16734 fid=$($LFS path2fid $DIR/$tfile)
16736 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
16738 dot_lustre_fid_permission_check "$fid" $DIR ||
16739 error "dot lustre permission check $fid failed"
16741 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
16743 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
16745 touch $MOUNT/.lustre/file &&
16746 error "creation is not allowed under .lustre"
16748 mkdir $MOUNT/.lustre/dir &&
16749 error "mkdir is not allowed under .lustre"
16753 run_test 154a "Open-by-FID"
16756 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16757 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16758 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16759 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
16760 skip "Need MDS version at least 2.2.51"
16762 local remote_dir=$DIR/$tdir/remote_dir
16766 mkdir -p $DIR/$tdir
16767 $LFS mkdir -i $MDTIDX $remote_dir ||
16768 error "create remote directory failed"
16770 cp /etc/hosts $remote_dir/$tfile
16772 fid=$($LFS path2fid $remote_dir/$tfile)
16774 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
16776 dot_lustre_fid_permission_check "$fid" $remote_dir ||
16777 error "dot lustre permission check $fid failed"
16780 run_test 154b "Open-by-FID for remote directory"
16783 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
16784 skip "Need MDS version at least 2.4.1"
16786 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
16787 local FID1=$($LFS path2fid $DIR/$tfile.1)
16788 local FID2=$($LFS path2fid $DIR/$tfile.2)
16789 local FID3=$($LFS path2fid $DIR/$tfile.3)
16792 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
16793 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
16794 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
16796 [ "$FID" = "${!want}" ] ||
16797 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
16801 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
16803 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
16804 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
16808 run_test 154c "lfs path2fid and fid2path multiple arguments"
16811 remote_mds_nodsh && skip "remote MDS with nodsh"
16812 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
16813 skip "Need MDS version at least 2.5.53"
16815 if remote_mds; then
16816 nid=$($LCTL list_nids | sed "s/\./\\\./g")
16820 local proc_ofile="mdt.*.exports.'$nid'.open_files"
16827 local fid=$($LFS path2fid $DIR/$tfile)
16830 cmd="exec $fd<$DIR/$tfile"
16832 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
16833 echo "$fid_list" | grep "$fid"
16836 cmd="exec $fd>/dev/null"
16838 if [ $rc -ne 0 ]; then
16839 error "FID $fid not found in open files list $fid_list"
16842 run_test 154d "Verify open file fid"
16846 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
16847 skip "Need MDS version at least 2.6.50"
16849 if ls -a $MOUNT | grep -q '^\.lustre$'; then
16850 error ".lustre returned by readdir"
16853 run_test 154e ".lustre is not returned by readdir"
16856 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16858 # create parent directory on a single MDT to avoid cross-MDT hardlinks
16859 mkdir_on_mdt0 $DIR/$tdir
16860 # test dirs inherit from its stripe
16861 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
16862 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
16863 cp /etc/hosts $DIR/$tdir/foo1/$tfile
16864 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
16867 # get fid of parents
16868 local FID0=$($LFS path2fid $DIR/$tdir)
16869 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
16870 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
16871 local FID3=$($LFS path2fid $DIR)
16873 # check that path2fid --parents returns expected <parent_fid>/name
16874 # 1) test for a directory (single parent)
16875 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
16876 [ "$parent" == "$FID0/foo1" ] ||
16877 error "expected parent: $FID0/foo1, got: $parent"
16879 # 2) test for a file with nlink > 1 (multiple parents)
16880 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
16881 echo "$parent" | grep -F "$FID1/$tfile" ||
16882 error "$FID1/$tfile not returned in parent list"
16883 echo "$parent" | grep -F "$FID2/link" ||
16884 error "$FID2/link not returned in parent list"
16886 # 3) get parent by fid
16887 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
16888 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16889 echo "$parent" | grep -F "$FID1/$tfile" ||
16890 error "$FID1/$tfile not returned in parent list (by fid)"
16891 echo "$parent" | grep -F "$FID2/link" ||
16892 error "$FID2/link not returned in parent list (by fid)"
16894 # 4) test for entry in root directory
16895 parent=$($LFS path2fid --parents $DIR/f)
16896 echo "$parent" | grep -F "$FID3/f" ||
16897 error "$FID3/f not returned in parent list"
16899 # 5) test it on root directory
16900 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
16901 error "$MOUNT should not have parents"
16903 # enable xattr caching and check that linkea is correctly updated
16904 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
16905 save_lustre_params client "llite.*.xattr_cache" > $save
16906 lctl set_param llite.*.xattr_cache 1
16908 # 6.1) linkea update on rename
16909 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
16911 # get parents by fid
16912 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16913 # foo1 should no longer be returned in parent list
16914 echo "$parent" | grep -F "$FID1" &&
16915 error "$FID1 should no longer be in parent list"
16916 # the new path should appear
16917 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
16918 error "$FID2/$tfile.moved is not in parent list"
16920 # 6.2) linkea update on unlink
16921 rm -f $DIR/$tdir/foo2/link
16922 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
16923 # foo2/link should no longer be returned in parent list
16924 echo "$parent" | grep -F "$FID2/link" &&
16925 error "$FID2/link should no longer be in parent list"
16929 restore_lustre_params < $save
16932 run_test 154f "get parent fids by reading link ea"
16936 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
16937 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
16938 skip "Need MDS version at least 2.6.92"
16940 mkdir_on_mdt0 $DIR/$tdir
16941 llapi_fid_test -d $DIR/$tdir
16943 run_test 154g "various llapi FID tests"
16947 (( $CLIENT_VERSION >= $(version_code 2.15.55.1) )) ||
16948 skip "Need client at least version 2.15.55.1"
16950 # Create an empty file
16953 # Get FID (interactive mode) and save under $TMP/$tfile.log
16954 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
16955 path2fid $DIR/$tfile
16958 fid=$(cat $TMP/$tfile.log)
16959 # $fid should not be empty
16960 [[ ! -z $fid ]] || error "FID is empty"
16961 $LFS rmfid $DIR "$fid" || error "rmfid failed for $fid"
16963 run_test 154h "Verify interactive path2fid"
16965 test_155_small_load() {
16966 local temp=$TMP/$tfile
16967 local file=$DIR/$tfile
16969 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
16970 error "dd of=$temp bs=6096 count=1 failed"
16972 cancel_lru_locks $OSC
16973 cmp $temp $file || error "$temp $file differ"
16975 $TRUNCATE $temp 6000
16976 $TRUNCATE $file 6000
16977 cmp $temp $file || error "$temp $file differ (truncate1)"
16979 echo "12345" >>$temp
16980 echo "12345" >>$file
16981 cmp $temp $file || error "$temp $file differ (append1)"
16983 echo "12345" >>$temp
16984 echo "12345" >>$file
16985 cmp $temp $file || error "$temp $file differ (append2)"
16991 test_155_big_load() {
16992 remote_ost_nodsh && skip "remote OST with nodsh"
16994 local temp=$TMP/$tfile
16995 local file=$DIR/$tfile
16998 local cache_size=$(do_facet ost$((MAXI+1)) \
16999 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
17001 # LU-16042: can not get the cache size on Arm64 VM here, fallback to a
17003 if [ -z "$cache_size" ]; then
17006 local large_file_size=$((cache_size * 2))
17008 echo "OSS cache size: $cache_size KB"
17009 echo "Large file size: $large_file_size KB"
17011 [ $MAXV -le $large_file_size ] &&
17012 skip_env "max available OST size needs > $large_file_size KB"
17014 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
17016 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
17017 error "dd of=$temp bs=$large_file_size count=1k failed"
17020 cancel_lru_locks osc
17021 cmp $temp $file || error "$temp $file differ"
17027 save_writethrough() {
17028 local facets=$(get_facets OST)
17030 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
17034 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17036 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17038 save_writethrough $p
17041 set_cache writethrough on
17042 test_155_small_load
17043 restore_lustre_params < $p
17046 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
17049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17051 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17053 save_writethrough $p
17056 set_cache writethrough off
17057 test_155_small_load
17058 restore_lustre_params < $p
17061 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
17064 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17066 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17068 save_writethrough $p
17071 set_cache writethrough on
17072 test_155_small_load
17073 restore_lustre_params < $p
17076 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
17079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17081 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17083 save_writethrough $p
17086 set_cache writethrough off
17087 test_155_small_load
17088 restore_lustre_params < $p
17091 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
17094 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17096 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17098 save_writethrough $p
17101 set_cache writethrough on
17103 restore_lustre_params < $p
17106 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
17109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17111 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17113 save_writethrough $p
17116 set_cache writethrough off
17118 restore_lustre_params < $p
17121 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
17124 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17126 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17128 save_writethrough $p
17131 set_cache writethrough on
17133 restore_lustre_params < $p
17136 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
17139 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17141 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17143 save_writethrough $p
17146 set_cache writethrough off
17148 restore_lustre_params < $p
17151 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
17154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17155 remote_ost_nodsh && skip "remote OST with nodsh"
17156 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
17157 skip "stats not implemented on old servers"
17158 [ "$ost1_FSTYPE" = "zfs" ] &&
17159 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
17160 (( CLIENT_VERSION == OST1_VERSION )) ||
17161 skip "LU-13081: no interop testing for OSS cache"
17166 local file="$DIR/$tfile"
17167 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
17169 save_writethrough $p
17172 log "Turn on read and write cache"
17174 set_cache writethrough on
17176 log "Write data and read it back."
17177 log "Read should be satisfied from the cache."
17178 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17180 cancel_lru_locks osc
17181 cat $file >/dev/null
17183 if ! let "AFTER - BEFORE == CPAGES"; then
17184 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
17186 log "cache hits: before: $BEFORE, after: $AFTER"
17189 log "Read again; it should be satisfied from the cache."
17191 cancel_lru_locks osc
17192 cat $file >/dev/null
17194 if ! let "AFTER - BEFORE == CPAGES"; then
17195 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
17197 log "cache hits:: before: $BEFORE, after: $AFTER"
17200 log "Turn off the read cache and turn on the write cache"
17202 set_cache writethrough on
17204 log "Read again; it should be satisfied from the cache."
17206 cancel_lru_locks osc
17207 cat $file >/dev/null
17209 if ! let "AFTER - BEFORE == CPAGES"; then
17210 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
17212 log "cache hits:: before: $BEFORE, after: $AFTER"
17215 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
17216 # > 2.12.56 uses pagecache if cached
17217 log "Read again; it should not be satisfied from the cache."
17219 cancel_lru_locks osc
17220 cat $file >/dev/null
17222 if ! let "AFTER - BEFORE == 0"; then
17223 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
17225 log "cache hits:: before: $BEFORE, after: $AFTER"
17229 log "Write data and read it back."
17230 log "Read should be satisfied from the cache."
17231 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17233 cancel_lru_locks osc
17234 cat $file >/dev/null
17236 if ! let "AFTER - BEFORE == CPAGES"; then
17237 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
17239 log "cache hits:: before: $BEFORE, after: $AFTER"
17242 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
17243 # > 2.12.56 uses pagecache if cached
17244 log "Read again; it should not be satisfied from the cache."
17246 cancel_lru_locks osc
17247 cat $file >/dev/null
17249 if ! let "AFTER - BEFORE == 0"; then
17250 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
17252 log "cache hits:: before: $BEFORE, after: $AFTER"
17256 log "Turn off read and write cache"
17258 set_cache writethrough off
17260 log "Write data and read it back"
17261 log "It should not be satisfied from the cache."
17263 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17264 cancel_lru_locks osc
17266 cat $file >/dev/null
17268 if ! let "AFTER - BEFORE == 0"; then
17269 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
17271 log "cache hits:: before: $BEFORE, after: $AFTER"
17274 log "Turn on the read cache and turn off the write cache"
17276 set_cache writethrough off
17278 log "Write data and read it back"
17279 log "It should not be satisfied from the cache."
17281 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
17283 cancel_lru_locks osc
17284 cat $file >/dev/null
17286 if ! let "AFTER - BEFORE == 0"; then
17287 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
17289 log "cache hits:: before: $BEFORE, after: $AFTER"
17292 log "Read again; it should be satisfied from the cache."
17294 cancel_lru_locks osc
17295 cat $file >/dev/null
17297 if ! let "AFTER - BEFORE == CPAGES"; then
17298 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
17300 log "cache hits:: before: $BEFORE, after: $AFTER"
17303 restore_lustre_params < $p
17306 run_test 156 "Verification of tunables"
17309 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17310 remote_mds_nodsh && skip "remote MDS with nodsh"
17311 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
17312 skip "Need MDS version at least 2.2.0"
17314 changelog_register || error "changelog_register failed"
17315 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17316 changelog_users $SINGLEMDS | grep -q $cl_user ||
17317 error "User $cl_user not found in changelog_users"
17319 mkdir_on_mdt0 $DIR/$tdir
17322 test_mkdir -p $DIR/$tdir/pics/2008/zachy
17323 changelog_clear 0 || error "changelog_clear failed"
17324 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
17325 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
17326 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
17327 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
17328 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
17329 rm $DIR/$tdir/pics/desktop.jpg
17331 echo "verifying changelog mask"
17332 changelog_chmask "-MKDIR"
17333 changelog_chmask "-CLOSE"
17335 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
17336 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
17338 changelog_chmask "+MKDIR"
17339 changelog_chmask "+CLOSE"
17341 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
17342 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
17344 MKDIRS=$(changelog_dump | grep -c "MKDIR")
17345 CLOSES=$(changelog_dump | grep -c "CLOSE")
17346 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
17347 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
17350 echo "verifying target fid"
17351 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
17352 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
17353 [ "$fidc" == "$fidf" ] ||
17354 error "changelog '$tfile' fid $fidc != file fid $fidf"
17355 echo "verifying parent fid"
17356 # The FID returned from the Changelog may be the directory shard on
17357 # a different MDT, and not the FID returned by path2fid on the parent.
17358 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
17359 # since this is what will matter when recreating this file in the tree.
17360 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
17361 local pathp=$($LFS fid2path $MOUNT "$fidp")
17362 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
17363 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
17365 echo "getting records for $cl_user"
17366 changelog_users $SINGLEMDS
17367 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
17369 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
17370 error "changelog_clear failed"
17371 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
17372 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
17373 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
17374 error "user index expect $user_rec1 + $nclr != $user_rec2"
17376 local min0_rec=$(changelog_users $SINGLEMDS |
17377 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
17378 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
17379 awk '{ print $1; exit; }')
17381 changelog_dump | tail -n 5
17382 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
17383 [ $first_rec == $((min0_rec + 1)) ] ||
17384 error "first index should be $min0_rec + 1 not $first_rec"
17386 # LU-3446 changelog index reset on MDT restart
17387 local cur_rec1=$(changelog_users $SINGLEMDS |
17388 awk '/^current.index:/ { print $NF }')
17389 changelog_clear 0 ||
17390 error "clear all changelog records for $cl_user failed"
17391 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
17392 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
17393 error "Fail to start $SINGLEMDS"
17394 local cur_rec2=$(changelog_users $SINGLEMDS |
17395 awk '/^current.index:/ { print $NF }')
17396 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
17397 [ $cur_rec1 == $cur_rec2 ] ||
17398 error "current index should be $cur_rec1 not $cur_rec2"
17400 echo "verifying users from this test are deregistered"
17401 changelog_deregister || error "changelog_deregister failed"
17402 changelog_users $SINGLEMDS | grep -q $cl_user &&
17403 error "User '$cl_user' still in changelog_users"
17405 # lctl get_param -n mdd.*.changelog_users
17406 # current_index: 144
17407 # ID index (idle seconds)
17408 # cl3 144 (2) mask=<list>
17409 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
17410 # this is the normal case where all users were deregistered
17411 # make sure no new records are added when no users are present
17412 local last_rec1=$(changelog_users $SINGLEMDS |
17413 awk '/^current.index:/ { print $NF }')
17414 touch $DIR/$tdir/chloe
17415 local last_rec2=$(changelog_users $SINGLEMDS |
17416 awk '/^current.index:/ { print $NF }')
17417 echo "verify changelogs are off: $last_rec1 == $last_rec2"
17418 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
17420 # any changelog users must be leftovers from a previous test
17421 changelog_users $SINGLEMDS
17422 echo "other changelog users; can't verify off"
17425 run_test 160a "changelog sanity"
17427 test_160b() { # LU-3587
17428 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17429 remote_mds_nodsh && skip "remote MDS with nodsh"
17430 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
17431 skip "Need MDS version at least 2.2.0"
17433 changelog_register || error "changelog_register failed"
17434 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
17435 changelog_users $SINGLEMDS | grep -q $cl_user ||
17436 error "User '$cl_user' not found in changelog_users"
17438 local longname1=$(str_repeat a 255)
17439 local longname2=$(str_repeat b 255)
17442 echo "creating very long named file"
17443 touch $longname1 || error "create of '$longname1' failed"
17444 echo "renaming very long named file"
17445 mv $longname1 $longname2
17447 changelog_dump | grep RENME | tail -n 5
17450 run_test 160b "Verify that very long rename doesn't crash in changelog"
17453 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17454 remote_mds_nodsh && skip "remote MDS with nodsh"
17456 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
17457 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
17458 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
17459 skip "Need MDS version at least 2.5.58 or 2.5.2+"
17463 # Registration step
17464 changelog_register || error "changelog_register failed"
17467 mkdir -p $DIR/$tdir
17468 $MCREATE $DIR/$tdir/foo_160c
17469 changelog_chmask "-TRUNC"
17470 $TRUNCATE $DIR/$tdir/foo_160c 200
17471 changelog_chmask "+TRUNC"
17472 $TRUNCATE $DIR/$tdir/foo_160c 199
17473 changelog_dump | tail -n 5
17474 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
17475 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
17477 run_test 160c "verify that changelog log catch the truncate event"
17480 remote_mds_nodsh && skip "remote MDS with nodsh"
17481 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17483 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
17484 skip "Need MDS version at least 2.7.60"
17486 # Registration step
17487 changelog_register || error "changelog_register failed"
17489 mkdir -p $DIR/$tdir/migrate_dir
17490 changelog_clear 0 || error "changelog_clear failed"
17492 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
17493 changelog_dump | tail -n 5
17494 local migrates=$(changelog_dump | grep -c "MIGRT")
17495 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
17497 run_test 160d "verify that changelog log catch the migrate event"
17500 remote_mds_nodsh && skip "remote MDS with nodsh"
17503 changelog_register || error "changelog_register failed"
17505 local MDT0=$(facet_svc $SINGLEMDS)
17508 # No user (expect fail)
17509 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
17511 if [ $rc -eq 0 ]; then
17512 error "Should fail without user"
17513 elif [ $rc -ne 4 ]; then
17514 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
17517 # Delete a future user (expect fail)
17518 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
17520 if [ $rc -eq 0 ]; then
17521 error "Deleted non-existant user cl77"
17522 elif [ $rc -ne 2 ]; then
17523 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
17526 # Clear to a bad index (1 billion should be safe)
17527 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
17530 if [ $rc -eq 0 ]; then
17531 error "Successfully cleared to invalid CL index"
17532 elif [ $rc -ne 22 ]; then
17533 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
17536 run_test 160e "changelog negative testing (should return errors)"
17539 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17540 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
17541 skip "Need MDS version at least 2.10.56"
17543 local mdts=$(comma_list $(mdts_nodes))
17546 changelog_register || error "first changelog_register failed"
17547 changelog_register || error "second changelog_register failed"
17549 declare -A cl_user1
17550 declare -A cl_user2
17555 # generate some changelog records to accumulate on each MDT
17556 # use all_char because created files should be evenly distributed
17557 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17558 error "test_mkdir $tdir failed"
17559 log "$(date +%s): creating first files"
17560 for ((i = 0; i < MDSCOUNT * 2; i++)); do
17561 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
17562 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
17565 # check changelogs have been generated
17566 local start=$SECONDS
17567 local idle_time=$((MDSCOUNT * 5 + 5))
17568 local nbcl=$(changelog_dump | wc -l)
17569 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17571 for param in "changelog_max_idle_time=$idle_time" \
17573 "changelog_min_gc_interval=2" \
17574 "changelog_min_free_cat_entries=3"; do
17575 local MDT0=$(facet_svc $SINGLEMDS)
17576 local var="${param%=*}"
17577 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17579 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17580 do_nodes $mdts $LCTL set_param mdd.*.$param
17583 # force cl_user2 to be idle (1st part), but also cancel the
17584 # cl_user1 records so that it is not evicted later in the test.
17585 local sleep1=$((idle_time / 2))
17586 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
17589 # simulate changelog catalog almost full
17590 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
17591 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
17593 for i in $(seq $MDSCOUNT); do
17594 cl_users=(${CL_USERS[mds$i]})
17595 cl_user1[mds$i]="${cl_users[0]}"
17596 cl_user2[mds$i]="${cl_users[1]}"
17598 [ -n "${cl_user1[mds$i]}" ] ||
17599 error "mds$i: no user registered"
17600 [ -n "${cl_user2[mds$i]}" ] ||
17601 error "mds$i: only ${cl_user2[mds$i]} is registered"
17603 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17604 [ -n "$user_rec1" ] ||
17605 error "mds$i: User ${cl_user1[mds$i]} not registered"
17606 __changelog_clear mds$i ${cl_user1[mds$i]} +2
17607 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17608 [ -n "$user_rec2" ] ||
17609 error "mds$i: User ${cl_user1[mds$i]} not registered"
17610 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
17611 "$user_rec1 + 2 == $user_rec2"
17612 [ $((user_rec1 + 2)) == $user_rec2 ] ||
17613 error "mds$i: user ${cl_user1[mds$i]} index expected " \
17614 "$user_rec1 + 2, but is $user_rec2"
17615 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
17616 [ -n "$user_rec2" ] ||
17617 error "mds$i: User ${cl_user2[mds$i]} not registered"
17618 [ $user_rec1 == $user_rec2 ] ||
17619 error "mds$i: user ${cl_user2[mds$i]} index expected " \
17620 "$user_rec1, but is $user_rec2"
17623 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
17624 local sleep2=$((idle_time - (SECONDS - start) + 1))
17625 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
17628 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
17629 # cl_user1 should be OK because it recently processed records.
17630 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
17631 for ((i = 0; i < MDSCOUNT * 2; i++)); do
17632 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
17633 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
17636 # ensure gc thread is done
17637 for i in $(mdts_nodes); do
17638 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
17639 error "$i: GC-thread not done"
17643 for (( i = 1; i <= MDSCOUNT; i++ )); do
17644 # check cl_user1 still registered
17645 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17646 error "mds$i: User ${cl_user1[mds$i]} not registered"
17647 # check cl_user2 unregistered
17648 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17649 error "mds$i: User ${cl_user2[mds$i]} still registered"
17651 # check changelogs are present and starting at $user_rec1 + 1
17652 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17653 [ -n "$user_rec1" ] ||
17654 error "mds$i: User ${cl_user1[mds$i]} not registered"
17655 first_rec=$($LFS changelog $(facet_svc mds$i) |
17656 awk '{ print $1; exit; }')
17658 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
17659 [ $((user_rec1 + 1)) == $first_rec ] ||
17660 error "mds$i: rec $first_rec != $user_rec1 + 1"
17663 run_test 160f "changelog garbage collect (timestamped users)"
17666 remote_mds_nodsh && skip "remote MDS with nodsh"
17667 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
17668 skip "Need MDS version at least 2.14.55"
17670 local mdts=$(comma_list $(mdts_nodes))
17673 changelog_register || error "first changelog_register failed"
17674 changelog_register || error "second changelog_register failed"
17676 declare -A cl_user1
17677 declare -A cl_user2
17682 # generate some changelog records to accumulate on each MDT
17683 # use all_char because created files should be evenly distributed
17684 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17685 error "test_mkdir $tdir failed"
17686 for ((i = 0; i < MDSCOUNT; i++)); do
17687 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17688 error "create $DIR/$tdir/d$i.1 failed"
17691 # check changelogs have been generated
17692 local nbcl=$(changelog_dump | wc -l)
17693 (( $nbcl > 0 )) || error "no changelogs found"
17695 # reduce the max_idle_indexes value to make sure we exceed it
17696 for param in "changelog_max_idle_indexes=2" \
17698 "changelog_min_gc_interval=2"; do
17699 local MDT0=$(facet_svc $SINGLEMDS)
17700 local var="${param%=*}"
17701 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17703 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17704 do_nodes $mdts $LCTL set_param mdd.*.$param ||
17705 error "unable to set mdd.*.$param"
17708 local start=$SECONDS
17709 for i in $(seq $MDSCOUNT); do
17710 cl_users=(${CL_USERS[mds$i]})
17711 cl_user1[mds$i]="${cl_users[0]}"
17712 cl_user2[mds$i]="${cl_users[1]}"
17714 [ -n "${cl_user1[mds$i]}" ] ||
17715 error "mds$i: user1 is not registered"
17716 [ -n "${cl_user2[mds$i]}" ] ||
17717 error "mds$i: only ${cl_user1[mds$i]} is registered"
17719 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17720 [ -n "$user_rec1" ] ||
17721 error "mds$i: user1 ${cl_user1[mds$i]} not found"
17722 __changelog_clear mds$i ${cl_user1[mds$i]} +2
17723 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17724 [ -n "$user_rec2" ] ||
17725 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
17726 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
17727 "$user_rec1 + 2 == $user_rec2"
17728 [ $((user_rec1 + 2)) == $user_rec2 ] ||
17729 error "mds$i: user1 ${cl_user1[mds$i]} index " \
17730 "expected $user_rec1 + 2, but is $user_rec2"
17731 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
17732 [ -n "$user_rec2" ] ||
17733 error "mds$i: user2 ${cl_user2[mds$i]} not found"
17734 [ $user_rec1 == $user_rec2 ] ||
17735 error "mds$i: user2 ${cl_user2[mds$i]} index " \
17736 "expected $user_rec1, but is $user_rec2"
17739 # ensure we are past the previous changelog_min_gc_interval set above
17740 local sleep2=$((start + 2 - SECONDS))
17741 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17742 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
17743 # cl_user1 should be OK because it recently processed records.
17744 for ((i = 0; i < MDSCOUNT; i++)); do
17745 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
17746 error "create $DIR/$tdir/d$i.3 failed"
17749 # ensure gc thread is done
17750 for i in $(mdts_nodes); do
17751 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
17752 error "$i: GC-thread not done"
17756 for (( i = 1; i <= MDSCOUNT; i++ )); do
17757 # check cl_user1 still registered
17758 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17759 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
17760 # check cl_user2 unregistered
17761 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17762 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
17764 # check changelogs are present and starting at $user_rec1 + 1
17765 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17766 [ -n "$user_rec1" ] ||
17767 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
17768 first_rec=$($LFS changelog $(facet_svc mds$i) |
17769 awk '{ print $1; exit; }')
17771 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
17772 [ $((user_rec1 + 1)) == $first_rec ] ||
17773 error "mds$i: rec $first_rec != $user_rec1 + 1"
17776 run_test 160g "changelog garbage collect on idle records"
17779 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17780 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
17781 skip "Need MDS version at least 2.10.56"
17783 local mdts=$(comma_list $(mdts_nodes))
17786 changelog_register || error "first changelog_register failed"
17787 changelog_register || error "second changelog_register failed"
17789 declare -A cl_user1
17790 declare -A cl_user2
17795 # generate some changelog records to accumulate on each MDT
17796 # use all_char because created files should be evenly distributed
17797 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17798 error "test_mkdir $tdir failed"
17799 for ((i = 0; i < MDSCOUNT; i++)); do
17800 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17801 error "create $DIR/$tdir/d$i.1 failed"
17804 # check changelogs have been generated
17805 local nbcl=$(changelog_dump | wc -l)
17806 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17808 for param in "changelog_max_idle_time=10" \
17810 "changelog_min_gc_interval=2"; do
17811 local MDT0=$(facet_svc $SINGLEMDS)
17812 local var="${param%=*}"
17813 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17815 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17816 do_nodes $mdts $LCTL set_param mdd.*.$param
17819 # force cl_user2 to be idle (1st part)
17822 for i in $(seq $MDSCOUNT); do
17823 cl_users=(${CL_USERS[mds$i]})
17824 cl_user1[mds$i]="${cl_users[0]}"
17825 cl_user2[mds$i]="${cl_users[1]}"
17827 [ -n "${cl_user1[mds$i]}" ] ||
17828 error "mds$i: no user registered"
17829 [ -n "${cl_user2[mds$i]}" ] ||
17830 error "mds$i: only ${cl_user2[mds$i]} is registered"
17832 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17833 [ -n "$user_rec1" ] ||
17834 error "mds$i: User ${cl_user1[mds$i]} not registered"
17835 __changelog_clear mds$i ${cl_user1[mds$i]} +2
17836 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17837 [ -n "$user_rec2" ] ||
17838 error "mds$i: User ${cl_user1[mds$i]} not registered"
17839 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
17840 "$user_rec1 + 2 == $user_rec2"
17841 [ $((user_rec1 + 2)) == $user_rec2 ] ||
17842 error "mds$i: user ${cl_user1[mds$i]} index expected " \
17843 "$user_rec1 + 2, but is $user_rec2"
17844 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
17845 [ -n "$user_rec2" ] ||
17846 error "mds$i: User ${cl_user2[mds$i]} not registered"
17847 [ $user_rec1 == $user_rec2 ] ||
17848 error "mds$i: user ${cl_user2[mds$i]} index expected " \
17849 "$user_rec1, but is $user_rec2"
17852 # force cl_user2 to be idle (2nd part) and to reach
17853 # changelog_max_idle_time
17856 # force each GC-thread start and block then
17857 # one per MDT/MDD, set fail_val accordingly
17858 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
17859 do_nodes $mdts $LCTL set_param fail_loc=0x1316
17861 # generate more changelogs to trigger fail_loc
17862 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
17863 error "create $DIR/$tdir/${tfile}bis failed"
17865 # stop MDT to stop GC-thread, should be done in back-ground as it will
17866 # block waiting for the thread to be released and exit
17867 declare -A stop_pids
17868 for i in $(seq $MDSCOUNT); do
17870 stop_pids[mds$i]=$!
17873 for i in $(mdts_nodes); do
17876 local facets=$(facets_up_on_host $i)
17878 for facet in ${facets//,/ }; do
17879 if [[ $facet == mds* ]]; then
17883 # ensure each MDS's gc threads are still present and all in "R"
17884 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
17885 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
17886 error "$i: expected $nb GC-thread"
17888 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
17890 error "$i: GC-thread not found in R-state"
17891 # check umounts of each MDT on MDS have reached kthread_stop()
17892 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
17893 error "$i: expected $nb umount"
17895 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
17896 error "$i: umount not found in D-state"
17899 # release all GC-threads
17900 do_nodes $mdts $LCTL set_param fail_loc=0
17902 # wait for MDT stop to complete
17903 for i in $(seq $MDSCOUNT); do
17904 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
17908 # may try to check if any orphan changelog records are present
17909 # via ldiskfs/zfs and llog_reader...
17911 # re-start/mount MDTs
17912 for i in $(seq $MDSCOUNT); do
17913 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
17914 error "Fail to start mds$i"
17918 for i in $(seq $MDSCOUNT); do
17919 # check cl_user1 still registered
17920 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
17921 error "mds$i: User ${cl_user1[mds$i]} not registered"
17922 # check cl_user2 unregistered
17923 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
17924 error "mds$i: User ${cl_user2[mds$i]} still registered"
17926 # check changelogs are present and starting at $user_rec1 + 1
17927 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
17928 [ -n "$user_rec1" ] ||
17929 error "mds$i: User ${cl_user1[mds$i]} not registered"
17930 first_rec=$($LFS changelog $(facet_svc mds$i) |
17931 awk '{ print $1; exit; }')
17933 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
17934 [ $((user_rec1 + 1)) == $first_rec ] ||
17935 error "mds$i: first index should be $user_rec1 + 1, " \
17936 "but is $first_rec"
17939 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
17944 local mdts=$(comma_list $(mdts_nodes))
17946 changelog_register || error "first changelog_register failed"
17948 # generate some changelog records to accumulate on each MDT
17949 # use all_char because created files should be evenly distributed
17950 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17951 error "test_mkdir $tdir failed"
17952 for ((i = 0; i < MDSCOUNT; i++)); do
17953 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17954 error "create $DIR/$tdir/d$i.1 failed"
17957 # check changelogs have been generated
17958 local nbcl=$(changelog_dump | wc -l)
17959 [[ $nbcl -eq 0 ]] && error "no changelogs found"
17961 # simulate race between register and unregister
17962 # XXX as fail_loc is set per-MDS, with DNE configs the race
17963 # simulation will only occur for one MDT per MDS and for the
17964 # others the normal race scenario will take place
17965 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
17966 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
17967 do_nodes $mdts $LCTL set_param fail_val=1
17969 # unregister 1st user
17970 changelog_deregister &
17972 # wait some time for deregister work to reach race rdv
17974 # register 2nd user
17975 changelog_register || error "2nd user register failed"
17977 wait $pid1 || error "1st user deregister failed"
17981 declare -A LAST_REC
17982 for i in $(seq $MDSCOUNT); do
17983 if changelog_users mds$i | grep "^cl"; then
17984 # make sure new records are added with one user present
17985 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
17986 awk '/^current.index:/ { print $NF }')
17988 error "mds$i has no user registered"
17992 # generate more changelog records to accumulate on each MDT
17993 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
17994 error "create $DIR/$tdir/${tfile}bis failed"
17996 for i in $(seq $MDSCOUNT); do
17997 last_rec=$(changelog_users $SINGLEMDS |
17998 awk '/^current.index:/ { print $NF }')
17999 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
18000 [ $last_rec != ${LAST_REC[mds$i]} ] ||
18001 error "changelogs are off on mds$i"
18004 run_test 160i "changelog user register/unregister race"
18007 remote_mds_nodsh && skip "remote MDS with nodsh"
18008 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
18009 skip "Need MDS version at least 2.12.56"
18011 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
18012 stack_trap "umount $MOUNT2" EXIT
18014 changelog_register || error "first changelog_register failed"
18015 stack_trap "changelog_deregister" EXIT
18017 # generate some changelog
18018 # use all_char because created files should be evenly distributed
18019 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
18020 error "mkdir $tdir failed"
18021 for ((i = 0; i < MDSCOUNT; i++)); do
18022 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
18023 error "create $DIR/$tdir/d$i.1 failed"
18026 # open the changelog device
18027 exec 3>/dev/changelog-$FSNAME-MDT0000
18028 stack_trap "exec 3>&-" EXIT
18029 exec 4</dev/changelog-$FSNAME-MDT0000
18030 stack_trap "exec 4<&-" EXIT
18032 # umount the first lustre mount
18034 stack_trap "mount_client $MOUNT" EXIT
18036 # read changelog, which may or may not fail, but should not crash
18040 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
18041 changelog_users $SINGLEMDS | grep -q $cl_user ||
18042 error "User $cl_user not found in changelog_users"
18044 printf 'clear:'$cl_user':0' >&3
18046 run_test 160j "client can be umounted while its chanangelog is being used"
18049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18050 remote_mds_nodsh && skip "remote MDS with nodsh"
18052 mkdir -p $DIR/$tdir/1/1
18054 changelog_register || error "changelog_register failed"
18055 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
18057 changelog_users $SINGLEMDS | grep -q $cl_user ||
18058 error "User '$cl_user' not found in changelog_users"
18059 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
18060 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
18061 rmdir $DIR/$tdir/1/1 & sleep 1
18063 touch $DIR/$tdir/2/2
18064 rm -rf $DIR/$tdir/2
18069 changelog_dump | grep rmdir || error "rmdir not recorded"
18071 run_test 160k "Verify that changelog records are not lost"
18073 # Verifies that a file passed as a parameter has recently had an operation
18074 # performed on it that has generated an MTIME changelog which contains the
18075 # correct parent FID. As files might reside on a different MDT from the
18076 # parent directory in DNE configurations, the FIDs are translated to paths
18077 # before being compared, which should be identical
18078 compare_mtime_changelog() {
18086 mdtidx=$($LFS getstripe --mdt-index $file)
18087 mdtidx=$(printf "%04x" $mdtidx)
18089 # Obtain the parent FID from the MTIME changelog
18090 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
18091 [ -z "$mtime" ] && error "MTIME changelog not recorded"
18093 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
18094 [ -z "$cl_fid" ] && error "parent FID not present"
18096 # Verify that the path for the parent FID is the same as the path for
18097 # the test directory
18098 pdir=$($LFS fid2path $MOUNT "$cl_fid")
18102 [[ "${pdir%/}" == "$dir" ]] ||
18103 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
18107 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18109 remote_mds_nodsh && skip "remote MDS with nodsh"
18110 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
18111 skip "Need MDS version at least 2.13.55"
18115 changelog_register || error "changelog_register failed"
18116 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
18118 changelog_users $SINGLEMDS | grep -q $cl_user ||
18119 error "User '$cl_user' not found in changelog_users"
18121 # Clear some types so that MTIME changelogs are generated
18122 changelog_chmask "-CREAT"
18123 changelog_chmask "-CLOSE"
18125 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
18127 # Test CL_MTIME during setattr
18128 touch $DIR/$tdir/$tfile
18129 compare_mtime_changelog $DIR/$tdir/$tfile
18131 # Test CL_MTIME during close
18132 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
18133 compare_mtime_changelog $DIR/$tdir/${tfile}_2
18135 run_test 160l "Verify that MTIME changelog records contain the parent FID"
18138 remote_mds_nodsh && skip "remote MDS with nodsh" && return
18139 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
18140 skip "Need MDS version at least 2.14.51"
18147 changelog_register || error "first changelog_register failed"
18148 changelog_register || error "second changelog_register failed"
18150 cl_users=(${CL_USERS[mds1]})
18151 cl_user1="${cl_users[0]}"
18152 cl_user2="${cl_users[1]}"
18153 # generate some changelog records to accumulate on MDT0
18154 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18155 createmany -m $DIR/$tdir/$tfile 50 ||
18156 error "create $DIR/$tdir/$tfile failed"
18157 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
18160 # check changelogs have been generated
18161 local nbcl=$(changelog_dump | wc -l)
18162 [[ $nbcl -eq 0 ]] && error "no changelogs found"
18164 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
18165 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
18167 __changelog_clear mds1 $cl_user1 +10
18168 __changelog_clear mds1 $cl_user2 0 &
18171 __changelog_clear mds1 $cl_user1 0 ||
18172 error "fail to cancel record for $cl_user1"
18174 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
18176 run_test 160m "Changelog clear race"
18179 remote_mds_nodsh && skip "remote MDS with nodsh" && return
18180 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
18181 skip "Need MDS version at least 2.14.51"
18190 changelog_register || error "first changelog_register failed"
18192 cl_users=(${CL_USERS[mds1]})
18193 cl_user1="${cl_users[0]}"
18195 # generate some changelog records to accumulate on MDT0
18196 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18197 first_rec=$(changelog_users $SINGLEMDS |
18198 awk '/^current.index:/ { print $NF }')
18199 while (( last_rec < (( first_rec + 65000)) )); do
18200 createmany -m $DIR/$tdir/$tfile 10000 ||
18201 error "create $DIR/$tdir/$tfile failed"
18203 for i in $(seq 0 10000); do
18204 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
18208 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
18209 error "unlinkmany failed unlink"
18210 last_rec=$(changelog_users $SINGLEMDS |
18211 awk '/^current.index:/ { print $NF }')
18212 echo last record $last_rec
18213 (( last_rec == 0 )) && error "no changelog found"
18216 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
18217 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
18219 __changelog_clear mds1 $cl_user1 0 &
18222 __changelog_clear mds1 $cl_user1 0 ||
18223 error "fail to cancel record for $cl_user1"
18225 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
18227 run_test 160n "Changelog destroy race"
18230 local mdt="$(facet_svc $SINGLEMDS)"
18232 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
18233 remote_mds_nodsh && skip "remote MDS with nodsh"
18234 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
18235 skip "Need MDS version at least 2.14.52"
18237 changelog_register --user test_160o -m unlnk+close+open ||
18238 error "changelog_register failed"
18240 do_facet $SINGLEMDS $LCTL --device $mdt \
18241 changelog_register -u "Tt3_-#" &&
18242 error "bad symbols in name should fail"
18244 do_facet $SINGLEMDS $LCTL --device $mdt \
18245 changelog_register -u test_160o &&
18246 error "the same name registration should fail"
18248 do_facet $SINGLEMDS $LCTL --device $mdt \
18249 changelog_register -u test_160toolongname &&
18250 error "too long name registration should fail"
18252 changelog_chmask "MARK+HSM"
18253 lctl get_param mdd.*.changelog*mask
18254 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
18255 changelog_users $SINGLEMDS | grep -q $cl_user ||
18256 error "User $cl_user not found in changelog_users"
18258 echo $cl_user | grep -q test_160o ||
18259 error "User $cl_user has no specific name 'test160o'"
18262 changelog_clear 0 || error "changelog_clear failed"
18263 # generate some changelog records to accumulate on MDT0
18264 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18265 touch $DIR/$tdir/$tfile # open 1
18267 OPENS=$(changelog_dump | grep -c "OPEN")
18268 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
18270 # must be no MKDIR it wasn't set as user mask
18271 MKDIR=$(changelog_dump | grep -c "MKDIR")
18272 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
18274 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
18275 mdd.$mdt.changelog_current_mask -n)
18276 # register maskless user
18277 changelog_register || error "changelog_register failed"
18278 # effective mask should be not changed because it is not minimal
18279 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18280 mdd.$mdt.changelog_current_mask -n)
18281 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
18282 # set server mask to minimal value
18283 changelog_chmask "MARK"
18284 # check effective mask again, should be treated as DEFMASK now
18285 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18286 mdd.$mdt.changelog_current_mask -n)
18287 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
18289 if (( $MDS1_VERSION >= $(version_code 2.15.52) )) ; then
18290 # set server mask back to some value
18291 changelog_chmask "CLOSE,UNLNK"
18292 # check effective mask again, should not remain as DEFMASK
18293 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18294 mdd.$mdt.changelog_current_mask -n)
18295 [[ $mask != *"HLINK"* ]] || error "mask is still DEFMASK"
18298 do_facet $SINGLEMDS $LCTL --device $mdt \
18299 changelog_deregister -u test_160o ||
18300 error "cannot deregister by name"
18302 run_test 160o "changelog user name and mask"
18305 remote_mds_nodsh && skip "remote MDS with nodsh" && return
18306 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
18307 skip "Need MDS version at least 2.14.51"
18308 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
18314 changelog_register || error "first changelog_register failed"
18316 cl_users=(${CL_USERS[mds1]})
18317 cl_user1="${cl_users[0]}"
18319 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
18320 createmany -m $DIR/$tdir/$tfile 50 ||
18321 error "create $DIR/$tdir/$tfile failed"
18322 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
18325 # check changelogs have been generated
18326 entry_count=$(changelog_dump | wc -l)
18327 ((entry_count != 0)) || error "no changelog entries found"
18329 # remove changelog_users and check that orphan entries are removed
18331 local dev=$(mdsdevname 1)
18332 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
18333 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
18334 entry_count=$(changelog_dump | wc -l)
18335 ((entry_count == 0)) ||
18336 error "found $entry_count changelog entries, expected none"
18338 run_test 160p "Changelog orphan cleanup with no users"
18341 local mdt="$(facet_svc $SINGLEMDS)"
18344 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
18345 remote_mds_nodsh && skip "remote MDS with nodsh"
18346 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
18347 skip "Need MDS version at least 2.14.54"
18349 # set server mask to minimal value like server init does
18350 changelog_chmask "MARK"
18351 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
18352 error "changelog_register failed"
18353 # check effective mask again, should be treated as DEFMASK now
18354 mask=$(do_facet $SINGLEMDS $LCTL get_param \
18355 mdd.$mdt.changelog_current_mask -n)
18356 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
18357 error "changelog_deregister failed"
18358 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
18360 run_test 160q "changelog effective mask is DEFMASK if not set"
18363 remote_mds_nodsh && skip "remote MDS with nodsh"
18364 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
18365 skip "Need MDS version at least 2.14.55"
18367 local mdts=$(comma_list $(mdts_nodes))
18369 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
18370 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
18371 fail_val=$((24 * 3600 * 10))
18373 # Create a user which is 10 days old
18374 changelog_register || error "first changelog_register failed"
18376 declare -A cl_user1
18379 # generate some changelog records to accumulate on each MDT
18380 # use all_char because created files should be evenly distributed
18381 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
18382 error "test_mkdir $tdir failed"
18383 for ((i = 0; i < MDSCOUNT; i++)); do
18384 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
18385 error "create $DIR/$tdir/d$i.1 failed"
18388 # check changelogs have been generated
18389 local nbcl=$(changelog_dump | wc -l)
18390 (( nbcl > 0 )) || error "no changelogs found"
18392 # reduce the max_idle_indexes value to make sure we exceed it
18393 for param in "changelog_max_idle_indexes=2097446912" \
18394 "changelog_max_idle_time=2592000" \
18396 "changelog_min_gc_interval=2"; do
18397 local MDT0=$(facet_svc $SINGLEMDS)
18398 local var="${param%=*}"
18399 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
18401 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
18402 do_nodes $mdts $LCTL set_param mdd.*.$param ||
18403 error "unable to set mdd.*.$param"
18406 local start=$SECONDS
18407 for i in $(seq $MDSCOUNT); do
18408 cl_users=(${CL_USERS[mds$i]})
18409 cl_user1[mds$i]="${cl_users[0]}"
18411 [[ -n "${cl_user1[mds$i]}" ]] ||
18412 error "mds$i: no user registered"
18415 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
18416 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
18418 # ensure we are past the previous changelog_min_gc_interval set above
18419 local sleep2=$((start + 2 - SECONDS))
18420 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
18422 # Generate one more changelog to trigger GC
18423 for ((i = 0; i < MDSCOUNT; i++)); do
18424 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
18425 error "create $DIR/$tdir/d$i.3 failed"
18428 # ensure gc thread is done
18429 for node in $(mdts_nodes); do
18430 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
18431 error "$node: GC-thread not done"
18434 do_nodes $mdts $LCTL set_param fail_loc=0
18436 for (( i = 1; i <= MDSCOUNT; i++ )); do
18437 # check cl_user1 is purged
18438 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
18439 error "mds$i: User ${cl_user1[mds$i]} is registered"
18443 run_test 160s "changelog garbage collect on idle records * time"
18446 remote_mds_nodsh && skip "remote MDS with nodsh"
18447 (( $MDS1_VERSION >= $(version_code 2.15.50) )) ||
18448 skip "Need MDS version at least 2.15.50"
18450 local MDT0=$(facet_svc $SINGLEMDS)
18456 changelog_register --user user1 -m all ||
18457 error "user1 failed to register"
18459 mkdir_on_mdt0 $DIR/$tdir
18460 # create default overstripe to maximize changelog size
18461 $LFS setstripe -C 8 $DIR/$tdir || error "setstripe failed"
18462 createmany -o $DIR/$tdir/u1_ 2000 || error "createmany for user1 failed"
18463 llog_size1=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
18465 # user2 consumes less records so less space
18466 changelog_register --user user2 || error "user2 failed to register"
18467 createmany -o $DIR/$tdir/u2_ 500 || error "createmany for user2 failed"
18468 llog_size2=$(do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size)
18470 # check changelogs have been generated
18471 local nbcl=$(changelog_dump | wc -l)
18472 (( nbcl > 0 )) || error "no changelogs found"
18474 # reduce the changelog_min_gc_interval to force check
18475 for param in "changelog_gc=1" "changelog_min_gc_interval=2"; do
18476 local var="${param%=*}"
18477 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
18479 stack_trap "do_facet mds1 $LCTL set_param mdd.$MDT0.$var=$old"
18480 do_facet mds1 $LCTL set_param mdd.$MDT0.$param ||
18481 error "unable to set mdd.*.$param"
18485 cl_users=(${CL_USERS[mds1]})
18486 cl_user1="${cl_users[0]}"
18487 cl_user2="${cl_users[1]}"
18489 [[ -n $cl_user1 ]] ||
18490 error "mds1: user #1 isn't registered"
18491 [[ -n $cl_user2 ]] ||
18492 error "mds1: user #2 isn't registered"
18494 # ensure we are past the previous changelog_min_gc_interval set above
18495 local sleep2=$((start + 2 - SECONDS))
18496 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
18498 #define OBD_FAIL_MDS_CHANGELOG_ENOSPC 0x018c
18499 do_facet mds1 $LCTL set_param fail_loc=0x018c \
18500 fail_val=$(((llog_size1 + llog_size2) / 2))
18502 # Generate more changelog to trigger GC
18503 createmany -o $DIR/$tdir/u3_ 4 ||
18504 error "create failed for more files"
18506 # ensure gc thread is done
18507 wait_update_facet mds1 "pgrep chlg_gc_thread" "" 20 ||
18508 error "mds1: GC-thread not done"
18510 do_facet mds1 $LCTL set_param fail_loc=0
18512 # check cl_user1 is purged
18513 changelog_users mds1 | grep -q "$cl_user1" &&
18514 error "User $cl_user1 is registered"
18515 # check cl_user2 is not purged
18516 changelog_users mds1 | grep -q "$cl_user2" ||
18517 error "User $cl_user2 is not registered"
18519 run_test 160t "changelog garbage collect on lack of space"
18522 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18524 test_mkdir -c1 $DIR/$tdir
18525 cp /etc/hosts $DIR/$tdir/$tfile
18526 test_mkdir -c1 $DIR/$tdir/foo1
18527 test_mkdir -c1 $DIR/$tdir/foo2
18528 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
18529 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
18530 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
18531 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
18532 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
18533 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
18534 $LFS fid2path $DIR $FID
18535 error "bad link ea"
18538 rm $DIR/$tdir/foo2/zachary
18540 rm $DIR/$tdir/foo2/thor
18542 rm $DIR/$tdir/$tfile
18544 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
18545 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
18546 { $LFS fid2path $DIR $FID; error "bad link rename"; }
18547 rm $DIR/$tdir/foo2/maggie
18550 local longname=$tfile.avg_len_is_thirty_two_
18551 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
18552 error_noexit 'failed to unlink many hardlinks'" EXIT
18553 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
18554 error "failed to hardlink many files"
18555 links=$($LFS fid2path $DIR $FID | wc -l)
18556 echo -n "${links}/1000 links in link EA"
18557 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
18559 run_test 161a "link ea sanity"
18562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18563 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
18566 local remote_dir=$DIR/$tdir/remote_dir
18568 mkdir -p $DIR/$tdir
18569 $LFS mkdir -i $MDTIDX $remote_dir ||
18570 error "create remote directory failed"
18572 cp /etc/hosts $remote_dir/$tfile
18573 mkdir -p $remote_dir/foo1
18574 mkdir -p $remote_dir/foo2
18575 ln $remote_dir/$tfile $remote_dir/foo1/sofia
18576 ln $remote_dir/$tfile $remote_dir/foo2/zachary
18577 ln $remote_dir/$tfile $remote_dir/foo1/luna
18578 ln $remote_dir/$tfile $remote_dir/foo2/thor
18580 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
18582 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
18583 $LFS fid2path $DIR $FID
18584 error "bad link ea"
18587 rm $remote_dir/foo2/zachary
18589 rm $remote_dir/foo2/thor
18591 rm $remote_dir/$tfile
18593 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
18594 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
18595 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
18596 $LFS fid2path $DIR $FID
18597 error "bad link rename"
18599 rm $remote_dir/foo2/maggie
18602 local longname=filename_avg_len_is_thirty_two_
18603 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
18604 error "failed to hardlink many files"
18605 links=$($LFS fid2path $DIR $FID | wc -l)
18606 echo -n "${links}/1000 links in link EA"
18607 [[ ${links} -gt 60 ]] ||
18608 error "expected at least 60 links in link EA"
18609 unlinkmany $remote_dir/foo2/$longname 1000 ||
18610 error "failed to unlink many hardlinks"
18612 run_test 161b "link ea sanity under remote directory"
18615 remote_mds_nodsh && skip "remote MDS with nodsh"
18616 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18617 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
18618 skip "Need MDS version at least 2.1.5"
18620 # define CLF_RENAME_LAST 0x0001
18621 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
18622 changelog_register || error "changelog_register failed"
18625 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
18626 touch $DIR/$tdir/foo_161c
18627 touch $DIR/$tdir/bar_161c
18628 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
18629 changelog_dump | grep RENME | tail -n 5
18630 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
18631 changelog_clear 0 || error "changelog_clear failed"
18632 if [ x$flags != "x0x1" ]; then
18633 error "flag $flags is not 0x1"
18636 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
18637 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
18638 touch $DIR/$tdir/foo_161c
18639 touch $DIR/$tdir/bar_161c
18640 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
18641 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
18642 changelog_dump | grep RENME | tail -n 5
18643 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
18644 changelog_clear 0 || error "changelog_clear failed"
18645 if [ x$flags != "x0x0" ]; then
18646 error "flag $flags is not 0x0"
18648 echo "rename overwrite a target having nlink > 1," \
18649 "changelog record has flags of $flags"
18651 # rename doesn't overwrite a target (changelog flag 0x0)
18652 touch $DIR/$tdir/foo_161c
18653 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
18654 changelog_dump | grep RENME | tail -n 5
18655 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
18656 changelog_clear 0 || error "changelog_clear failed"
18657 if [ x$flags != "x0x0" ]; then
18658 error "flag $flags is not 0x0"
18660 echo "rename doesn't overwrite a target," \
18661 "changelog record has flags of $flags"
18663 # define CLF_UNLINK_LAST 0x0001
18664 # unlink a file having nlink = 1 (changelog flag 0x1)
18665 rm -f $DIR/$tdir/foo2_161c
18666 changelog_dump | grep UNLNK | tail -n 5
18667 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
18668 changelog_clear 0 || error "changelog_clear failed"
18669 if [ x$flags != "x0x1" ]; then
18670 error "flag $flags is not 0x1"
18672 echo "unlink a file having nlink = 1," \
18673 "changelog record has flags of $flags"
18675 # unlink a file having nlink > 1 (changelog flag 0x0)
18676 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
18677 rm -f $DIR/$tdir/foobar_161c
18678 changelog_dump | grep UNLNK | tail -n 5
18679 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
18680 changelog_clear 0 || error "changelog_clear failed"
18681 if [ x$flags != "x0x0" ]; then
18682 error "flag $flags is not 0x0"
18684 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
18686 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
18689 remote_mds_nodsh && skip "remote MDS with nodsh"
18690 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
18695 changelog_register || error "changelog_register failed"
18697 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
18698 # interfer with $MOUNT/.lustre/fid/ access
18700 [[ $? -eq 0 ]] || error "mkdir failed"
18702 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | CFS_FAIL_ONCE
18703 $LCTL set_param fail_loc=0x8000140c
18705 $LCTL set_param fail_val=5
18708 echo foofoo > $DIR/$tdir/$tfile &
18711 # wait for create to be delayed
18715 [[ $? -eq 0 ]] || error "create should be blocked"
18717 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
18718 stack_trap "rm -f $tempfile"
18719 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
18720 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
18721 # some delay may occur during ChangeLog publishing and file read just
18722 # above, that could allow file write to happen finally
18723 [[ -s $tempfile ]] && echo "file should be empty"
18725 $LCTL set_param fail_loc=0
18728 [[ $? -eq 0 ]] || error "create failed"
18730 run_test 161d "create with concurrent .lustre/fid access"
18733 local expected="$1"
18738 path=$($LFS fid2path "$@")
18741 if [ $rc -ne 0 ]; then
18742 error "path looked up of '$expected' failed: rc=$rc"
18743 elif [ "$path" != "$expected" ]; then
18744 error "path looked up '$path' instead of '$expected'"
18746 echo "FID '$fid' resolves to path '$path' as expected"
18750 test_162a() { # was test_162
18751 test_mkdir -p -c1 $DIR/$tdir/d2
18752 touch $DIR/$tdir/d2/$tfile
18753 touch $DIR/$tdir/d2/x1
18754 touch $DIR/$tdir/d2/x2
18755 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
18756 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
18758 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
18759 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
18762 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
18763 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
18764 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
18766 # softlink to wrong file
18767 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
18768 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
18769 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
18772 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
18773 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
18774 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
18775 # fid2path dir/fsname should both work
18776 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
18777 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
18779 # hardlink count: check that there are 2 links
18780 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
18781 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
18783 # hardlink indexing: remove the first link
18784 rm $DIR/$tdir/d2/p/q/r/hlink
18785 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
18787 run_test 162a "path lookup sanity"
18790 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18791 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18794 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18795 error "create striped dir failed"
18797 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
18798 tail -n 1 | awk '{print $2}')
18799 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
18801 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
18802 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
18805 for ((i=0;i<5;i++)); do
18806 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
18807 error "get fid for f$i failed"
18808 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
18810 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
18811 error "get fid for d$i failed"
18812 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
18817 run_test 162b "striped directory path lookup sanity"
18819 # LU-4239: Verify fid2path works with paths 100 or more directories deep
18821 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
18822 skip "Need MDS version at least 2.7.51"
18824 local lpath=$tdir.local
18825 local rpath=$tdir.remote
18827 test_mkdir $DIR/$lpath
18828 test_mkdir $DIR/$rpath
18830 for ((i = 0; i <= 101; i++)); do
18833 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
18834 error "get fid for local directory $DIR/$lpath failed"
18835 check_path "$DIR/$lpath" $MOUNT $FID --link 0
18838 test_mkdir $DIR/$rpath
18839 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
18840 error "get fid for remote directory $DIR/$rpath failed"
18841 check_path "$DIR/$rpath" $MOUNT $FID --link 0
18846 run_test 162c "fid2path works with paths 100 or more directories deep"
18848 oalr_event_count() {
18852 awk -v name="${FSNAME}-OST0000" \
18853 -v event="${event}" \
18854 '$1 == "TRACE" && $2 == event && $3 == name' \
18859 oalr_expect_event_count() {
18862 local expect="${3}"
18865 count=$(oalr_event_count "${event}" "${trace}")
18866 if ((count == expect)); then
18870 error_noexit "${event} event count was '${count}', expected ${expect}"
18876 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
18878 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
18882 sync # Flush previous IOs so we can count log entries.
18883 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
18884 stack_trap cleanup_165 EXIT
18888 local trace="/tmp/${tfile}.trace"
18892 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18893 skip "OFD access log unsupported"
18896 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18899 do_facet ost1 ofd_access_log_reader --list
18902 do_facet ost1 killall -TERM ofd_access_log_reader
18906 if ((rc != 0)); then
18907 error "ofd_access_log_reader exited with rc = '${rc}'"
18910 # Parse trace file for discovery events:
18911 oalr_expect_event_count alr_log_add "${trace}" 1
18912 oalr_expect_event_count alr_log_eof "${trace}" 1
18913 oalr_expect_event_count alr_log_free "${trace}" 1
18915 run_test 165a "ofd access log discovery"
18918 local trace="/tmp/${tfile}.trace"
18919 local file="${DIR}/${tfile}"
18928 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
18929 skip "OFD access log unsupported"
18932 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18935 do_facet ost1 ofd_access_log_reader --list
18937 lfs setstripe -c 1 -i 0 "${file}"
18938 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
18939 error "cannot create '${file}'"
18942 do_facet ost1 killall -TERM ofd_access_log_reader
18946 if ((rc != 0)); then
18947 error "ofd_access_log_reader exited with rc = '${rc}'"
18950 oalr_expect_event_count alr_log_entry "${trace}" 1
18952 pfid1=$($LFS path2fid "${file}")
18954 # 1 2 3 4 5 6 7 8 9 10
18955 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
18956 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
18958 echo "entry = '${entry[*]}'" >&2
18961 if [[ "${pfid1}" != "${pfid2}" ]]; then
18962 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
18966 if ((size != 1048576)); then
18967 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
18971 if [[ "${flags}" != "w" ]]; then
18972 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
18975 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
18978 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
18979 error "cannot read '${file}'"
18982 do_facet ost1 killall -TERM ofd_access_log_reader
18986 if ((rc != 0)); then
18987 error "ofd_access_log_reader exited with rc = '${rc}'"
18990 oalr_expect_event_count alr_log_entry "${trace}" 1
18992 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
18993 echo "entry = '${entry[*]}'" >&2
18996 if [[ "${pfid1}" != "${pfid2}" ]]; then
18997 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
19001 if ((size != 524288)); then
19002 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
19006 if [[ "${flags}" != "r" ]]; then
19007 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
19010 run_test 165b "ofd access log entries are produced and consumed"
19013 local trace="/tmp/${tfile}.trace"
19014 local file="${DIR}/${tdir}/${tfile}"
19016 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
19017 skip "OFD access log unsupported"
19019 test_mkdir "${DIR}/${tdir}"
19022 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
19025 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
19027 # 4096 / 64 = 64. Create twice as many entries.
19028 for ((i = 0; i < 128; i++)); do
19029 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
19030 error "cannot create file"
19035 do_facet ost1 killall -TERM ofd_access_log_reader
19038 if ((rc != 0)); then
19039 error "ofd_access_log_reader exited with rc = '${rc}'"
19042 unlinkmany "${file}-%d" 128
19044 run_test 165c "full ofd access logs do not block IOs"
19046 oal_get_read_count() {
19049 # STATS lustre-OST0001 alr_read_count 1
19051 do_facet ost1 cat "${stats}" |
19052 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
19053 END { print count; }'
19056 oal_expect_read_count() {
19061 # Ask ofd_access_log_reader to write stats.
19062 do_facet ost1 killall -USR1 ofd_access_log_reader
19064 # Allow some time for things to happen.
19067 count=$(oal_get_read_count "${stats}")
19068 if ((count == expect)); then
19072 error_noexit "bad read count, got ${count}, expected ${expect}"
19073 do_facet ost1 cat "${stats}" >&2
19078 local stats="/tmp/${tfile}.stats"
19079 local file="${DIR}/${tdir}/${tfile}"
19080 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
19082 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
19083 skip "OFD access log unsupported"
19085 test_mkdir "${DIR}/${tdir}"
19088 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
19091 lfs setstripe -c 1 -i 0 "${file}"
19093 do_facet ost1 lctl set_param "${param}=rw"
19094 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
19095 error "cannot create '${file}'"
19096 oal_expect_read_count "${stats}" 1
19098 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
19099 error "cannot read '${file}'"
19100 oal_expect_read_count "${stats}" 2
19102 do_facet ost1 lctl set_param "${param}=r"
19103 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
19104 error "cannot create '${file}'"
19105 oal_expect_read_count "${stats}" 2
19107 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
19108 error "cannot read '${file}'"
19109 oal_expect_read_count "${stats}" 3
19111 do_facet ost1 lctl set_param "${param}=w"
19112 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
19113 error "cannot create '${file}'"
19114 oal_expect_read_count "${stats}" 4
19116 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
19117 error "cannot read '${file}'"
19118 oal_expect_read_count "${stats}" 4
19120 do_facet ost1 lctl set_param "${param}=0"
19121 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
19122 error "cannot create '${file}'"
19123 oal_expect_read_count "${stats}" 4
19125 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
19126 error "cannot read '${file}'"
19127 oal_expect_read_count "${stats}" 4
19129 do_facet ost1 killall -TERM ofd_access_log_reader
19132 if ((rc != 0)); then
19133 error "ofd_access_log_reader exited with rc = '${rc}'"
19136 run_test 165d "ofd_access_log mask works"
19139 local stats="/tmp/${tfile}.stats"
19140 local file0="${DIR}/${tdir}-0/${tfile}"
19141 local file1="${DIR}/${tdir}-1/${tfile}"
19143 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
19144 skip "OFD access log unsupported"
19146 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
19148 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
19149 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
19151 lfs setstripe -c 1 -i 0 "${file0}"
19152 lfs setstripe -c 1 -i 0 "${file1}"
19155 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
19158 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
19159 error "cannot create '${file0}'"
19161 oal_expect_read_count "${stats}" 0
19163 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
19164 error "cannot create '${file1}'"
19166 oal_expect_read_count "${stats}" 1
19168 do_facet ost1 killall -TERM ofd_access_log_reader
19171 if ((rc != 0)); then
19172 error "ofd_access_log_reader exited with rc = '${rc}'"
19175 run_test 165e "ofd_access_log MDT index filter works"
19178 local trace="/tmp/${tfile}.trace"
19183 do_facet ost1 timeout 60 ofd_access_log_reader \
19184 --exit-on-close --debug=- --trace=- > "${trace}" &
19191 if ((rc != 0)); then
19192 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
19197 run_test 165f "ofd_access_log_reader --exit-on-close works"
19200 # do directio so as not to populate the page cache
19201 log "creating a 10 Mb file"
19202 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
19203 error "multiop failed while creating a file"
19204 log "starting reads"
19205 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19206 log "truncating the file"
19207 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
19208 error "multiop failed while truncating the file"
19210 kill %+ || true # reads might have finished
19211 echo "wait until dd is finished"
19213 log "removing the temporary file"
19214 rm -rf $DIR/$tfile || error "tmp file removal failed"
19216 run_test 169 "parallel read and truncate should not deadlock"
19219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19221 $LCTL clear # bug 18514
19222 $LCTL debug_daemon start $TMP/${tfile}_log_good
19224 $LCTL debug_daemon stop
19225 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
19226 error "sed failed to read log_good"
19228 $LCTL debug_daemon start $TMP/${tfile}_log_good
19230 $LCTL debug_daemon stop
19232 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
19233 error "lctl df log_bad failed"
19235 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
19236 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
19238 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
19239 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
19241 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
19242 error "bad_line good_line1 good_line2 are empty"
19244 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
19245 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
19246 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
19248 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
19249 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
19250 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
19252 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
19253 error "bad_line_new good_line_new are empty"
19255 local expected_good=$((good_line1 + good_line2*2))
19257 rm -f $TMP/${tfile}*
19258 # LU-231, short malformed line may not be counted into bad lines
19259 if [ $bad_line -ne $bad_line_new ] &&
19260 [ $bad_line -ne $((bad_line_new - 1)) ]; then
19261 error "expected $bad_line bad lines, but got $bad_line_new"
19265 if [ $expected_good -ne $good_line_new ]; then
19266 error "expected $expected_good good lines, but got $good_line_new"
19271 run_test 170 "test lctl df to handle corrupted log ====================="
19273 test_171() { # bug20592
19274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19276 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
19277 $LCTL set_param fail_loc=0x50e
19278 $LCTL set_param fail_val=3000
19279 multiop_bg_pause $DIR/$tfile O_s || true
19281 kill -USR1 $MULTIPID
19285 if dmesg | grep "recursive fault"; then
19286 error "caught a recursive fault"
19288 $LCTL set_param fail_loc=0
19291 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
19295 #define OBD_FAIL_OBD_CLEANUP 0x60e
19296 $LCTL set_param fail_loc=0x60e
19297 umount $MOUNT || error "umount $MOUNT failed"
19298 stack_trap "mount_client $MOUNT"
19300 (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )) ||
19301 error "no client OBDs are remained"
19303 $LCTL dl | while read devno state type name foo; do
19306 $LCTL --device $name cleanup
19307 $LCTL --device $name detach
19310 # skip server devices
19315 if (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )); then
19316 $LCTL dl | egrep " osc | lov | lmv | mdc "
19317 error "some client OBDs are still remained"
19321 run_test 172 "manual device removal with lctl cleanup/detach ======"
19323 # it would be good to share it with obdfilter-survey/iokit-libecho code
19324 setup_obdecho_osc () {
19327 local obdfilter_name=$2
19328 echo "Creating new osc for $obdfilter_name on $ost_nid"
19329 # make sure we can find loopback nid
19330 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
19332 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
19333 ${obdfilter_name}_osc_UUID || rc=2; }
19334 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
19335 ${obdfilter_name}_UUID $ost_nid || rc=3; }
19339 cleanup_obdecho_osc () {
19340 local obdfilter_name=$1
19341 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
19342 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
19349 local pages=${3:-64}
19354 local obd_size=$(get_obd_size $node $OBD)
19355 local page_size=$(get_page_size $node)
19356 if [[ -n "$obd_size" ]]; then
19357 local new_count=$((obd_size / (pages * page_size / 1024)))
19358 [[ $new_count -ge $count ]] || count=$new_count
19361 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
19362 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
19364 if [ $rc -eq 0 ]; then
19365 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
19366 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
19368 echo "New object id is $id"
19369 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
19371 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
19372 "test_brw $count w v $pages $id" || rc=4; }
19373 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
19375 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
19376 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
19377 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
19378 { do_facet $node "$LCTL --device ec detach" || rc=6; }
19379 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
19384 skip "obdecho on osc is no longer supported"
19386 run_test 180a "test obdecho on osc"
19389 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19390 remote_ost_nodsh && skip "remote OST with nodsh"
19392 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
19393 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
19394 error "failed to load module obdecho"
19396 local target=$(do_facet ost1 $LCTL dl |
19397 awk '/obdfilter/ { print $4; exit; }')
19399 if [ -n "$target" ]; then
19400 obdecho_test $target ost1 || error "obdecho_test failed with $?"
19402 do_facet ost1 $LCTL dl
19403 error "there is no obdfilter target on ost1"
19406 run_test 180b "test obdecho directly on obdfilter"
19408 test_180c() { # LU-2598
19409 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19410 remote_ost_nodsh && skip "remote OST with nodsh"
19411 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
19412 skip "Need MDS version at least 2.4.0"
19414 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
19415 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
19416 error "failed to load module obdecho"
19418 local target=$(do_facet ost1 $LCTL dl |
19419 awk '/obdfilter/ { print $4; exit; }')
19421 if [ -n "$target" ]; then
19422 local pages=16384 # 64MB bulk I/O RPC size
19424 obdecho_test "$target" ost1 "$pages" ||
19425 error "obdecho_test with pages=$pages failed with $?"
19427 do_facet ost1 $LCTL dl
19428 error "there is no obdfilter target on ost1"
19431 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
19433 test_181() { # bug 22177
19434 test_mkdir $DIR/$tdir
19435 # create enough files to index the directory
19436 createmany -o $DIR/$tdir/foobar 4000
19437 # print attributes for debug purpose
19440 multiop_bg_pause $DIR/$tdir D_Sc || return 1
19442 # remove the files & current working dir
19443 unlinkmany $DIR/$tdir/foobar 4000
19445 kill -USR1 $MULTIPID
19447 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
19450 run_test 181 "Test open-unlinked dir ========================"
19456 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
19458 $LCTL set_param mdc.*.rpc_stats=clear
19460 for (( i = 0; i < $tcount; i++ )) ; do
19461 mkdir $DIR/$tdir/$i
19464 for (( i = 0; i < $tcount; i++ )) ; do
19465 createmany -o $DIR/$tdir/$i/f- $fcount &
19469 for (( i = 0; i < $tcount; i++ )) ; do
19470 unlinkmany $DIR/$tdir/$i/f- $fcount &
19474 $LCTL get_param mdc.*.rpc_stats
19478 run_test 182a "Test parallel modify metadata operations from mdc"
19481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
19482 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19489 do_facet mds1 $LCTL list_param \
19490 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
19491 skip "MDS lacks parallel RPC handling"
19493 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
19495 rpc_count=$(do_facet mds1 $LCTL get_param -n \
19496 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
19499 createmany -i 0 -d $DIR/$tdir/t- $tcount
19501 for (( i = 0; i < $tcount; i++ )) ; do
19502 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
19506 delta=$((etime - stime))
19507 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
19510 for (( i = 0; i < $tcount; i++ )) ; do
19511 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
19515 delta=$((etime - stime))
19516 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
19520 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
19522 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
19525 createmany -i 0 -d $DIR/$tdir/t- $tcount
19527 for (( i = 0; i < $tcount; i++ )) ; do
19528 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
19532 delta=$((etime - stime))
19533 echo "Time for file creation $delta sec for 1 RPC sent at a time"
19536 for (( i = 0; i < $tcount; i++ )) ; do
19537 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
19541 delta=$((etime - stime))
19542 echo "Time for file removal $delta sec for 1 RPC sent at a time"
19544 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
19546 run_test 182b "Test parallel modify metadata operations from osp"
19548 test_183() { # LU-2275
19549 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19550 remote_mds_nodsh && skip "remote MDS with nodsh"
19551 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
19552 skip "Need MDS version at least 2.3.56"
19554 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
19555 echo aaa > $DIR/$tdir/$tfile
19557 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
19558 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
19560 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
19561 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
19563 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
19565 # Flush negative dentry cache
19566 touch $DIR/$tdir/$tfile
19568 # We are not checking for any leaked references here, they'll
19569 # become evident next time we do cleanup with module unload.
19572 run_test 183 "No crash or request leak in case of strange dispositions ========"
19574 # test suite 184 is for LU-2016, LU-2017
19576 check_swap_layouts_support
19578 dir0=$DIR/$tdir/$testnum
19579 test_mkdir -p -c1 $dir0
19584 $LFS setstripe -c1 $file1
19586 $LFS setstripe -c2 $file2
19588 gen1=$($LFS getstripe -g $file1)
19589 gen2=$($LFS getstripe -g $file2)
19591 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
19592 gen=$($LFS getstripe -g $file1)
19593 [[ $gen1 != $gen ]] ||
19594 error "Layout generation on $file1 does not change"
19595 gen=$($LFS getstripe -g $file2)
19596 [[ $gen2 != $gen ]] ||
19597 error "Layout generation on $file2 does not change"
19599 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
19600 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
19602 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
19604 run_test 184a "Basic layout swap"
19607 check_swap_layouts_support
19609 dir0=$DIR/$tdir/$testnum
19610 mkdir -p $dir0 || error "creating dir $dir0"
19617 $LFS setstripe -c1 $file1
19618 $LFS setstripe -c2 $file2
19619 $LFS setstripe -c1 $file3
19620 chown $RUNAS_ID $file3
19621 gen1=$($LFS getstripe -g $file1)
19622 gen2=$($LFS getstripe -g $file2)
19624 $LFS swap_layouts $dir1 $dir2 &&
19625 error "swap of directories layouts should fail"
19626 $LFS swap_layouts $dir1 $file1 &&
19627 error "swap of directory and file layouts should fail"
19628 $RUNAS $LFS swap_layouts $file1 $file2 &&
19629 error "swap of file we cannot write should fail"
19630 $LFS swap_layouts $file1 $file3 &&
19631 error "swap of file with different owner should fail"
19632 /bin/true # to clear error code
19634 run_test 184b "Forbidden layout swap (will generate errors)"
19637 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
19638 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
19639 check_swap_layouts_support
19640 check_swap_layout_no_dom $DIR
19642 local dir0=$DIR/$tdir/$testnum
19643 mkdir -p $dir0 || error "creating dir $dir0"
19645 local ref1=$dir0/ref1
19646 local ref2=$dir0/ref2
19647 local file1=$dir0/file1
19648 local file2=$dir0/file2
19649 # create a file large enough for the concurrent test
19650 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
19651 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
19652 echo "ref file size: ref1($(stat -c %s $ref1))," \
19653 "ref2($(stat -c %s $ref2))"
19656 dd if=$ref1 of=$file1 bs=16k &
19659 # Make sure dd starts to copy file, but wait at most 5 seconds
19661 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
19663 $LFS swap_layouts $file1 $file2
19666 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
19667 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
19669 # how many bytes copied before swapping layout
19670 local copied=$(stat -c %s $file2)
19671 local remaining=$(stat -c %s $ref1)
19672 remaining=$((remaining - copied))
19673 echo "Copied $copied bytes before swapping layout..."
19675 cmp -n $copied $file1 $ref2 | grep differ &&
19676 error "Content mismatch [0, $copied) of ref2 and file1"
19677 cmp -n $copied $file2 $ref1 ||
19678 error "Content mismatch [0, $copied) of ref1 and file2"
19679 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
19680 error "Content mismatch [$copied, EOF) of ref1 and file1"
19683 rm -f $ref1 $ref2 $file1 $file2
19685 run_test 184c "Concurrent write and layout swap"
19688 check_swap_layouts_support
19689 check_swap_layout_no_dom $DIR
19690 [ -z "$(which getfattr 2>/dev/null)" ] &&
19691 skip_env "no getfattr command"
19693 local file1=$DIR/$tdir/$tfile-1
19694 local file2=$DIR/$tdir/$tfile-2
19695 local file3=$DIR/$tdir/$tfile-3
19699 mkdir -p $DIR/$tdir
19700 touch $file1 || error "create $file1 failed"
19701 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
19702 error "create $file2 failed"
19703 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
19704 error "create $file3 failed"
19705 lovea1=$(get_layout_param $file1)
19707 $LFS swap_layouts $file2 $file3 ||
19708 error "swap $file2 $file3 layouts failed"
19709 $LFS swap_layouts $file1 $file2 ||
19710 error "swap $file1 $file2 layouts failed"
19712 lovea2=$(get_layout_param $file2)
19715 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
19717 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
19718 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
19720 run_test 184d "allow stripeless layouts swap"
19723 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
19724 skip "Need MDS version at least 2.6.94"
19725 check_swap_layouts_support
19726 check_swap_layout_no_dom $DIR
19727 [ -z "$(which getfattr 2>/dev/null)" ] &&
19728 skip_env "no getfattr command"
19730 local file1=$DIR/$tdir/$tfile-1
19731 local file2=$DIR/$tdir/$tfile-2
19732 local file3=$DIR/$tdir/$tfile-3
19735 mkdir -p $DIR/$tdir
19736 touch $file1 || error "create $file1 failed"
19737 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
19738 error "create $file2 failed"
19739 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
19740 error "create $file3 failed"
19742 $LFS swap_layouts $file1 $file2 ||
19743 error "swap $file1 $file2 layouts failed"
19745 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
19746 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
19748 echo 123 > $file1 || error "Should be able to write into $file1"
19750 $LFS swap_layouts $file1 $file3 ||
19751 error "swap $file1 $file3 layouts failed"
19753 echo 123 > $file1 || error "Should be able to write into $file1"
19755 rm -rf $file1 $file2 $file3
19757 run_test 184e "Recreate layout after stripeless layout swaps"
19760 # Create a file with name longer than sizeof(struct stat) ==
19761 # 144 to see if we can get chars from the file name to appear
19762 # in the returned striping. Note that 'f' == 0x66.
19763 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
19765 mkdir -p $DIR/$tdir
19766 mcreate $DIR/$tdir/$file
19767 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
19768 error "IOC_MDC_GETFILEINFO returned garbage striping"
19771 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
19773 test_185() { # LU-2441
19774 # LU-3553 - no volatile file support in old servers
19775 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
19776 skip "Need MDS version at least 2.3.60"
19778 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
19779 touch $DIR/$tdir/spoo
19780 local mtime1=$(stat -c "%Y" $DIR/$tdir)
19781 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
19782 error "cannot create/write a volatile file"
19783 [ "$FILESET" == "" ] &&
19784 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
19785 error "FID is still valid after close"
19787 multiop_bg_pause $DIR/$tdir Vw4096_c
19794 # assume that the next FID for this client is sequential, since stdout
19795 # is unfortunately eaten by multiop_bg_pause
19796 local n=$((${fidv[1]} + 1))
19797 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
19798 if [ "$FILESET" == "" ]; then
19799 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
19800 error "FID is missing before close"
19802 kill -USR1 $multi_pid
19803 # 1 second delay, so if mtime change we will see it
19805 local mtime2=$(stat -c "%Y" $DIR/$tdir)
19806 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
19808 run_test 185 "Volatile file support"
19810 function create_check_volatile() {
19814 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
19817 local FID=$(cat /tmp/${tfile}.fid)
19818 [ "$FID" == "" ] && error "can't get FID for volatile"
19819 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
19820 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
19821 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
19825 cancel_lru_locks mdc # flush opencache
19826 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
19831 # LU-12516 - volatile creation via .lustre
19832 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
19833 skip "Need MDS version at least 2.3.55"
19835 create_check_volatile 0
19836 [ $MDSCOUNT -lt 2 ] && return 0
19839 create_check_volatile 1
19843 run_test 185a "Volatile file creation in .lustre/fid/"
19846 remote_mds_nodsh && skip "remote MDS with nodsh"
19847 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
19848 skip "Need MDS version at least 2.3.0"
19850 local dir0=$DIR/$tdir/$testnum
19851 mkdir -p $dir0 || error "creating dir $dir0"
19853 local file=$dir0/file1
19854 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
19855 stack_trap "rm -f $file"
19856 local dv1=$($LFS data_version $file)
19857 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
19858 local dv2=$($LFS data_version $file)
19859 [[ $dv1 != $dv2 ]] ||
19860 error "data version did not change on write $dv1 == $dv2"
19862 run_test 187a "Test data version change"
19865 remote_mds_nodsh && skip "remote MDS with nodsh"
19866 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
19867 skip "Need MDS version at least 2.3.0"
19869 local dir0=$DIR/$tdir/$testnum
19870 mkdir -p $dir0 || error "creating dir $dir0"
19872 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
19873 [[ ${DV[0]} != ${DV[1]} ]] ||
19874 error "data version did not change on write"\
19875 " ${DV[0]} == ${DV[1]}"
19880 run_test 187b "Test data version change on volatile file"
19883 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19884 remote_mgs_nodsh && skip "remote MGS with nodsh"
19885 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19887 local POOL=${POOL:-cea1}
19888 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
19889 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
19892 local last_ost=$(($OSTCOUNT - 1))
19894 local ost_list=$(seq $first_ost $ost_step $last_ost)
19895 local ost_range="$first_ost $last_ost $ost_step"
19896 local test_path=$POOL_ROOT/$POOL_DIR_NAME
19897 local file_dir=$POOL_ROOT/file_tst
19898 local subdir=$test_path/subdir
19902 # former test_200a test_200b
19903 pool_add $POOL || { rc=$? ; break; }
19904 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
19905 # former test_200c test_200d
19906 mkdir -p $test_path
19907 pool_set_dir $POOL $test_path || { rc=$? ; break; }
19908 pool_check_dir $POOL $test_path || { rc=$? ; break; }
19910 pool_check_dir $POOL $subdir || { rc=$? ; break; }
19911 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
19912 || { rc=$? ; break; }
19913 # former test_200e test_200f
19914 local files=$((OSTCOUNT*3))
19915 pool_alloc_files $POOL $test_path $files "$ost_list" \
19916 || { rc=$? ; break; }
19917 pool_create_files $POOL $file_dir $files "$ost_list" \
19918 || { rc=$? ; break; }
19919 # former test_200g test_200h
19920 pool_lfs_df $POOL || { rc=$? ; break; }
19921 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
19923 # former test_201a test_201b test_201c
19924 pool_remove_first_target $POOL || { rc=$? ; break; }
19926 local f=$test_path/$tfile
19927 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
19928 pool_remove $POOL $f || { rc=$? ; break; }
19936 run_test 200 "OST pools"
19938 # usage: default_attr <count | size | offset>
19940 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
19943 # usage: check_default_stripe_attr
19944 check_default_stripe_attr() {
19945 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
19948 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
19950 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
19954 error "unknown getstripe attr '$1'"
19957 [ $ACTUAL == $EXPECTED ] ||
19958 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
19962 test_mkdir $DIR/$tdir
19963 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
19965 check_default_stripe_attr --stripe-count
19966 check_default_stripe_attr --stripe-size
19967 check_default_stripe_attr --stripe-index
19969 run_test 204a "Print default stripe attributes"
19972 test_mkdir $DIR/$tdir
19973 $LFS setstripe --stripe-count 1 $DIR/$tdir
19975 check_default_stripe_attr --stripe-size
19976 check_default_stripe_attr --stripe-index
19978 run_test 204b "Print default stripe size and offset"
19981 test_mkdir $DIR/$tdir
19982 $LFS setstripe --stripe-size 65536 $DIR/$tdir
19984 check_default_stripe_attr --stripe-count
19985 check_default_stripe_attr --stripe-index
19987 run_test 204c "Print default stripe count and offset"
19990 test_mkdir $DIR/$tdir
19991 $LFS setstripe --stripe-index 0 $DIR/$tdir
19993 check_default_stripe_attr --stripe-count
19994 check_default_stripe_attr --stripe-size
19996 run_test 204d "Print default stripe count and size"
19999 test_mkdir $DIR/$tdir
20000 $LFS setstripe -d $DIR/$tdir
20002 # LU-16904 check if root is set as PFL layout
20003 local numcomp=$($LFS getstripe --component-count $MOUNT)
20005 if [[ $numcomp -gt 0 ]]; then
20006 check_default_stripe_attr --stripe-count
20008 check_default_stripe_attr --stripe-count --raw
20010 check_default_stripe_attr --stripe-size --raw
20011 check_default_stripe_attr --stripe-index --raw
20013 run_test 204e "Print raw stripe attributes"
20016 test_mkdir $DIR/$tdir
20017 $LFS setstripe --stripe-count 1 $DIR/$tdir
20019 check_default_stripe_attr --stripe-size --raw
20020 check_default_stripe_attr --stripe-index --raw
20022 run_test 204f "Print raw stripe size and offset"
20025 test_mkdir $DIR/$tdir
20026 $LFS setstripe --stripe-size 65536 $DIR/$tdir
20028 check_default_stripe_attr --stripe-count --raw
20029 check_default_stripe_attr --stripe-index --raw
20031 run_test 204g "Print raw stripe count and offset"
20034 test_mkdir $DIR/$tdir
20035 $LFS setstripe --stripe-index 0 $DIR/$tdir
20037 check_default_stripe_attr --stripe-count --raw
20038 check_default_stripe_attr --stripe-size --raw
20040 run_test 204h "Print raw stripe count and size"
20042 # Figure out which job scheduler is being used, if any,
20043 # or use a fake one
20044 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
20045 JOBENV=SLURM_JOB_ID
20046 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
20048 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
20050 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
20051 JOBENV=LOADL_STEP_ID
20052 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
20055 $LCTL list_param jobid_name > /dev/null 2>&1
20056 if [ $? -eq 0 ]; then
20062 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
20064 verify_jobstats() {
20069 # we don't really need to clear the stats for this test to work, since each
20070 # command has a unique jobid, but it makes debugging easier if needed.
20071 # for facet in $facets; do
20072 # local dev=$(convert_facet2label $facet)
20073 # # clear old jobstats
20074 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
20077 # use a new JobID for each test, or we might see an old one
20078 [ "$JOBENV" = "FAKE_JOBID" ] &&
20079 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
20081 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
20083 [ "$JOBENV" = "nodelocal" ] && {
20084 FAKE_JOBID=id.$testnum.%e.$RANDOM
20085 $LCTL set_param jobid_name=$FAKE_JOBID
20086 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
20089 log "Test: ${cmd[*]}"
20090 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
20092 if [ $JOBENV = "FAKE_JOBID" ]; then
20093 FAKE_JOBID=$JOBVAL ${cmd[*]}
20098 # all files are created on OST0000
20099 for facet in $facets; do
20100 local stats="*.$(convert_facet2label $facet).job_stats"
20102 # strip out libtool wrappers for in-tree executables
20103 if (( $(do_facet $facet lctl get_param $stats |
20104 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
20105 do_facet $facet lctl get_param $stats
20106 error "No jobstats for $JOBVAL found on $facet::$stats"
20112 local new_jobenv=$1
20114 set_persistent_param_and_check client "jobid_var" \
20115 "$FSNAME.sys.jobid_var" $new_jobenv
20118 test_205a() { # Job stats
20119 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20120 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
20121 skip "Need MDS version with at least 2.7.1"
20122 remote_mgs_nodsh && skip "remote MGS with nodsh"
20123 remote_mds_nodsh && skip "remote MDS with nodsh"
20124 remote_ost_nodsh && skip "remote OST with nodsh"
20125 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
20126 skip "Server doesn't support jobstats"
20127 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
20129 local old_jobenv=$($LCTL get_param -n jobid_var)
20130 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
20131 stack_trap "jobstats_set $old_jobenv" EXIT
20135 local old_jobid_name=$($LCTL get_param jobid_name)
20136 stack_trap "$LCTL set_param $old_jobid_name" EXIT
20138 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
20139 mdt.*.job_cleanup_interval | head -n 1)
20140 local new_interval=5
20141 do_facet $SINGLEMDS \
20142 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
20143 stack_trap "do_facet $SINGLEMDS \
20144 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
20145 local start=$SECONDS
20149 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
20150 verify_jobstats "$cmd" "$SINGLEMDS"
20152 cmd="rmdir $DIR/$tdir"
20153 verify_jobstats "$cmd" "$SINGLEMDS"
20154 # mkdir on secondary MDT
20155 if [ $MDSCOUNT -gt 1 ]; then
20156 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
20157 verify_jobstats "$cmd" "mds2"
20160 cmd="mknod $DIR/$tfile c 1 3"
20161 verify_jobstats "$cmd" "$SINGLEMDS"
20163 cmd="rm -f $DIR/$tfile"
20164 verify_jobstats "$cmd" "$SINGLEMDS"
20165 # create all files on OST0000 so verify_jobstats can find OST stats
20167 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
20168 verify_jobstats "$cmd" "$SINGLEMDS"
20170 cmd="touch $DIR/$tfile"
20171 verify_jobstats "$cmd" "$SINGLEMDS ost1"
20173 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
20174 verify_jobstats "$cmd" "ost1"
20176 cancel_lru_locks osc
20177 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
20178 verify_jobstats "$cmd" "ost1"
20180 cmd="$TRUNCATE $DIR/$tfile 0"
20181 verify_jobstats "$cmd" "$SINGLEMDS ost1"
20183 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
20184 verify_jobstats "$cmd" "$SINGLEMDS"
20185 # jobstats expiry - sleep until old stats should be expired
20186 local left=$((new_interval + 5 - (SECONDS - start)))
20187 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
20188 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
20190 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
20191 verify_jobstats "$cmd" "$SINGLEMDS"
20192 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
20193 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
20195 # Ensure that jobid are present in changelog (if supported by MDS)
20196 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
20197 changelog_dump | tail -10
20198 jobids=$(changelog_dump | tail -9 | grep -c "j=")
20199 [ $jobids -eq 9 ] ||
20200 error "Wrong changelog jobid count $jobids != 9"
20204 jobstats_set $JOBENV
20206 changelog_dump | grep $tfile
20207 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
20208 [ $jobids -eq 0 ] ||
20209 error "Unexpected jobids when jobid_var=$JOBENV"
20212 # test '%j' access to environment variable - if supported
20213 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
20214 JOBENV="JOBCOMPLEX"
20215 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
20217 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
20220 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
20221 JOBENV="JOBCOMPLEX"
20222 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
20224 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
20227 # test '%j' access to per-session jobid - if supported
20228 if lctl list_param jobid_this_session > /dev/null 2>&1
20230 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
20231 lctl set_param jobid_this_session=$USER
20233 JOBENV="JOBCOMPLEX"
20234 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
20236 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
20239 run_test 205a "Verify job stats"
20241 # LU-13117, LU-13597, LU-16599
20243 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
20244 skip "Need MDS version at least 2.13.54.91"
20246 local job_stats="mdt.*.job_stats"
20247 local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
20249 do_facet mds1 $LCTL set_param $job_stats=clear
20251 # Setting jobid_var to USER might not be supported
20252 [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
20253 $LCTL set_param jobid_var=USER || true
20254 stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
20255 $LCTL set_param jobid_name="%j.%e.%u"
20257 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
20258 do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
20259 { do_facet mds1 $LCTL get_param $job_stats;
20260 error "Unexpected jobid found"; }
20261 do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
20262 { do_facet mds1 $LCTL get_param $job_stats;
20263 error "wrong job_stats format found"; }
20265 (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
20266 echo "MDS does not yet escape jobid" && return 0
20268 mkdir_on_mdt0 $DIR/$tdir
20269 $LCTL set_param jobid_var=TEST205b
20270 env -i TEST205b="has sp" touch $DIR/$tdir/$tfile.2
20271 local jobid=$(do_facet mds1 $LCTL get_param $job_stats |
20272 awk '/has\\x20sp/ {print $3}')
20273 [[ -n "$jobid" ]] || { do_facet mds1 $LCTL get_param $job_stats;
20274 error "jobid not escaped"; }
20276 if (( $MDS1_VERSION >= $(version_code 2.15.53.139) )); then
20277 # need to run such a command on mds1:
20278 # lctl set_param mdt.$FSNAME-MDT0000.job_stats='"has\x20sp.touch.0"'
20280 # there might be multiple MDTs on single mds server, so need to
20281 # specifiy MDT0000. Or the command will fail due to other MDTs
20282 do_facet_vp mds1 $LCTL set_param mdt.$FSNAME-MDT0000.job_stats=$jobid ||
20283 error "cannot clear escaped jobid in job_stats";
20285 echo "MDS does not support clearing escaped jobid"
20288 run_test 205b "Verify job stats jobid and output format"
20292 $LCTL set_param llite.*.stats=0
20293 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
20294 $LCTL get_param llite.*.stats
20295 $LCTL get_param llite.*.stats | grep \
20296 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
20297 error "wrong client stats format found"
20299 run_test 205c "Verify client stats format"
20302 local file=$DIR/$tdir/$tfile
20304 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
20305 skip "need lustre >= 2.15.53 for lljobstat"
20306 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
20307 skip "need lustre >= 2.15.53 for lljobstat"
20308 verify_yaml_available || skip_env "YAML verification not installed"
20310 test_mkdir -i 0 $DIR/$tdir
20311 $LFS setstripe -E 1M -L mdt -E -1 $file || error "create file failed"
20312 stack_trap "rm -rf $DIR/$tdir"
20314 dd if=/dev/zero of=$file bs=1M count=10 conv=sync ||
20315 error "failed to write data to $file"
20318 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats"
20319 echo -n 'verify rename_stats...'
20320 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats" |
20321 verify_yaml || error "rename_stats is not valid YAML"
20324 echo -n 'verify mdt job_stats...'
20325 do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.job_stats" |
20326 verify_yaml || error "job_stats on mds1 is not valid YAML"
20329 echo -n 'verify ost job_stats...'
20330 do_facet ost1 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.job_stats" |
20331 verify_yaml || error "job_stats on ost1 is not valid YAML"
20334 run_test 205d "verify the format of some stats files"
20338 local file=$DIR/$tdir/$tfile
20339 local -a cli_params
20341 (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
20342 skip "need lustre >= 2.15.53 for lljobstat"
20343 (( $OST1_VERSION >= $(version_code 2.15.53) )) ||
20344 skip "need lustre >= 2.15.53 for lljobstat"
20345 verify_yaml_available || skip_env "YAML verification not installed"
20347 cli_params=( $($LCTL get_param jobid_name jobid_var) )
20348 $LCTL set_param jobid_var=nodelocal jobid_name=205e.%e.%u
20349 stack_trap "$LCTL set_param ${cli_params[*]}" EXIT
20351 mkdir_on_mdt0 $DIR/$tdir || error "failed to create dir"
20352 stack_trap "rm -rf $DIR/$tdir"
20354 $LFS setstripe -E EOF -i 0 -c 1 $file ||
20355 error "failed to create $file on ost1"
20356 dd if=/dev/zero of=$file bs=1M count=10 oflag=sync ||
20357 error "failed to write data to $file"
20359 do_facet mds1 "$LCTL get_param *.*.job_stats"
20360 do_facet ost1 "$LCTL get_param *.*.job_stats"
20362 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000"
20363 do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" | verify_yaml ||
20364 error "The output of lljobstat is not an valid YAML"
20366 # verify that job dd.0 does exist and has some ops on ost1
20367 # typically this line is like:
20368 # - 205e.dd.0: {ops: 20, ...}
20369 ops_comma=$(do_facet ost1 "lljobstat -n 1 -i 0 -c 1000" |
20370 awk '$2=="205e.dd.0:" {print $4}')
20372 (( ${ops_comma%,} >= 10 )) ||
20373 error "cannot find job 205e.dd.0 with ops >= 10"
20375 run_test 205e "verify the output of lljobstat"
20378 verify_yaml_available || skip_env "YAML verification not installed"
20380 # check both qos_ost_weights and qos_mdt_weights
20381 do_facet mds1 $LCTL get_param -n lod.*.qos*weights
20382 do_facet mds1 $LCTL get_param -n lod.*.qos*weights | verify_yaml ||
20383 error "qos_ost_weights is not valid YAML"
20385 run_test 205f "verify qos_ost_weights YAML format "
20387 __test_205_jobstats_dump() {
20389 local nbr_instance=$1
20392 if (( ${#pids[@]} >= nbr_instance )); then
20397 do_facet mds1 "$LCTL get_param mdt.*.job_stats > /dev/null" &
20402 __test_205_cleanup() {
20404 # Clear all job entries
20405 do_facet mds1 "$LCTL set_param mdt.*.job_stats=clear"
20409 local -a mds1_params
20410 local -a cli_params
20414 mds1_params=( $(do_facet mds1 $LCTL get_param mdt.*.job_cleanup_interval) )
20415 do_facet mds1 $LCTL set_param mdt.*.job_cleanup_interval=$interval
20416 stack_trap "do_facet mds1 $LCTL set_param ${mds1_params[*]}" EXIT
20418 cli_params=( $($LCTL get_param jobid_name jobid_var) )
20419 $LCTL set_param jobid_var=TEST205G_ID jobid_name=%j.%p
20420 stack_trap "$LCTL set_param ${cli_params[*]}" EXIT
20423 export TEST205G_ID=205g
20424 stack_trap "unset TEST205G_ID" EXIT
20426 printf $DIR/$tfile.{0001..1000} | xargs -P10 -n1 touch
20429 __test_205_jobstats_dump 4 & pids+="$! "
20430 stack_trap "__test_205_cleanup $pids" EXIT INT
20432 [[ $SLOW == "no" ]] && sleep 90 || sleep 240
20434 run_test 205g "stress test for job_stats procfile"
20437 (( $MDS1_VERSION >= $(version_code 2.15.57.7) )) ||
20438 skip "Need MDS >= v2_15_57-7-g23a2db28dc for jobid xattr"
20439 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
20441 local dir=$DIR/$tdir
20442 local f=$dir/$tfile
20443 local f2=$dir/$tfile-2
20444 local f3=$dir/$tfile-3
20445 local subdir=$DIR/dir
20448 local mdts=$(comma_list $(mdts_nodes))
20449 local mds_saved=$(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.job_xattr)
20450 local client_saved=$($LCTL get_param -n jobid_var)
20452 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.job_xattr=$mds_saved" EXIT
20453 stack_trap "$LCTL set_param jobid_var=$client_saved" EXIT
20455 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.job ||
20456 error "failed to set job_xattr parameter to user.job"
20457 $LCTL set_param jobid_var=procname.uid ||
20458 error "failed to set jobid_var parameter"
20463 val=$(getfattr -n user.job $f | grep user.job)
20464 [[ $val = user.job=\"touch.0\" ]] ||
20465 error "expected user.job=\"touch.0\", got '$val'"
20468 val=$(getfattr -n user.job $subdir | grep user.job)
20469 [[ $val = user.job=\"mkdir.0\" ]] ||
20470 error "expected user.job=\"mkdir.0\", got '$val'"
20472 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=NONE ||
20473 error "failed to set job_xattr parameter to NONE"
20476 val=$(getfattr -d $f2)
20478 error "expected no user xattr, got '$val'"
20480 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=trusted.job ||
20481 error "failed to set job_xattr parameter to trusted.job"
20484 val=$(getfattr -n trusted.job $f3 | grep trusted.job)
20485 [[ $val = trusted.job=\"touch.0\" ]] ||
20486 error "expected trusted.job=\"touch.0\", got '$val'"
20488 run_test 205h "check jobid xattr is stored correctly"
20491 (( $MDS1_VERSION >= $(version_code 2.15.57.7) )) ||
20492 skip "Need MDS >= v2_15_57-7-g23a2db28dc for jobid xattr"
20494 local mdts=$(comma_list $(mdts_nodes))
20495 local mds_saved=$(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.job_xattr)
20497 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.job_xattr=$mds_saved" EXIT
20499 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.1234567 ||
20500 error "failed to set mdt.*.job_xattr to user.1234567"
20502 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.12345678 &&
20503 error "failed to reject too long job_xattr name"
20505 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=userjob &&
20506 error "failed to reject job_xattr name in bad format"
20508 do_nodes $mdts $LCTL set_param mdt.*.job_xattr=user.job/ &&
20509 error "failed to reject job_xattr name with invalid character"
20511 do_nodes $mdts "printf 'mdt.*.job_xattr=user.job\x80' |
20512 xargs $LCTL set_param" &&
20513 error "failed to reject job_xattr name with non-ascii character"
20517 run_test 205i "check job_xattr parameter accepts and rejects values correctly"
20519 # LU-1480, LU-1773 and LU-1657
20521 mkdir -p $DIR/$tdir
20522 $LFS setstripe -c -1 $DIR/$tdir
20523 #define OBD_FAIL_LOV_INIT 0x1403
20524 $LCTL set_param fail_loc=0xa0001403
20525 $LCTL set_param fail_val=1
20526 touch $DIR/$tdir/$tfile || true
20528 run_test 206 "fail lov_init_raid0() doesn't lbug"
20531 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
20532 local fsz=`stat -c %s $DIR/$tfile`
20533 cancel_lru_locks mdc
20535 # do not return layout in getattr intent
20536 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
20537 $LCTL set_param fail_loc=0x170
20538 local sz=`stat -c %s $DIR/$tfile`
20540 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
20544 run_test 207a "can refresh layout at glimpse"
20547 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
20548 local cksum=`md5sum $DIR/$tfile`
20549 local fsz=`stat -c %s $DIR/$tfile`
20550 cancel_lru_locks mdc
20551 cancel_lru_locks osc
20553 # do not return layout in getattr intent
20554 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
20555 $LCTL set_param fail_loc=0x171
20557 # it will refresh layout after the file is opened but before read issues
20558 echo checksum is "$cksum"
20559 echo "$cksum" |md5sum -c --quiet || error "file differs"
20563 run_test 207b "can refresh layout at open"
20566 # FIXME: in this test suite, only RD lease is used. This is okay
20567 # for now as only exclusive open is supported. After generic lease
20568 # is done, this test suite should be revised. - Jinshan
20570 remote_mds_nodsh && skip "remote MDS with nodsh"
20571 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
20572 skip "Need MDS version at least 2.4.52"
20574 echo "==== test 1: verify get lease work"
20575 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
20577 echo "==== test 2: verify lease can be broken by upcoming open"
20578 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
20582 $MULTIOP $DIR/$tfile oO_RDWR:c
20583 kill -USR1 $PID && wait $PID || error "break lease error"
20585 echo "==== test 3: verify lease can't be granted if an open already exists"
20586 $MULTIOP $DIR/$tfile oO_RDWR:_c &
20590 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
20591 kill -USR1 $PID && wait $PID || error "open file error"
20593 echo "==== test 4: lease can sustain over recovery"
20594 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
20600 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
20602 echo "==== test 5: lease broken can't be regained by replay"
20603 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
20607 # open file to break lease and then recovery
20608 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
20611 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
20615 run_test 208 "Exclusive open"
20618 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
20619 skip_env "must have disp_stripe"
20622 sync; sleep 5; sync;
20624 echo 3 > /proc/sys/vm/drop_caches
20625 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
20626 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
20627 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
20629 # open/close 500 times
20630 for i in $(seq 500); do
20634 echo 3 > /proc/sys/vm/drop_caches
20635 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
20636 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
20637 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
20639 echo "before: $req_before, after: $req_after"
20640 [ $((req_after - req_before)) -ge 300 ] &&
20641 error "open/close requests are not freed"
20644 run_test 209 "read-only open/close requests should be freed promptly"
20649 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
20653 $LFS getstripe $DIR/$tfile
20655 wait $pid || error "multiop failed"
20657 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
20661 $LFS getstripe $DIR/$tfile
20663 wait $pid || error "multiop failed"
20665 run_test 210 "lfs getstripe does not break leases"
20667 function test_211() {
20672 stack_trap "rm -f $DIR/$tfile" EXIT
20673 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=10 oflag=direct ||
20674 error "can't create file"
20675 $LFS mirror extend -N $DIR/$tfile ||
20676 error "can't create a replica"
20677 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
20678 $LFS getstripe $DIR/$tfile
20679 stale=$($LFS getstripe $DIR/$tfile | grep stale | wc -l)
20680 (( $stale != 1 )) && error "expected 1 stale, found $stale"
20682 $MULTIOP $DIR/$tfile OeW_E+eUc &
20686 id=$($LFS getstripe $DIR/$tfile |
20687 awk '/lcme_mirror_id:/{id=$2}/lcme_flags.*init$/{print id}')
20688 $LFS mirror split -d --mirror-id $id $DIR/$tfile &&
20689 error "removed last in-sync replica?"
20693 (( $? == 0 )) || error "failed split broke the lease"
20695 run_test 211 "failed mirror split doesn't break write lease"
20699 size=$((size % 8192 + 1))
20700 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
20701 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
20702 rm -f $DIR/f212 $DIR/f212.xyz
20704 run_test 212 "Sendfile test ============================================"
20707 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
20708 cancel_lru_locks osc
20709 lctl set_param fail_loc=0x8000040f
20710 # generate a read lock
20711 cat $DIR/$tfile > /dev/null
20712 # write to the file, it will try to cancel the above read lock.
20713 cat /etc/hosts >> $DIR/$tfile
20715 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
20717 test_214() { # for bug 20133
20718 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
20719 for (( i=0; i < 340; i++ )) ; do
20720 touch $DIR/$tdir/d214c/a$i
20723 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
20724 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
20725 ls $DIR/d214c || error "ls $DIR/d214c failed"
20726 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
20727 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
20729 run_test 214 "hash-indexed directory test - bug 20133"
20731 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
20732 create_lnet_proc_files() {
20733 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
20736 # counterpart of create_lnet_proc_files
20737 remove_lnet_proc_files() {
20738 rm -f $TMP/lnet_$1.sys
20741 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
20742 # 3rd arg as regexp for body
20743 check_lnet_proc_stats() {
20744 local l=$(cat "$TMP/lnet_$1" |wc -l)
20745 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
20747 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
20750 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
20751 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
20752 # optional and can be regexp for 2nd line (lnet.routes case)
20753 check_lnet_proc_entry() {
20754 local blp=2 # blp stands for 'position of 1st line of body'
20755 [ -z "$5" ] || blp=3 # lnet.routes case
20757 local l=$(cat "$TMP/lnet_$1" |wc -l)
20758 # subtracting one from $blp because the body can be empty
20759 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
20761 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
20762 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
20764 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
20765 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
20767 # bail out if any unexpected line happened
20768 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
20769 [ "$?" != 0 ] || error "$2 misformatted"
20772 test_215() { # for bugs 18102, 21079, 21517
20773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20775 local N='(0|[1-9][0-9]*)' # non-negative numeric
20776 local P='[1-9][0-9]*' # positive numeric
20777 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
20778 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
20779 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
20780 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
20782 local L1 # regexp for 1st line
20783 local L2 # regexp for 2nd line (optional)
20784 local BR # regexp for the rest (body)
20786 # lnet.stats should look as 11 space-separated non-negative numerics
20787 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
20788 create_lnet_proc_files "stats"
20789 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
20790 remove_lnet_proc_files "stats"
20792 # lnet.routes should look like this:
20793 # Routing disabled/enabled
20794 # net hops priority state router
20795 # where net is a string like tcp0, hops > 0, priority >= 0,
20796 # state is up/down,
20797 # router is a string like 192.168.1.1@tcp2
20798 L1="^Routing (disabled|enabled)$"
20799 L2="^net +hops +priority +state +router$"
20800 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
20801 create_lnet_proc_files "routes"
20802 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
20803 remove_lnet_proc_files "routes"
20805 # lnet.routers should look like this:
20806 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
20807 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
20808 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
20809 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
20810 L1="^ref +rtr_ref +alive +router$"
20811 BR="^$P +$P +(up|down) +$NID$"
20812 create_lnet_proc_files "routers"
20813 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
20814 remove_lnet_proc_files "routers"
20816 # lnet.peers should look like this:
20817 # nid refs state last max rtr min tx min queue
20818 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
20819 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
20820 # numeric (0 or >0 or <0), queue >= 0.
20821 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
20822 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
20823 create_lnet_proc_files "peers"
20824 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
20825 remove_lnet_proc_files "peers"
20827 # lnet.buffers should look like this:
20828 # pages count credits min
20829 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
20830 L1="^pages +count +credits +min$"
20831 BR="^ +$N +$N +$I +$I$"
20832 create_lnet_proc_files "buffers"
20833 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
20834 remove_lnet_proc_files "buffers"
20836 # lnet.nis should look like this:
20837 # nid status alive refs peer rtr max tx min
20838 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
20839 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
20840 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
20841 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
20842 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
20843 create_lnet_proc_files "nis"
20844 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
20845 remove_lnet_proc_files "nis"
20847 # can we successfully write to lnet.stats?
20848 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
20850 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
20852 test_216() { # bug 20317
20853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20854 remote_ost_nodsh && skip "remote OST with nodsh"
20857 local facets=$(get_facets OST)
20858 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
20860 save_lustre_params client "osc.*.contention_seconds" > $p
20861 save_lustre_params $facets \
20862 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
20863 save_lustre_params $facets \
20864 "ldlm.namespaces.filter-*.contended_locks" >> $p
20865 save_lustre_params $facets \
20866 "ldlm.namespaces.filter-*.contention_seconds" >> $p
20867 clear_stats osc.*.osc_stats
20869 # agressive lockless i/o settings
20870 do_nodes $(comma_list $(osts_nodes)) \
20871 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
20872 ldlm.namespaces.filter-*.contended_locks=0 \
20873 ldlm.namespaces.filter-*.contention_seconds=60"
20874 lctl set_param -n osc.*.contention_seconds=60
20876 $DIRECTIO write $DIR/$tfile 0 10 4096
20877 $CHECKSTAT -s 40960 $DIR/$tfile
20879 # disable lockless i/o
20880 do_nodes $(comma_list $(osts_nodes)) \
20881 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
20882 ldlm.namespaces.filter-*.contended_locks=32 \
20883 ldlm.namespaces.filter-*.contention_seconds=0"
20884 lctl set_param -n osc.*.contention_seconds=0
20885 clear_stats osc.*.osc_stats
20887 dd if=/dev/zero of=$DIR/$tfile count=0
20888 $CHECKSTAT -s 0 $DIR/$tfile
20890 restore_lustre_params <$p
20894 run_test 216 "check lockless direct write updates file size and kms correctly"
20896 test_217() { # bug 22430
20897 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20901 for node in $(nodes_list); do
20902 local nid=$(host_nids_address $node $NETTYPE)
20903 local node_ip=$(do_node $node getent ahostsv4 $node |
20904 awk '{ print $1; exit; }')
20906 echo "node: '$node', nid: '$nid', node_ip='$node_ip'"
20907 # if hostname matches any NID, use hostname for better testing
20908 if [[ -z "$nid" || "$nid" =~ "$node_ip" ]]; then
20909 echo "lctl ping node $node@$NETTYPE"
20910 lctl ping $node@$NETTYPE
20911 else # otherwise, at least test 'lctl ping' is working
20912 echo "lctl ping nid $(h2nettype $nid)"
20913 lctl ping $(h2nettype $nid)
20914 echo "skipping $node (no hyphen detected)"
20918 run_test 217 "check lctl ping for hostnames with embedded hyphen ('-')"
20921 # do directio so as not to populate the page cache
20922 log "creating a 10 Mb file"
20923 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
20924 error "multiop failed while creating a file"
20925 log "starting reads"
20926 dd if=$DIR/$tfile of=/dev/null bs=4096 &
20927 log "truncating the file"
20928 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
20929 error "multiop failed while truncating the file"
20931 kill %+ || true # reads might have finished
20932 echo "wait until dd is finished"
20934 log "removing the temporary file"
20935 rm -rf $DIR/$tfile || error "tmp file removal failed"
20937 run_test 218 "parallel read and truncate should not deadlock"
20940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20942 # write one partial page
20943 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
20944 # set no grant so vvp_io_commit_write will do sync write
20945 $LCTL set_param fail_loc=0x411
20946 # write a full page at the end of file
20947 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
20949 $LCTL set_param fail_loc=0
20950 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
20951 $LCTL set_param fail_loc=0x411
20952 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
20955 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
20956 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
20958 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
20960 test_220() { #LU-325
20961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20962 remote_ost_nodsh && skip "remote OST with nodsh"
20963 remote_mds_nodsh && skip "remote MDS with nodsh"
20964 remote_mgs_nodsh && skip "remote MGS with nodsh"
20968 # create on MDT0000 so the last_id and next_id are correct
20969 mkdir_on_mdt0 $DIR/$tdir
20970 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
20974 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
20975 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
20976 osp.$mdtosc_proc1.prealloc_last_id)
20977 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
20978 osp.$mdtosc_proc1.prealloc_next_id)
20982 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
20983 #define OBD_FAIL_OST_ENOINO 0x229
20984 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
20985 create_pool $FSNAME.$TESTNAME || return 1
20986 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
20988 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
20990 MDSOBJS=$((last_id - next_id))
20991 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
20993 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
20994 echo "OST still has $count kbytes free"
20996 echo "create $MDSOBJS files @next_id..."
20997 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
20999 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
21000 osp.$mdtosc_proc1.prealloc_last_id)
21001 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
21002 osp.$mdtosc_proc1.prealloc_next_id)
21004 echo "after creation, last_id=$last_id2, next_id=$next_id2"
21009 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
21010 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
21012 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
21013 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
21014 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
21015 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
21016 echo "unlink $MDSOBJS files @$next_id..."
21017 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
21019 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
21022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21024 dd if=`which date` of=$MOUNT/date oflag=sync
21025 chmod +x $MOUNT/date
21027 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
21028 $LCTL set_param fail_loc=0x80001401
21030 $MOUNT/date > /dev/null
21033 run_test 221 "make sure fault and truncate race to not cause OOM"
21036 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21039 test_mkdir $DIR/$tdir
21040 $LFS setstripe -c 1 -i 0 $DIR/$tdir
21041 createmany -o $DIR/$tdir/$tfile 10
21042 cancel_lru_locks mdc
21043 cancel_lru_locks osc
21044 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
21045 $LCTL set_param fail_loc=0x31a
21046 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
21047 $LCTL set_param fail_loc=0
21050 run_test 222a "AGL for ls should not trigger CLIO lock failure"
21053 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21056 test_mkdir $DIR/$tdir
21057 $LFS setstripe -c 1 -i 0 $DIR/$tdir
21058 createmany -o $DIR/$tdir/$tfile 10
21059 cancel_lru_locks mdc
21060 cancel_lru_locks osc
21061 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
21062 $LCTL set_param fail_loc=0x31a
21063 rm -r $DIR/$tdir || error "AGL for rmdir failed"
21064 $LCTL set_param fail_loc=0
21066 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
21069 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21072 test_mkdir $DIR/$tdir
21073 $LFS setstripe -c 1 -i 0 $DIR/$tdir
21074 createmany -o $DIR/$tdir/$tfile 10
21075 cancel_lru_locks mdc
21076 cancel_lru_locks osc
21077 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
21078 $LCTL set_param fail_loc=0x31b
21079 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
21080 $LCTL set_param fail_loc=0
21083 run_test 223 "osc reenqueue if without AGL lock granted ======================="
21085 test_224a() { # LU-1039, MRP-303
21086 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21087 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
21088 $LCTL set_param fail_loc=0x508
21089 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
21090 $LCTL set_param fail_loc=0
21093 run_test 224a "Don't panic on bulk IO failure"
21095 test_224bd_sub() { # LU-1039, MRP-303
21096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21100 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
21102 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21104 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
21105 cancel_lru_locks osc
21107 stack_trap "set_checksums $ORIG_CSUM" EXIT
21108 local at_max_saved=0
21110 # adaptive timeouts may prevent seeing the issue
21111 if at_is_enabled; then
21112 at_max_saved=$(at_max_get mds)
21113 at_max_set 0 mds client
21114 stack_trap "at_max_set $at_max_saved mds client" EXIT
21117 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
21118 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
21119 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
21121 do_facet ost1 $LCTL set_param fail_loc=0
21122 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
21127 test_224bd_sub 3 error "dd failed"
21129 run_test 224b "Don't panic on bulk IO failure"
21131 test_224c() { # LU-6441
21132 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21133 remote_mds_nodsh && skip "remote MDS with nodsh"
21135 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
21136 save_writethrough $p
21137 set_cache writethrough on
21139 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
21140 local at_max=$($LCTL get_param -n at_max)
21141 local timeout=$($LCTL get_param -n timeout)
21142 local test_at="at_max"
21143 local param_at="$FSNAME.sys.at_max"
21144 local test_timeout="timeout"
21145 local param_timeout="$FSNAME.sys.timeout"
21147 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
21149 set_persistent_param_and_check client "$test_at" "$param_at" 0
21150 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
21152 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
21153 do_facet ost1 "$LCTL set_param fail_loc=0x520"
21154 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21155 stack_trap "rm -f $DIR/$tfile"
21156 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
21158 do_facet ost1 "$LCTL set_param fail_loc=0"
21160 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
21161 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
21164 $LCTL set_param -n $pages_per_rpc
21165 restore_lustre_params < $p
21168 run_test 224c "Don't hang if one of md lost during large bulk RPC"
21170 test_224d() { # LU-11169
21171 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
21173 run_test 224d "Don't corrupt data on bulk IO timeout"
21175 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
21177 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21178 if [ -z ${MDSSURVEY} ]; then
21179 skip_env "mds-survey not found"
21181 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
21182 skip "Need MDS version at least 2.2.51"
21184 local mds=$(facet_host $SINGLEMDS)
21185 local target=$(do_nodes $mds 'lctl dl' |
21186 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
21188 local cmd1="file_count=1000 thrhi=4"
21189 local cmd2="dir_count=2 layer=mdd stripe_count=0"
21190 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
21191 local cmd="$cmd1 $cmd2 $cmd3"
21193 rm -f ${TMP}/mds_survey*
21195 eval $cmd || error "mds-survey with zero-stripe failed"
21196 cat ${TMP}/mds_survey*
21197 rm -f ${TMP}/mds_survey*
21199 run_test 225a "Metadata survey sanity with zero-stripe"
21202 if [ -z ${MDSSURVEY} ]; then
21203 skip_env "mds-survey not found"
21205 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
21206 skip "Need MDS version at least 2.2.51"
21207 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21208 remote_mds_nodsh && skip "remote MDS with nodsh"
21209 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
21210 skip_env "Need to mount OST to test"
21213 local mds=$(facet_host $SINGLEMDS)
21214 local target=$(do_nodes $mds 'lctl dl' |
21215 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
21217 local cmd1="file_count=1000 thrhi=4"
21218 local cmd2="dir_count=2 layer=mdd stripe_count=1"
21219 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
21220 local cmd="$cmd1 $cmd2 $cmd3"
21222 rm -f ${TMP}/mds_survey*
21224 eval $cmd || error "mds-survey with stripe_count failed"
21225 cat ${TMP}/mds_survey*
21226 rm -f ${TMP}/mds_survey*
21228 run_test 225b "Metadata survey sanity with stripe_count = 1"
21230 mcreate_path2fid () {
21236 local path=$DIR/$tdir/$name
21241 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
21242 error "cannot create $desc"
21244 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
21246 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
21248 fid_path=$($LFS fid2path $MOUNT $fid)
21250 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
21252 [ "$path" == "$fid_path" ] ||
21253 error "fid2path returned $fid_path, expected $path"
21255 echo "pass with $path and $fid"
21260 mkdir -p $DIR/$tdir
21262 mcreate_path2fid 0010666 0 0 fifo "FIFO"
21263 mcreate_path2fid 0020666 1 3 null "character special file (null)"
21264 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
21265 mcreate_path2fid 0040666 0 0 dir "directory"
21266 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
21267 mcreate_path2fid 0100666 0 0 file "regular file"
21268 mcreate_path2fid 0120666 0 0 link "symbolic link"
21269 mcreate_path2fid 0140666 0 0 sock "socket"
21271 run_test 226a "call path2fid and fid2path on files of all type"
21274 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21279 mkdir -p $DIR/$tdir
21280 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
21281 error "create remote directory failed"
21282 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
21283 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
21284 "character special file (null)"
21285 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
21286 "character special file (no device)"
21287 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
21288 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
21289 "block special file (loop)"
21290 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
21291 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
21292 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
21294 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
21297 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21298 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
21299 skip "Need MDS version at least 2.13.55"
21301 local submnt=/mnt/submnt
21302 local srcfile=/etc/passwd
21303 local dstfile=$submnt/passwd
21309 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
21310 error "create remote directory failed"
21311 mkdir -p $submnt || error "create $submnt failed"
21312 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
21313 error "mount $submnt failed"
21314 stack_trap "umount $submnt" EXIT
21316 cp $srcfile $dstfile
21317 fid=$($LFS path2fid $dstfile)
21318 path=$($LFS fid2path $submnt "$fid")
21319 [ "$path" = "$dstfile" ] ||
21320 error "fid2path $submnt $fid failed ($path != $dstfile)"
21322 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
21325 (( $CLIENT_VERSION >= $(version_code 2.15.57) )) ||
21326 skip "Need client at least version 2.15.57"
21328 # Define First test dataset
21329 local testdirs_01=$DIR/$tdir
21330 local testdata_01=$testdirs_01/${tdir}_01
21331 local testresult_01=${tdir}_01
21332 # Define Second test dataset
21333 local testdirs_02=$DIR/$tdir/$tdir
21334 local testdata_02=$testdirs_02/${tdir}_02
21335 local testresult_02=${tdir}_02
21336 # Define third test dataset (top level)
21337 local testdata_03=$DIR/${tdir}_03
21338 local testresult_03=${tdir}_03
21340 # Create first test dataset
21341 mkdir -p $testdirs_01 || error "cannot create dir $testdirs_01"
21342 touch $testdata_01 || error "cannot create file $testdata_01"
21344 # Create second test dataset
21345 mkdir -p $testdirs_02 || error "cannot create dir $testdirs_02"
21346 touch $testdata_02 || error "cannot create file $testdata_02"
21348 # Create third test dataset
21349 touch $testdata_03 || error "cannot create file $testdata_03"
21351 local fid01=$($LFS getstripe -F "$testdata_01") ||
21352 error "getstripe failed on $testdata_01"
21353 local fid02=$($LFS getstripe -F "$testdata_02") ||
21354 error "getstripe failed on $testdata_01"
21355 local fid03=$($LFS getstripe -F "$testdata_03") ||
21356 error "getstripe failed on $testdata_03"
21358 # Verify only -n option
21359 local out1=$($LFS fid2path -n $DIR $fid01) ||
21360 error "fid2path failed on $fid01"
21361 local out2=$($LFS fid2path -n $DIR $fid02) ||
21362 error "fid2path failed on $fid02"
21363 local out3=$($LFS fid2path -n $DIR $fid03) ||
21364 error "fid2path failed on $fid03"
21366 [[ "$out1" == "$testresult_01" ]] ||
21367 error "fid2path failed: Expected $testresult_01 got $out1"
21368 [[ "$out2" == "$testresult_02" ]] ||
21369 error "fid2path failed: Expected $testresult_02 got $out2"
21370 [[ "$out3" == "$testresult_03" ]] ||
21371 error "fid2path failed: Expected $testresult_03 got $out3"
21373 # Verify with option -fn together
21374 out1=$($LFS fid2path -fn $DIR $fid01) ||
21375 error "fid2path -fn failed on $fid01"
21376 out2=$($LFS fid2path -fn $DIR $fid02) ||
21377 error "fid2path -fn failed on $fid02"
21378 out3=$($LFS fid2path -fn $DIR $fid03) ||
21379 error "fid2path -fn failed on $fid03"
21381 local tmpout=$(echo $out1 | cut -d" " -f2)
21382 [[ "$tmpout" == "$testresult_01" ]] ||
21383 error "fid2path -fn failed: Expected $testresult_01 got $out1"
21385 tmpout=$(echo $out2 | cut -d" " -f2)
21386 [[ "$tmpout" == "$testresult_02" ]] ||
21387 error "fid2path -fn failed: Expected $testresult_02 got $out2"
21389 tmpout=$(echo $out3 | cut -d" " -f2)
21390 [[ "$tmpout" == "$testresult_03" ]] ||
21391 error "fid2path -fn failed: Expected $testresult_03 got $out3"
21393 run_test 226d "verify fid2path with -n and -fn option"
21396 (( $CLIENT_VERSION >= $(version_code 2.15.56) )) ||
21397 skip "Need client at least version 2.15.56"
21399 # Define filename with 'newline' and a space
21400 local testfile="Test"$'\n'"file 01"
21401 # Define link name with multiple 'newline' and a space
21402 local linkfile="Link"$'\n'"file "$'\n'"01"
21403 # Remove prior hard link
21404 rm -f $DIR/"$linkfile"
21407 touch $DIR/"$testfile"
21409 ln $DIR/"$testfile" $DIR/"$linkfile"
21411 local fid=$($LFS getstripe -F "$DIR/$testfile") ||
21412 error "getstripe failed on $DIR/$testfile"
21414 # Call with -0 option
21415 local out1=$($LFS fid2path -0 $DIR $fid | xargs --null -n1 \
21416 echo "FILE:" | grep -c "FILE:")
21418 # With -0 option the output should be exactly 2 lines.
21419 (( $out1 == 2 )) || error "fid2path -0 failed on $fid, $out1"
21421 run_test 226e "Verify path2fid -0 option with newline and space"
21423 # LU-1299 Executing or running ldd on a truncated executable does not
21424 # cause an out-of-memory condition.
21426 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21427 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
21429 dd if=$(which date) of=$MOUNT/date bs=1k count=1
21430 chmod +x $MOUNT/date
21432 $MOUNT/date > /dev/null
21433 ldd $MOUNT/date > /dev/null
21436 run_test 227 "running truncated executable does not cause OOM"
21438 # LU-1512 try to reuse idle OI blocks
21440 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21441 remote_mds_nodsh && skip "remote MDS with nodsh"
21442 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21444 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
21445 local myDIR=$DIR/$tdir
21448 #define OBD_FAIL_SEQ_EXHAUST 0x1002
21449 $LCTL set_param fail_loc=0x80001002
21450 createmany -o $myDIR/t- 10000
21451 $LCTL set_param fail_loc=0
21452 # The guard is current the largest FID holder
21454 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
21456 local IDX=$(($SEQ % 64))
21458 do_facet $SINGLEMDS sync
21459 # Make sure journal flushed.
21461 local blk1=$(do_facet $SINGLEMDS \
21462 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21463 grep Blockcount | awk '{print $4}')
21465 # Remove old files, some OI blocks will become idle.
21466 unlinkmany $myDIR/t- 10000
21467 # Create new files, idle OI blocks should be reused.
21468 createmany -o $myDIR/t- 2000
21469 do_facet $SINGLEMDS sync
21470 # Make sure journal flushed.
21472 local blk2=$(do_facet $SINGLEMDS \
21473 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21474 grep Blockcount | awk '{print $4}')
21476 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
21478 run_test 228a "try to reuse idle OI blocks"
21481 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21482 remote_mds_nodsh && skip "remote MDS with nodsh"
21483 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21485 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
21486 local myDIR=$DIR/$tdir
21489 #define OBD_FAIL_SEQ_EXHAUST 0x1002
21490 $LCTL set_param fail_loc=0x80001002
21491 createmany -o $myDIR/t- 10000
21492 $LCTL set_param fail_loc=0
21493 # The guard is current the largest FID holder
21495 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
21497 local IDX=$(($SEQ % 64))
21499 do_facet $SINGLEMDS sync
21500 # Make sure journal flushed.
21502 local blk1=$(do_facet $SINGLEMDS \
21503 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21504 grep Blockcount | awk '{print $4}')
21506 # Remove old files, some OI blocks will become idle.
21507 unlinkmany $myDIR/t- 10000
21510 stop $SINGLEMDS || error "Fail to stop MDT."
21512 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
21513 error "Fail to start MDT."
21515 client_up || error "Fail to df."
21516 # Create new files, idle OI blocks should be reused.
21517 createmany -o $myDIR/t- 2000
21518 do_facet $SINGLEMDS sync
21519 # Make sure journal flushed.
21521 local blk2=$(do_facet $SINGLEMDS \
21522 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21523 grep Blockcount | awk '{print $4}')
21525 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
21527 run_test 228b "idle OI blocks can be reused after MDT restart"
21531 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21532 remote_mds_nodsh && skip "remote MDS with nodsh"
21533 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21535 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
21536 local myDIR=$DIR/$tdir
21539 #define OBD_FAIL_SEQ_EXHAUST 0x1002
21540 $LCTL set_param fail_loc=0x80001002
21541 # 20000 files can guarantee there are index nodes in the OI file
21542 createmany -o $myDIR/t- 20000
21543 $LCTL set_param fail_loc=0
21544 # The guard is current the largest FID holder
21546 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
21548 local IDX=$(($SEQ % 64))
21550 do_facet $SINGLEMDS sync
21551 # Make sure journal flushed.
21553 local blk1=$(do_facet $SINGLEMDS \
21554 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21555 grep Blockcount | awk '{print $4}')
21557 # Remove old files, some OI blocks will become idle.
21558 unlinkmany $myDIR/t- 20000
21560 # The OI file should become empty now
21562 # Create new files, idle OI blocks should be reused.
21563 createmany -o $myDIR/t- 2000
21564 do_facet $SINGLEMDS sync
21565 # Make sure journal flushed.
21567 local blk2=$(do_facet $SINGLEMDS \
21568 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
21569 grep Blockcount | awk '{print $4}')
21571 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
21573 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
21575 test_229() { # LU-2482, LU-3448
21576 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21577 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
21578 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
21579 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
21583 # Create a file with a released layout and stripe count 2.
21584 $MULTIOP $DIR/$tfile H2c ||
21585 error "failed to create file with released layout"
21587 $LFS getstripe -v $DIR/$tfile
21589 local pattern=$($LFS getstripe -L $DIR/$tfile)
21590 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
21592 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
21594 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
21595 stat $DIR/$tfile || error "failed to stat released file"
21597 chown $RUNAS_ID $DIR/$tfile ||
21598 error "chown $RUNAS_ID $DIR/$tfile failed"
21600 chgrp $RUNAS_ID $DIR/$tfile ||
21601 error "chgrp $RUNAS_ID $DIR/$tfile failed"
21603 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
21604 rm $DIR/$tfile || error "failed to remove released file"
21606 run_test 229 "getstripe/stat/rm/attr changes work on released files"
21609 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21610 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21611 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21612 skip "Need MDS version at least 2.11.52"
21616 test_mkdir $DIR/$tdir
21617 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
21618 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
21619 [ $mdt_idx -ne 0 ] &&
21620 error "create local directory on wrong MDT $mdt_idx"
21622 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
21623 error "create remote directory failed"
21624 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
21625 [ $mdt_idx -ne $MDTIDX ] &&
21626 error "create remote directory on wrong MDT $mdt_idx"
21628 createmany -o $DIR/$tdir/test_230/t- 10 ||
21629 error "create files on remote directory failed"
21630 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
21631 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
21632 rm -r $DIR/$tdir || error "unlink remote directory failed"
21634 run_test 230a "Create remote directory and files under the remote directory"
21637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21638 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21639 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21640 skip "Need MDS version at least 2.11.52"
21648 local migrate_dir=$DIR/$tdir/migrate_dir
21649 local other_dir=$DIR/$tdir/other_dir
21651 test_mkdir $DIR/$tdir
21652 test_mkdir -i0 -c1 $migrate_dir
21653 test_mkdir -i0 -c1 $other_dir
21654 for ((i=0; i<10; i++)); do
21655 mkdir -p $migrate_dir/dir_${i}
21656 createmany -o $migrate_dir/dir_${i}/f 10 ||
21657 error "create files under remote dir failed $i"
21660 cp /etc/passwd $migrate_dir/$tfile
21661 cp /etc/passwd $other_dir/$tfile
21662 chattr +SAD $migrate_dir
21663 chattr +SAD $migrate_dir/$tfile
21665 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
21666 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
21667 local old_dir_mode=$(stat -c%f $migrate_dir)
21668 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
21670 mkdir -p $migrate_dir/dir_default_stripe2
21671 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
21672 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
21674 mkdir -p $other_dir
21675 ln $migrate_dir/$tfile $other_dir/luna
21676 ln $migrate_dir/$tfile $migrate_dir/sofia
21677 ln $other_dir/$tfile $migrate_dir/david
21678 ln -s $migrate_dir/$tfile $other_dir/zachary
21679 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
21680 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
21686 for len in 58 59 60; do
21687 lnktgt=$(str_repeat 'l' $len)
21688 touch $migrate_dir/$lnktgt
21689 ln -s $lnktgt $migrate_dir/${len}char_ln
21693 for len in 4094 4095; do
21694 lnktgt=$(str_repeat 'l' $len)
21695 ln -s $lnktgt $migrate_dir/${len}char_ln
21699 for len in 254 255; do
21700 touch $migrate_dir/$(str_repeat 'l' $len)
21703 $LFS migrate -m $MDTIDX $migrate_dir ||
21704 error "fails on migrating remote dir to MDT1"
21706 echo "migratate to MDT1, then checking.."
21707 for ((i = 0; i < 10; i++)); do
21708 for file in $(find $migrate_dir/dir_${i}); do
21709 mdt_index=$($LFS getstripe -m $file)
21710 # broken symlink getstripe will fail
21711 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
21712 error "$file is not on MDT${MDTIDX}"
21716 # the multiple link file should still in MDT0
21717 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
21718 [ $mdt_index == 0 ] ||
21719 error "$file is not on MDT${MDTIDX}"
21721 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
21722 [ "$old_dir_flag" = "$new_dir_flag" ] ||
21723 error " expect $old_dir_flag get $new_dir_flag"
21725 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
21726 [ "$old_file_flag" = "$new_file_flag" ] ||
21727 error " expect $old_file_flag get $new_file_flag"
21729 local new_dir_mode=$(stat -c%f $migrate_dir)
21730 [ "$old_dir_mode" = "$new_dir_mode" ] ||
21731 error "expect mode $old_dir_mode get $new_dir_mode"
21733 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
21734 [ "$old_file_mode" = "$new_file_mode" ] ||
21735 error "expect mode $old_file_mode get $new_file_mode"
21737 diff /etc/passwd $migrate_dir/$tfile ||
21738 error "$tfile different after migration"
21740 diff /etc/passwd $other_dir/luna ||
21741 error "luna different after migration"
21743 diff /etc/passwd $migrate_dir/sofia ||
21744 error "sofia different after migration"
21746 diff /etc/passwd $migrate_dir/david ||
21747 error "david different after migration"
21749 diff /etc/passwd $other_dir/zachary ||
21750 error "zachary different after migration"
21752 diff /etc/passwd $migrate_dir/${tfile}_ln ||
21753 error "${tfile}_ln different after migration"
21755 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
21756 error "${tfile}_ln_other different after migration"
21758 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
21759 [ $stripe_count = 2 ] ||
21760 error "dir strpe_count $d != 2 after migration."
21762 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
21763 [ $stripe_count = 2 ] ||
21764 error "file strpe_count $d != 2 after migration."
21766 #migrate back to MDT0
21769 $LFS migrate -m $MDTIDX $migrate_dir ||
21770 error "fails on migrating remote dir to MDT0"
21772 echo "migrate back to MDT0, checking.."
21773 for file in $(find $migrate_dir); do
21774 mdt_index=$($LFS getstripe -m $file)
21775 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
21776 error "$file is not on MDT${MDTIDX}"
21779 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
21780 [ "$old_dir_flag" = "$new_dir_flag" ] ||
21781 error " expect $old_dir_flag get $new_dir_flag"
21783 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
21784 [ "$old_file_flag" = "$new_file_flag" ] ||
21785 error " expect $old_file_flag get $new_file_flag"
21787 local new_dir_mode=$(stat -c%f $migrate_dir)
21788 [ "$old_dir_mode" = "$new_dir_mode" ] ||
21789 error "expect mode $old_dir_mode get $new_dir_mode"
21791 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
21792 [ "$old_file_mode" = "$new_file_mode" ] ||
21793 error "expect mode $old_file_mode get $new_file_mode"
21795 diff /etc/passwd ${migrate_dir}/$tfile ||
21796 error "$tfile different after migration"
21798 diff /etc/passwd ${other_dir}/luna ||
21799 error "luna different after migration"
21801 diff /etc/passwd ${migrate_dir}/sofia ||
21802 error "sofia different after migration"
21804 diff /etc/passwd ${other_dir}/zachary ||
21805 error "zachary different after migration"
21807 diff /etc/passwd $migrate_dir/${tfile}_ln ||
21808 error "${tfile}_ln different after migration"
21810 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
21811 error "${tfile}_ln_other different after migration"
21813 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
21814 [ $stripe_count = 2 ] ||
21815 error "dir strpe_count $d != 2 after migration."
21817 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
21818 [ $stripe_count = 2 ] ||
21819 error "file strpe_count $d != 2 after migration."
21821 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21823 run_test 230b "migrate directory"
21826 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21827 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21828 remote_mds_nodsh && skip "remote MDS with nodsh"
21829 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21830 skip "Need MDS version at least 2.11.52"
21836 local migrate_dir=$DIR/$tdir/migrate_dir
21838 #If migrating directory fails in the middle, all entries of
21839 #the directory is still accessiable.
21840 test_mkdir $DIR/$tdir
21841 test_mkdir -i0 -c1 $migrate_dir
21842 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
21844 createmany -o $migrate_dir/f $total ||
21845 error "create files under ${migrate_dir} failed"
21847 # fail after migrating top dir, and this will fail only once, so the
21848 # first sub file migration will fail (currently f3), others succeed.
21849 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
21850 do_facet mds1 lctl set_param fail_loc=0x1801
21851 local t=$(ls $migrate_dir | wc -l)
21852 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
21853 error "migrate should fail"
21854 local u=$(ls $migrate_dir | wc -l)
21855 [ "$u" == "$t" ] || error "$u != $t during migration"
21857 # add new dir/file should succeed
21858 mkdir $migrate_dir/dir ||
21859 error "mkdir failed under migrating directory"
21860 touch $migrate_dir/file ||
21861 error "create file failed under migrating directory"
21863 # add file with existing name should fail
21864 for file in $migrate_dir/f*; do
21865 stat $file > /dev/null || error "stat $file failed"
21866 $OPENFILE -f O_CREAT:O_EXCL $file &&
21867 error "open(O_CREAT|O_EXCL) $file should fail"
21868 $MULTIOP $file m && error "create $file should fail"
21869 touch $DIR/$tdir/remote_dir/$tfile ||
21870 error "touch $tfile failed"
21871 ln $DIR/$tdir/remote_dir/$tfile $file &&
21872 error "link $file should fail"
21873 mdt_index=$($LFS getstripe -m $file)
21874 if [ $mdt_index == 0 ]; then
21875 # file failed to migrate is not allowed to rename to
21876 mv $DIR/$tdir/remote_dir/$tfile $file &&
21877 error "rename to $file should fail"
21879 mv $DIR/$tdir/remote_dir/$tfile $file ||
21880 error "rename to $file failed"
21882 echo hello >> $file || error "write $file failed"
21885 # resume migration with different options should fail
21886 $LFS migrate -m 0 $migrate_dir &&
21887 error "migrate -m 0 $migrate_dir should fail"
21889 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
21890 error "migrate -c 2 $migrate_dir should fail"
21892 # resume migration should succeed
21893 $LFS migrate -m $MDTIDX $migrate_dir ||
21894 error "migrate $migrate_dir failed"
21896 echo "Finish migration, then checking.."
21897 for file in $(find $migrate_dir); do
21898 mdt_index=$($LFS getstripe -m $file)
21899 [ $mdt_index == $MDTIDX ] ||
21900 error "$file is not on MDT${MDTIDX}"
21903 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21905 run_test 230c "check directory accessiblity if migration failed"
21908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21909 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21910 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21911 skip "Need MDS version at least 2.11.52"
21913 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
21915 local migrate_dir=$DIR/$tdir/migrate_dir
21925 old_index=$((RANDOM % MDSCOUNT))
21926 old_count=$((MDSCOUNT - old_index))
21927 new_index=$((RANDOM % MDSCOUNT))
21928 new_count=$((MDSCOUNT - new_index))
21929 new_hash=1 # for all_char
21931 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
21932 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
21934 test_mkdir $DIR/$tdir
21935 test_mkdir -i $old_index -c $old_count $migrate_dir
21937 for ((i=0; i<100; i++)); do
21938 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
21939 createmany -o $migrate_dir/dir_${i}/f 100 ||
21940 error "create files under remote dir failed $i"
21943 echo -n "Migrate from MDT$old_index "
21944 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
21945 echo -n "to MDT$new_index"
21946 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
21949 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
21950 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
21951 error "migrate remote dir error"
21953 echo "Finish migration, then checking.."
21954 for file in $(find $migrate_dir -maxdepth 1); do
21955 mdt_index=$($LFS getstripe -m $file)
21956 if [ $mdt_index -lt $new_index ] ||
21957 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
21958 error "$file is on MDT$mdt_index"
21962 rm -rf $DIR/$tdir || error "rm dir failed after migration"
21964 run_test 230d "check migrate big directory"
21967 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21968 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21969 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21970 skip "Need MDS version at least 2.11.52"
21977 mkdir_on_mdt0 $DIR/$tdir
21978 mkdir $DIR/$tdir/migrate_dir
21979 mkdir $DIR/$tdir/other_dir
21980 touch $DIR/$tdir/migrate_dir/a
21981 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
21982 ls $DIR/$tdir/other_dir
21984 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
21985 error "migrate dir fails"
21987 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
21988 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
21990 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
21991 [ $mdt_index == 0 ] || error "a is not on MDT0"
21993 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
21994 error "migrate dir fails"
21996 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
21997 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
21999 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
22000 [ $mdt_index == 1 ] || error "a is not on MDT1"
22002 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
22003 [ $mdt_index == 1 ] || error "b is not on MDT1"
22005 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
22006 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
22008 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
22010 rm -rf $DIR/$tdir || error "rm dir failed after migration"
22012 run_test 230e "migrate mulitple local link files"
22015 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22016 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22017 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22018 skip "Need MDS version at least 2.11.52"
22023 mkdir -p $DIR/$tdir
22024 mkdir $DIR/$tdir/migrate_dir
22025 $LFS mkdir -i1 $DIR/$tdir/other_dir
22026 touch $DIR/$tdir/migrate_dir/a
22027 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
22028 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
22029 ls $DIR/$tdir/other_dir
22031 # a should be migrated to MDT1, since no other links on MDT0
22032 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
22033 error "#1 migrate dir fails"
22034 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
22035 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
22036 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
22037 [ $mdt_index == 1 ] || error "a is not on MDT1"
22039 # a should stay on MDT1, because it is a mulitple link file
22040 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
22041 error "#2 migrate dir fails"
22042 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
22043 [ $mdt_index == 1 ] || error "a is not on MDT1"
22045 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
22046 error "#3 migrate dir fails"
22048 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
22049 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
22050 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
22052 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
22053 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
22055 # a should be migrated to MDT0, since no other links on MDT1
22056 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
22057 error "#4 migrate dir fails"
22058 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
22059 [ $mdt_index == 0 ] || error "a is not on MDT0"
22061 rm -rf $DIR/$tdir || error "rm dir failed after migration"
22063 run_test 230f "migrate mulitple remote link files"
22066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22067 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22068 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22069 skip "Need MDS version at least 2.11.52"
22071 mkdir -p $DIR/$tdir/migrate_dir
22073 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
22074 error "migrating dir to non-exist MDT succeeds"
22077 run_test 230g "migrate dir to non-exist MDT"
22080 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22081 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22082 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22083 skip "Need MDS version at least 2.11.52"
22087 mkdir -p $DIR/$tdir/migrate_dir
22089 $LFS migrate -m1 $DIR &&
22090 error "migrating mountpoint1 should fail"
22092 $LFS migrate -m1 $DIR/$tdir/.. &&
22093 error "migrating mountpoint2 should fail"
22096 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
22097 error "migrating $tdir/migrate_dir/.. should fail"
22101 run_test 230h "migrate .. and root"
22104 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22105 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22106 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22107 skip "Need MDS version at least 2.11.52"
22109 mkdir -p $DIR/$tdir/migrate_dir
22111 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
22112 error "migration fails with a tailing slash"
22114 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
22115 error "migration fails with two tailing slashes"
22117 run_test 230i "lfs migrate -m tolerates trailing slashes"
22120 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22121 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
22122 skip "Need MDS version at least 2.11.52"
22124 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
22125 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
22126 error "create $tfile failed"
22127 cat /etc/passwd > $DIR/$tdir/$tfile
22129 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
22131 cmp /etc/passwd $DIR/$tdir/$tfile ||
22132 error "DoM file mismatch after migration"
22134 run_test 230j "DoM file data not changed after dir migration"
22137 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
22138 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22139 skip "Need MDS version at least 2.11.56"
22142 local files_on_starting_mdt=0
22144 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
22145 $LFS getdirstripe $DIR/$tdir
22146 for i in $(seq $total); do
22147 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
22148 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
22149 files_on_starting_mdt=$((files_on_starting_mdt + 1))
22152 echo "$files_on_starting_mdt files on MDT0"
22154 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
22155 $LFS getdirstripe $DIR/$tdir
22157 files_on_starting_mdt=0
22158 for i in $(seq $total); do
22159 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
22160 error "file $tfile.$i mismatch after migration"
22161 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
22162 files_on_starting_mdt=$((files_on_starting_mdt + 1))
22165 echo "$files_on_starting_mdt files on MDT1 after migration"
22166 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
22168 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
22169 $LFS getdirstripe $DIR/$tdir
22171 files_on_starting_mdt=0
22172 for i in $(seq $total); do
22173 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
22174 error "file $tfile.$i mismatch after 2nd migration"
22175 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
22176 files_on_starting_mdt=$((files_on_starting_mdt + 1))
22179 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
22180 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
22184 run_test 230k "file data not changed after dir migration"
22187 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22188 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22189 skip "Need MDS version at least 2.11.56"
22191 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
22192 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
22193 error "create files under remote dir failed $i"
22194 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
22196 run_test 230l "readdir between MDTs won't crash"
22199 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22200 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22201 skip "Need MDS version at least 2.11.56"
22204 local mig_dir=$DIR/$tdir/migrate_dir
22205 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
22209 echo "Creating files and dirs with xattrs"
22210 test_mkdir $DIR/$tdir
22211 test_mkdir -i0 -c1 $mig_dir
22213 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
22214 error "cannot set xattr attr1 on dir"
22215 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
22216 error "cannot set xattr attr2 on dir"
22217 touch $mig_dir/dir/f0
22218 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
22219 error "cannot set xattr attr1 on file"
22220 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
22221 error "cannot set xattr attr2 on file"
22222 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
22223 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
22224 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
22225 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
22226 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
22227 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
22228 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
22229 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
22230 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
22232 echo "Migrating to MDT1"
22233 $LFS migrate -m $MDTIDX $mig_dir ||
22234 error "fails on migrating dir to MDT1"
22236 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
22237 echo "Checking xattrs"
22238 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
22239 [ "$val" = $longstr ] ||
22240 error "expecting xattr1 $longstr on dir, found $val"
22241 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
22242 [ "$val" = $shortstr ] ||
22243 error "expecting xattr2 $shortstr on dir, found $val"
22244 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
22245 [ "$val" = $longstr ] ||
22246 error "expecting xattr1 $longstr on file, found $val"
22247 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
22248 [ "$val" = $shortstr ] ||
22249 error "expecting xattr2 $shortstr on file, found $val"
22251 run_test 230m "xattrs not changed after dir migration"
22254 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22255 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
22256 skip "Need MDS version at least 2.13.53"
22258 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
22259 cat /etc/hosts > $DIR/$tdir/$tfile
22260 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
22261 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
22263 cmp /etc/hosts $DIR/$tdir/$tfile ||
22264 error "File data mismatch after migration"
22266 run_test 230n "Dir migration with mirrored file"
22269 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
22270 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
22271 skip "Need MDS version at least 2.13.52"
22273 local mdts=$(comma_list $(mdts_nodes))
22275 local restripe_status
22279 [[ $mds1_FSTYPE == zfs ]] && timeout=300
22281 # in case "crush" hash type is not set
22282 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
22284 restripe_status=$(do_facet mds1 $LCTL get_param -n \
22285 mdt.*MDT0000.enable_dir_restripe)
22286 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
22287 stack_trap "do_nodes $mdts $LCTL set_param \
22288 mdt.*.enable_dir_restripe=$restripe_status"
22291 createmany -m $DIR/$tdir/f 100 ||
22292 error "create files under remote dir failed $i"
22293 createmany -d $DIR/$tdir/d 100 ||
22294 error "create dirs under remote dir failed $i"
22296 for i in $(seq 2 $MDSCOUNT); do
22297 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
22298 $LFS setdirstripe -c $i $DIR/$tdir ||
22299 error "split -c $i $tdir failed"
22300 wait_update $HOSTNAME \
22301 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
22302 error "dir split not finished"
22303 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
22304 awk '/migrate/ {sum += $2} END { print sum }')
22305 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
22306 # delta is around total_files/stripe_count
22307 (( $delta < 200 / (i - 1) + 4 )) ||
22308 error "$delta files migrated >= $((200 / (i - 1) + 4))"
22311 run_test 230o "dir split"
22314 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22315 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
22316 skip "Need MDS version at least 2.13.52"
22318 local mdts=$(comma_list $(mdts_nodes))
22320 local restripe_status
22324 [[ $mds1_FSTYPE == zfs ]] && timeout=300
22326 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
22328 restripe_status=$(do_facet mds1 $LCTL get_param -n \
22329 mdt.*MDT0000.enable_dir_restripe)
22330 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
22331 stack_trap "do_nodes $mdts $LCTL set_param \
22332 mdt.*.enable_dir_restripe=$restripe_status"
22334 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
22335 createmany -m $DIR/$tdir/f 100 ||
22336 error "create files under remote dir failed"
22337 createmany -d $DIR/$tdir/d 100 ||
22338 error "create dirs under remote dir failed"
22340 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
22341 local mdt_hash="crush"
22343 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
22344 $LFS setdirstripe -c $c $DIR/$tdir ||
22345 error "split -c $c $tdir failed"
22346 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
22347 mdt_hash="$mdt_hash,fixed"
22348 elif [ $c -eq 1 ]; then
22351 wait_update $HOSTNAME \
22352 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
22353 error "dir merge not finished"
22354 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
22355 awk '/migrate/ {sum += $2} END { print sum }')
22356 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
22357 # delta is around total_files/stripe_count
22358 (( delta < 200 / c + 4 )) ||
22359 error "$delta files migrated >= $((200 / c + 4))"
22362 run_test 230p "dir merge"
22365 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
22366 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
22367 skip "Need MDS version at least 2.13.52"
22369 local mdts=$(comma_list $(mdts_nodes))
22370 local saved_threshold=$(do_facet mds1 \
22371 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
22372 local saved_delta=$(do_facet mds1 \
22373 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
22374 local threshold=100
22377 local stripe_count=0
22382 # test with fewer files on ZFS
22383 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
22385 stack_trap "do_nodes $mdts $LCTL set_param \
22386 mdt.*.dir_split_count=$saved_threshold"
22387 stack_trap "do_nodes $mdts $LCTL set_param \
22388 mdt.*.dir_split_delta=$saved_delta"
22389 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
22390 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
22391 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
22392 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
22393 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
22394 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
22396 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
22397 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
22399 create=$((threshold * 3 / 2))
22400 while [ $stripe_count -lt $MDSCOUNT ]; do
22401 createmany -m $DIR/$tdir/f $total $create ||
22402 error "create sub files failed"
22403 stat $DIR/$tdir > /dev/null
22404 total=$((total + create))
22405 stripe_count=$((stripe_count + delta))
22406 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
22408 wait_update $HOSTNAME \
22409 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
22410 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
22412 wait_update $HOSTNAME \
22413 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
22414 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
22416 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
22417 echo "$nr_files/$total files on MDT$stripe_index after split"
22418 # allow 10% margin of imbalance with crush hash
22419 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
22420 error "$nr_files files on MDT$stripe_index after split"
22422 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
22423 [ $nr_files -eq $total ] ||
22424 error "total sub files $nr_files != $total"
22427 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
22429 echo "fixed layout directory won't auto split"
22430 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
22431 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
22432 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
22433 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
22434 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
22436 run_test 230q "dir auto split"
22439 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
22440 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
22441 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
22442 skip "Need MDS version at least 2.13.54"
22444 # maximum amount of local locks:
22445 # parent striped dir - 2 locks
22446 # new stripe in parent to migrate to - 1 lock
22447 # source and target - 2 locks
22448 # Total 5 locks for regular file
22449 mkdir -p $DIR/$tdir
22450 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
22451 touch $DIR/$tdir/dir1/eee
22453 # create 4 hardlink for 4 more locks
22454 # Total: 9 locks > RS_MAX_LOCKS (8)
22455 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
22456 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
22457 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
22458 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
22459 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
22460 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
22461 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
22462 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
22464 cancel_lru_locks mdc
22466 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
22467 error "migrate dir fails"
22469 rm -rf $DIR/$tdir || error "rm dir failed after migration"
22471 run_test 230r "migrate with too many local locks"
22474 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
22475 skip "Need MDS version at least 2.14.52"
22477 local mdts=$(comma_list $(mdts_nodes))
22478 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
22479 mdt.*MDT0000.enable_dir_restripe)
22481 stack_trap "do_nodes $mdts $LCTL set_param \
22482 mdt.*.enable_dir_restripe=$restripe_status"
22486 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
22487 test_mkdir $DIR/$tdir
22488 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
22489 error "$LFS mkdir should return EEXIST if target exists"
22493 run_test 230s "lfs mkdir should return -EEXIST if target exists"
22497 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
22498 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
22499 skip "Need MDS version at least 2.14.50"
22501 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
22502 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
22503 $LFS project -p 1 -s $DIR/$tdir ||
22504 error "set $tdir project id failed"
22505 $LFS project -p 2 -s $DIR/$tdir/subdir ||
22506 error "set subdir project id failed"
22507 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
22509 run_test 230t "migrate directory with project ID set"
22513 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
22514 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
22515 skip "Need MDS version at least 2.14.53"
22519 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
22520 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
22521 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
22522 for i in $(seq 0 $((MDSCOUNT - 1))); do
22523 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
22524 echo "$count dirs migrated to MDT$i"
22526 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
22527 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
22529 run_test 230u "migrate directory by QOS"
22533 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
22534 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
22535 skip "Need MDS version at least 2.14.53"
22539 mkdir $DIR/$tdir || error "mkdir $tdir failed"
22540 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
22541 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
22542 for i in $(seq 0 $((MDSCOUNT - 1))); do
22543 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
22544 echo "$count subdirs migrated to MDT$i"
22545 (( i == 3 )) && (( count > 0 )) &&
22546 error "subdir shouldn't be migrated to MDT3"
22548 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
22549 (( count == 3 )) || error "dirs migrated to $count MDTs"
22551 run_test 230v "subdir migrated to the MDT where its parent is located"
22554 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22555 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
22556 skip "Need MDS version at least 2.15.0"
22558 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
22559 createmany -o $DIR/$tdir/f 10 || error "create files failed"
22560 createmany -d $DIR/$tdir/d 10 || error "create dirs failed"
22562 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
22563 error "migrate failed"
22565 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
22566 error "$tdir stripe count mismatch"
22568 for i in $(seq 0 9); do
22569 (( $($LFS getdirstripe -c $DIR/$tdir/d$i) == 0 )) ||
22570 error "d$i is striped"
22573 run_test 230w "non-recursive mode dir migration"
22576 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22577 (( MDS1_VERSION >= $(version_code 2.15.0) )) ||
22578 skip "Need MDS version at least 2.15.0"
22580 mkdir -p $DIR/$tdir || error "mkdir failed"
22581 createmany -d $DIR/$tdir/sub 100 || error "createmany failed"
22583 local mdt_name=$(mdtname_from_index 0)
22584 local low=$(do_facet mds2 $LCTL get_param -n \
22585 osp.*$mdt_name-osp-MDT0001.reserved_ino_low)
22586 local high=$(do_facet mds2 $LCTL get_param -n \
22587 osp.*$mdt_name-osp-MDT0001.reserved_ino_high)
22588 local ffree=$($LFS df -i $MOUNT | awk "/$mdt_name/ { print \$4 }")
22589 local maxage=$(do_facet mds2 $LCTL get_param -n \
22590 osp.*$mdt_name-osp-MDT0001.maxage)
22592 stack_trap "do_facet mds2 $LCTL set_param -n \
22593 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low \
22594 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high" EXIT
22595 stack_trap "do_facet mds2 $LCTL set_param -n \
22596 osp.*$mdt_name-osp-MDT0001.maxage=$maxage" EXIT
22598 do_facet mds2 $LCTL set_param -n \
22599 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$((ffree + 1))
22600 do_facet mds2 $LCTL set_param -n osp.*$mdt_name-osp-MDT0001.maxage=1
22602 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir &&
22603 error "migrate $tdir should fail"
22605 do_facet mds2 $LCTL set_param -n \
22606 osp.*$mdt_name-osp-MDT0001.reserved_ino_low=$low
22607 do_facet mds2 $LCTL set_param -n \
22608 osp.*$mdt_name-osp-MDT0001.reserved_ino_high=$high
22610 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir ||
22611 error "migrate failed"
22612 (( $($LFS getdirstripe -c $DIR/$tdir) == $MDSCOUNT )) ||
22613 error "$tdir stripe count mismatch"
22615 run_test 230x "dir migration check space"
22618 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22619 (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
22620 skip "Need MDS version at least 2.15.55.45"
22624 test_mkdir -c -1 $DIR/$tdir || error "mkdir $tdir failed"
22625 $LFS getdirstripe $DIR/$tdir
22626 createmany -d $DIR/$tdir/d 100 || error "createmany failed"
22627 $LFS migrate -m 1 -c 2 $DIR/$tdir &
22631 #OBD_FAIL_MIGRATE_BAD_HASH 0x1802
22632 do_facet mds2 lctl set_param fail_loc=0x1802
22635 do_facet mds2 lctl set_param fail_loc=0
22636 $LFS getdirstripe $DIR/$tdir
22637 unlinkmany -d $DIR/$tdir/d 100 || error "unlinkmany failed"
22638 rmdir $DIR/$tdir || error "rmdir $tdir failed"
22640 run_test 230y "unlink dir with bad hash type"
22643 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
22644 (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
22645 skip "Need MDS version at least 2.15.55.45"
22649 test_mkdir -c -1 $DIR/$tdir || error "mkdir $tdir failed"
22650 $LFS getdirstripe $DIR/$tdir
22651 createmany -d $DIR/$tdir/d 100 || error "createmany failed"
22652 $LFS migrate -m 1 -c 2 -H fnv_1a_64 $DIR/$tdir &
22656 #OBD_FAIL_MIGRATE_BAD_HASH 0x1802
22657 do_facet mds2 lctl set_param fail_loc=0x1802
22660 do_facet mds2 lctl set_param fail_loc=0
22661 $LFS getdirstripe $DIR/$tdir
22664 $LFS migrate -m 1 -c 2 -H fnv_1a_64 $DIR/$tdir ||
22665 error "resume migration failed"
22666 $LFS getdirstripe $DIR/$tdir
22667 [ $($LFS getdirstripe -H $DIR/$tdir) == "fnv_1a_64,fixed" ] ||
22668 error "migration is not finished"
22670 run_test 230z "resume dir migration with bad hash type"
22674 # For simplicity this test assumes that max_pages_per_rpc
22675 # is the same across all OSCs
22676 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
22677 local bulk_size=$((max_pages * PAGE_SIZE))
22678 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
22681 mkdir -p $DIR/$tdir
22682 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
22683 error "failed to set stripe with -S ${brw_size}M option"
22684 stack_trap "rm -rf $DIR/$tdir"
22686 # clear the OSC stats
22687 $LCTL set_param osc.*.stats=0 &>/dev/null
22690 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
22691 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
22692 oflag=direct &>/dev/null || error "dd failed"
22694 sync; sleep 1; sync # just to be safe
22695 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
22696 if [ x$nrpcs != "x1" ]; then
22697 $LCTL get_param osc.*.stats
22698 error "found $nrpcs ost_write RPCs, not 1 as expected"
22702 # Drop the OSC cache, otherwise we will read from it
22703 cancel_lru_locks osc
22705 # clear the OSC stats
22706 $LCTL set_param osc.*.stats=0 &>/dev/null
22708 # Client reads $bulk_size.
22709 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
22710 iflag=direct &>/dev/null || error "dd failed"
22712 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
22713 if [ x$nrpcs != "x1" ]; then
22714 $LCTL get_param osc.*.stats
22715 error "found $nrpcs ost_read RPCs, not 1 as expected"
22718 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
22721 mkdir -p $DIR/$tdir
22722 stack_trap "rm -rf $DIR/$tdir"
22724 for i in {0..1023}; do
22725 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
22726 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
22727 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
22731 run_test 231b "must not assert on fully utilized OST request buffer"
22734 mkdir -p $DIR/$tdir
22735 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
22737 #define OBD_FAIL_LDLM_OST_LVB 0x31c
22738 do_facet ost1 $LCTL set_param fail_loc=0x31c
22740 # ignore dd failure
22741 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
22742 stack_trap "rm -f $DIR/$tdir/$tfile"
22744 do_facet ost1 $LCTL set_param fail_loc=0
22745 umount_client $MOUNT || error "umount failed"
22746 mount_client $MOUNT || error "mount failed"
22747 stop ost1 || error "cannot stop ost1"
22748 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22750 run_test 232a "failed lock should not block umount"
22753 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
22754 skip "Need MDS version at least 2.10.58"
22756 mkdir -p $DIR/$tdir
22757 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
22758 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
22759 stack_trap "rm -f $DIR/$tdir/$tfile"
22761 cancel_lru_locks osc
22763 #define OBD_FAIL_LDLM_OST_LVB 0x31c
22764 do_facet ost1 $LCTL set_param fail_loc=0x31c
22767 $LFS data_version $DIR/$tdir/$tfile || true
22769 do_facet ost1 $LCTL set_param fail_loc=0
22770 umount_client $MOUNT || error "umount failed"
22771 mount_client $MOUNT || error "mount failed"
22772 stop ost1 || error "cannot stop ost1"
22773 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22775 run_test 232b "failed data version lock should not block umount"
22778 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
22779 skip "Need MDS version at least 2.3.64"
22780 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
22782 local fid=$($LFS path2fid $MOUNT)
22784 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
22785 error "cannot access $MOUNT using its FID '$fid'"
22787 run_test 233a "checking that OBF of the FS root succeeds"
22790 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
22791 skip "Need MDS version at least 2.5.90"
22792 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
22794 local fid=$($LFS path2fid $MOUNT/.lustre)
22796 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
22797 error "cannot access $MOUNT/.lustre using its FID '$fid'"
22799 fid=$($LFS path2fid $MOUNT/.lustre/fid)
22800 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
22801 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
22803 run_test 233b "checking that OBF of the FS .lustre succeeds"
22806 local p="$TMP/sanityN-$TESTNAME.parameters"
22807 save_lustre_params client "llite.*.xattr_cache" > $p
22808 lctl set_param llite.*.xattr_cache 1 ||
22809 skip_env "xattr cache is not supported"
22811 mkdir -p $DIR/$tdir || error "mkdir failed"
22812 touch $DIR/$tdir/$tfile || error "touch failed"
22813 # OBD_FAIL_LLITE_XATTR_ENOMEM
22814 $LCTL set_param fail_loc=0x1405
22815 getfattr -n user.attr $DIR/$tdir/$tfile &&
22816 error "getfattr should have failed with ENOMEM"
22817 $LCTL set_param fail_loc=0x0
22820 restore_lustre_params < $p
22823 run_test 234 "xattr cache should not crash on ENOMEM"
22826 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
22827 skip "Need MDS version at least 2.4.52"
22829 flock_deadlock $DIR/$tfile
22834 124) error "process hangs on a deadlock"
22836 *) error "error executing flock_deadlock $DIR/$tfile"
22840 run_test 235 "LU-1715: flock deadlock detection does not work properly"
22844 check_swap_layouts_support
22846 local ref1=/etc/passwd
22847 local ref2=/etc/group
22848 local file1=$DIR/$tdir/f1
22849 local file2=$DIR/$tdir/f2
22851 test_mkdir -c1 $DIR/$tdir
22852 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
22853 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
22854 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
22855 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
22856 local fd=$(free_fd)
22857 local cmd="exec $fd<>$file2"
22860 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
22861 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
22864 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
22869 run_test 236 "Layout swap on open unlinked file"
22871 # LU-4659 linkea consistency
22873 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
22874 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
22875 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
22876 skip "Need MDS version at least 2.5.58 or 2.5.2+"
22879 ln $DIR/$tfile $DIR/$tfile.lnk
22880 touch $DIR/$tfile.new
22881 mv $DIR/$tfile.new $DIR/$tfile
22882 local fid1=$($LFS path2fid $DIR/$tfile)
22883 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
22884 local path1=$($LFS fid2path $FSNAME "$fid1")
22885 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
22886 local path2=$($LFS fid2path $FSNAME "$fid2")
22887 [ $tfile.lnk == $path2 ] ||
22888 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
22891 run_test 238 "Verify linkea consistency"
22893 test_239A() { # was test_239
22894 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
22895 skip "Need MDS version at least 2.5.60"
22897 local list=$(comma_list $(mdts_nodes))
22899 mkdir -p $DIR/$tdir
22900 createmany -o $DIR/$tdir/f- 5000
22901 unlinkmany $DIR/$tdir/f- 5000
22902 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
22903 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
22904 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
22905 osp.*MDT*.sync_in_flight" | calc_sum)
22906 [ "$changes" -eq 0 ] || error "$changes not synced"
22908 run_test 239A "osp_sync test"
22910 test_239a() { #LU-5297
22911 remote_mds_nodsh && skip "remote MDS with nodsh"
22914 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
22915 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
22916 chgrp $RUNAS_GID $DIR/$tfile
22917 wait_delete_completed
22919 run_test 239a "process invalid osp sync record correctly"
22921 test_239b() { #LU-5297
22922 remote_mds_nodsh && skip "remote MDS with nodsh"
22925 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
22926 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
22927 chgrp $RUNAS_GID $DIR/$tfile1
22928 wait_delete_completed
22929 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
22931 chgrp $RUNAS_GID $DIR/$tfile2
22932 wait_delete_completed
22934 run_test 239b "process osp sync record with ENOMEM error correctly"
22937 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22938 remote_mds_nodsh && skip "remote MDS with nodsh"
22940 mkdir -p $DIR/$tdir
22942 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
22943 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
22944 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
22945 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
22947 umount_client $MOUNT || error "umount failed"
22948 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
22949 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
22950 mount_client $MOUNT || error "failed to mount client"
22952 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
22953 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
22955 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
22961 for LOOP in $(seq $count); do
22962 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
22963 cancel_lru_locks $OSC || true
22971 for LOOP in $(seq $1); do
22972 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
22977 test_241a() { # was test_241
22978 local bsize=$PAGE_SIZE
22980 (( bsize < 40960 )) && bsize=40960
22981 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
22983 cancel_lru_locks $OSC
22984 test_241_bio 1000 $bsize &
22986 test_241_dio 1000 $bsize
22989 run_test 241a "bio vs dio"
22992 local bsize=$PAGE_SIZE
22994 (( bsize < 40960 )) && bsize=40960
22995 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
22997 test_241_dio 1000 $bsize &
22999 test_241_dio 1000 $bsize
23002 run_test 241b "dio vs dio"
23005 remote_mds_nodsh && skip "remote MDS with nodsh"
23007 mkdir_on_mdt0 $DIR/$tdir
23008 touch $DIR/$tdir/$tfile
23010 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
23011 do_facet mds1 lctl set_param fail_loc=0x105
23012 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
23014 do_facet mds1 lctl set_param fail_loc=0
23015 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
23017 run_test 242 "mdt_readpage failure should not cause directory unreadable"
23021 test_mkdir $DIR/$tdir
23022 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
23024 run_test 243 "various group lock tests"
23028 test_mkdir $DIR/$tdir
23029 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
23030 sendfile_grouplock $DIR/$tdir/$tfile || \
23031 error "sendfile+grouplock failed"
23034 run_test 244a "sendfile with group lock tests"
23038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
23041 local size=$((1024*1024))
23043 test_mkdir $DIR/$tdir
23044 for i in $(seq 1 $threads); do
23045 local file=$DIR/$tdir/file_$((i / 10))
23046 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
23049 for i in $(seq 1 $threads); do
23053 run_test 244b "multi-threaded write with group lock"
23056 local flagname="multi_mod_rpcs"
23057 local connect_data_name="max_mod_rpcs"
23060 # check if multiple modify RPCs flag is set
23061 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
23062 grep "connect_flags:")
23065 echo "$out" | grep -qw $flagname
23066 if [ $? -ne 0 ]; then
23067 echo "connect flag $flagname is not set"
23071 # check if multiple modify RPCs data is set
23072 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
23075 echo "$out" | grep -qw $connect_data_name ||
23076 error "import should have connect data $connect_data_name"
23078 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
23081 local flagname="multi_mod_rpcs"
23082 local connect_data_name="max_mod_rpcs"
23085 remote_mds_nodsh && skip "remote MDS with nodsh"
23086 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
23088 # check if multiple modify RPCs flag is set
23089 out=$(do_facet mds1 \
23090 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
23091 grep "connect_flags:")
23094 [[ "$out" =~ $flagname ]] || skip "connect flag $flagname is not set"
23096 # check if multiple modify RPCs data is set
23097 out=$(do_facet mds1 \
23098 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
23100 [[ "$out" =~ $connect_data_name ]] ||
23103 error "missing connect data $connect_data_name"
23106 run_test 245b "check osp connection flag/data: multiple modify RPCs"
23112 umount_client $submount
23117 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
23119 skip_env "Fileset feature is not supported"
23121 local submount=${MOUNT}_$tdir
23124 mkdir -p $submount || error "mkdir $submount failed"
23125 FILESET="$FILESET/$tdir" mount_client $submount ||
23126 error "mount $submount failed"
23127 trap "cleanup_247 $submount" EXIT
23128 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
23129 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
23130 error "read $MOUNT/$tdir/$tfile failed"
23131 cleanup_247 $submount
23133 run_test 247a "mount subdir as fileset"
23136 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
23137 skip_env "Fileset feature is not supported"
23139 local submount=${MOUNT}_$tdir
23141 rm -rf $MOUNT/$tdir
23142 mkdir -p $submount || error "mkdir $submount failed"
23144 FILESET="$FILESET/$tdir" mount_client $submount &&
23145 error "mount $submount should fail"
23148 run_test 247b "mount subdir that dose not exist"
23151 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
23152 skip_env "Fileset feature is not supported"
23154 local submount=${MOUNT}_$tdir
23156 mkdir -p $MOUNT/$tdir/dir1
23157 mkdir -p $submount || error "mkdir $submount failed"
23158 trap "cleanup_247 $submount" EXIT
23159 FILESET="$FILESET/$tdir" mount_client $submount ||
23160 error "mount $submount failed"
23161 local fid=$($LFS path2fid $MOUNT/)
23162 $LFS fid2path $submount $fid && error "fid2path should fail"
23163 cleanup_247 $submount
23165 run_test 247c "running fid2path outside subdirectory root"
23168 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
23169 skip "Fileset feature is not supported"
23171 local submount=${MOUNT}_$tdir
23173 mkdir -p $MOUNT/$tdir/dir1
23174 mkdir -p $submount || error "mkdir $submount failed"
23175 FILESET="$FILESET/$tdir" mount_client $submount ||
23176 error "mount $submount failed"
23177 trap "cleanup_247 $submount" EXIT
23179 local td=$submount/dir1
23180 local fid=$($LFS path2fid $td)
23181 [ -z "$fid" ] && error "path2fid unable to get $td FID"
23183 # check that we get the same pathname back
23186 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
23187 echo "$rootpath $fid"
23188 found=$($LFS fid2path $rootpath "$fid")
23189 [ -n "$found" ] || error "fid2path should succeed"
23190 [ "$found" == "$td" ] || error "fid2path $found != $td"
23192 # check wrong root path format
23193 rootpath=$submount"_wrong"
23194 found=$($LFS fid2path $rootpath "$fid")
23195 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
23197 cleanup_247 $submount
23199 run_test 247d "running fid2path inside subdirectory root"
23203 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
23205 skip "Fileset feature is not supported"
23207 local submount=${MOUNT}_$tdir
23210 mkdir -p $submount || error "mkdir $submount failed"
23211 FILESET="$FILESET/.." mount_client $submount &&
23212 error "mount $submount should fail"
23215 run_test 247e "mount .. as fileset"
23218 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
23219 (( $MDS1_VERSION >= $(version_code 2.14.50.162) )) ||
23220 skip "Need at least version 2.14.50.162"
23221 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
23222 skip "Fileset feature is not supported"
23224 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
23225 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
23226 error "mkdir remote failed"
23227 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
23228 error "mkdir remote/subdir failed"
23229 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
23230 error "mkdir striped failed"
23231 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
23233 local submount=${MOUNT}_$tdir
23235 mkdir -p $submount || error "mkdir $submount failed"
23236 stack_trap "rmdir $submount"
23239 local fileset=$FILESET
23240 local mdts=$(comma_list $(mdts_nodes))
23242 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
23243 for dir in $tdir/remote $tdir/remote/subdir $tdir/striped \
23244 $tdir/striped/subdir $tdir/striped/.; do
23245 FILESET="$fileset/$dir" mount_client $submount ||
23246 error "mount $dir failed"
23247 umount_client $submount
23250 run_test 247f "mount striped or remote directory as fileset"
23252 test_subdir_mount_lock()
23255 local submount=${MOUNT}_$(basename $testdir)
23257 touch $DIR/$testdir/$tfile || error "touch $tfile failed"
23259 mkdir -p $submount || error "mkdir $submount failed"
23260 stack_trap "rmdir $submount"
23262 FILESET="$fileset/$testdir" mount_client $submount ||
23263 error "mount $FILESET failed"
23264 stack_trap "umount $submount"
23266 local mdts=$(comma_list $(mdts_nodes))
23270 stat $submount > /dev/null || error "stat $submount failed"
23271 cancel_lru_locks $MDC
23272 stat $submount > /dev/null || error "stat $submount failed"
23273 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
23274 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
23275 stat $submount/$tfile > /dev/null || error "stat $tfile failed"
23276 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
23277 awk '/getattr/ {sum += $2} END {print sum}')
23279 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
23283 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
23285 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
23286 error "mkdir $tdir failed"
23287 test_subdir_mount_lock $tdir
23289 run_test 247g "striped directory submount revalidate ROOT from cache"
23292 (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
23293 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
23294 skip "Need MDS version at least 2.15.51"
23296 $LFS mkdir -i 1 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
23297 test_subdir_mount_lock $tdir
23298 mkdir_on_mdt -i 0 $DIR/$tdir/$tdir.0 || error "mkdir $tdir.0 failed"
23299 mkdir_on_mdt -i 1 $DIR/$tdir/$tdir.0/$tdir.1 ||
23300 error "mkdir $tdir.1 failed"
23301 test_subdir_mount_lock $tdir/$tdir.0/$tdir.1
23303 run_test 247h "remote directory submount revalidate ROOT from cache"
23306 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
23307 [ -z "$fast_read_sav" ] && skip "no fast read support"
23309 # create a large file for fast read verification
23310 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
23312 # make sure the file is created correctly
23313 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
23314 { rm -f $DIR/$tfile; skip "file creation error"; }
23316 echo "Test 1: verify that fast read is 4 times faster on cache read"
23318 # small read with fast read enabled
23319 $LCTL set_param -n llite.*.fast_read=1
23320 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
23321 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23322 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23323 # small read with fast read disabled
23324 $LCTL set_param -n llite.*.fast_read=0
23325 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
23326 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23327 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23329 # verify that fast read is 4 times faster for cache read
23330 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
23331 error_not_in_vm "fast read was not 4 times faster: " \
23332 "$t_fast vs $t_slow"
23334 echo "Test 2: verify the performance between big and small read"
23335 $LCTL set_param -n llite.*.fast_read=1
23337 # 1k non-cache read
23338 cancel_lru_locks osc
23339 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
23340 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23341 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23343 # 1M non-cache read
23344 cancel_lru_locks osc
23345 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
23346 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
23347 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
23349 # verify that big IO is not 4 times faster than small IO
23350 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
23351 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
23353 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
23356 run_test 248a "fast read verification"
23359 # Default short_io_bytes=16384, try both smaller and larger sizes.
23360 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
23361 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
23362 echo "bs=53248 count=113 normal buffered write"
23363 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
23364 error "dd of initial data file failed"
23365 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
23367 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
23368 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
23369 error "dd with sync normal writes failed"
23370 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
23372 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
23373 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
23374 error "dd with sync small writes failed"
23375 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
23377 cancel_lru_locks osc
23379 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
23380 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
23381 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
23382 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
23383 iflag=direct || error "dd with O_DIRECT small read failed"
23384 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
23385 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
23386 error "compare $TMP/$tfile.1 failed"
23388 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
23389 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
23391 # just to see what the maximum tunable value is, and test parsing
23392 echo "test invalid parameter 2MB"
23393 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
23394 error "too-large short_io_bytes allowed"
23395 echo "test maximum parameter 512KB"
23396 # if we can set a larger short_io_bytes, run test regardless of version
23397 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
23398 # older clients may not allow setting it this large, that's OK
23399 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
23400 skip "Need at least client version 2.13.50"
23401 error "medium short_io_bytes failed"
23403 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
23404 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
23406 echo "test large parameter 64KB"
23407 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
23408 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
23410 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
23411 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
23412 error "dd with sync large writes failed"
23413 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
23415 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
23416 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
23417 num=$((113 * 4096 / PAGE_SIZE))
23418 echo "bs=$size count=$num oflag=direct large write $tfile.3"
23419 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
23420 error "dd with O_DIRECT large writes failed"
23421 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
23422 error "compare $DIR/$tfile.3 failed"
23424 cancel_lru_locks osc
23426 echo "bs=$size count=$num iflag=direct large read $tfile.2"
23427 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
23428 error "dd with O_DIRECT large read failed"
23429 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
23430 error "compare $TMP/$tfile.2 failed"
23432 echo "bs=$size count=$num iflag=direct large read $tfile.3"
23433 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
23434 error "dd with O_DIRECT large read failed"
23435 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
23436 error "compare $TMP/$tfile.3 failed"
23438 run_test 248b "test short_io read and write for both small and large sizes"
23440 test_249() { # LU-7890
23441 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
23442 skip "Need at least version 2.8.54"
23445 $LFS setstripe -c 1 $DIR/$tfile
23446 # Offset 2T == 4k * 512M
23447 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
23448 error "dd to 2T offset failed"
23450 run_test 249 "Write above 2T file size"
23453 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
23454 && skip "no 16TB file size limit on ZFS"
23456 $LFS setstripe -c 1 $DIR/$tfile
23457 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
23458 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
23459 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
23460 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
23461 conv=notrunc,fsync && error "append succeeded"
23464 run_test 250 "Write above 16T limit"
23467 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
23469 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
23470 #Skip once - writing the first stripe will succeed
23471 $LCTL set_param fail_loc=0xa0001407 fail_val=1
23472 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
23473 error "short write happened"
23475 $LCTL set_param fail_loc=0xa0001407 fail_val=1
23476 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
23477 error "short read happened"
23481 run_test 251 "Handling short read and write correctly"
23484 remote_mds_nodsh && skip "remote MDS with nodsh"
23485 remote_ost_nodsh && skip "remote OST with nodsh"
23486 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
23487 skip_env "ldiskfs only test"
23497 # check lr_reader on OST0000
23499 dev=$(facet_device $tgt)
23500 out=$(do_facet $tgt $LR_READER $dev)
23501 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
23503 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
23504 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
23505 error "Invalid uuid returned by $LR_READER on target $tgt"
23506 echo -e "uuid returned by $LR_READER is '$uuid'\n"
23508 # check lr_reader -c on MDT0000
23510 dev=$(facet_device $tgt)
23511 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
23512 skip "$LR_READER does not support additional options"
23514 out=$(do_facet $tgt $LR_READER -c $dev)
23515 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
23517 num=$(echo "$out" | grep -c "mdtlov")
23518 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
23519 error "Invalid number of mdtlov clients returned by $LR_READER"
23520 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
23522 # check lr_reader -cr on MDT0000
23523 out=$(do_facet $tgt $LR_READER -cr $dev)
23524 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
23526 echo "$out" | grep -q "^reply_data:$" ||
23527 error "$LR_READER should have returned 'reply_data' section"
23528 num=$(echo "$out" | grep -c "client_generation")
23529 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
23531 run_test 252 "check lr_reader tool"
23534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23535 remote_mds_nodsh && skip "remote MDS with nodsh"
23536 remote_mgs_nodsh && skip "remote MGS with nodsh"
23540 local ost_name=$(ostname_from_index $ostidx)
23543 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
23544 do_facet $SINGLEMDS $LCTL get_param -n \
23545 osp.$mdtosc_proc1.reserved_mb_high ||
23546 skip "remote MDS does not support reserved_mb_high"
23550 wait_delete_completed
23552 stack_trap "rm -rf $DIR/$tdir"
23554 pool_add $TESTNAME || error "Pool creation failed"
23555 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
23557 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
23558 error "Setstripe failed"
23560 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
23562 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
23564 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
23566 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
23567 osp.$mdtosc_proc1.prealloc_status)
23568 echo "prealloc_status $oa_status"
23570 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
23571 error "File creation should fail"
23573 #object allocation was stopped, but we still able to append files
23574 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
23575 oflag=append || error "Append failed"
23577 rm -f $DIR/$tdir/$tfile.0
23579 # For this test, we want to delete the files we created to go out of
23580 # space but leave the watermark, so we remain nearly out of space
23581 ost_watermarks_enospc_delete_files $tfile $ostidx
23583 wait_delete_completed
23587 for i in $(seq 10 12); do
23588 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
23589 2>/dev/null || error "File creation failed after rm"
23592 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
23593 osp.$mdtosc_proc1.prealloc_status)
23594 echo "prealloc_status $oa_status"
23596 if (( oa_status != 0 )); then
23597 error "Object allocation still disable after rm"
23600 run_test 253 "Check object allocation limit"
23603 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23604 remote_mds_nodsh && skip "remote MDS with nodsh"
23606 local mdt=$(facet_svc $SINGLEMDS)
23608 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
23609 skip "MDS does not support changelog_size"
23613 changelog_register || error "changelog_register failed"
23615 changelog_clear 0 || error "changelog_clear failed"
23617 local size1=$(do_facet $SINGLEMDS \
23618 $LCTL get_param -n mdd.$mdt.changelog_size)
23619 echo "Changelog size $size1"
23622 $LFS mkdir -i 0 $DIR/$tdir
23624 mkdir -p $DIR/$tdir/pics/2008/zachy
23625 touch $DIR/$tdir/pics/2008/zachy/timestamp
23626 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
23627 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
23628 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
23629 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
23630 rm $DIR/$tdir/pics/desktop.jpg
23632 local size2=$(do_facet $SINGLEMDS \
23633 $LCTL get_param -n mdd.$mdt.changelog_size)
23634 echo "Changelog size after work $size2"
23636 (( $size2 > $size1 )) ||
23637 error "new Changelog size=$size2 less than old size=$size1"
23639 run_test 254 "Check changelog size"
23646 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
23647 awk -F: '{print $2}' | grep $type > /dev/null
23648 if [ $? -ne 0 ]; then
23658 lfs ladvise -a willread $file > /dev/null 2>&1
23659 if [ $? -eq 0 ]; then
23663 lfs ladvise -a willread $file 2>&1 |
23664 grep "Inappropriate ioctl for device" > /dev/null
23665 if [ $? -eq 0 ]; then
23672 bc <<<"scale=2; ($1 - $2) * 100 / $2"
23675 # run a random read IO workload
23676 # usage: random_read_iops <filename> <filesize> <iosize>
23677 random_read_iops() {
23680 local iosize=${3:-4096}
23682 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
23683 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
23686 drop_file_oss_cache() {
23690 $LFS ladvise -a dontneed $file 2>/dev/null ||
23691 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
23694 ladvise_willread_performance()
23697 local average_origin=0
23698 local average_cache=0
23699 local average_ladvise=0
23701 for ((i = 1; i <= $repeat; i++)); do
23702 echo "Iter $i/$repeat: reading without willread hint"
23703 cancel_lru_locks osc
23704 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
23705 local speed_origin=$(random_read_iops $DIR/$tfile $size)
23706 echo "Iter $i/$repeat: uncached speed: $speed_origin"
23707 average_origin=$(bc <<<"$average_origin + $speed_origin")
23709 cancel_lru_locks osc
23710 local speed_cache=$(random_read_iops $DIR/$tfile $size)
23711 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
23712 average_cache=$(bc <<<"$average_cache + $speed_cache")
23714 cancel_lru_locks osc
23715 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
23716 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
23717 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
23718 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
23719 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
23721 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
23722 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
23723 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
23725 speedup_cache=$(percent $average_cache $average_origin)
23726 speedup_ladvise=$(percent $average_ladvise $average_origin)
23728 echo "Average uncached read: $average_origin"
23729 echo "Average speedup with OSS cached read: " \
23730 "$average_cache = +$speedup_cache%"
23731 echo "Average speedup with ladvise willread: " \
23732 "$average_ladvise = +$speedup_ladvise%"
23734 local lowest_speedup=20
23735 if (( ${average_cache%.*} < $lowest_speedup )); then
23736 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
23737 " got $average_cache%. Skipping ladvise willread check."
23741 # the test won't work on ZFS until it supports 'ladvise dontneed', but
23742 # it is still good to run until then to exercise 'ladvise willread'
23743 ! $LFS ladvise -a dontneed $DIR/$tfile &&
23744 [ "$ost1_FSTYPE" = "zfs" ] &&
23745 echo "osd-zfs does not support dontneed or drop_caches" &&
23748 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
23749 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
23750 error_not_in_vm "Speedup with willread is less than " \
23751 "$lowest_speedup%, got $average_ladvise%"
23755 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
23756 skip "lustre < 2.8.54 does not support ladvise "
23757 remote_ost_nodsh && skip "remote OST with nodsh"
23759 stack_trap "rm -f $DIR/$tfile"
23760 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
23762 ladvise_no_type willread $DIR/$tfile &&
23763 skip "willread ladvise is not supported"
23765 ladvise_no_ioctl $DIR/$tfile &&
23766 skip "ladvise ioctl is not supported"
23769 local size=$((size_mb * 1048576))
23770 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
23771 error "dd to $DIR/$tfile failed"
23773 lfs ladvise -a willread $DIR/$tfile ||
23774 error "Ladvise failed with no range argument"
23776 lfs ladvise -a willread -s 0 $DIR/$tfile ||
23777 error "Ladvise failed with no -l or -e argument"
23779 lfs ladvise -a willread -e 1 $DIR/$tfile ||
23780 error "Ladvise failed with only -e argument"
23782 lfs ladvise -a willread -l 1 $DIR/$tfile ||
23783 error "Ladvise failed with only -l argument"
23785 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
23786 error "End offset should not be smaller than start offset"
23788 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
23789 error "End offset should not be equal to start offset"
23791 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
23792 error "Ladvise failed with overflowing -s argument"
23794 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
23795 error "Ladvise failed with overflowing -e argument"
23797 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
23798 error "Ladvise failed with overflowing -l argument"
23800 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
23801 error "Ladvise succeeded with conflicting -l and -e arguments"
23803 echo "Synchronous ladvise should wait"
23805 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
23806 do_nodes $(comma_list $(osts_nodes)) \
23807 $LCTL set_param fail_val=$delay fail_loc=0x237
23808 stack_trap "do_nodes $(comma_list $(osts_nodes)) \
23809 $LCTL set_param fail_loc=0"
23811 local start_ts=$SECONDS
23812 lfs ladvise -a willread $DIR/$tfile ||
23813 error "Ladvise failed with no range argument"
23814 local end_ts=$SECONDS
23815 local inteval_ts=$((end_ts - start_ts))
23817 if [ $inteval_ts -lt $(($delay - 1)) ]; then
23818 error "Synchronous advice didn't wait reply"
23821 echo "Asynchronous ladvise shouldn't wait"
23822 local start_ts=$SECONDS
23823 lfs ladvise -a willread -b $DIR/$tfile ||
23824 error "Ladvise failed with no range argument"
23825 local end_ts=$SECONDS
23826 local inteval_ts=$((end_ts - start_ts))
23828 if [ $inteval_ts -gt $(($delay / 2)) ]; then
23829 error "Asynchronous advice blocked"
23832 ladvise_willread_performance
23834 run_test 255a "check 'lfs ladvise -a willread'"
23840 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
23844 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
23845 skip "lustre < 2.8.54 does not support ladvise "
23846 remote_ost_nodsh && skip "remote OST with nodsh"
23848 stack_trap "rm -f $DIR/$tfile"
23849 lfs setstripe -c 1 -i 0 $DIR/$tfile
23851 ladvise_no_type dontneed $DIR/$tfile &&
23852 skip "dontneed ladvise is not supported"
23854 ladvise_no_ioctl $DIR/$tfile &&
23855 skip "ladvise ioctl is not supported"
23857 ! $LFS ladvise -a dontneed $DIR/$tfile &&
23858 [ "$ost1_FSTYPE" = "zfs" ] &&
23859 skip "zfs-osd does not support 'ladvise dontneed'"
23862 local size=$((size_mb * 1048576))
23863 # In order to prevent disturbance of other processes, only check 3/4
23864 # of the memory usage
23865 local kibibytes=$((size_mb * 1024 * 3 / 4))
23867 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
23868 error "dd to $DIR/$tfile failed"
23870 #force write to complete before dropping OST cache & checking memory
23873 local total=$(facet_meminfo ost1 MemTotal)
23874 echo "Total memory: $total KiB"
23876 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
23877 local before_read=$(facet_meminfo ost1 Cached)
23878 echo "Cache used before read: $before_read KiB"
23880 lfs ladvise -a willread $DIR/$tfile ||
23881 error "Ladvise willread failed"
23882 local after_read=$(facet_meminfo ost1 Cached)
23883 echo "Cache used after read: $after_read KiB"
23885 lfs ladvise -a dontneed $DIR/$tfile ||
23886 error "Ladvise dontneed again failed"
23887 local no_read=$(facet_meminfo ost1 Cached)
23888 echo "Cache used after dontneed ladvise: $no_read KiB"
23890 if [ $total -lt $((before_read + kibibytes)) ]; then
23891 echo "Memory is too small, abort checking"
23895 if [ $((before_read + kibibytes)) -gt $after_read ]; then
23896 error "Ladvise willread should use more memory" \
23897 "than $kibibytes KiB"
23900 if [ $((no_read + kibibytes)) -gt $after_read ]; then
23901 error "Ladvise dontneed should release more memory" \
23902 "than $kibibytes KiB"
23905 run_test 255b "check 'lfs ladvise -a dontneed'"
23908 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
23909 skip "lustre < 2.10.50 does not support lockahead"
23911 local ost1_imp=$(get_osc_import_name client ost1)
23912 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
23920 test_mkdir -p $DIR/$tdir
23921 $LFS setstripe -i 0 -c 1 $DIR/$tdir
23923 #test 10 returns only success/failure
23925 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23927 if [ $rc -eq 255 ]; then
23928 error "Ladvise test${i} failed, ${rc}"
23931 #test 11 counts lock enqueue requests, all others count new locks
23933 count=$(do_facet ost1 \
23934 $LCTL get_param -n ost.OSS.ost.stats)
23935 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
23937 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23939 if [ $rc -eq 255 ]; then
23940 error "Ladvise test${i} failed, ${rc}"
23943 new_count=$(do_facet ost1 \
23944 $LCTL get_param -n ost.OSS.ost.stats)
23945 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
23946 awk '{ print $2 }')
23948 difference="$((new_count - count))"
23949 if [ $difference -ne $rc ]; then
23950 error "Ladvise test${i}, bad enqueue count, returned " \
23951 "${rc}, actual ${difference}"
23954 for i in $(seq 12 21); do
23955 # If we do not do this, we run the risk of having too many
23956 # locks and starting lock cancellation while we are checking
23958 cancel_lru_locks osc
23960 count=$($LCTL get_param -n \
23961 ldlm.namespaces.$imp_name.lock_unused_count)
23963 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23965 if [ $rc -eq 255 ]; then
23966 error "Ladvise test ${i} failed, ${rc}"
23969 new_count=$($LCTL get_param -n \
23970 ldlm.namespaces.$imp_name.lock_unused_count)
23971 difference="$((new_count - count))"
23973 # Test 15 output is divided by 100 to map down to valid return
23974 if [ $i -eq 15 ]; then
23978 if [ $difference -ne $rc ]; then
23979 error "Ladvise test ${i}, bad lock count, returned " \
23980 "${rc}, actual ${difference}"
23984 #test 22 returns only success/failure
23986 lockahead_test -d $DIR/$tdir -t $i -f $tfile
23988 if [ $rc -eq 255 ]; then
23989 error "Ladvise test${i} failed, ${rc}"
23992 run_test 255c "suite of ladvise lockahead tests"
23995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23996 remote_mds_nodsh && skip "remote MDS with nodsh"
23997 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
23998 changelog_users $SINGLEMDS | grep "^cl" &&
23999 skip "active changelog user"
24005 mdt_dev=$(facet_device $SINGLEMDS)
24008 changelog_register || error "changelog_register failed"
24011 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
24013 changelog_clear 0 || error "changelog_clear failed"
24016 touch $DIR/$tdir/{1..10}
24019 stop $SINGLEMDS || error "Fail to stop MDT"
24022 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
24023 error "Fail to start MDT"
24025 #after mount new plainllog is used
24026 touch $DIR/$tdir/{11..19}
24027 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
24028 stack_trap "rm -f $tmpfile"
24029 cat_sl=$(do_facet $SINGLEMDS "sync; \
24030 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
24031 llog_reader $tmpfile | grep -c type=1064553b")
24032 do_facet $SINGLEMDS llog_reader $tmpfile
24034 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
24036 changelog_clear 0 || error "changelog_clear failed"
24038 cat_sl=$(do_facet $SINGLEMDS "sync; \
24039 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
24040 llog_reader $tmpfile | grep -c type=1064553b")
24042 if (( cat_sl == 2 )); then
24043 error "Empty plain llog was not deleted from changelog catalog"
24044 elif (( cat_sl != 1 )); then
24045 error "Active plain llog shouldn't be deleted from catalog"
24048 run_test 256 "Check llog delete for empty and not full state"
24051 remote_mds_nodsh && skip "remote MDS with nodsh"
24052 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
24053 skip "Need MDS version at least 2.8.55"
24055 test_mkdir $DIR/$tdir
24057 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
24058 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
24061 #define OBD_FAIL_MDS_XATTR_REP 0x161
24062 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
24063 local facet=mds$((mdtidx + 1))
24064 set_nodes_failloc $(facet_active_host $facet) 0x80000161
24065 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
24067 stop $facet || error "stop MDS failed"
24068 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
24069 error "start MDS fail"
24070 wait_recovery_complete $facet
24072 run_test 257 "xattr locks are not lost"
24074 # Verify we take the i_mutex when security requires it
24076 #define OBD_FAIL_IMUTEX_SEC 0x141c
24077 $LCTL set_param fail_loc=0x141c
24079 chmod u+s $DIR/$tfile
24080 chmod a+rwx $DIR/$tfile
24081 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
24083 if [ $RC -ne 0 ]; then
24084 error "error, failed to take i_mutex, rc=$?"
24088 run_test 258a "verify i_mutex security behavior when suid attributes is set"
24090 # Verify we do NOT take the i_mutex in the normal case
24092 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
24093 $LCTL set_param fail_loc=0x141d
24096 chmod a+rw $DIR/$tfile
24097 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
24099 if [ $RC -ne 0 ]; then
24100 error "error, took i_mutex unnecessarily, rc=$?"
24105 run_test 258b "verify i_mutex security behavior"
24108 local file=$DIR/$tfile
24112 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
24114 stack_trap "rm -f $file" EXIT
24116 wait_delete_completed
24117 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
24118 echo "before: $before"
24120 $LFS setstripe -i 0 -c 1 $file
24121 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
24123 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
24124 echo "after write: $after"
24126 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
24127 do_facet ost1 $LCTL set_param fail_loc=0x2301
24129 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
24130 echo "after truncate: $after"
24133 do_facet ost1 $LCTL set_param fail_loc=0
24134 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
24136 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
24137 echo "after restart: $after"
24138 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
24139 error "missing truncate?"
24143 run_test 259 "crash at delayed truncate"
24146 #define OBD_FAIL_MDC_CLOSE 0x806
24147 $LCTL set_param fail_loc=0x80000806
24151 run_test 260 "Check mdc_close fail"
24153 ### Data-on-MDT sanity tests ###
24155 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24156 skip "Need MDS version at least 2.10.55 for DoM"
24159 local dom=$DIR/$tdir/dom_file
24160 local tmp=$DIR/$tdir/tmp_file
24162 mkdir_on_mdt0 $DIR/$tdir
24164 # basic checks for DoM component creation
24165 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
24166 error "Can set MDT layout to non-first entry"
24168 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
24169 error "Can define multiple entries as MDT layout"
24171 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
24173 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
24174 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
24175 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
24177 local mdtidx=$($LFS getstripe -m $dom)
24178 local mdtname=MDT$(printf %04x $mdtidx)
24179 local facet=mds$((mdtidx + 1))
24180 local space_check=1
24182 # Skip free space checks with ZFS
24183 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
24187 local size_tmp=$((65536 * 3))
24188 local mdtfree1=$(do_facet $facet \
24189 lctl get_param -n osd*.*$mdtname.kbytesfree)
24191 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
24192 # check also direct IO along write
24193 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
24194 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
24196 cmp $tmp $dom || error "file data is different"
24197 [ $(stat -c%s $dom) == $size_tmp ] ||
24198 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
24199 if [ $space_check == 1 ]; then
24200 local mdtfree2=$(do_facet $facet \
24201 lctl get_param -n osd*.*$mdtname.kbytesfree)
24203 # increase in usage from by $size_tmp
24204 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
24205 error "MDT free space wrong after write: " \
24206 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
24210 local size_dom=10000
24212 $TRUNCATE $dom $size_dom
24213 [ $(stat -c%s $dom) == $size_dom ] ||
24214 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
24215 if [ $space_check == 1 ]; then
24216 mdtfree1=$(do_facet $facet \
24217 lctl get_param -n osd*.*$mdtname.kbytesfree)
24218 # decrease in usage from $size_tmp to new $size_dom
24219 [ $(($mdtfree1 - $mdtfree2)) -ge \
24220 $(((size_tmp - size_dom) / 1024)) ] ||
24221 error "MDT free space is wrong after truncate: " \
24222 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
24228 size_dom=$((size_dom + size_tmp))
24229 [ $(stat -c%s $dom) == $size_dom ] ||
24230 error "bad size after append: $(stat -c%s $dom) != $size_dom"
24231 if [ $space_check == 1 ]; then
24232 mdtfree2=$(do_facet $facet \
24233 lctl get_param -n osd*.*$mdtname.kbytesfree)
24234 # increase in usage by $size_tmp from previous
24235 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
24236 error "MDT free space is wrong after append: " \
24237 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
24242 if [ $space_check == 1 ]; then
24243 mdtfree1=$(do_facet $facet \
24244 lctl get_param -n osd*.*$mdtname.kbytesfree)
24245 # decrease in usage by $size_dom from previous
24246 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
24247 error "MDT free space is wrong after removal: " \
24248 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
24251 # combined striping
24252 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
24253 error "Can't create DoM + OST striping"
24255 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
24256 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
24257 # check also direct IO along write
24258 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
24260 cmp $tmp $dom || error "file data is different"
24261 [ $(stat -c%s $dom) == $size_tmp ] ||
24262 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
24267 run_test 270a "DoM: basic functionality tests"
24270 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24271 skip "Need MDS version at least 2.10.55"
24273 local dom=$DIR/$tdir/dom_file
24274 local max_size=1048576
24276 mkdir -p $DIR/$tdir
24277 $LFS setstripe -E $max_size -L mdt $dom
24279 # truncate over the limit
24280 $TRUNCATE $dom $(($max_size + 1)) &&
24281 error "successful truncate over the maximum size"
24282 # write over the limit
24283 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
24284 error "successful write over the maximum size"
24285 # append over the limit
24286 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
24287 echo "12345" >> $dom && error "successful append over the maximum size"
24292 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
24295 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24296 skip "Need MDS version at least 2.10.55"
24298 mkdir -p $DIR/$tdir
24299 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24301 # check files inherit DoM EA
24302 touch $DIR/$tdir/first
24303 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
24304 error "bad pattern"
24305 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
24306 error "bad stripe count"
24307 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
24308 error "bad stripe size"
24310 # check directory inherits DoM EA and uses it as default
24311 mkdir $DIR/$tdir/subdir
24312 touch $DIR/$tdir/subdir/second
24313 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
24314 error "bad pattern in sub-directory"
24315 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
24316 error "bad stripe count in sub-directory"
24317 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
24318 error "bad stripe size in sub-directory"
24321 run_test 270c "DoM: DoM EA inheritance tests"
24324 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24325 skip "Need MDS version at least 2.10.55"
24327 mkdir -p $DIR/$tdir
24328 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24330 # inherit default DoM striping
24331 mkdir $DIR/$tdir/subdir
24332 touch $DIR/$tdir/subdir/f1
24334 # change default directory striping
24335 $LFS setstripe -c 1 $DIR/$tdir/subdir
24336 touch $DIR/$tdir/subdir/f2
24337 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
24338 error "wrong default striping in file 2"
24339 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
24340 error "bad pattern in file 2"
24343 run_test 270d "DoM: change striping from DoM to RAID0"
24346 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24347 skip "Need MDS version at least 2.10.55"
24349 mkdir -p $DIR/$tdir/dom
24350 mkdir -p $DIR/$tdir/norm
24353 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
24354 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
24356 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
24357 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
24359 # find DoM files by layout
24360 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
24361 [ $NUM -eq $DOMFILES ] ||
24362 error "lfs find -L: found $NUM, expected $DOMFILES"
24363 echo "Test 1: lfs find 20 DOM files by layout: OK"
24365 # there should be 1 dir with default DOM striping
24366 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
24368 error "lfs find -L: found $NUM, expected 1 dir"
24369 echo "Test 2: lfs find 1 DOM dir by layout: OK"
24371 # find DoM files by stripe size
24372 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
24373 [ $NUM -eq $DOMFILES ] ||
24374 error "lfs find -S: found $NUM, expected $DOMFILES"
24375 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
24377 # find files by stripe offset except DoM files
24378 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
24379 [ $NUM -eq $NORMFILES ] ||
24380 error "lfs find -i: found $NUM, expected $NORMFILES"
24381 echo "Test 5: lfs find no DOM files by stripe index: OK"
24384 run_test 270e "DoM: lfs find with DoM files test"
24387 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24388 skip "Need MDS version at least 2.10.55"
24390 local mdtname=${FSNAME}-MDT0000-mdtlov
24391 local dom=$DIR/$tdir/dom_file
24392 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
24393 lod.$mdtname.dom_stripesize)
24394 local dom_limit=131072
24396 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
24397 local dom_current=$(do_facet mds1 $LCTL get_param -n \
24398 lod.$mdtname.dom_stripesize)
24399 [ ${dom_limit} -eq ${dom_current} ] ||
24400 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
24402 $LFS mkdir -i 0 -c 1 $DIR/$tdir
24403 $LFS setstripe -d $DIR/$tdir
24404 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
24405 error "Can't set directory default striping"
24407 # exceed maximum stripe size
24408 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
24409 error "Can't create file with $((dom_limit * 2)) DoM stripe"
24410 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
24411 error "Able to create DoM component size more than LOD limit"
24413 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
24414 dom_current=$(do_facet mds1 $LCTL get_param -n \
24415 lod.$mdtname.dom_stripesize)
24416 [ 0 -eq ${dom_current} ] ||
24417 error "Can't set zero DoM stripe limit"
24420 # attempt to create DoM file on server with disabled DoM should
24421 # remove DoM entry from layout and be succeed
24422 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
24423 error "Can't create DoM file (DoM is disabled)"
24424 [ $($LFS getstripe -L $dom) == "mdt" ] &&
24425 error "File has DoM component while DoM is disabled"
24428 # attempt to create DoM file with only DoM stripe should return error
24429 $LFS setstripe -E $dom_limit -L mdt $dom &&
24430 error "Able to create DoM-only file while DoM is disabled"
24432 # too low values to be aligned with smallest stripe size 64K
24433 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
24434 dom_current=$(do_facet mds1 $LCTL get_param -n \
24435 lod.$mdtname.dom_stripesize)
24436 [ 30000 -eq ${dom_current} ] &&
24437 error "Can set too small DoM stripe limit"
24439 # 64K is a minimal stripe size in Lustre, expect limit of that size
24440 [ 65536 -eq ${dom_current} ] ||
24441 error "Limit is not set to 64K but ${dom_current}"
24443 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
24444 dom_current=$(do_facet mds1 $LCTL get_param -n \
24445 lod.$mdtname.dom_stripesize)
24447 [ 2147483648 -eq ${dom_current} ] &&
24448 error "Can set too large DoM stripe limit"
24450 do_facet mds1 $LCTL set_param -n \
24451 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
24452 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
24453 error "Can't create DoM component size after limit change"
24454 do_facet mds1 $LCTL set_param -n \
24455 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
24456 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
24457 error "Can't create DoM file after limit decrease"
24458 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
24459 error "Can create big DoM component after limit decrease"
24460 touch ${dom}_def ||
24461 error "Can't create file with old default layout"
24463 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
24466 run_test 270f "DoM: maximum DoM stripe size checks"
24469 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
24470 skip "Need MDS version at least 2.13.52"
24471 local dom=$DIR/$tdir/$tfile
24473 $LFS mkdir -i 0 -c 1 $DIR/$tdir
24474 local lodname=${FSNAME}-MDT0000-mdtlov
24476 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
24477 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
24478 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
24479 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
24481 local dom_limit=1024
24482 local dom_threshold="50%"
24484 $LFS setstripe -d $DIR/$tdir
24485 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
24486 error "Can't set directory default striping"
24488 do_facet mds1 $LCTL set_param -n \
24489 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
24490 # set 0 threshold and create DOM file to change tunable stripesize
24491 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
24492 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
24493 error "Failed to create $dom file"
24494 # now tunable dom_cur_stripesize should reach maximum
24495 local dom_current=$(do_facet mds1 $LCTL get_param -n \
24496 lod.${lodname}.dom_stripesize_cur_kb)
24497 [[ $dom_current == $dom_limit ]] ||
24498 error "Current DOM stripesize is not maximum"
24501 # set threshold for further tests
24502 do_facet mds1 $LCTL set_param -n \
24503 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
24504 echo "DOM threshold is $dom_threshold free space"
24507 # Spoof bfree to exceed threshold
24508 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
24509 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
24510 for spfree in 40 20 0 15 30 55; do
24511 do_facet mds1 $LCTL set_param -n fail_val=$spfree
24512 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
24513 error "Failed to create $dom file"
24514 dom_def=$(do_facet mds1 $LCTL get_param -n \
24515 lod.${lodname}.dom_stripesize_cur_kb)
24516 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
24517 [[ $dom_def != $dom_current ]] ||
24518 error "Default stripe size was not changed"
24519 if (( spfree > 0 )) ; then
24520 dom_set=$($LFS getstripe -S $dom)
24521 (( dom_set == dom_def * 1024 )) ||
24522 error "DOM component size is still old"
24524 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
24525 error "DoM component is set with no free space"
24528 dom_current=$dom_def
24531 run_test 270g "DoM: default DoM stripe size depends on free space"
24534 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
24535 skip "Need MDS version at least 2.13.53"
24537 local mdtname=${FSNAME}-MDT0000-mdtlov
24538 local dom=$DIR/$tdir/$tfile
24539 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
24541 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
24542 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
24544 $LFS mkdir -i 0 -c 1 $DIR/$tdir
24545 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
24546 error "can't create OST file"
24547 # mirrored file with DOM entry in the second mirror
24548 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
24549 error "can't create mirror with DoM component"
24551 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
24553 # DOM component in the middle and has other enries in the same mirror,
24554 # should succeed but lost DoM component
24555 $LFS setstripe --copy=${dom}_1 $dom ||
24556 error "Can't create file from OST|DOM mirror layout"
24557 # check new file has no DoM layout after all
24558 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
24559 error "File has DoM component while DoM is disabled"
24561 run_test 270h "DoM: DoM stripe removal when disabled on server"
24564 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
24565 skip "Need MDS version at least 2.14.54"
24568 # DoM with plain layout
24569 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
24570 error "default plain layout with DoM must fail"
24571 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir/$tfile &&
24572 error "setstripe plain file layout with DoM must fail"
24573 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir &&
24574 error "default DoM layout with bad striping must fail"
24575 $LFS setstripe -E 1M -L mdt -S 128k -c -1 -E eof $DIR/$tdir/$tfile &&
24576 error "setstripe to DoM layout with bad striping must fail"
24579 run_test 270i "DoM: setting invalid DoM striping should fail"
24582 (( $MDS1_VERSION >= $(version_code 2.15.55.203) )) ||
24583 skip "Need MDS version at least 2.15.55.203"
24585 local dom=$DIR/$tdir/$tfile
24589 mkdir -p $DIR/$tdir
24591 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
24593 odv=$($LFS data_version $dom)
24595 mv $dom ${dom}_moved
24596 link ${dom}_moved $dom
24597 setfattr -n user.attrx -v "some_attr" $dom
24598 ndv=$($LFS data_version $dom)
24599 (( $ndv == $odv )) ||
24600 error "data version was changed by metadata operations"
24602 dd if=/dev/urandom of=$dom bs=1M count=1 ||
24603 error "failed to write data into $dom"
24604 cancel_lru_locks mdc
24605 ndv=$($LFS data_version $dom)
24606 (( $ndv != $odv )) ||
24607 error "data version wasn't changed on write"
24610 $TRUNCATE $dom 1000 || error "failed to truncate $dom"
24611 ndv=$($LFS data_version $dom)
24612 (( $ndv != $odv )) ||
24613 error "data version wasn't changed on truncate down"
24616 $TRUNCATE $dom 25000
24617 ndv=$($LFS data_version $dom)
24618 (( $ndv != $odv )) ||
24619 error "data version wasn't changed on truncate up"
24621 # check also fallocate for ldiskfs
24622 if [[ "$mds1_FSTYPE" == ldiskfs ]]; then
24624 fallocate -l 1048576 $dom
24625 ndv=$($LFS data_version $dom)
24626 (( $ndv != $odv )) ||
24627 error "data version wasn't changed on fallocate"
24630 fallocate -p --offset 4096 -l 4096 $dom
24631 ndv=$($LFS data_version $dom)
24632 (( $ndv != $odv )) ||
24633 error "data version wasn't changed on fallocate punch"
24636 run_test 270j "DoM migration: DOM file to the OST-striped file (plain)"
24639 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24640 skip "Need MDS version at least 2.10.55"
24642 local dom=$DIR/$tdir/dom
24644 mkdir -p $DIR/$tdir
24646 $LFS setstripe -E 1024K -L mdt $dom
24648 lctl set_param -n mdc.*.stats=clear
24649 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
24650 cat $dom > /dev/null
24651 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
24652 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
24656 run_test 271a "DoM: data is cached for read after write"
24659 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24660 skip "Need MDS version at least 2.10.55"
24662 local dom=$DIR/$tdir/dom
24664 mkdir -p $DIR/$tdir
24666 $LFS setstripe -E 1024K -L mdt -E EOF $dom
24668 lctl set_param -n mdc.*.stats=clear
24669 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
24670 cancel_lru_locks mdc
24671 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
24672 # second stat to check size is cached on client
24673 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
24674 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
24675 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
24678 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
24681 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24682 skip "Need MDS version at least 2.10.55"
24684 local dom=$DIR/$tdir/dom
24686 mkdir -p $DIR/$tdir
24688 $LFS setstripe -E 1024K -L mdt -E EOF $dom
24690 lctl set_param -n mdc.*.stats=clear
24691 lctl set_param -n osc.*.stats=clear
24692 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
24693 cancel_lru_locks mdc
24694 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
24695 # second stat to check size is cached on client
24696 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
24697 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
24698 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
24699 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
24700 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
24703 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
24709 local mdt=MDT$(printf %04x $mdtidx)
24711 if [ -z $param ]; then
24712 lctl get_param -n mdc.*$mdt*.stats
24714 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
24719 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
24720 skip "Need MDS version at least 2.10.55"
24722 local dom=$DIR/$tdir/dom
24724 mkdir -p $DIR/$tdir
24726 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24728 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
24729 local facet=mds$((mdtidx + 1))
24731 cancel_lru_locks mdc
24732 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
24733 createmany -o $dom 1000
24734 lctl set_param -n mdc.*.stats=clear
24735 smalliomany -w $dom 1000 200
24736 get_mdc_stats $mdtidx
24737 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
24738 # Each file has 1 open, 1 IO enqueues, total 2000
24739 # but now we have also +1 getxattr for security.capability, total 3000
24740 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
24741 unlinkmany $dom 1000
24743 cancel_lru_locks mdc
24744 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
24745 createmany -o $dom 1000
24746 lctl set_param -n mdc.*.stats=clear
24747 smalliomany -w $dom 1000 200
24748 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
24749 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
24750 # for OPEN and IO lock.
24751 [ $((enq - enq_2)) -ge 1000 ] ||
24752 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
24753 unlinkmany $dom 1000
24756 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
24758 cleanup_271def_tests() {
24764 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
24765 skip "Need MDS version at least 2.10.57"
24767 local dom=$DIR/$tdir/dom
24768 local tmp=$TMP/$tfile
24769 trap "cleanup_271def_tests $tmp" EXIT
24771 mkdir -p $DIR/$tdir
24773 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24775 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
24777 cancel_lru_locks mdc
24778 dd if=/dev/urandom of=$tmp bs=1000 count=1
24779 dd if=$tmp of=$dom bs=1000 count=1
24780 cancel_lru_locks mdc
24782 cat /etc/hosts >> $tmp
24783 lctl set_param -n mdc.*.stats=clear
24785 # append data to the same file it should update local page
24786 echo "Append to the same page"
24787 cat /etc/hosts >> $dom
24788 local num=$(get_mdc_stats $mdtidx ost_read)
24789 local ra=$(get_mdc_stats $mdtidx req_active)
24790 local rw=$(get_mdc_stats $mdtidx req_waittime)
24792 [ -z $num ] || error "$num READ RPC occured"
24793 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24797 cmp $tmp $dom || error "file miscompare"
24799 cancel_lru_locks mdc
24800 lctl set_param -n mdc.*.stats=clear
24802 echo "Open and read file"
24803 cat $dom > /dev/null
24804 local num=$(get_mdc_stats $mdtidx ost_read)
24805 local ra=$(get_mdc_stats $mdtidx req_active)
24806 local rw=$(get_mdc_stats $mdtidx req_waittime)
24808 [ -z $num ] || error "$num READ RPC occured"
24809 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24813 cmp $tmp $dom || error "file miscompare"
24817 run_test 271d "DoM: read on open (1K file in reply buffer)"
24820 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
24821 skip "Need MDS version at least 2.10.57"
24823 local dom=$DIR/$tdir/dom
24824 local tmp=$TMP/$tfile
24825 trap "cleanup_271def_tests $tmp" EXIT
24827 mkdir -p $DIR/$tdir
24829 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
24831 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
24833 cancel_lru_locks mdc
24834 dd if=/dev/urandom of=$tmp bs=265000 count=1
24835 dd if=$tmp of=$dom bs=265000 count=1
24836 cancel_lru_locks mdc
24837 cat /etc/hosts >> $tmp
24838 lctl set_param -n mdc.*.stats=clear
24840 echo "Append to the same page"
24841 cat /etc/hosts >> $dom
24842 local num=$(get_mdc_stats $mdtidx ost_read)
24843 local ra=$(get_mdc_stats $mdtidx req_active)
24844 local rw=$(get_mdc_stats $mdtidx req_waittime)
24846 [ -z $num ] || error "$num READ RPC occured"
24847 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24851 cmp $tmp $dom || error "file miscompare"
24853 cancel_lru_locks mdc
24854 lctl set_param -n mdc.*.stats=clear
24856 echo "Open and read file"
24857 cat $dom > /dev/null
24858 local num=$(get_mdc_stats $mdtidx ost_read)
24859 local ra=$(get_mdc_stats $mdtidx req_active)
24860 local rw=$(get_mdc_stats $mdtidx req_waittime)
24862 [ -z $num ] && num=0
24863 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
24864 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
24868 cmp $tmp $dom || error "file miscompare"
24872 run_test 271f "DoM: read on open (200K file and read tail)"
24875 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
24876 skip "Skipping due to old client or server version"
24878 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
24880 $CHECKSTAT -t file $DIR1/$tfile
24882 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
24885 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
24886 $LCTL set_param fail_loc=0x80000314
24887 rm $DIR1/$tfile || error "Unlink fails"
24889 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
24890 [ $RC -eq 0 ] || error "Failed write to stale object"
24892 run_test 271g "Discard DoM data vs client flush race"
24895 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24896 skip "Need MDS version at least 2.11.50"
24898 local dom=$DIR/$tdir/dom
24899 mkdir -p $DIR/$tdir
24901 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
24902 dd if=/dev/urandom of=$dom bs=512K count=1 ||
24903 error "failed to write data into $dom"
24904 local old_md5=$(md5sum $dom)
24906 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
24907 error "failed to migrate to the same DoM component"
24909 local new_md5=$(md5sum $dom)
24911 [ "$old_md5" == "$new_md5" ] ||
24912 error "md5sum differ: $old_md5, $new_md5"
24914 [ $($LFS getstripe -c $dom) -eq 2 ] ||
24915 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
24917 run_test 272a "DoM migration: new layout with the same DOM component"
24920 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24921 skip "Need MDS version at least 2.11.50"
24923 local dom=$DIR/$tdir/dom
24924 mkdir -p $DIR/$tdir
24925 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
24926 stack_trap "rm -rf $DIR/$tdir"
24928 local mdtidx=$($LFS getstripe -m $dom)
24929 local mdtname=MDT$(printf %04x $mdtidx)
24930 local facet=mds$((mdtidx + 1))
24932 local mdtfree1=$(do_facet $facet \
24933 lctl get_param -n osd*.*$mdtname.kbytesfree)
24934 dd if=/dev/urandom of=$dom bs=2M count=1 ||
24935 error "failed to write data into $dom"
24936 local old_md5=$(md5sum $dom)
24937 cancel_lru_locks mdc
24938 local mdtfree1=$(do_facet $facet \
24939 lctl get_param -n osd*.*$mdtname.kbytesfree)
24941 $LFS migrate -c2 $dom ||
24942 error "failed to migrate to the new composite layout"
24943 [[ $($LFS getstripe --component-start=0 -L $dom) != 'mdt' ]] ||
24944 error "MDT stripe was not removed"
24945 ! getfattr -n trusted.dataver $dom &> /dev/null ||
24946 error "$dir1 shouldn't have DATAVER EA"
24948 cancel_lru_locks mdc
24949 local new_md5=$(md5sum $dom)
24950 [ "$old_md5" == "$new_md5" ] ||
24951 error "$old_md5 != $new_md5"
24953 # Skip free space checks with ZFS
24954 if [ "$(facet_fstype $facet)" != "zfs" ]; then
24955 local mdtfree2=$(do_facet $facet \
24956 lctl get_param -n osd*.*$mdtname.kbytesfree)
24957 [ $mdtfree2 -gt $mdtfree1 ] ||
24958 error "MDT space is not freed after migration"
24962 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
24965 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
24966 skip "Need MDS version at least 2.11.50"
24968 local dom=$DIR/$tdir/$tfile
24969 mkdir -p $DIR/$tdir
24970 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
24971 stack_trap "rm -rf $DIR/$tdir"
24973 local mdtidx=$($LFS getstripe -m $dom)
24974 local mdtname=MDT$(printf %04x $mdtidx)
24975 local facet=mds$((mdtidx + 1))
24977 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
24978 error "failed to write data into $dom"
24979 local old_md5=$(md5sum $dom)
24980 cancel_lru_locks mdc
24981 local mdtfree1=$(do_facet $facet \
24982 lctl get_param -n osd*.*$mdtname.kbytesfree)
24984 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
24985 error "failed to migrate to the new composite layout"
24986 [[ $($LFS getstripe --component-start=0 -L $dom) != 'mdt' ]] ||
24987 error "MDT stripe was not removed"
24989 cancel_lru_locks mdc
24990 local new_md5=$(md5sum $dom)
24991 [ "$old_md5" == "$new_md5" ] ||
24992 error "$old_md5 != $new_md5"
24994 # Skip free space checks with ZFS
24995 if [ "$(facet_fstype $facet)" != "zfs" ]; then
24996 local mdtfree2=$(do_facet $facet \
24997 lctl get_param -n osd*.*$mdtname.kbytesfree)
24998 [ $mdtfree2 -gt $mdtfree1 ] ||
24999 error "MDS space is not freed after migration"
25003 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
25006 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
25007 skip "Need MDS version at least 2.12.55"
25009 local dom=$DIR/$tdir/$tfile
25010 mkdir -p $DIR/$tdir
25011 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
25013 local mdtidx=$($LFS getstripe -m $dom)
25014 local mdtname=MDT$(printf %04x $mdtidx)
25015 local facet=mds$((mdtidx + 1))
25017 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
25018 error "failed to write data into $dom"
25019 local old_md5=$(md5sum $dom)
25020 cancel_lru_locks mdc
25021 local mdtfree1=$(do_facet $facet \
25022 lctl get_param -n osd*.*$mdtname.kbytesfree)
25024 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
25025 error "failed mirroring to the new composite layout"
25026 $LFS mirror resync $dom ||
25027 error "failed mirror resync"
25028 $LFS mirror split --mirror-id 1 -d $dom ||
25029 error "failed mirror split"
25031 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
25032 error "MDT stripe was not removed"
25034 cancel_lru_locks mdc
25035 local new_md5=$(md5sum $dom)
25036 [ "$old_md5" == "$new_md5" ] ||
25037 error "$old_md5 != $new_md5"
25039 # Skip free space checks with ZFS
25040 if [ "$(facet_fstype $facet)" != "zfs" ]; then
25041 local mdtfree2=$(do_facet $facet \
25042 lctl get_param -n osd*.*$mdtname.kbytesfree)
25043 [ $mdtfree2 -gt $mdtfree1 ] ||
25044 error "MDS space is not freed after DOM mirror deletion"
25048 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
25051 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
25052 skip "Need MDS version at least 2.12.55"
25054 local dom=$DIR/$tdir/$tfile
25055 mkdir -p $DIR/$tdir
25056 $LFS setstripe -c 2 $dom
25058 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
25059 error "failed to write data into $dom"
25060 local old_md5=$(md5sum $dom)
25063 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
25064 error "failed mirroring to the DOM layout"
25065 $LFS mirror resync $dom ||
25066 error "failed mirror resync"
25067 $LFS mirror split --mirror-id 1 -d $dom ||
25068 error "failed mirror split"
25070 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
25071 error "MDT stripe wasn't set"
25074 local new_md5=$(md5sum $dom)
25075 [ "$old_md5" == "$new_md5" ] ||
25076 error "$old_md5 != $new_md5"
25080 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
25083 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
25084 skip "Need MDS version at least 2.12.55"
25086 local dom=$DIR/$tdir/$tfile
25087 mkdir -p $DIR/$tdir
25088 $LFS setstripe -c 2 $dom
25090 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
25091 error "failed to write data into $dom"
25092 local old_md5=$(md5sum $dom)
25095 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
25096 error "failed migrating to the DOM file"
25098 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
25099 error "MDT stripe wasn't set"
25102 local new_md5=$(md5sum $dom)
25103 [ "$old_md5" != "$new_md5" ] &&
25104 error "$old_md5 != $new_md5"
25108 run_test 272f "DoM migration: OST-striped file to DOM file"
25111 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
25112 skip "Need MDS version at least 2.11.50"
25114 # Layout swap cannot be done if either file has DOM component,
25115 # this will never be supported, migration should be used instead
25117 local dom=$DIR/$tdir/$tfile
25118 mkdir -p $DIR/$tdir
25120 $LFS setstripe -c2 ${dom}_plain
25121 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
25122 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
25123 error "can swap layout with DoM component"
25124 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
25125 error "can swap layout with DoM component"
25127 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
25128 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
25129 error "can swap layout with DoM component"
25130 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
25131 error "can swap layout with DoM component"
25134 run_test 273a "DoM: layout swapping should fail with DOM"
25137 mkdir -p $DIR/$tdir
25138 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
25140 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
25141 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
25143 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
25145 run_test 273b "DoM: race writeback and object destroy"
25148 mkdir -p $DIR/$tdir
25149 $LFS setstripe -E 1M -E-1 -c-1 $DIR/$tdir
25151 #define OBD_FAIL_OFD_COMMITRW_DELAY 0x1e1
25152 do_facet ost1 $LCTL set_param fail_loc=0x800001e1 fail_val=2
25154 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
25156 run_test 273c "race writeback and object destroy"
25159 remote_ost_nodsh && skip "remote OST with nodsh"
25160 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
25161 skip "Need OST version >= 2.10.57"
25163 local file=$DIR/$tfile
25166 oss=$(comma_list $(osts_nodes))
25168 dd if=/dev/urandom of=$file bs=1M count=2 ||
25169 error "failed to create a file"
25170 stack_trap "rm -f $file"
25171 cancel_lru_locks osc
25174 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
25175 error "failed to read a file"
25177 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
25178 $LCTL set_param fail_loc=0x8000031f
25180 cancel_lru_locks osc &
25183 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
25184 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
25185 #IO takes another lock, but matches the PENDING one
25186 #and places it to the IO RPC
25187 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
25188 error "failed to read a file with PENDING lock"
25190 run_test 275 "Read on a canceled duplicate lock"
25193 remote_ost_nodsh && skip "remote OST with nodsh"
25196 do_facet ost1 "(while true; do \
25197 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
25198 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
25201 for LOOP in $(seq 20); do
25203 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
25206 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
25207 rm $TMP/sanity_276_pid"
25209 run_test 276 "Race between mount and obd_statfs"
25212 $LCTL set_param ldlm.namespaces.*.lru_size=0
25213 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
25214 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
25215 awk '/^used_mb/ { print $2 }')
25216 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
25217 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
25218 oflag=direct conv=notrunc
25219 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
25220 awk '/^used_mb/ { print $2 }')
25221 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
25223 run_test 277 "Direct IO shall drop page cache"
25226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
25227 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
25228 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
25229 skip "needs the same host for mdt1 mdt2" && return
25234 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
25235 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
25241 echo "Starting MDTs"
25242 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
25244 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
25246 do_facet mds2 $LCTL set_param fail_loc=0
25248 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
25249 wait_recovery_complete mds2
25251 run_test 278 "Race starting MDS between MDTs stop/start"
25254 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
25255 skip "Need MGS version at least 2.13.52"
25256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25257 combined_mgs_mds || skip "needs combined MGS/MDT"
25259 umount_client $MOUNT
25260 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
25261 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
25263 mount_client $MOUNT &
25265 stop mgs || error "stop mgs failed"
25266 #for a race mgs would crash
25267 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
25268 # make sure we unmount client before remounting
25270 umount_client $MOUNT
25271 mount_client $MOUNT || error "mount client failed"
25273 run_test 280 "Race between MGS umount and client llog processing"
25275 cleanup_test_300() {
25279 test_striped_dir() {
25284 mkdir -p $DIR/$tdir
25286 SAVE_UMASK=$(umask)
25287 trap cleanup_test_300 RETURN EXIT
25289 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
25290 $DIR/$tdir/striped_dir ||
25291 error "set striped dir error"
25293 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
25294 [ "$mode" = "755" ] || error "expect 755 got $mode"
25296 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
25297 error "getdirstripe failed"
25298 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
25299 if [ "$stripe_count" != "2" ]; then
25300 error "1:stripe_count is $stripe_count, expect 2"
25302 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
25303 if [ "$stripe_count" != "2" ]; then
25304 error "2:stripe_count is $stripe_count, expect 2"
25307 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
25308 if [ "$stripe_index" != "$mdt_index" ]; then
25309 error "stripe_index is $stripe_index, expect $mdt_index"
25312 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
25313 error "nlink error after create striped dir"
25315 mkdir $DIR/$tdir/striped_dir/a
25316 mkdir $DIR/$tdir/striped_dir/b
25318 stat $DIR/$tdir/striped_dir/a ||
25319 error "create dir under striped dir failed"
25320 stat $DIR/$tdir/striped_dir/b ||
25321 error "create dir under striped dir failed"
25323 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
25324 error "nlink error after mkdir"
25326 rmdir $DIR/$tdir/striped_dir/a
25327 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
25328 error "nlink error after rmdir"
25330 rmdir $DIR/$tdir/striped_dir/b
25331 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
25332 error "nlink error after rmdir"
25334 chattr +i $DIR/$tdir/striped_dir
25335 createmany -o $DIR/$tdir/striped_dir/f 10 &&
25336 error "immutable flags not working under striped dir!"
25337 chattr -i $DIR/$tdir/striped_dir
25339 rmdir $DIR/$tdir/striped_dir ||
25340 error "rmdir striped dir error"
25348 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25349 skip "skipped for lustre < 2.7.0"
25350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25351 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25353 test_striped_dir 0 || error "failed on striped dir on MDT0"
25354 test_striped_dir 1 || error "failed on striped dir on MDT0"
25356 run_test 300a "basic striped dir sanity test"
25359 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25360 skip "skipped for lustre < 2.7.0"
25361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25362 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25369 test_mkdir $DIR/$tdir || error "mkdir fail"
25370 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25371 error "set striped dir error"
25372 for i in {0..9}; do
25373 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
25375 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
25376 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
25377 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
25379 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
25380 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
25381 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
25385 run_test 300b "check ctime/mtime for striped dir"
25388 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25389 skip "skipped for lustre < 2.7.0"
25390 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25391 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25395 mkdir_on_mdt0 $DIR/$tdir
25396 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
25397 error "set striped dir error"
25399 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
25400 error "chown striped dir failed"
25402 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
25403 error "create 5k files failed"
25405 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
25407 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
25411 run_test 300c "chown && check ls under striped directory"
25414 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
25415 skip "skipped for lustre < 2.7.0"
25416 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25417 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25422 mkdir -p $DIR/$tdir
25423 $LFS setstripe -c 2 $DIR/$tdir
25425 #local striped directory
25426 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25427 error "set striped dir error"
25428 #look at the directories for debug purposes
25430 $LFS getdirstripe $DIR/$tdir
25431 ls -l $DIR/$tdir/striped_dir
25432 $LFS getdirstripe $DIR/$tdir/striped_dir
25433 createmany -o $DIR/$tdir/striped_dir/f 10 ||
25434 error "create 10 files failed"
25436 #remote striped directory
25437 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
25438 error "set striped dir error"
25439 #look at the directories for debug purposes
25441 $LFS getdirstripe $DIR/$tdir
25442 ls -l $DIR/$tdir/remote_striped_dir
25443 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
25444 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
25445 error "create 10 files failed"
25447 for file in $(find $DIR/$tdir); do
25448 stripe_count=$($LFS getstripe -c $file)
25449 [ $stripe_count -eq 2 ] ||
25450 error "wrong stripe $stripe_count for $file"
25455 run_test 300d "check default stripe under striped directory"
25458 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25459 skip "Need MDS version at least 2.7.55"
25460 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25461 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25466 mkdir -p $DIR/$tdir
25468 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25469 error "set striped dir error"
25471 touch $DIR/$tdir/striped_dir/a
25472 touch $DIR/$tdir/striped_dir/b
25473 touch $DIR/$tdir/striped_dir/c
25475 mkdir $DIR/$tdir/striped_dir/dir_a
25476 mkdir $DIR/$tdir/striped_dir/dir_b
25477 mkdir $DIR/$tdir/striped_dir/dir_c
25479 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
25480 error "set striped adir under striped dir error"
25482 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
25483 error "set striped bdir under striped dir error"
25485 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
25486 error "set striped cdir under striped dir error"
25488 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
25489 error "rename dir under striped dir fails"
25491 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
25492 error "rename dir under different stripes fails"
25494 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
25495 error "rename file under striped dir should succeed"
25497 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
25498 error "rename dir under striped dir should succeed"
25502 run_test 300e "check rename under striped directory"
25505 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25506 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25507 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25508 skip "Need MDS version at least 2.7.55"
25514 mkdir -p $DIR/$tdir
25516 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
25517 error "set striped dir error"
25519 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
25520 error "set striped dir error"
25522 touch $DIR/$tdir/striped_dir/a
25523 mkdir $DIR/$tdir/striped_dir/dir_a
25524 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
25525 error "create striped dir under striped dir fails"
25527 touch $DIR/$tdir/striped_dir1/b
25528 mkdir $DIR/$tdir/striped_dir1/dir_b
25529 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
25530 error "create striped dir under striped dir fails"
25532 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
25533 error "rename dir under different striped dir should fail"
25535 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
25536 error "rename striped dir under diff striped dir should fail"
25538 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
25539 error "rename file under diff striped dirs fails"
25543 run_test 300f "check rename cross striped directory"
25545 test_300_check_default_striped_dir()
25548 local default_count=$2
25549 local default_index=$3
25552 local dir_stripe_index
25555 echo "checking $dirname $default_count $default_index"
25556 $LFS setdirstripe -D -c $default_count -i $default_index \
25557 -H all_char $DIR/$tdir/$dirname ||
25558 error "set default stripe on striped dir error"
25559 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
25560 [ $stripe_count -eq $default_count ] ||
25561 error "expect $default_count get $stripe_count for $dirname"
25563 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
25564 [ $stripe_index -eq $default_index ] ||
25565 error "expect $default_index get $stripe_index for $dirname"
25567 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
25568 error "create dirs failed"
25570 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
25571 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
25572 for dir in $(find $DIR/$tdir/$dirname/*); do
25573 stripe_count=$($LFS getdirstripe -c $dir)
25574 (( $stripe_count == $default_count )) ||
25575 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
25576 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
25577 error "stripe count $default_count != $stripe_count for $dir"
25579 stripe_index=$($LFS getdirstripe -i $dir)
25580 [ $default_index -eq -1 ] ||
25581 [ $stripe_index -eq $default_index ] ||
25582 error "$stripe_index != $default_index for $dir"
25584 #check default stripe
25585 stripe_count=$($LFS getdirstripe -D -c $dir)
25586 [ $stripe_count -eq $default_count ] ||
25587 error "default count $default_count != $stripe_count for $dir"
25589 stripe_index=$($LFS getdirstripe -D -i $dir)
25590 [ $stripe_index -eq $default_index ] ||
25591 error "default index $default_index != $stripe_index for $dir"
25593 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
25597 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25598 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25599 skip "Need MDS version at least 2.7.55"
25605 mkdir_on_mdt0 $DIR/$tdir
25606 mkdir $DIR/$tdir/normal_dir
25608 #Checking when client cache stripe index
25609 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
25610 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
25611 error "create striped_dir failed"
25613 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
25614 error "create dir0 fails"
25615 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
25616 [ $stripe_index -eq 0 ] ||
25617 error "dir0 expect index 0 got $stripe_index"
25619 mkdir $DIR/$tdir/striped_dir/dir1 ||
25620 error "create dir1 fails"
25621 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
25622 [ $stripe_index -eq 1 ] ||
25623 error "dir1 expect index 1 got $stripe_index"
25625 #check default stripe count/stripe index
25626 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
25627 test_300_check_default_striped_dir normal_dir 1 0
25628 test_300_check_default_striped_dir normal_dir -1 1
25629 test_300_check_default_striped_dir normal_dir 2 -1
25631 #delete default stripe information
25632 echo "delete default stripeEA"
25633 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
25634 error "set default stripe on striped dir error"
25636 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
25637 for dir in $(find $DIR/$tdir/normal_dir/*); do
25638 stripe_count=$($LFS getdirstripe -c $dir)
25639 [ $stripe_count -eq 0 ] ||
25640 error "expect 1 get $stripe_count for $dir"
25643 run_test 300g "check default striped directory for normal directory"
25646 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25647 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25648 skip "Need MDS version at least 2.7.55"
25654 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
25655 error "set striped dir error"
25657 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
25658 test_300_check_default_striped_dir striped_dir 1 0
25659 test_300_check_default_striped_dir striped_dir -1 1
25660 test_300_check_default_striped_dir striped_dir 2 -1
25662 #delete default stripe information
25663 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
25664 error "set default stripe on striped dir error"
25666 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
25667 for dir in $(find $DIR/$tdir/striped_dir/*); do
25668 stripe_count=$($LFS getdirstripe -c $dir)
25669 [ $stripe_count -eq 0 ] ||
25670 error "expect 1 get $stripe_count for $dir"
25673 run_test 300h "check default striped directory for striped directory"
25676 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
25677 (( $MDSCOUNT >= 2 )) || skip_env "needs >= 2 MDTs"
25678 (( $MDS1_VERSION >= $(version_code 2.7.55) )) ||
25679 skip "Need MDS version at least 2.7.55"
25686 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
25687 error "set striped dir error"
25689 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
25690 error "create files under striped dir failed"
25692 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
25693 error "set striped hashdir error"
25695 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
25696 error "create dir0 under hash dir failed"
25697 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
25698 error "create dir1 under hash dir failed"
25699 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
25700 error "create dir2 under hash dir failed"
25702 # unfortunately, we need to umount to clear dir layout cache for now
25703 # once we fully implement dir layout, we can drop this
25704 umount_client $MOUNT || error "umount failed"
25705 mount_client $MOUNT || error "mount failed"
25707 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
25708 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
25709 (( $dircnt == 2 )) || error "lfs find striped dir got $dircnt != 2"
25711 if (( $MDS1_VERSION > $(version_code 2.15.0) )); then
25712 $LFS mkdir -i0 -c$MDSCOUNT -H crush2 $DIR/$tdir/hashdir/d3 ||
25713 error "create crush2 dir $tdir/hashdir/d3 failed"
25714 $LFS find -H crush2 $DIR/$tdir/hashdir
25715 dircnt=$($LFS find -H crush2 $DIR/$tdir/hashdir | wc -l)
25716 (( $dircnt == 1 )) || error "find crush2 dir got $dircnt != 1"
25718 # mkdir with an invalid hash type (hash=fail_val) from client
25719 # should be replaced on MDS with a valid (default) hash type
25720 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
25721 $LCTL set_param fail_loc=0x1901 fail_val=99
25722 $LFS mkdir -c2 $DIR/$tdir/hashdir/d99
25724 local hash=$($LFS getdirstripe -H $DIR/$tdir/hashdir/d99)
25725 local expect=$(do_facet mds1 \
25726 $LCTL get_param -n lod.$FSNAME-MDT0000-mdtlov.mdt_hash)
25727 [[ $hash == $expect ]] ||
25728 error "d99 hash '$hash' != expected hash '$expect'"
25731 #set the stripe to be unknown hash type on read
25732 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
25733 $LCTL set_param fail_loc=0x1901 fail_val=99
25734 for ((i = 0; i < 10; i++)); do
25735 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
25736 error "stat f-$i failed"
25737 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
25740 touch $DIR/$tdir/striped_dir/f0 &&
25741 error "create under striped dir with unknown hash should fail"
25743 $LCTL set_param fail_loc=0
25745 umount_client $MOUNT || error "umount failed"
25746 mount_client $MOUNT || error "mount failed"
25750 run_test 300i "client handle unknown hash type striped directory"
25753 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25755 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25756 skip "Need MDS version at least 2.7.55"
25763 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
25764 $LCTL set_param fail_loc=0x1702
25765 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
25766 error "set striped dir error"
25768 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
25769 error "create files under striped dir failed"
25771 $LCTL set_param fail_loc=0
25773 rm -rf $DIR/$tdir || error "unlink striped dir fails"
25777 run_test 300j "test large update record"
25780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25781 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25782 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25783 skip "Need MDS version at least 2.7.55"
25785 # this test needs a huge transaction
25787 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
25788 osd*.$FSNAME-MDT0000.kbytestotal")
25789 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
25796 #define OBD_FAIL_LARGE_STRIPE 0x1703
25797 $LCTL set_param fail_loc=0x1703
25798 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
25799 error "set striped dir error"
25800 $LCTL set_param fail_loc=0
25802 $LFS getdirstripe $DIR/$tdir/striped_dir ||
25803 error "getstripeddir fails"
25804 rm -rf $DIR/$tdir/striped_dir ||
25805 error "unlink striped dir fails"
25809 run_test 300k "test large striped directory"
25812 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25813 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25814 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25815 skip "Need MDS version at least 2.7.55"
25819 test_mkdir -p $DIR/$tdir/striped_dir
25820 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
25821 error "chown $RUNAS_ID failed"
25822 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
25823 error "set default striped dir failed"
25825 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
25826 $LCTL set_param fail_loc=0x80000158
25827 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
25829 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
25830 [ $stripe_index -eq 1 ] ||
25831 error "expect 1 get $stripe_index for $dir"
25833 run_test 300l "non-root user to create dir under striped dir with stale layout"
25836 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25837 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
25838 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25839 skip "Need MDS version at least 2.7.55"
25841 mkdir -p $DIR/$tdir/striped_dir
25842 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
25843 error "set default stripes dir error"
25845 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
25847 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
25848 [ $stripe_count -eq 0 ] ||
25849 error "expect 0 get $stripe_count for a"
25851 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
25852 error "set default stripes dir error"
25854 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
25856 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
25857 [ $stripe_count -eq 0 ] ||
25858 error "expect 0 get $stripe_count for b"
25860 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
25861 error "set default stripes dir error"
25863 mkdir $DIR/$tdir/striped_dir/c &&
25864 error "default stripe_index is invalid, mkdir c should fails"
25866 rm -rf $DIR/$tdir || error "rmdir fails"
25868 run_test 300m "setstriped directory on single MDT FS"
25871 local list=$(comma_list $(mdts_nodes))
25874 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
25878 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25879 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25880 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25881 skip "Need MDS version at least 2.7.55"
25882 remote_mds_nodsh && skip "remote MDS with nodsh"
25885 local list=$(comma_list $(mdts_nodes))
25887 trap cleanup_300n RETURN EXIT
25888 mkdir -p $DIR/$tdir
25889 chmod 777 $DIR/$tdir
25890 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
25891 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
25892 error "create striped dir succeeds with gid=0"
25894 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
25895 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
25896 error "create striped dir fails with gid=-1"
25898 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
25899 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
25900 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
25901 error "set default striped dir succeeds with gid=0"
25904 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
25905 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
25906 error "set default striped dir fails with gid=-1"
25909 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
25910 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
25911 error "create test_dir fails"
25912 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
25913 error "create test_dir1 fails"
25914 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
25915 error "create test_dir2 fails"
25918 run_test 300n "non-root user to create dir under striped dir with default EA"
25921 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25922 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25923 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25924 skip "Need MDS version at least 2.7.55"
25929 mkdir -p $DIR/$tdir
25931 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
25932 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
25933 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
25934 skip "not enough free inodes $numfree1 $numfree2"
25937 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
25938 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
25939 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
25940 skip "not enough free space $numfree1 $numfree2"
25943 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
25944 error "setdirstripe fails"
25946 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
25947 error "create dirs fails"
25949 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
25950 ls $DIR/$tdir/striped_dir > /dev/null ||
25951 error "ls striped dir fails"
25952 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
25953 error "unlink big striped dir fails"
25955 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
25958 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25959 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25960 remote_mds_nodsh && skip "remote MDS with nodsh"
25962 mkdir_on_mdt0 $DIR/$tdir
25964 #define OBD_FAIL_OUT_ENOSPC 0x1704
25965 do_facet mds2 lctl set_param fail_loc=0x80001704
25966 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
25967 && error "create striped directory should fail"
25969 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
25971 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
25974 run_test 300p "create striped directory without space"
25977 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25978 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25980 local fd=$(free_fd)
25981 local cmd="exec $fd<$tdir"
25983 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
25986 trap "eval $cmd" EXIT
25987 cd $tdir || error "cd $tdir fails"
25988 rmdir ../$tdir || error "rmdir $tdir fails"
25989 mkdir local_dir && error "create dir succeeds"
25990 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
25994 run_test 300q "create remote directory under orphan directory"
25997 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
25998 skip "Need MDS version at least 2.7.55" && return
25999 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
26003 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
26004 error "set striped dir error"
26006 $LFS getdirstripe $DIR/$tdir/striped_dir ||
26007 error "getstripeddir fails"
26010 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
26011 awk '/lmv_stripe_count:/ { print $2 }')
26013 [ $MDSCOUNT -ne $stripe_count ] &&
26014 error "wrong stripe count $stripe_count expected $MDSCOUNT"
26016 rm -rf $DIR/$tdir/striped_dir ||
26017 error "unlink striped dir fails"
26019 run_test 300r "test -1 striped directory"
26021 test_300s_helper() {
26024 local stripe_dir=$DIR/$tdir/striped_dir.$count
26026 $LFS mkdir -c $count $stripe_dir ||
26027 error "lfs mkdir -c error"
26029 $LFS getdirstripe $stripe_dir ||
26030 error "lfs getdirstripe fails"
26033 stripe_count=$($LFS getdirstripe $stripe_dir |
26034 awk '/lmv_stripe_count:/ { print $2 }')
26036 [ $count -ne $stripe_count ] &&
26037 error_noexit "bad stripe count $stripe_count expected $count"
26040 dupe_stripes=$($LFS getdirstripe $stripe_dir |
26041 awk '/0x/ {count[$1] += 1}; END {
26042 for (idx in count) {
26043 if (count[idx]>1) {
26044 print "index " idx " count " count[idx]
26049 if [[ -n "$dupe_stripes" ]] ; then
26050 lfs getdirstripe $stripe_dir
26051 error_noexit "Dupe MDT above: $dupe_stripes "
26054 rm -rf $stripe_dir ||
26055 error_noexit "unlink $stripe_dir fails"
26059 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
26060 skip "Need MDS version at least 2.7.55" && return
26061 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
26064 for count in $(seq 2 $MDSCOUNT); do
26065 test_300s_helper $count
26068 run_test 300s "test lfs mkdir -c without -i"
26071 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
26072 skip "need MDS 2.14.55 or later"
26073 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
26075 local testdir="$DIR/$tdir/striped_dir"
26076 local dir1=$testdir/dir1
26077 local dir2=$testdir/dir2
26081 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
26082 error "failed to set default stripe count for $testdir"
26085 local stripe_count=$($LFS getdirstripe -c $dir1)
26087 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
26089 local max_count=$((MDSCOUNT - 1))
26090 local mdts=$(comma_list $(mdts_nodes))
26092 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
26093 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
26096 stripe_count=$($LFS getdirstripe -c $dir2)
26098 (( $stripe_count == $max_count )) || error "wrong stripe count"
26100 run_test 300t "test max_mdt_stripecount"
26102 prepare_remote_file() {
26103 mkdir $DIR/$tdir/src_dir ||
26104 error "create remote source failed"
26106 cp /etc/hosts $DIR/$tdir/src_dir/a ||
26107 error "cp to remote source failed"
26108 touch $DIR/$tdir/src_dir/a
26110 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
26111 error "create remote target dir failed"
26113 touch $DIR/$tdir/tgt_dir/b
26115 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
26116 error "rename dir cross MDT failed!"
26118 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
26119 error "src_child still exists after rename"
26121 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
26122 error "missing file(a) after rename"
26124 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
26125 error "diff after rename"
26129 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
26130 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26132 local remote_file=$DIR/$tdir/tgt_dir/b
26134 mkdir -p $DIR/$tdir
26136 prepare_remote_file || error "prepare remote file failed"
26139 $OPENUNLINK $remote_file $remote_file ||
26140 error "openunlink $remote_file failed"
26141 $CHECKSTAT -a $remote_file || error "$remote_file exists"
26143 run_test 310a "open unlink remote file"
26146 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
26147 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26149 local remote_file=$DIR/$tdir/tgt_dir/b
26151 mkdir -p $DIR/$tdir
26153 prepare_remote_file || error "prepare remote file failed"
26155 ln $remote_file $DIR/$tfile || error "link failed for remote file"
26156 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
26157 $CHECKSTAT -t file $remote_file || error "check file failed"
26159 run_test 310b "unlink remote file with multiple links while open"
26162 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26163 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
26165 local remote_file=$DIR/$tdir/tgt_dir/b
26167 mkdir -p $DIR/$tdir
26169 prepare_remote_file || error "prepare remote file failed"
26171 ln $remote_file $DIR/$tfile || error "link failed for remote file"
26172 multiop_bg_pause $remote_file O_uc ||
26173 error "mulitop failed for remote file"
26175 $MULTIOP $DIR/$tfile Ouc
26176 kill -USR1 $MULTIPID
26179 run_test 310c "open-unlink remote file with multiple links"
26183 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26184 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
26185 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
26186 skip "lustre < 2.8.54 does not contain LU-4825 fix"
26187 remote_mds_nodsh && skip "remote MDS with nodsh"
26189 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
26190 local mdts=$(comma_list $(mdts_nodes))
26192 mkdir -p $DIR/$tdir
26193 $LFS setstripe -i 0 -c 1 $DIR/$tdir
26194 createmany -o $DIR/$tdir/$tfile. 1000
26196 # statfs data is not real time, let's just calculate it
26197 old_iused=$((old_iused + 1000))
26199 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
26200 osp.*OST0000*MDT0000.create_count")
26201 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
26202 osp.*OST0000*MDT0000.max_create_count")
26203 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
26205 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
26206 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
26207 [ $index -ne 0 ] || error "$tfile stripe index is 0"
26209 unlinkmany $DIR/$tdir/$tfile. 1000
26211 do_nodes $mdts "$LCTL set_param -n \
26212 osp.*OST0000*.max_create_count=$max_count"
26213 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
26214 do_nodes $mdts "$LCTL set_param -n \
26215 osp.*OST0000*.create_count=$count"
26216 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
26217 grep "=0" && error "create_count is zero"
26220 for i in $(seq 120); do
26221 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
26222 # system may be too busy to destroy all objs in time, use
26223 # a somewhat small value to not fail autotest
26224 [ $((old_iused - new_iused)) -gt 400 ] && break
26228 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
26229 [ $((old_iused - new_iused)) -gt 400 ] ||
26230 error "objs not destroyed after unlink"
26232 run_test 311 "disable OSP precreate, and unlink should destroy objs"
26238 local fid=($($LFS getstripe $tf | grep 0x))
26239 local seq=${fid[3]#0x}
26240 local objid=${fid[1]}
26242 local vdevdir=$(dirname $(facet_vdevice $ost))
26243 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
26244 local zfs_zapid=$(do_facet $ost $cmd |
26245 grep -w "/O/$seq/d$((objid%32))" -C 5 |
26246 awk '/Object/{getline; print $1}')
26247 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
26248 awk "/$objid = /"'{printf $3}')
26253 zfs_object_blksz() {
26257 local vdevdir=$(dirname $(facet_vdevice $ost))
26258 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
26259 local blksz=$(do_facet $ost $cmd $objid |
26260 awk '/dblk/{getline; printf $4}')
26262 case "${blksz: -1}" in
26263 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
26264 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
26271 test_312() { # LU-4856
26272 remote_ost_nodsh && skip "remote OST with nodsh"
26273 [[ "$ost1_FSTYPE" == "zfs" ]] || skip "the test only applies to zfs"
26275 local max_blksz=$(do_facet ost1 \
26276 $ZFS get -p recordsize $(facet_device ost1) |
26277 awk '!/VALUE/{print $3}')
26278 local tf=$DIR/$tfile
26280 $LFS setstripe -c1 $tf
26281 local facet="ost$(($($LFS getstripe -i $tf) + 1))"
26283 # Get ZFS object id
26284 local zfs_objid=$(zfs_get_objid $facet $tf)
26285 # block size change by sequential overwrite
26288 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
26289 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
26291 local blksz=$(zfs_object_blksz $facet $zfs_objid)
26292 [[ $blksz -eq $bs ]] || error "blksz error: $blksz, expected: $bs"
26296 $LFS setstripe -c1 $tf
26297 facet="ost$(($($LFS getstripe -i $tf) + 1))"
26299 # block size change by sequential append write
26300 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
26301 zfs_objid=$(zfs_get_objid $facet $tf)
26304 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
26305 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
26306 oflag=sync conv=notrunc
26308 blksz=$(zfs_object_blksz $facet $zfs_objid)
26309 (( $blksz == 2 * count * PAGE_SIZE )) ||
26310 error "blksz error, actual $blksz, " \
26311 "expected: 2 * $count * $PAGE_SIZE"
26316 $LFS setstripe -c1 $tf
26317 facet="ost$(($($LFS getstripe -i $tf) + 1))"
26318 zfs_objid=$(zfs_get_objid $facet $tf)
26320 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
26321 blksz=$(zfs_object_blksz $facet $zfs_objid)
26322 (( blksz == PAGE_SIZE )) ||
26323 error "blksz error: $blksz, expected: $PAGE_SIZE"
26325 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
26326 blksz=$(zfs_object_blksz $facet $zfs_objid)
26327 (( blksz == 65536 )) || error "blksz error: $blksz, expected: 64k"
26329 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
26330 blksz=$(zfs_object_blksz $facet $zfs_objid)
26331 (( blksz == 65536 )) || error "rewrite error: $blksz, expected: 64k"
26333 run_test 312 "make sure ZFS adjusts its block size by write pattern"
26336 remote_ost_nodsh && skip "remote OST with nodsh"
26338 local file=$DIR/$tfile
26341 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
26343 # define OBD_FAIL_TGT_RCVD_EIO 0x720
26344 do_facet ost1 "$LCTL set_param fail_loc=0x720"
26345 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
26346 error "write should failed"
26347 do_facet ost1 "$LCTL set_param fail_loc=0"
26350 run_test 313 "io should fail after last_rcvd update fail"
26353 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
26355 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
26356 do_facet ost1 "$LCTL set_param fail_loc=0x720"
26358 wait_delete_completed
26359 do_facet ost1 "$LCTL set_param fail_loc=0"
26361 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
26363 test_315() { # LU-618
26364 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
26366 local file=$DIR/$tfile
26369 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
26370 error "multiop file write failed"
26371 $MULTIOP $file oO_RDONLY:r4063232_c &
26376 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
26379 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
26382 run_test 315 "read should be accounted"
26385 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
26386 large_xattr_enabled || skip "ea_inode feature disabled"
26388 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
26389 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
26390 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
26391 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
26393 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
26395 run_test 316 "lfs migrate of file with large_xattr enabled"
26398 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
26399 skip "Need MDS version at least 2.11.53"
26400 if [ "$ost1_FSTYPE" == "zfs" ]; then
26401 skip "LU-10370: no implementation for ZFS"
26405 local grant_blk_size
26407 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
26408 awk '/grant_block_size:/ { print $2; exit; }')
26410 # Create File of size 5M. Truncate it to below size's and verify
26413 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
26414 error "Create file $DIR/$tfile failed"
26415 stack_trap "rm -f $DIR/$tfile" EXIT
26417 for trunc_sz in 2097152 4097 4000 509 0; do
26418 $TRUNCATE $DIR/$tfile $trunc_sz ||
26419 error "truncate $tfile to $trunc_sz failed"
26420 local sz=$(stat --format=%s $DIR/$tfile)
26421 local blk=$(stat --format=%b $DIR/$tfile)
26422 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
26423 grant_blk_size) * 8))
26425 if [[ $blk -ne $trunc_blk ]]; then
26426 $(which stat) $DIR/$tfile
26427 error "Expected Block $trunc_blk got $blk for $tfile"
26430 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
26431 error "Expected Size $trunc_sz got $sz for $tfile"
26436 # Create file with a hole and write actual 65536 bytes which aligned
26437 # with 4K and 64K PAGE_SIZE. Block count must be 128.
26440 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
26441 error "Create file : $DIR/$tfile"
26444 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
26445 # blocks. The block count must drop to 8.
26447 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
26448 ((bs - grant_blk_size) + 1)))
26449 $TRUNCATE $DIR/$tfile $trunc_sz ||
26450 error "truncate $tfile to $trunc_sz failed"
26452 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
26453 sz=$(stat --format=%s $DIR/$tfile)
26454 blk=$(stat --format=%b $DIR/$tfile)
26456 if [[ $blk -ne $trunc_bsz ]]; then
26457 $(which stat) $DIR/$tfile
26458 error "Expected Block $trunc_bsz got $blk for $tfile"
26461 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
26462 error "Expected Size $trunc_sz got $sz for $tfile"
26464 run_test 317 "Verify blocks get correctly update after truncate"
26467 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
26468 local old_max_active=$($LCTL get_param -n \
26469 ${llite_name}.max_read_ahead_async_active \
26472 $LCTL set_param llite.*.max_read_ahead_async_active=256
26473 local max_active=$($LCTL get_param -n \
26474 ${llite_name}.max_read_ahead_async_active \
26476 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
26478 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
26479 error "set max_read_ahead_async_active should succeed"
26481 $LCTL set_param llite.*.max_read_ahead_async_active=512
26482 max_active=$($LCTL get_param -n \
26483 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
26484 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
26486 # restore @max_active
26487 [ $old_max_active -ne 0 ] && $LCTL set_param \
26488 llite.*.max_read_ahead_async_active=$old_max_active
26490 local old_threshold=$($LCTL get_param -n \
26491 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
26492 local max_per_file_mb=$($LCTL get_param -n \
26493 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
26495 local invalid=$(($max_per_file_mb + 1))
26497 llite.*.read_ahead_async_file_threshold_mb=$invalid\
26498 && error "set $invalid should fail"
26500 local valid=$(($invalid - 1))
26502 llite.*.read_ahead_async_file_threshold_mb=$valid ||
26503 error "set $valid should succeed"
26504 local threshold=$($LCTL get_param -n \
26505 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
26506 [ $threshold -eq $valid ] || error \
26507 "expect threshold $valid got $threshold"
26509 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
26511 run_test 318 "Verify async readahead tunables"
26514 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
26516 local before=$(date +%s)
26518 local mdir=$DIR/$tdir
26519 local file=$mdir/xxx
26521 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
26524 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
26525 $LCTL set_param fail_val=5 fail_loc=0x8000032c
26526 $LFS migrate -m1 $mdir &
26529 dd if=$file of=/dev/null
26531 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
26532 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
26534 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
26536 run_test 319 "lost lease lock on migrate error"
26538 test_398a() { # LU-4198
26539 local ost1_imp=$(get_osc_import_name client ost1)
26540 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
26543 $LFS setstripe -c 1 -i 0 $DIR/$tfile
26544 stack_trap "rm -f $DIR/$tfile"
26545 $LCTL set_param ldlm.namespaces.*.lru_size=clear
26547 # request a new lock on client
26548 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
26550 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
26551 local lock_count=$($LCTL get_param -n \
26552 ldlm.namespaces.$imp_name.lru_size)
26553 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
26555 $LCTL set_param ldlm.namespaces.$imp_name.lru_size=clear
26557 # no lock cached, should use lockless DIO and not enqueue new lock
26558 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
26559 lock_count=$($LCTL get_param -n \
26560 ldlm.namespaces.$imp_name.lru_size)
26561 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
26563 $LCTL set_param ldlm.namespaces.$imp_name.lru_size=clear
26565 # no lock cached, should use locked DIO append
26566 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
26567 conv=notrunc || error "DIO append failed"
26568 lock_count=$($LCTL get_param -n \
26569 ldlm.namespaces.$imp_name.lru_size)
26570 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
26572 run_test 398a "direct IO should cancel lock otherwise lockless"
26574 test_398b() { # LU-4198
26575 local before=$(date +%s)
26579 which fio || skip_env "no fio installed"
26580 $LFS setstripe -c -1 -S 1M $DIR/$tfile
26581 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
26583 # Single page, multiple pages, stripe size, 4*stripe size
26584 for bsize in $(( $PAGE_SIZE )) $(( 4*$PAGE_SIZE )) 1048576 4194304; do
26585 echo "mix direct rw ${bsize} by fio with $njobs jobs..."
26586 fio --name=rand-rw --rw=randrw --bs=$bsize --direct=1 \
26587 --numjobs=$njobs --fallocate=none \
26588 --iodepth=16 --allow_file_create=0 \
26589 --size=$((size/njobs))M \
26590 --filename=$DIR/$tfile &
26593 echo "mix buffer rw ${bsize} by fio with $njobs jobs..."
26594 fio --name=rand-rw --rw=randrw --bs=$bsize \
26595 --numjobs=$njobs --fallocate=none \
26596 --iodepth=16 --allow_file_create=0 \
26597 --size=$((size/njobs))M \
26598 --filename=$DIR/$tfile || true
26602 evict=$(do_facet client $LCTL get_param \
26603 osc.$FSNAME-OST*-osc-*/state |
26604 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
26606 [ -z "$evict" ] || [[ $evict -le $before ]] ||
26607 (do_facet client $LCTL get_param \
26608 osc.$FSNAME-OST*-osc-*/state;
26609 error "eviction happened: $evict before:$before")
26613 run_test 398b "DIO and buffer IO race"
26615 test_398c() { # LU-4198
26616 local ost1_imp=$(get_osc_import_name client ost1)
26617 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
26620 which fio || skip_env "no fio installed"
26622 saved_debug=$($LCTL get_param -n debug)
26623 $LCTL set_param debug=0
26625 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
26626 ((size /= 1024)) # by megabytes
26627 ((size /= 2)) # write half of the OST at most
26628 [ $size -gt 40 ] && size=40 #reduce test time anyway
26630 $LFS setstripe -c 1 $DIR/$tfile
26632 # it seems like ldiskfs reserves more space than necessary if the
26633 # writing blocks are not mapped, so it extends the file firstly
26634 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
26635 cancel_lru_locks osc
26637 # clear and verify rpc_stats later
26638 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
26641 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
26642 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
26643 --numjobs=$njobs --fallocate=none --ioengine=libaio \
26644 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
26645 --filename=$DIR/$tfile
26646 [ $? -eq 0 ] || error "fio write error"
26648 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
26649 error "Locks were requested while doing AIO"
26651 # get the percentage of 1-page I/O
26652 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
26653 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
26655 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
26657 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
26658 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
26659 --numjobs=$njobs --fallocate=none --ioengine=libaio \
26660 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
26661 --filename=$DIR/$tfile
26662 [ $? -eq 0 ] || error "fio mixed read write error"
26664 echo "AIO with large block size ${size}M"
26665 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
26666 --numjobs=1 --fallocate=none --ioengine=libaio \
26667 --iodepth=16 --allow_file_create=0 --size=${size}M \
26668 --filename=$DIR/$tfile
26669 [ $? -eq 0 ] || error "fio large block size failed"
26672 $LCTL set_param debug="$saved_debug"
26674 run_test 398c "run fio to test AIO"
26676 test_398d() { # LU-13846
26677 which aiocp || skip_env "no aiocp installed"
26678 local aio_file=$DIR/$tfile.aio
26680 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
26682 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
26683 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
26684 stack_trap "rm -f $DIR/$tfile $aio_file"
26686 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
26688 # test memory unaligned aio
26689 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file ||
26690 error "unaligned aio failed"
26691 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
26693 rm -f $DIR/$tfile $aio_file
26695 run_test 398d "run aiocp to verify block size > stripe size"
26698 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
26699 touch $DIR/$tfile.new
26700 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
26702 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
26704 test_398f() { # LU-14687
26705 which aiocp || skip_env "no aiocp installed"
26706 local aio_file=$DIR/$tfile.aio
26708 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
26710 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
26711 stack_trap "rm -f $DIR/$tfile $aio_file"
26713 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
26714 $LCTL set_param fail_loc=0x1418
26715 # make sure we don't crash and fail properly
26716 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
26717 error "aio with page allocation failure succeeded"
26718 $LCTL set_param fail_loc=0
26719 diff $DIR/$tfile $aio_file
26720 [[ $? != 0 ]] || error "no diff after failed aiocp"
26722 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
26724 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
26725 # stripe and i/o size must be > stripe size
26726 # Old style synchronous DIO waits after submitting each chunk, resulting in a
26727 # single RPC in flight. This test shows async DIO submission is working by
26728 # showing multiple RPCs in flight.
26729 test_398g() { # LU-13798
26730 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
26732 # We need to do some i/o first to acquire enough grant to put our RPCs
26733 # in flight; otherwise a new connection may not have enough grant
26735 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
26736 error "parallel dio failed"
26737 stack_trap "rm -f $DIR/$tfile"
26739 # Reduce RPC size to 1M to avoid combination in to larger RPCs
26740 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
26741 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
26742 stack_trap "$LCTL set_param -n $pages_per_rpc"
26744 # Recreate file so it's empty
26746 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
26747 #Pause rpc completion to guarantee we see multiple rpcs in flight
26748 #define OBD_FAIL_OST_BRW_PAUSE_BULK
26749 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
26750 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
26753 $LCTL set_param osc.*.rpc_stats=c
26755 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
26756 error "parallel dio failed"
26757 stack_trap "rm -f $DIR/$tfile"
26759 $LCTL get_param osc.*-OST0000-*.rpc_stats
26760 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
26761 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
26762 grep "8:" | awk '{print $8}')
26763 # We look at the "8 rpcs in flight" field, and verify A) it is present
26764 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
26765 # as expected for an 8M DIO to a file with 1M stripes.
26766 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
26768 # Verify turning off parallel dio works as expected
26770 $LCTL set_param osc.*.rpc_stats=c
26771 $LCTL set_param llite.*.parallel_dio=0
26772 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
26774 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
26775 error "dio with parallel dio disabled failed"
26777 # Ideally, we would see only one RPC in flight here, but there is an
26778 # unavoidable race between i/o completion and RPC in flight counting,
26779 # so while only 1 i/o is in flight at a time, the RPC in flight counter
26780 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
26781 # So instead we just verify it's always < 8.
26782 $LCTL get_param osc.*-OST0000-*.rpc_stats
26783 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
26784 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
26785 grep '^$' -B1 | grep . | awk '{print $1}')
26786 [ $ret != "8:" ] ||
26787 error "we should see fewer than 8 RPCs in flight (saw $ret)"
26789 run_test 398g "verify parallel dio async RPC submission"
26791 test_398h() { # LU-13798
26792 local dio_file=$DIR/$tfile.dio
26794 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
26796 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
26797 stack_trap "rm -f $DIR/$tfile $dio_file"
26799 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
26800 error "parallel dio failed"
26801 diff $DIR/$tfile $dio_file
26802 [[ $? == 0 ]] || error "file diff after aiocp"
26804 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
26806 test_398i() { # LU-13798
26807 local dio_file=$DIR/$tfile.dio
26809 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
26811 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
26812 stack_trap "rm -f $DIR/$tfile $dio_file"
26814 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
26815 $LCTL set_param fail_loc=0x1418
26816 # make sure we don't crash and fail properly
26817 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
26818 error "parallel dio page allocation failure succeeded"
26819 diff $DIR/$tfile $dio_file
26820 [[ $? != 0 ]] || error "no diff after failed aiocp"
26822 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
26824 test_398j() { # LU-13798
26825 # Stripe size > RPC size but less than i/o size tests split across
26826 # stripes and RPCs for individual i/o op
26827 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
26829 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
26830 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
26831 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
26832 stack_trap "$LCTL set_param -n $pages_per_rpc"
26834 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
26835 error "parallel dio write failed"
26836 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
26838 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
26839 error "parallel dio read failed"
26840 diff $DIR/$tfile $DIR/$tfile.2
26841 [[ $? == 0 ]] || error "file diff after parallel dio read"
26843 run_test 398j "test parallel dio where stripe size > rpc_size"
26845 test_398k() { # LU-13798
26846 wait_delete_completed
26849 # 4 stripe file; we will cause out of space on OST0
26850 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
26852 # Fill OST0 (if it's not too large)
26853 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
26855 if [[ $ORIGFREE -gt $MAXFREE ]]; then
26856 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
26858 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
26859 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
26860 error "dd should fill OST0"
26861 stack_trap "rm -f $DIR/$tfile.1"
26863 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
26867 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
26868 error "file is not 0 bytes in size"
26870 # dd above should not succeed, but don't error until here so we can
26871 # get debug info above
26873 error "parallel dio write with enospc succeeded"
26874 stack_trap "rm -f $DIR/$tfile"
26876 run_test 398k "test enospc on first stripe"
26878 test_398l() { # LU-13798
26879 wait_delete_completed
26882 # 4 stripe file; we will cause out of space on OST0
26883 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
26884 # happens on the second i/o chunk we issue
26885 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
26887 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
26888 stack_trap "rm -f $DIR/$tfile"
26890 # Fill OST0 (if it's not too large)
26891 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
26893 if [[ $ORIGFREE -gt $MAXFREE ]]; then
26894 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
26896 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
26897 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
26898 error "dd should fill OST0"
26899 stack_trap "rm -f $DIR/$tfile.1"
26901 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
26903 stack_trap "rm -f $DIR/$tfile.2"
26905 # Check that short write completed as expected
26906 ls -la $DIR/$tfile.2
26907 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
26908 error "file is not 1M in size"
26910 # dd above should not succeed, but don't error until here so we can
26911 # get debug info above
26913 error "parallel dio write with enospc succeeded"
26915 # Truncate source file to same length as output file and diff them
26916 $TRUNCATE $DIR/$tfile 1048576
26917 diff $DIR/$tfile $DIR/$tfile.2
26918 [[ $? == 0 ]] || error "data incorrect after short write"
26920 run_test 398l "test enospc on intermediate stripe/RPC"
26922 test_398m() { # LU-13798
26923 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
26925 # Set up failure on OST0, the first stripe:
26926 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
26927 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
26928 # OST0 is on ost1, OST1 is on ost2.
26929 # So this fail_val specifies OST0
26930 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
26931 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
26933 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
26934 error "parallel dio write with failure on first stripe succeeded"
26935 stack_trap "rm -f $DIR/$tfile"
26936 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
26938 # Place data in file for read
26939 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
26940 error "parallel dio write failed"
26942 # Fail read on OST0, first stripe
26943 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
26944 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
26945 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
26946 error "parallel dio read with error on first stripe succeeded"
26947 rm -f $DIR/$tfile.2
26948 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
26950 # Switch to testing on OST1, second stripe
26951 # Clear file contents, maintain striping
26953 # Set up failure on OST1, second stripe:
26954 do_facet ost2 $LCTL set_param fail_loc=0x20e fail_val=2
26955 stack_trap "do_facet ost2 $LCTL set_param fail_loc=0"
26957 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
26958 error "parallel dio write with failure on second stripe succeeded"
26959 stack_trap "rm -f $DIR/$tfile"
26960 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
26962 # Place data in file for read
26963 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
26964 error "parallel dio write failed"
26966 # Fail read on OST1, second stripe
26967 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
26968 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
26969 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
26970 error "parallel dio read with error on second stripe succeeded"
26971 rm -f $DIR/$tfile.2
26972 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
26974 run_test 398m "test RPC failures with parallel dio"
26976 # Parallel submission of DIO should not cause problems for append, but it's
26977 # important to verify.
26978 test_398n() { # LU-13798
26979 $LFS setstripe -C 2 -S 1M $DIR/$tfile
26981 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
26982 error "dd to create source file failed"
26983 stack_trap "rm -f $DIR/$tfile"
26985 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
26986 error "parallel dio write with failure on second stripe succeeded"
26987 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
26988 diff $DIR/$tfile $DIR/$tfile.1
26989 [[ $? == 0 ]] || error "data incorrect after append"
26992 run_test 398n "test append with parallel DIO"
26995 directio rdwr $DIR/$tfile 0 1 1 || error "bad KMS"
26997 run_test 398o "right kms with DIO"
27001 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
27002 which aiocp || skip_env "no aiocp installed"
27004 local stripe_size=$((1024 * 1024)) #1 MiB
27005 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
27006 local file_size=$((25 * stripe_size))
27008 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
27009 stack_trap "rm -f $DIR/$tfile*"
27010 # Just a bit bigger than the largest size in the test set below
27011 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
27012 error "buffered i/o to create file failed"
27014 for bs in $PAGE_SIZE $((PAGE_SIZE * 4)) $stripe_size \
27015 $((stripe_size * 4)); do
27017 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
27019 echo "bs: $bs, file_size $file_size"
27020 aiocp -a $PAGE_SIZE -b $bs -s $file_size -f O_DIRECT \
27021 $DIR/$tfile.1 $DIR/$tfile.2 &
27023 # Buffered I/O with similar but not the same block size
27024 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
27031 if (( rc1 != 0 )); then
27032 error "aio copy 1 w/bsize $bs failed: $rc1"
27034 if (( rc2 != 0 )); then
27035 error "buffered copy 2 w/bsize $bs failed: $rc2"
27038 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
27039 error "size incorrect"
27040 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
27041 error "files differ, bsize $bs"
27042 rm -f $DIR/$tfile.2
27045 run_test 398p "race aio with buffered i/o"
27049 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
27051 local stripe_size=$((1024 * 1024)) #1 MiB
27052 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
27053 local file_size=$((25 * stripe_size))
27055 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
27056 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
27058 # Just a bit bigger than the largest size in the test set below
27059 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
27060 error "buffered i/o to create file failed"
27062 for bs in $PAGE_SIZE $((PAGE_SIZE * 4)) $stripe_size \
27063 $((stripe_size * 4)); do
27065 echo "bs: $bs, file_size $file_size"
27066 dd if=$DIR/$tfile.1 bs=$((bs *2 )) of=$DIR/tfile.2 \
27067 conv=notrunc oflag=direct iflag=direct &
27069 # Buffered I/O with similar but not the same block size
27070 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
27077 if (( rc1 != 0 )); then
27078 error "dio copy 1 w/bsize $bs failed: $rc1"
27080 if (( rc2 != 0 )); then
27081 error "buffered copy 2 w/bsize $bs failed: $rc2"
27084 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
27085 error "size incorrect"
27086 diff $DIR/$tfile.1 $DIR/$tfile.2 ||
27087 error "files differ, bsize $bs"
27092 run_test 398q "race dio with buffered i/o"
27095 local read_write=$1
27096 if [ "$read_write" = "write" ]; then
27097 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
27098 elif [ "$read_write" = "read" ]; then
27099 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
27101 error "argument error"
27104 # turn off debug for performance testing
27105 local saved_debug=$($LCTL get_param -n debug)
27106 $LCTL set_param debug=0
27108 $LFS setstripe -c 1 -i 0 $DIR/$tfile
27110 # get ost1 size - $FSNAME-OST0000
27111 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
27112 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
27113 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
27115 if [ "$read_write" = "read" ]; then
27116 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
27119 local start_time=$(date +%s.%N)
27120 $dd_cmd bs=1M count=$blocks oflag=sync ||
27121 error "real dd $read_write error"
27122 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
27124 if [ "$read_write" = "write" ]; then
27128 # define OBD_FAIL_OST_FAKE_RW 0x238
27129 do_facet ost1 $LCTL set_param fail_loc=0x238
27131 local start_time=$(date +%s.%N)
27132 $dd_cmd bs=1M count=$blocks oflag=sync ||
27133 error "fake dd $read_write error"
27134 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
27136 if [ "$read_write" = "write" ]; then
27138 cancel_lru_locks osc
27139 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
27140 error "$tfile size not $blocks MB"
27142 do_facet ost1 $LCTL set_param fail_loc=0
27144 echo "fake $read_write $duration_fake vs. normal $read_write" \
27145 "$duration in seconds"
27146 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
27147 error_not_in_vm "fake write is slower"
27149 $LCTL set_param -n debug="$saved_debug"
27152 test_399a() { # LU-7655 for OST fake write
27153 remote_ost_nodsh && skip "remote OST with nodsh"
27157 run_test 399a "fake write should not be slower than normal write"
27159 test_399b() { # LU-8726 for OST fake read
27160 remote_ost_nodsh && skip "remote OST with nodsh"
27161 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
27162 skip_env "ldiskfs only test"
27167 run_test 399b "fake read should not be slower than normal read"
27169 test_400a() { # LU-1606, was conf-sanity test_74
27170 if ! which $CC > /dev/null 2>&1; then
27171 skip_env "$CC is not installed"
27174 local extra_flags=''
27175 local out=$TMP/$tfile
27176 local prefix=/usr/include/lustre
27179 # Oleg removes .c files in his test rig so test if any c files exist
27180 [[ -n "$(ls -A $LUSTRE_TESTS_API_DIR)" ]] ||
27181 skip_env "Needed .c test files are missing"
27183 if ! [[ -d $prefix ]]; then
27184 # Assume we're running in tree and fixup the include path.
27185 extra_flags+=" -I$LUSTRE/../lnet/include/uapi"
27186 extra_flags+=" -I$LUSTRE/include/uapi -I$LUSTRE/include"
27187 extra_flags+=" -L$LUSTRE/utils/.libs"
27190 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
27191 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
27192 error "client api broken"
27196 run_test 400a "Lustre client api program can compile and link"
27198 test_400b() { # LU-1606, LU-5011
27200 local out=$TMP/$tfile
27201 local prefix=/usr/include/linux/lustre
27203 # We use a hard coded prefix so that this test will not fail
27204 # when run in tree. There are headers in lustre/include/lustre/
27205 # that are not packaged (like lustre_idl.h) and have more
27206 # complicated include dependencies (like config.h and lnet/types.h).
27207 # Since this test about correct packaging we just skip them when
27208 # they don't exist (see below) rather than try to fixup cppflags.
27210 if ! which $CC > /dev/null 2>&1; then
27211 skip_env "$CC is not installed"
27214 for header in $prefix/*.h; do
27215 if ! [[ -f "$header" ]]; then
27219 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
27220 continue # lustre_ioctl.h is internal header
27223 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
27224 error "cannot compile '$header'"
27228 run_test 400b "packaged headers can be compiled"
27230 test_401a() { #LU-7437
27231 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
27232 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
27234 #count the number of parameters by "list_param -R"
27235 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
27236 #count the number of parameters by listing proc files
27237 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
27238 echo "proc_dirs='$proc_dirs'"
27239 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
27240 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
27243 [ $params -eq $procs ] ||
27244 error "found $params parameters vs. $procs proc files"
27246 # test the list_param -D option only returns directories
27247 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
27248 #count the number of parameters by listing proc directories
27249 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
27252 [ $params -eq $procs ] ||
27253 error "found $params parameters vs. $procs proc files"
27255 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
27258 # jobid_var may not allow arbitrary values, so use jobid_name
27260 if $LCTL list_param jobid_name > /dev/null 2>&1; then
27261 local testname=jobid_name tmp='testing%p'
27263 local testname=jobid_var tmp=testing
27266 local save=$($LCTL get_param -n $testname)
27268 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
27269 error "no error returned when setting bad parameters"
27271 local jobid_new=$($LCTL get_param -n foe $testname baz)
27272 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
27274 $LCTL set_param -n fog=bam $testname=$save bat=fog
27275 local jobid_old=$($LCTL get_param -n foe $testname bag)
27276 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
27278 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
27281 # jobid_var may not allow arbitrary values, so use jobid_name
27283 if $LCTL list_param jobid_name > /dev/null 2>&1; then
27284 local testname=jobid_name
27286 local testname=jobid_var
27289 local jobid_var_old=$($LCTL get_param -n $testname)
27290 local jobid_var_new
27292 $LCTL set_param $testname= &&
27293 error "no error returned for 'set_param a='"
27295 jobid_var_new=$($LCTL get_param -n $testname)
27296 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
27297 error "$testname was changed by setting without value"
27299 $LCTL set_param $testname &&
27300 error "no error returned for 'set_param a'"
27302 jobid_var_new=$($LCTL get_param -n $testname)
27303 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
27304 error "$testname was changed by setting without value"
27306 run_test 401c "Verify 'lctl set_param' without value fails in either format."
27309 # jobid_var may not allow arbitrary values, so use jobid_name
27311 if $LCTL list_param jobid_name > /dev/null 2>&1; then
27312 local testname=jobid_name new_value='foo=bar%p'
27314 local testname=jobid_var new_valuie=foo=bar
27317 local jobid_var_old=$($LCTL get_param -n $testname)
27318 local jobid_var_new
27320 $LCTL set_param $testname=$new_value ||
27321 error "'set_param a=b' did not accept a value containing '='"
27323 jobid_var_new=$($LCTL get_param -n $testname)
27324 [[ "$jobid_var_new" == "$new_value" ]] ||
27325 error "'set_param a=b' failed on a value containing '='"
27327 # Reset the $testname to test the other format
27328 $LCTL set_param $testname=$jobid_var_old
27329 jobid_var_new=$($LCTL get_param -n $testname)
27330 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
27331 error "failed to reset $testname"
27333 $LCTL set_param $testname $new_value ||
27334 error "'set_param a b' did not accept a value containing '='"
27336 jobid_var_new=$($LCTL get_param -n $testname)
27337 [[ "$jobid_var_new" == "$new_value" ]] ||
27338 error "'set_param a b' failed on a value containing '='"
27340 $LCTL set_param $testname $jobid_var_old
27341 jobid_var_new=$($LCTL get_param -n $testname)
27342 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
27343 error "failed to reset $testname"
27345 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
27347 test_401e() { # LU-14779
27348 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
27349 error "lctl list_param MGC* failed"
27350 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
27351 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
27352 error "lctl get_param lru_size failed"
27354 run_test 401e "verify 'lctl get_param' works with NID in parameter"
27357 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
27358 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
27359 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
27360 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
27361 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
27362 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
27363 remote_mds_nodsh && skip "remote MDS with nodsh"
27365 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
27366 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
27367 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
27368 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
27369 echo "Touch failed - OK"
27371 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
27374 local file1=$DIR/$tfile.1
27375 local file2=$DIR/$tfile.2
27376 local tfile=$TMP/$tfile
27378 rm -f $file1 $file2 $tfile
27383 # 30 sec OBD_TIMEOUT in ll_getattr()
27384 # right before populating st_nlink
27385 $LCTL set_param fail_loc=0x80001409
27386 stat -c %h $file1 > $tfile &
27388 # create an alias, drop all locks and reclaim the dentry
27390 cancel_lru_locks mdc
27391 cancel_lru_locks osc
27392 sysctl -w vm.drop_caches=2
27396 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
27398 rm -f $tfile $file1 $file2
27400 run_test 403 "i_nlink should not drop to zero due to aliasing"
27402 test_404() { # LU-6601
27403 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
27404 skip "Need server version newer than 2.8.52"
27405 remote_mds_nodsh && skip "remote MDS with nodsh"
27407 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
27408 awk '/osp .*-osc-MDT/ { print $4}')
27411 for osp in $mosps; do
27412 echo "Deactivate: " $osp
27413 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
27414 local stat=$(do_facet $SINGLEMDS $LCTL dl |
27415 awk -vp=$osp '$4 == p { print $2 }')
27416 [ $stat = IN ] || {
27417 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
27418 error "deactivate error"
27420 echo "Activate: " $osp
27421 do_facet $SINGLEMDS $LCTL --device %$osp activate
27422 local stat=$(do_facet $SINGLEMDS $LCTL dl |
27423 awk -vp=$osp '$4 == p { print $2 }')
27424 [ $stat = UP ] || {
27425 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
27426 error "activate error"
27430 run_test 404 "validate manual {de}activated works properly for OSPs"
27433 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
27434 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
27435 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
27436 skip "Layout swap lock is not supported"
27438 check_swap_layouts_support
27439 check_swap_layout_no_dom $DIR
27441 test_mkdir $DIR/$tdir
27442 swap_lock_test -d $DIR/$tdir ||
27443 error "One layout swap locked test failed"
27445 run_test 405 "Various layout swap lock tests"
27448 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
27449 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
27450 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
27451 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27452 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
27453 skip "Need MDS version at least 2.8.50"
27455 local def_stripe_size=$($LFS getstripe -S $MOUNT)
27456 local test_pool=$TESTNAME
27458 pool_add $test_pool || error "pool_add failed"
27459 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
27460 error "pool_add_targets failed"
27462 save_layout_restore_at_exit $MOUNT
27464 # parent set default stripe count only, child will stripe from both
27465 # parent and fs default
27466 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
27467 error "setstripe $MOUNT failed"
27468 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
27469 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
27470 for i in $(seq 10); do
27471 local f=$DIR/$tdir/$tfile.$i
27472 touch $f || error "touch failed"
27473 local count=$($LFS getstripe -c $f)
27474 [ $count -eq $OSTCOUNT ] ||
27475 error "$f stripe count $count != $OSTCOUNT"
27476 local offset=$($LFS getstripe -i $f)
27477 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
27478 local size=$($LFS getstripe -S $f)
27479 [ $size -eq $((def_stripe_size * 2)) ] ||
27480 error "$f stripe size $size != $((def_stripe_size * 2))"
27481 local pool=$($LFS getstripe -p $f)
27482 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
27485 # change fs default striping, delete parent default striping, now child
27486 # will stripe from new fs default striping only
27487 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
27488 error "change $MOUNT default stripe failed"
27489 $LFS setstripe -c 0 $DIR/$tdir ||
27490 error "delete $tdir default stripe failed"
27491 for i in $(seq 11 20); do
27492 local f=$DIR/$tdir/$tfile.$i
27493 touch $f || error "touch $f failed"
27494 local count=$($LFS getstripe -c $f)
27495 [ $count -eq 1 ] || error "$f stripe count $count != 1"
27496 local offset=$($LFS getstripe -i $f)
27497 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
27498 local size=$($LFS getstripe -S $f)
27499 [ $size -eq $def_stripe_size ] ||
27500 error "$f stripe size $size != $def_stripe_size"
27501 local pool=$($LFS getstripe -p $f)
27502 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
27505 unlinkmany $DIR/$tdir/$tfile. 1 20
27507 local f=$DIR/$tdir/$tfile
27508 pool_remove_all_targets $test_pool $f
27509 pool_remove $test_pool $f
27511 run_test 406 "DNE support fs default striping"
27514 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
27515 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
27516 skip "Need MDS version at least 2.8.55"
27517 remote_mds_nodsh && skip "remote MDS with nodsh"
27519 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
27520 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
27521 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
27522 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
27523 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
27525 #define OBD_FAIL_DT_TXN_STOP 0x2019
27526 for idx in $(seq $MDSCOUNT); do
27527 do_facet mds$idx "lctl set_param fail_loc=0x2019"
27529 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
27530 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
27531 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
27534 run_test 407 "transaction fail should cause operation fail"
27537 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
27539 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
27540 lctl set_param fail_loc=0x8000040a
27541 # let ll_prepare_partial_page() fail
27542 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
27546 # create at least 100 unused inodes so that
27547 # shrink_icache_memory(0) should not return 0
27548 touch $DIR/$tfile-{0..100}
27549 rm -f $DIR/$tfile-{0..100}
27552 echo 2 > /proc/sys/vm/drop_caches
27554 run_test 408 "drop_caches should not hang due to page leaks"
27558 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
27560 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
27561 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
27562 touch $DIR/$tdir/guard || error "(2) Fail to create"
27564 local PREFIX=$(str_repeat 'A' 128)
27565 echo "Create 1K hard links start at $(date)"
27566 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
27567 error "(3) Fail to hard link"
27569 echo "Links count should be right although linkEA overflow"
27570 stat $DIR/$tdir/guard || error "(4) Fail to stat"
27571 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
27572 [ $linkcount -eq 1001 ] ||
27573 error "(5) Unexpected hard links count: $linkcount"
27575 echo "List all links start at $(date)"
27576 ls -l $DIR/$tdir/foo > /dev/null ||
27577 error "(6) Fail to list $DIR/$tdir/foo"
27579 echo "Unlink hard links start at $(date)"
27580 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
27581 error "(7) Fail to unlink"
27582 echo "Unlink hard links finished at $(date)"
27584 run_test 409 "Large amount of cross-MDTs hard links on the same file"
27588 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
27589 skip "Need client version at least 2.9.59"
27590 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
27591 skip "Need MODULES build"
27593 # Create a file, and stat it from the kernel
27594 local testfile=$DIR/$tfile
27597 local run_id=$RANDOM
27598 local my_ino=$(stat --format "%i" $testfile)
27600 # Try to insert the module. This will always fail as the
27601 # module is designed to not be inserted.
27602 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
27605 # Anything but success is a test failure
27607 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
27608 error "no inode match"
27610 run_test 410 "Test inode number returned from kernel thread"
27612 cleanup_test411_cgroup() {
27619 local cg_basedir=/sys/fs/cgroup/memory
27621 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
27622 skip "no setup for cgroup"
27624 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
27625 error "test file creation failed"
27626 cancel_lru_locks osc
27628 # Create a very small memory cgroup to force a slab allocation error
27629 local cgdir=$cg_basedir/osc_slab_alloc
27630 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
27631 trap "cleanup_test411_cgroup $cgdir" EXIT
27632 echo 2M > $cgdir/memory.kmem.limit_in_bytes
27633 echo 1M > $cgdir/memory.limit_in_bytes
27635 # Should not LBUG, just be killed by oom-killer
27636 # dd will return 0 even allocation failure in some environment.
27637 # So don't check return value
27638 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
27639 cleanup_test411_cgroup $cgdir
27643 run_test 411a "Slab allocation error with cgroup does not LBUG"
27646 local cg_basedir=/sys/fs/cgroup/memory
27648 [ -e "$cg_basedir/memory.kmem.limit_in_bytes" ] ||
27649 skip "no setup for cgroup"
27650 $LFS setstripe -c 2 $DIR/$tfile || error "unable to setstripe"
27651 # (x86) testing suggests we can't reliably avoid OOM with a 64M-256M
27652 # limit, so we have 384M in cgroup
27653 # (arm) this seems to hit OOM more often than x86, so 1024M
27654 if [[ $(uname -m) = aarch64 ]]; then
27655 local memlimit_mb=1024
27657 local memlimit_mb=384
27660 # Create a cgroup and set memory limit
27661 # (tfile is used as an easy way to get a recognizable cgroup name)
27662 local cgdir=$cg_basedir/$tfile
27663 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
27664 stack_trap "cleanup_test411_cgroup $cgdir" EXIT
27665 echo $((memlimit_mb * 1024 * 1024)) > $cgdir/memory.limit_in_bytes
27667 echo "writing first file"
27668 # Write a file 4x the memory limit in size
27669 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile bs=1M count=$((memlimit_mb * 4))" ||
27670 error "(1) failed to write successfully"
27673 cancel_lru_locks osc
27676 $LFS setstripe -c 2 $DIR/$tfile || error "unable to setstripe"
27678 # Try writing at a larger block size
27679 # NB: if block size is >= 1/2 cgroup size, we sometimes get OOM killed
27680 # so test with 1/4 cgroup size (this seems reasonable to me - we do
27681 # need *some* memory to do IO in)
27682 echo "writing at larger block size"
27683 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile bs=64M count=$((memlimit_mb * 4 / 128))" ||
27684 error "(3) failed to write successfully"
27687 cancel_lru_locks osc
27689 $LFS setstripe -c 2 $DIR/$tfile.{1..4} || error "unable to setstripe"
27691 # Try writing multiple files at once
27692 echo "writing multiple files"
27693 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile.1 bs=32M count=$((memlimit_mb * 4 / 64))" &
27695 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile.2 bs=32M count=$((memlimit_mb * 4 / 64))" &
27697 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile.3 bs=32M count=$((memlimit_mb * 4 / 64))" &
27699 bash -c "echo \$$ > $cgdir/tasks && dd if=/dev/zero of=$DIR/$tfile.4 bs=32M count=$((memlimit_mb * 4 / 64))" &
27710 if (( rc1 != 0)); then
27711 error "error $rc1 writing to file from $pid1"
27713 if (( rc2 != 0)); then
27714 error "error $rc2 writing to file from $pid2"
27716 if (( rc3 != 0)); then
27717 error "error $rc3 writing to file from $pid3"
27719 if (( rc4 != 0)); then
27720 error "error $rc4 writing to file from $pid4"
27724 cancel_lru_locks osc
27726 # These files can be large-ish (~1 GiB total), so delete them rather
27727 # than leave for later cleanup
27728 rm -f $DIR/$tfile.*
27731 run_test 411b "confirm Lustre can avoid OOM with reasonable cgroups limits"
27734 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
27735 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
27736 skip "Need server version at least 2.10.55"
27738 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
27739 error "mkdir failed"
27740 $LFS getdirstripe $DIR/$tdir
27741 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
27742 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
27743 error "expect $((MDSCOUT - 1)) get $stripe_index"
27744 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
27745 [ $stripe_count -eq 2 ] ||
27746 error "expect 2 get $stripe_count"
27748 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
27753 # subdirs should be on the same MDT as parent
27754 for i in $(seq 0 $((MDSCOUNT - 1))); do
27755 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
27756 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
27757 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
27758 (( index == i )) || error "mdt$i/sub on MDT$index"
27761 # stripe offset -1, ditto
27762 for i in {1..10}; do
27763 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
27764 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
27765 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
27766 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
27767 (( index == index2 )) ||
27768 error "qos$i on MDT$index, sub on MDT$index2"
27771 local testdir=$DIR/$tdir/inherit
27773 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
27776 testdir=$testdir/s$i
27777 mkdir $testdir || error "mkdir $testdir failed"
27778 index=$($LFS getstripe -m $testdir)
27779 (( index == 1 )) ||
27780 error "$testdir on MDT$index"
27783 # not inherit any more
27784 testdir=$testdir/s3
27785 mkdir $testdir || error "mkdir $testdir failed"
27786 getfattr -d -m dmv $testdir | grep dmv &&
27787 error "default LMV set on $testdir" || true
27789 run_test 412 "mkdir on specific MDTs"
27791 TEST413_COUNT=${TEST413_COUNT:-200}
27794 # set_maxage() is used by test_413 only.
27795 # This is a helper function to set maxage. Does not return any value.
27796 # Input: maxage to set
27799 local lmv_qos_maxage
27800 local lod_qos_maxage
27801 local new_maxage=$1
27803 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
27804 $LCTL set_param lmv.*.qos_maxage=$new_maxage
27805 stack_trap "$LCTL set_param \
27806 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
27807 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
27808 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
27809 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
27810 lod.*.mdt_qos_maxage=$new_maxage
27811 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
27812 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
27815 generate_uneven_mdts() {
27827 echo "Check for uneven MDTs: "
27829 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
27830 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
27831 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
27833 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
27834 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
27837 for ((i = 1; i < ${#ffree[@]}; i++)); do
27838 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
27839 if [ $tmp -gt $max ]; then
27843 if [ $tmp -lt $min ]; then
27849 (( min > 0 )) || skip "low space on MDT$min_index"
27850 (( ${ffree[min_index]} > 0 )) ||
27851 skip "no free files on MDT$min_index"
27852 (( ${ffree[min_index]} < 10000000 )) ||
27853 skip "too many free files on MDT$min_index"
27855 # Check if we need to generate uneven MDTs
27856 local diff=$(((max - min) * 100 / min))
27857 local testdirp=$DIR/$tdir-fillmdt # parent fill folder
27858 local testdir # individual folder within $testdirp
27862 # fallocate is faster to consume space on MDT, if available
27863 if check_fallocate_supported mds$((min_index + 1)); then
27864 cmd="fallocate -l 128K "
27866 cmd="dd if=/dev/zero bs=128K count=1 of="
27869 echo "using cmd $cmd"
27870 for (( i = 0; diff < threshold; i++ )); do
27871 testdir=${testdirp}/$i
27872 [ -d $testdir ] && continue
27874 (( i % 10 > 0 )) || { $LFS df; $LFS df -i; }
27877 # generate uneven MDTs, create till $threshold% diff
27878 echo -n "weight diff=$diff% must be > $threshold% ..."
27879 echo "Fill MDT$min_index with $TEST413_COUNT files: loop $i"
27880 $LFS mkdir -i $min_index $testdir ||
27881 error "mkdir $testdir failed"
27882 $LFS setstripe -E 1M -L mdt $testdir ||
27883 error "setstripe $testdir failed"
27885 for (( f = 0; f < TEST413_COUNT; f++ )); do
27886 $cmd$testdir/f.$f &> /dev/null || error "$cmd $f failed"
27888 sync; sleep 1; sync
27890 # wait for QOS to update
27891 (( SECONDS < start + 2 )) && sleep $((start + 2 - SECONDS))
27893 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
27894 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
27895 max=$(((${ffree[max_index]} >> 8) *
27896 (${bavail[max_index]} * bsize >> 16)))
27897 min=$(((${ffree[min_index]} >> 8) *
27898 (${bavail[min_index]} * bsize >> 16)))
27899 (( min > 0 )) || skip "low space on MDT$min_index"
27900 diff=$(((max - min) * 100 / min))
27903 echo "MDT filesfree available: ${ffree[*]}"
27904 echo "MDT blocks available: ${bavail[*]}"
27905 echo "weight diff=$diff%"
27910 local stripe_count=$2
27911 local mdts=$(comma_list $(mdts_nodes))
27914 local lmv_qos_prio_free
27915 local lmv_qos_threshold_rr
27916 local lod_qos_prio_free
27917 local lod_qos_threshold_rr
27922 # @total is total directories created if it's testing plain
27923 # directories, otherwise it's total stripe object count for
27924 # striped directories test.
27925 # remote/striped directory unlinking is slow on zfs and may
27926 # timeout, test with fewer directories
27927 [ "$mds1_FSTYPE" = "zfs" ] && total=120 || total=240
27929 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
27930 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
27931 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
27933 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
27934 stack_trap "$LCTL set_param \
27935 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
27936 stack_trap "$LCTL set_param \
27937 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
27939 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
27940 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
27941 lod_qos_prio_free=${lod_qos_prio_free%%%}
27942 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
27943 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
27944 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
27945 stack_trap "do_nodes $mdts $LCTL set_param \
27946 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
27947 stack_trap "do_nodes $mdts $LCTL set_param \
27948 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
27950 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
27951 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
27953 testdir=$DIR/$tdir-s$stripe_count/rr
27955 local stripe_index=$($LFS getstripe -m $testdir)
27956 local test_mkdir_rr=true
27958 getfattr -d -m dmv -e hex $testdir | grep dmv
27959 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
27960 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
27961 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
27962 test_mkdir_rr=false
27967 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
27968 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
27970 stack_trap "unlinkmany -d $testdir/subdir $((total / stripe_count))"
27971 for (( i = 0; i < total / stripe_count; i++ )); do
27972 eval $mkdir_cmd $testdir/subdir$i ||
27973 error "$mkdir_cmd subdir$i failed"
27976 for (( i = 0; i < $MDSCOUNT; i++ )); do
27977 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
27978 echo "$count directories created on MDT$i"
27979 if $test_mkdir_rr; then
27980 (( count == total / stripe_count / MDSCOUNT )) ||
27981 error "subdirs are not evenly distributed"
27982 elif (( i == stripe_index )); then
27983 (( count == total / stripe_count )) ||
27984 error "$count subdirs created on MDT$i"
27986 (( count == 0 )) ||
27987 error "$count subdirs created on MDT$i"
27990 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
27991 count=$($LFS getdirstripe $testdir/* |
27992 grep -c -P "^\s+$i\t")
27993 echo "$count stripes created on MDT$i"
27994 # deviation should < 5% of average
27995 delta=$((count - total / MDSCOUNT))
27996 (( ${delta#-} <= total / MDSCOUNT / 20 )) ||
27997 error "stripes are not evenly distributed"
28002 echo "Check for uneven MDTs: "
28012 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
28013 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
28014 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
28016 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
28017 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
28020 for ((i = 1; i < ${#ffree[@]}; i++)); do
28021 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
28022 if [ $tmp -gt $max ]; then
28026 if [ $tmp -lt $min ]; then
28031 echo "stripe_count=$stripe_count min_idx=$min_index max_idx=$max_index"
28033 (( min > 0 )) || skip "low space on MDT$min_index"
28034 (( ${ffree[min_index]} < 10000000 )) ||
28035 skip "too many free files on MDT$min_index"
28037 generate_uneven_mdts 120
28039 echo "MDT filesfree available: ${ffree[*]}"
28040 echo "MDT blocks available: ${bavail[*]}"
28041 echo "weight diff=$(((max - min) * 100 / min))%"
28043 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
28045 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
28046 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
28047 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
28048 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
28049 # decrease statfs age, so that it can be updated in time
28050 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
28051 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
28055 testdir=$DIR/$tdir-s$stripe_count/qos
28057 stack_trap "unlinkmany -d $testdir/subdir $((total / stripe_count))"
28058 for (( i = 0; i < total / stripe_count; i++ )); do
28059 eval $mkdir_cmd $testdir/subdir$i ||
28060 error "$mkdir_cmd subdir$i failed"
28064 for (( i = 0; i < $MDSCOUNT; i++ )); do
28065 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
28066 (( count > max )) && max=$count
28067 echo "$count directories created on MDT$i : curmax=$max"
28070 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
28072 # D-value should > 10% of average
28073 (( max - min > total / stripe_count / MDSCOUNT / 10 )) ||
28074 error "subdirs shouldn't be evenly distributed: $max - $min <= $((total / stripe_count / MDSCOUNT / 10))"
28076 # ditto for stripes
28077 if (( stripe_count > 1 )); then
28079 for (( i = 0; i < $MDSCOUNT; i++ )); do
28080 count=$($LFS getdirstripe $testdir/* |
28081 grep -c -P "^\s+$i\t")
28082 (( count > max )) && max=$count
28083 echo "$count stripes created on MDT$i"
28086 min=$($LFS getdirstripe $testdir/* |
28087 grep -c -P "^\s+$min_index\t")
28088 (( max - min > total / MDSCOUNT / 10 )) ||
28089 error "stripes shouldn't be evenly distributed: $max - $min <= $((total / MDSCOUNT / 10))"
28101 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
28102 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
28103 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
28105 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
28107 for ((i = 1; i < ${#ffree[@]}; i++)); do
28108 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
28109 (( tmp < min )) && min=$tmp && min_index=$i
28116 [ $MDSCOUNT -lt 2 ] &&
28117 skip "We need at least 2 MDTs for this test"
28119 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
28120 skip "Need server version at least 2.12.52"
28122 local stripe_max=$((MDSCOUNT - 1))
28125 # let caller set maxage for latest result
28128 # fill MDT unevenly
28129 generate_uneven_mdts 120
28131 # test 4-stripe directory at most, otherwise it's too slow
28132 # We are being very defensive. Although Autotest uses 4 MDTs.
28133 # We make sure stripe_max does not go over 4.
28134 (( stripe_max > 4 )) && stripe_max=4
28135 # unlinking striped directory is slow on zfs, and may timeout, only test
28137 [ "$mds1_FSTYPE" == "zfs" ] && stripe_max=1
28138 for stripe_count in $(seq 1 $stripe_max); do
28139 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
28140 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
28141 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
28142 error "mkdir failed"
28143 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
28146 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
28149 [ $MDSCOUNT -lt 2 ] &&
28150 skip "We need at least 2 MDTs for this test"
28152 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
28153 skip "Need server version at least 2.12.52"
28155 local stripe_max=$((MDSCOUNT - 1))
28159 # let caller set maxage for latest result
28162 # fill MDT unevenly
28163 generate_uneven_mdts 120
28165 # test 4-stripe directory at most, otherwise it's too slow
28166 # We are being very defensive. Although Autotest uses 4 MDTs.
28167 # We make sure stripe_max does not go over 4.
28168 (( stripe_max > 4 )) && stripe_max=4
28169 [ "$mds1_FSTYPE" == "zfs" ] && stripe_max=1
28170 for stripe_count in $(seq 1 $stripe_max); do
28171 testdir=$DIR/$tdir-s$stripe_count
28172 mkdir $testdir || error "mkdir $testdir failed"
28173 mkdir $testdir/rr || error "mkdir rr failed"
28174 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
28175 error "mkdir qos failed"
28176 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
28177 $testdir/rr || error "setdirstripe rr failed"
28178 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
28179 error "setdirstripe failed"
28180 test_qos_mkdir "mkdir" $stripe_count
28183 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
28186 (( $MDSCOUNT >= 2 )) ||
28187 skip "We need at least 2 MDTs for this test"
28189 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
28190 skip "Need server version at least 2.14.51"
28195 local lmv_qos_maxage
28196 local lod_qos_maxage
28198 # let caller set maxage for latest result
28199 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
28200 $LCTL set_param lmv.*.qos_maxage=1
28201 stack_trap "$LCTL set_param \
28202 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
28203 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
28204 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
28205 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
28206 lod.*.mdt_qos_maxage=1
28207 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
28208 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
28210 # fill MDT unevenly
28211 generate_uneven_mdts 120
28213 testdir=$DIR/${tdir}-s1
28214 mkdir $testdir || error "mkdir $testdir failed"
28215 mkdir $testdir/rr || error "mkdir rr failed"
28216 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
28217 # default max_inherit is -1, default max_inherit_rr is 0
28218 $LFS setdirstripe -D -c 1 $testdir/rr ||
28219 error "setdirstripe rr failed"
28220 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
28221 error "setdirstripe qos failed"
28222 test_qos_mkdir "mkdir" 1
28224 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
28225 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
28226 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
28227 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
28228 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
28230 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
28231 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
28232 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
28233 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
28234 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
28235 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
28236 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
28237 error "level2 shouldn't have default LMV" || true
28239 run_test 413c "mkdir with default LMV max inherit rr"
28242 (( MDSCOUNT >= 2 )) ||
28243 skip "We need at least 2 MDTs for this test"
28245 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
28246 skip "Need server version at least 2.14.51"
28248 local lmv_qos_threshold_rr
28250 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
28252 stack_trap "$LCTL set_param \
28253 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
28255 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
28256 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
28257 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
28258 error "$tdir shouldn't have default LMV"
28259 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
28260 error "mkdir sub failed"
28262 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
28264 (( count == 100 )) || error "$count subdirs on MDT0"
28266 run_test 413d "inherit ROOT default LMV"
28269 (( MDSCOUNT >= 2 )) ||
28270 skip "We need at least 2 MDTs for this test"
28271 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
28272 skip "Need server version at least 2.14.55"
28274 local testdir=$DIR/$tdir
28275 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
28277 local sub_max_inherit
28279 mkdir -p $testdir || error "failed to create $testdir"
28281 # set default max-inherit to -1 if stripe count is 0 or 1
28282 $LFS setdirstripe -D -c 1 $testdir ||
28283 error "failed to set default LMV"
28284 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
28285 (( max_inherit == -1 )) ||
28286 error "wrong max_inherit value $max_inherit"
28288 # set default max_inherit to a fixed value if stripe count is not 0 or 1
28289 $LFS setdirstripe -D -c -1 $testdir ||
28290 error "failed to set default LMV"
28291 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
28292 (( max_inherit > 0 )) ||
28293 error "wrong max_inherit value $max_inherit"
28295 # and the subdir will decrease the max_inherit by 1
28296 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
28297 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
28298 (( sub_max_inherit == max_inherit - 1)) ||
28299 error "wrong max-inherit of subdir $sub_max_inherit"
28301 # check specified --max-inherit and warning message
28302 stack_trap "rm -f $tmpfile"
28303 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
28304 error "failed to set default LMV"
28305 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
28306 (( max_inherit == -1 )) ||
28307 error "wrong max_inherit value $max_inherit"
28309 # check the warning messages
28310 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
28311 error "failed to detect warning string"
28314 run_test 413e "check default max-inherit value"
28316 test_fs_dmv_inherit()
28318 local testdir=$DIR/$tdir
28325 mkdir $testdir || error "mkdir $testdir failed"
28326 count=$($LFS getdirstripe -D -c $testdir)
28327 (( count == 1 )) ||
28328 error "$testdir default LMV count mismatch $count != 1"
28329 inherit=$($LFS getdirstripe -D -X $testdir)
28330 (( inherit == 3 - i )) ||
28331 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
28332 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
28333 (( inherit_rr == 3 - i )) ||
28334 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
28335 testdir=$testdir/sub
28338 mkdir $testdir || error "mkdir $testdir failed"
28339 count=$($LFS getdirstripe -D -c $testdir)
28340 (( count == 0 )) ||
28341 error "$testdir default LMV count not zero: $count"
28345 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
28347 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
28348 skip "Need server version at least 2.14.55"
28350 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
28351 error "dump $DIR default LMV failed"
28352 stack_trap "setfattr --restore=$TMP/dmv.ea"
28354 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
28355 error "set $DIR default LMV failed"
28357 test_fs_dmv_inherit
28359 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
28362 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
28364 mkdir -p $DIR/$tdir/l2/l3/l4 || error "mkdir $tdir/l1/l2/l3 failed"
28365 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
28366 error "dump $DIR default LMV failed"
28367 stack_trap "setfattr --restore=$TMP/dmv.ea"
28369 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
28370 error "set $DIR default LMV failed"
28372 FILESET="$FILESET/$tdir/l2/l3/l4" mount_client $MOUNT2 ||
28373 error "mount $MOUNT2 failed"
28374 stack_trap "umount_client $MOUNT2"
28376 local saved_DIR=$DIR
28380 stack_trap "export DIR=$saved_DIR"
28382 # first check filesystem-wide default LMV inheritance
28383 test_fs_dmv_inherit || error "incorrect fs default LMV inheritance"
28385 # then check subdirs are spread to all MDTs
28386 createmany -d $DIR/s $((MDSCOUNT * 100)) || error "createmany failed"
28388 local count=$($LFS getstripe -m $DIR/s* | sort -u | wc -l)
28390 (( $count == $MDSCOUNT )) || error "dirs are spread to $count MDTs"
28392 run_test 413g "enforce ROOT default LMV on subdir mount"
28395 (( MDSCOUNT >= 2 )) ||
28396 skip "We need at least 2 MDTs for this test"
28398 (( MDS1_VERSION >= $(version_code 2.15.50.6) )) ||
28399 skip "Need server version at least 2.15.50.6"
28401 local lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
28403 stack_trap "$LCTL set_param \
28404 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
28405 $LCTL set_param lmv.*.qos_maxage=1
28409 local dir=$DIR/$tdir/l1/l2/l3/l4/l5
28410 local count=$((MDSCOUNT * 20))
28412 generate_uneven_mdts 50
28414 mkdir -p $dir || error "mkdir $dir failed"
28415 stack_trap "rm -rf $dir"
28416 $LFS setdirstripe -D -c 1 -i -1 --max-inherit=$depth \
28417 --max-inherit-rr=$rr_depth $dir
28419 for ((d=0; d < depth + 2; d++)); do
28421 for ((sub=0; sub < count; sub++)); do
28424 $LFS getdirstripe -i $dir/d* | sort | uniq -c | sort -nr
28425 local num=($($LFS getdirstripe -i $dir/d* | sort | uniq -c))
28426 # subdirs within $rr_depth should be created round-robin
28427 if (( d < rr_depth )); then
28428 (( ${num[0]} != count )) ||
28429 error "all objects created on MDT ${num[1]}"
28435 run_test 413h "don't stick to parent for round-robin dirs"
28438 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
28440 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
28441 skip "Need server version at least 2.14.55"
28443 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
28444 error "dump $DIR default LMV failed"
28445 stack_trap "setfattr --restore=$TMP/dmv.ea"
28447 local testdir=$DIR/$tdir
28452 $LFS setdirstripe -D -i-1 -c1 --max-inherit=$def_max \
28453 --max-inherit-rr=$def_max_rr $DIR ||
28454 error "set $DIR default LMV failed"
28456 for i in $(seq 2 3); do
28457 def_max=$((def_max - 1))
28458 (( def_max_rr == 0 )) || def_max_rr=$((def_max_rr - 1))
28461 # RR is decremented and keeps zeroed once exhausted
28462 count=$($LFS getdirstripe -D --max-inherit-rr $testdir)
28463 (( count == def_max_rr )) ||
28464 error_noexit "$testdir: max-inherit-rr $count != $def_max_rr"
28466 # max-inherit is decremented
28467 count=$($LFS getdirstripe -D --max-inherit $testdir)
28468 (( count == def_max )) ||
28469 error_noexit "$testdir: max-inherit $count != $def_max"
28471 testdir=$testdir/d$i
28474 # d3 is the last inherited from ROOT, no inheritance anymore
28475 # i.e. no the default layout anymore
28476 mkdir -p $testdir/d4/d5
28477 count=$($LFS getdirstripe -D --max-inherit $testdir)
28478 (( count == -1 )) ||
28479 error_noexit "$testdir: max-inherit $count != -1"
28481 local p_count=$($LFS getdirstripe -i $testdir)
28483 for i in $(seq 4 5); do
28484 testdir=$testdir/d$i
28486 # the root default layout is not applied once exhausted
28487 count=$($LFS getdirstripe -i $testdir)
28488 (( count == p_count )) ||
28489 error_noexit "$testdir: stripe-offset $count != parent offset $p_count"
28492 $LFS setdirstripe -i 0 $DIR/d2
28493 count=$($LFS getdirstripe -D --max-inherit $DIR/d2)
28494 (( count == -1 )) ||
28495 error_noexit "$DIR/d2: max-inherit non-striped default $count != -1"
28497 run_test 413i "check default layout inheritance"
28504 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
28505 unlinkmany $subdir/f. $TEST413_COUNT &
28509 for pid in $pids; do
28515 run_test 413z "413 test cleanup"
28518 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
28519 $LCTL set_param fail_loc=0x80000521
28520 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
28523 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
28526 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
28527 (( $MDS1_VERSION >= $(version_code 2.11.52) )) ||
28528 skip "Need server version at least 2.11.52"
28534 # this test may be slow on ZFS
28535 [[ "$mds1_FSTYPE" == "zfs" ]] && total=50
28537 # though this test is designed for striped directory, let's test normal
28538 # directory too since lock is always saved as CoS lock.
28539 test_mkdir $DIR/$tdir || error "mkdir $tdir"
28540 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
28541 stack_trap "unlinkmany $DIR/$tdir/$tfile. $total || true"
28542 # if looping with ONLY_REPEAT, wait for previous deletions to finish
28543 wait_delete_completed_mds
28545 # run a loop without concurrent touch to measure rename duration.
28546 # only for test debug/robustness, NOT part of COS functional test.
28547 local start_time=$SECONDS
28548 for ((i = 0; i < total; i++)); do
28549 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
28552 local baseline=$((SECONDS - start_time))
28553 echo "rename $total files without 'touch' took $baseline sec"
28560 local setattr_pid=$!
28562 # rename files back to original name so unlinkmany works
28563 start_time=$SECONDS
28564 for ((i = 0; i < total; i++)); do
28565 mrename $DIR/$tdir/$tfile-new.$i $DIR/$tdir/$tfile.$i\
28568 local duration=$((SECONDS - start_time))
28570 kill -9 $setattr_pid
28572 echo "rename $total files with 'touch' took $duration sec"
28573 (( max > 2 * baseline )) || max=$((2 * baseline + 5))
28574 (( duration <= max )) ||
28575 error_not_in_vm "rename took $duration > $max sec"
28577 run_test 415 "lock revoke is not missing"
28580 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
28581 skip "Need server version at least 2.11.55"
28583 # define OBD_FAIL_OSD_TXN_START 0x19a
28584 do_facet mds1 lctl set_param fail_loc=0x19a
28586 lfs mkdir -c $MDSCOUNT $DIR/$tdir
28590 run_test 416 "transaction start failure won't cause system hung"
28594 do_nodes $(comma_list $(mdts_nodes)) \
28595 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
28596 do_nodes $(comma_list $(mdts_nodes)) \
28597 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
28598 do_nodes $(comma_list $(mdts_nodes)) \
28599 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
28603 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
28604 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
28605 skip "Need MDS version at least 2.11.56"
28607 trap cleanup_417 RETURN EXIT
28609 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
28610 do_nodes $(comma_list $(mdts_nodes)) \
28611 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
28612 $LFS migrate -m 0 $DIR/$tdir.1 &&
28613 error "migrate dir $tdir.1 should fail"
28615 do_nodes $(comma_list $(mdts_nodes)) \
28616 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
28617 $LFS mkdir -i 1 $DIR/$tdir.2 &&
28618 error "create remote dir $tdir.2 should fail"
28620 do_nodes $(comma_list $(mdts_nodes)) \
28621 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
28622 $LFS mkdir -c 2 $DIR/$tdir.3 &&
28623 error "create striped dir $tdir.3 should fail"
28626 run_test 417 "disable remote dir, striped dir and dir migration"
28628 # Checks that the outputs of df [-i] and lfs df [-i] match
28630 # usage: check_lfs_df <blocks | inodes> <mountpoint>
28640 [ "$1" == "blocks" ] && inodes= || inodes="-i"
28642 for count in {1..100}; do
28643 do_nodes "$CLIENTS" \
28644 $LCTL set_param ldlm.namespaces.*.lru_size=clear
28647 # read the lines of interest
28648 df_out=($(df -P $inodes $dir | tail -n +2)) ||
28649 error "df $inodes $dir | tail -n +2 failed"
28650 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
28651 error "lfs df $inodes $dir | grep summary: failed"
28653 # skip first substrings of each output as they are different
28654 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
28655 # compare the two outputs
28657 # skip "available" on MDT until LU-13997 is fixed.
28658 #for i in {1..5}; do
28659 for i in 1 2 4 5; do
28660 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
28668 lfs df $inodes $dir
28669 error "df and lfs df $1 output mismatch: " \
28670 "df ${inodes}: ${df_out[*]}, " \
28671 "lfs df ${inodes}: ${lfs_df_out[*]}"
28676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28678 local dir=$DIR/$tdir
28679 local numfiles=$((RANDOM % 4096 + 2))
28680 local numblocks=$((RANDOM % 256 + 1))
28682 wait_delete_completed
28685 # check block output
28686 check_lfs_df blocks $dir
28687 # check inode output
28688 check_lfs_df inodes $dir
28690 # create a single file and retest
28691 echo "Creating a single file and testing"
28692 createmany -o $dir/$tfile- 1 &>/dev/null ||
28693 error "creating 1 file in $dir failed"
28694 check_lfs_df blocks $dir
28695 check_lfs_df inodes $dir
28697 # create a random number of files
28698 echo "Creating $((numfiles - 1)) files and testing"
28699 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
28700 error "creating $((numfiles - 1)) files in $dir failed"
28702 # write a random number of blocks to the first test file
28703 echo "Writing $numblocks 4K blocks and testing"
28704 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
28705 count=$numblocks &>/dev/null ||
28706 error "dd to $dir/${tfile}-0 failed"
28709 check_lfs_df blocks $dir
28710 check_lfs_df inodes $dir
28712 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
28713 error "unlinking $numfiles files in $dir failed"
28715 run_test 418 "df and lfs df outputs match"
28719 local dir=$DIR/$tdir
28724 cancel_lru_locks mdc
28726 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
28727 $LCTL set_param fail_loc=0x1410
28729 $LCTL set_param fail_loc=0
28732 run_test 419 "Verify open file by name doesn't crash kernel"
28736 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
28737 skip "Need MDS version at least 2.12.53"
28739 local SAVE_UMASK=$(umask)
28740 local dir=$DIR/$tdir
28741 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
28745 mkdir -m03777 $dir/testdir
28746 ls -dn $dir/testdir
28747 # Need to remove trailing '.' when SELinux is enabled
28748 local dirperms=$(ls -dn $dir/testdir |
28749 awk '{ sub(/\.$/, "", $1); print $1}')
28750 [ $dirperms == "drwxrwsrwt" ] ||
28751 error "incorrect perms on $dir/testdir"
28753 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
28754 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
28755 ls -n $dir/testdir/testfile
28756 local fileperms=$(ls -n $dir/testdir/testfile |
28757 awk '{ sub(/\.$/, "", $1); print $1}')
28758 [ $fileperms == "-rwxr-xr-x" ] ||
28759 error "incorrect perms on $dir/testdir/testfile"
28763 run_test 420 "clear SGID bit on non-directories for non-members"
28770 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28771 skip "Need MDS version at least 2.12.54"
28773 test_mkdir $DIR/$tdir
28774 createmany -o $DIR/$tdir/f 3
28775 cnt=$(ls -1 $DIR/$tdir | wc -l)
28776 [ $cnt != 3 ] && error "unexpected #files: $cnt"
28778 fid1=$(lfs path2fid $DIR/$tdir/f1)
28779 fid2=$(lfs path2fid $DIR/$tdir/f2)
28780 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
28782 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
28783 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
28785 cnt=$(ls -1 $DIR/$tdir | wc -l)
28786 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
28788 rm -f $DIR/$tdir/f3 || error "can't remove f3"
28789 createmany -o $DIR/$tdir/f 3
28790 cnt=$(ls -1 $DIR/$tdir | wc -l)
28791 [ $cnt != 3 ] && error "unexpected #files: $cnt"
28793 fid1=$(lfs path2fid $DIR/$tdir/f1)
28794 fid2=$(lfs path2fid $DIR/$tdir/f2)
28795 echo "remove using fsname $FSNAME"
28796 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
28798 cnt=$(ls -1 $DIR/$tdir | wc -l)
28799 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
28801 run_test 421a "simple rm by fid"
28808 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28809 skip "Need MDS version at least 2.12.54"
28811 test_mkdir $DIR/$tdir
28812 createmany -o $DIR/$tdir/f 3
28813 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
28816 FID1=$(lfs path2fid $DIR/$tdir/f1)
28817 FID2=$(lfs path2fid $DIR/$tdir/f2)
28818 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
28820 kill -USR1 $MULTIPID
28823 cnt=$(ls $DIR/$tdir | wc -l)
28824 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
28826 run_test 421b "rm by fid on open file"
28832 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28833 skip "Need MDS version at least 2.12.54"
28835 test_mkdir $DIR/$tdir
28836 createmany -o $DIR/$tdir/f 3
28837 touch $DIR/$tdir/$tfile
28838 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
28839 cnt=$(ls -1 $DIR/$tdir | wc -l)
28840 [ $cnt != 184 ] && error "unexpected #files: $cnt"
28842 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
28843 $LFS rmfid $DIR $FID1 || error "rmfid failed"
28845 cnt=$(ls $DIR/$tdir | wc -l)
28846 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
28848 run_test 421c "rm by fid against hardlinked files"
28854 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28855 skip "Need MDS version at least 2.12.54"
28857 test_mkdir $DIR/$tdir
28858 createmany -o $DIR/$tdir/f 4097
28859 cnt=$(ls -1 $DIR/$tdir | wc -l)
28860 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
28862 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
28863 $LFS rmfid $DIR $FIDS || error "rmfid failed"
28865 cnt=$(ls $DIR/$tdir | wc -l)
28867 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
28869 run_test 421d "rmfid en masse"
28875 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
28876 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28877 skip "Need MDS version at least 2.12.54"
28879 mkdir -p $DIR/$tdir
28880 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
28881 createmany -o $DIR/$tdir/striped_dir/f 512
28882 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
28883 [ $cnt != 512 ] && error "unexpected #files: $cnt"
28885 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
28886 sed "s/[/][^:]*://g")
28887 $LFS rmfid $DIR $FIDS || error "rmfid failed"
28889 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
28891 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
28893 run_test 421e "rmfid in DNE"
28899 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28900 skip "Need MDS version at least 2.12.54"
28902 test_mkdir $DIR/$tdir
28904 cnt=$(ls -1 $DIR/$tdir | wc -l)
28905 [ $cnt != 1 ] && error "unexpected #files: $cnt"
28907 FID=$(lfs path2fid $DIR/$tdir/f)
28908 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
28909 # rmfid should fail
28910 cnt=$(ls -1 $DIR/$tdir | wc -l)
28911 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
28913 chmod a+rw $DIR/$tdir
28915 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
28916 # rmfid should fail
28917 cnt=$(ls -1 $DIR/$tdir | wc -l)
28918 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
28921 $RUNAS touch $DIR/$tdir/f
28922 FID=$(lfs path2fid $DIR/$tdir/f)
28923 echo "rmfid as root"
28924 $LFS rmfid $DIR $FID || error "rmfid as root failed"
28925 cnt=$(ls -1 $DIR/$tdir | wc -l)
28926 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
28929 $RUNAS touch $DIR/$tdir/f
28930 cnt=$(ls -1 $DIR/$tdir | wc -l)
28931 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
28932 FID=$(lfs path2fid $DIR/$tdir/f)
28933 # rmfid w/o user_fid2path mount option should fail
28934 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
28935 cnt=$(ls -1 $DIR/$tdir | wc -l)
28936 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
28938 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
28939 stack_trap "rmdir $tmpdir"
28940 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
28941 error "failed to mount client'"
28942 stack_trap "umount_client $tmpdir"
28944 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
28945 # rmfid should succeed
28946 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
28947 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
28949 # rmfid shouldn't allow to remove files due to dir's permission
28950 chmod a+rwx $tmpdir/$tdir
28951 touch $tmpdir/$tdir/f
28952 ls -la $tmpdir/$tdir
28953 FID=$(lfs path2fid $tmpdir/$tdir/f)
28954 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
28957 run_test 421f "rmfid checks permissions"
28963 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
28964 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
28965 skip "Need MDS version at least 2.12.54"
28967 mkdir -p $DIR/$tdir
28968 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
28969 createmany -o $DIR/$tdir/striped_dir/f 512
28970 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
28971 [ $cnt != 512 ] && error "unexpected #files: $cnt"
28973 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
28974 sed "s/[/][^:]*://g")
28976 rm -f $DIR/$tdir/striped_dir/f1*
28977 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
28978 removed=$((512 - cnt))
28980 # few files have been just removed, so we expect
28981 # rmfid to fail on their fids
28982 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
28983 [ $removed != $errors ] && error "$errors != $removed"
28985 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
28987 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
28989 run_test 421g "rmfid to return errors properly"
29001 (( MDS1_VERSION >= $(version_code 2.15.53) )) ||
29002 skip "Need MDS version at least 2.15.53"
29004 test_mkdir $DIR/$tdir
29005 test_mkdir $DIR/$tdir/subdir
29006 touch $DIR/$tdir/subdir/file0
29007 old_fid=$(lfs path2fid $DIR/$tdir/subdir/file0 | sed "s/[/][^:]*://g")
29008 echo File $DIR/$tdir/subdir/file0 FID $old_fid
29009 rm -f $DIR/$tdir/subdir/file0
29010 touch $DIR/$tdir/subdir/fileA
29011 fidA=$(lfs path2fid $DIR/$tdir/subdir/fileA | sed "s/[/][^:]*://g")
29012 echo File $DIR/$tdir/subdir/fileA FID $fidA
29013 touch $DIR/$tdir/subdir/fileB
29014 fidB=$(lfs path2fid $DIR/$tdir/subdir/fileB | sed "s/[/][^:]*://g")
29015 echo File $DIR/$tdir/subdir/fileB FID $fidB
29016 ln $DIR/$tdir/subdir/fileB $DIR/$tdir/subdir/fileB_hl
29017 touch $DIR/$tdir/subdir/fileC
29018 fidC=$(lfs path2fid $DIR/$tdir/subdir/fileC | sed "s/[/][^:]*://g")
29019 echo File $DIR/$tdir/subdir/fileC FID $fidC
29020 ln $DIR/$tdir/subdir/fileC $DIR/$tdir/fileC
29021 touch $DIR/$tdir/fileD
29022 fidD=$(lfs path2fid $DIR/$tdir/fileD | sed "s/[/][^:]*://g")
29023 echo File $DIR/$tdir/fileD FID $fidD
29025 # mount another client mount point with subdirectory mount
29026 export FILESET=/$tdir/subdir
29027 mount_other=${MOUNT}_other
29028 mount_client $mount_other ${MOUNT_OPTS}
29031 (( mount_ret == 0 )) || error "mount $mount_other failed"
29033 echo Removing FIDs:
29034 echo $LFS rmfid $mount_other $old_fid $fidA $fidD $fidB $fidC
29035 $LFS rmfid $mount_other $old_fid $fidA $fidD $fidB $fidC
29038 umount_client $mount_other || error "umount $mount_other failed"
29040 (( rmfid_ret != 0 )) || error "rmfid should have failed"
29042 # fileA should have been deleted
29043 stat $DIR/$tdir/subdir/fileA && error "fileA not deleted"
29045 # fileB should have been deleted
29046 stat $DIR/$tdir/subdir/fileB && error "fileB not deleted"
29048 # fileC should not have been deleted, fid also exists outside of fileset
29049 stat $DIR/$tdir/subdir/fileC || error "fileC deleted"
29051 # fileD should not have been deleted, it exists outside of fileset
29052 stat $DIR/$tdir/fileD || error "fileD deleted"
29054 run_test 421h "rmfid with fileset mount"
29057 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
29058 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
29059 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
29060 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
29061 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
29063 local amc=$(at_max_get client)
29064 local amo=$(at_max_get mds1)
29065 local timeout=`lctl get_param -n timeout`
29067 at_max_set 0 client
29070 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
29071 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
29072 fail_val=$(((2*timeout + 10)*1000))
29073 touch $DIR/$tdir/d3/file &
29075 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
29076 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
29077 fail_val=$((2*timeout + 5))
29078 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
29082 sleep $((2 * timeout))
29086 touch $DIR/$tdir/d2/file3
29087 touch $DIR/$tdir/d2/file4
29088 touch $DIR/$tdir/d2/file5
29091 at_max_set $amc client
29092 at_max_set $amo mds1
29094 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
29095 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
29096 error "Watchdog is always throttled"
29098 run_test 422 "kill a process with RPC in progress"
29111 # ensure statfs cache is expired
29114 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
29115 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
29119 run_test 423 "statfs should return a right data"
29122 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | CFS_FAIL_ONCE
29123 $LCTL set_param fail_loc=0x80000522
29124 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
29127 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
29130 test_mkdir -c -1 $DIR/$tdir
29131 $LFS setstripe -c -1 $DIR/$tdir
29133 lru_resize_disable "" 100
29134 stack_trap "lru_resize_enable" EXIT
29138 for i in $(seq $((MDSCOUNT * 125))); do
29139 local t=$DIR/$tdir/$tfile_$i
29141 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
29142 error_noexit "Create file $t"
29144 stack_trap "rm -rf $DIR/$tdir" EXIT
29146 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
29147 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
29148 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
29150 [ $lock_count -le $lru_size ] ||
29151 error "osc lock count $lock_count > lru size $lru_size"
29154 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
29155 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
29156 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
29158 [ $lock_count -le $lru_size ] ||
29159 error "mdc lock count $lock_count > lru size $lru_size"
29162 run_test 425 "lock count should not exceed lru size"
29165 splice-test -r $DIR/$tfile
29166 splice-test -rd $DIR/$tfile
29167 splice-test $DIR/$tfile
29168 splice-test -d $DIR/$tfile
29170 run_test 426 "splice test on Lustre"
29173 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
29174 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
29175 skip "Need MDS version at least 2.12.4"
29181 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
29182 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
29184 $LFS getdirstripe $DIR/$tdir/1/dir
29186 #first setfattr for creating updatelog
29187 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
29189 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
29190 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
29191 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
29192 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
29196 wait_recovery_complete mds2 $((2*TIMEOUT))
29198 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
29199 echo $log | grep "get update log failed" &&
29200 error "update log corruption is detected" || true
29202 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
29205 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29206 local max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
29207 awk '/^max_cached_mb/ { print $2 }')
29208 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$max_cached_mb"
29210 $LCTL set_param -n llite.*.max_cached_mb=64
29213 $LFS setstripe -c 1 $DIR/$tdir
29214 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
29215 stack_trap "rm -f $DIR/$tdir/$tfile.*"
29217 for f in $(seq 4); do
29218 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
29222 cancel_lru_locks osc
29224 for f in $(seq 4); do
29225 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
29229 run_test 428 "large block size IO should not hang"
29231 test_429() { # LU-7915 / LU-10948
29232 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
29233 local testfile=$DIR/$tfile
29234 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
29240 $LCTL get_param $ll_opencache_threshold_count ||
29241 skip "client does not have opencache parameter"
29243 set_opencache $new_flag
29244 stack_trap "restore_opencache"
29245 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
29246 error "enable opencache failed"
29248 # drop MDC DLM locks
29249 cancel_lru_locks mdc
29250 # clear MDC RPC stats counters
29251 $LCTL set_param $mdc_rpcstats=clear
29253 # According to the current implementation, we need to run 3 times
29254 # open & close file to verify if opencache is enabled correctly.
29255 # 1st, RPCs are sent for lookup/open and open handle is released on
29257 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
29258 # so open handle won't be released thereafter.
29259 # 3rd, No RPC is sent out.
29260 $MULTIOP $testfile oc || error "multiop failed"
29261 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
29262 echo "1st: $first_rpc RPCs in flight"
29264 $MULTIOP $testfile oc || error "multiop failed"
29265 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
29266 echo "2nd: $second_rpc RPCs in flight"
29268 $MULTIOP $testfile oc || error "multiop failed"
29269 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
29270 echo "3rd: $third_rpc RPCs in flight"
29272 #verify no MDC RPC is sent
29273 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
29275 run_test 429 "verify if opencache flag on client side does work"
29281 # data at [200K, 400K)
29282 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
29283 error "256K->512K dd fails"
29285 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
29286 error "2M->3M dd fails"
29288 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
29289 error "4M->5M dd fails"
29290 echo "Data at 256K...512K, 2M...3M and 4M...5M"
29291 # start at first component hole #1
29292 printf "Seeking hole from 1000 ... "
29293 offset=$(lseek_test -l 1000 $file)
29295 [[ $offset == 1000 ]] || error "offset $offset != 1000"
29296 printf "Seeking data from 1000 ... "
29297 offset=$(lseek_test -d 1000 $file)
29299 [[ $offset == 262144 ]] || error "offset $offset != 262144"
29301 # start at first component data block
29302 printf "Seeking hole from 300000 ... "
29303 offset=$(lseek_test -l 300000 $file)
29305 [[ $offset == 524288 ]] || error "offset $offset != 524288"
29306 printf "Seeking data from 300000 ... "
29307 offset=$(lseek_test -d 300000 $file)
29309 [[ $offset == 300000 ]] || error "offset $offset != 300000"
29311 # start at the first component but beyond end of object size
29312 printf "Seeking hole from 1000000 ... "
29313 offset=$(lseek_test -l 1000000 $file)
29315 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
29316 printf "Seeking data from 1000000 ... "
29317 offset=$(lseek_test -d 1000000 $file)
29319 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
29321 # start at second component stripe 2 (empty file)
29322 printf "Seeking hole from 1500000 ... "
29323 offset=$(lseek_test -l 1500000 $file)
29325 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
29326 printf "Seeking data from 1500000 ... "
29327 offset=$(lseek_test -d 1500000 $file)
29329 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
29331 # start at second component stripe 1 (all data)
29332 printf "Seeking hole from 3000000 ... "
29333 offset=$(lseek_test -l 3000000 $file)
29335 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
29336 printf "Seeking data from 3000000 ... "
29337 offset=$(lseek_test -d 3000000 $file)
29339 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
29341 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
29342 error "2nd dd fails"
29343 echo "Add data block at 640K...1280K"
29345 # start at before new data block, in hole
29346 printf "Seeking hole from 600000 ... "
29347 offset=$(lseek_test -l 600000 $file)
29349 [[ $offset == 600000 ]] || error "offset $offset != 600000"
29350 printf "Seeking data from 600000 ... "
29351 offset=$(lseek_test -d 600000 $file)
29353 [[ $offset == 655360 ]] || error "offset $offset != 655360"
29355 # start at the first component new data block
29356 printf "Seeking hole from 1000000 ... "
29357 offset=$(lseek_test -l 1000000 $file)
29359 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
29360 printf "Seeking data from 1000000 ... "
29361 offset=$(lseek_test -d 1000000 $file)
29363 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
29365 # start at second component stripe 2, new data
29366 printf "Seeking hole from 1200000 ... "
29367 offset=$(lseek_test -l 1200000 $file)
29369 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
29370 printf "Seeking data from 1200000 ... "
29371 offset=$(lseek_test -d 1200000 $file)
29373 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
29375 # start beyond file end
29376 printf "Using offset > filesize ... "
29377 lseek_test -l 4000000 $file && error "lseek should fail"
29378 printf "Using offset > filesize ... "
29379 lseek_test -d 4000000 $file && error "lseek should fail"
29385 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
29386 skip "MDT does not support SEEK_HOLE"
29388 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
29389 skip "OST does not support SEEK_HOLE"
29391 local file=$DIR/$tdir/$tfile
29393 mkdir -p $DIR/$tdir
29395 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
29396 # OST stripe #1 will have continuous data at [1M, 3M)
29397 # OST stripe #2 is empty
29398 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
29399 lseek_test_430 $file
29401 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
29402 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
29403 lseek_test_430 $file
29405 $LFS setstripe -c2 -S 512K $file
29406 echo "Two stripes, stripe size 512K"
29407 lseek_test_430 $file
29409 # FLR with stale mirror
29410 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
29412 echo "Mirrored file:"
29413 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
29414 echo "Plain 2 stripes 1M"
29415 lseek_test_430 $file
29418 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
29421 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
29422 skip "OST does not support SEEK_HOLE"
29425 local file=$DIR/$tdir/$tfile
29427 mkdir -p $DIR/$tdir
29428 # Empty layout lseek should fail
29431 printf "Seeking hole from 0 ... "
29432 lseek_test -l 0 $file && error "lseek should fail"
29433 printf "Seeking data from 0 ... "
29434 lseek_test -d 0 $file && error "lseek should fail"
29438 $LFS setstripe -E 1M -c2 -E eof $file
29439 $TRUNCATE $file 1048576
29440 printf "Seeking hole from 1000000 ... "
29441 offset=$(lseek_test -l 1000000 $file)
29443 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
29444 printf "Seeking data from 1000000 ... "
29445 lseek_test -d 1000000 $file && error "lseek should fail"
29448 # full component followed by non-inited one
29449 $LFS setstripe -E 1M -c2 -E eof $file
29450 dd if=/dev/urandom of=$file bs=1M count=1
29451 printf "Seeking hole from 1000000 ... "
29452 offset=$(lseek_test -l 1000000 $file)
29454 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
29455 printf "Seeking hole from 1048576 ... "
29456 lseek_test -l 1048576 $file && error "lseek should fail"
29457 # init second component and truncate back
29458 echo "123" >> $file
29459 $TRUNCATE $file 1048576
29460 printf "Seeking hole from 1000000 ... "
29461 offset=$(lseek_test -l 1000000 $file)
29463 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
29464 printf "Seeking hole from 1048576 ... "
29465 lseek_test -l 1048576 $file && error "lseek should fail"
29466 # boundary checks for big values
29467 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
29468 offset=$(lseek_test -d 0 $file.10g)
29469 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
29470 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
29471 offset=$(lseek_test -d 0 $file.100g)
29472 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
29475 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
29478 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
29479 skip "OST does not support SEEK_HOLE"
29481 local file=$DIR/$tdir/$tfile
29484 mkdir -p $DIR/$tdir
29485 stack_trap "rm -f $file $file.tmp"
29486 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M || error "dd failed"
29488 # cp version 8.33+ prefers lseek over fiemap
29489 local ver=$(cp --version | awk '{ print $4; exit; }')
29491 echo "cp $ver installed"
29492 if (( $(version_code $ver) >= $(version_code 8.33) )); then
29494 time cp -v $file $file.tmp || error "cp $file failed"
29495 (( SECONDS - start < 5 )) || {
29496 strace cp $file $file.tmp |&
29497 grep -E "open|read|seek|FIEMAP" |
29499 error "cp: too long runtime $((SECONDS - start))"
29502 echo "cp test skipped due to $ver < 8.33"
29505 # tar version 1.29+ supports SEEK_HOLE/DATA
29506 ver=$(tar --version | awk '{ print $4; exit; }')
29507 echo "tar $ver installed"
29508 if (( $(version_code $ver) >= $(version_code 1.29) )); then
29510 time tar cvf $file.tmp --sparse $file || error "tar $file error"
29511 (( SECONDS - start < 5 )) || {
29512 strace tar cf $file.tmp --sparse $file |&
29513 grep -E "open|read|seek|FIEMAP" |
29515 error "tar: too long runtime $((SECONDS - start))"
29518 echo "tar test skipped due to $ver < 1.29"
29521 run_test 430c "lseek: external tools check"
29523 test_431() { # LU-14187
29524 local file=$DIR/$tdir/$tfile
29526 mkdir -p $DIR/$tdir
29527 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
29528 dd if=/dev/urandom of=$file bs=4k count=1
29529 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
29530 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
29531 #define OBD_FAIL_OST_RESTART_IO 0x251
29532 do_facet ost1 "$LCTL set_param fail_loc=0x251"
29533 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
29537 echo 3 > /proc/sys/vm/drop_caches
29538 diff $file $file.0 || error "data diff"
29540 run_test 431 "Restart transaction for IO"
29542 cleanup_test_432() {
29543 do_facet mgs $LCTL nodemap_activate 0
29544 wait_nm_sync active
29548 local tmpdir=$TMP/dir432
29550 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
29551 skip "Need MDS version at least 2.14.52"
29553 stack_trap cleanup_test_432 EXIT
29557 do_facet mgs $LCTL nodemap_activate 1
29558 wait_nm_sync active
29559 do_facet mgs $LCTL nodemap_modify --name default \
29560 --property admin --value 1
29561 do_facet mgs $LCTL nodemap_modify --name default \
29562 --property trusted --value 1
29563 cancel_lru_locks mdc
29564 wait_nm_sync default admin_nodemap
29565 wait_nm_sync default trusted_nodemap
29567 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
29568 grep -ci "Operation not permitted") -ne 0 ]; then
29569 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
29572 run_test 432 "mv dir from outside Lustre"
29575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29577 [[ -n "$($LCTL list_param llite.*.inode_cache 2>/dev/null)" ]] ||
29578 skip "inode cache not supported"
29580 $LCTL set_param llite.*.inode_cache=0
29581 stack_trap "$LCTL set_param llite.*.inode_cache=1"
29587 cancel_lru_locks mdc
29588 test_mkdir $DIR/$tdir || error "mkdir $tdir"
29589 createmany -m $DIR/$tdir/f $count
29590 createmany -d $DIR/$tdir/d $count
29591 ls -l $DIR/$tdir > /dev/null
29592 stack_trap "rm -rf $DIR/$tdir"
29594 before=$(num_objects)
29595 cancel_lru_locks mdc
29596 after=$(num_objects)
29598 # sometimes even @before is less than 2 * count
29599 while (( before - after < count )); do
29601 after=$(num_objects)
29603 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
29604 if (( wait > 60 )); then
29605 error "inode slab grew from $before to $after"
29609 echo "lustre_inode_cache $before objs before lock cancel, $after after"
29611 run_test 433 "ldlm lock cancel releases dentries and inodes"
29615 local getxattr_count
29616 local mdc_stat_param="mdc.$FSNAME-MDT0000*.md_stats"
29617 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
29619 [[ $(getenforce) == "Disabled" ]] ||
29620 skip "lsm selinux module have to be disabled for this test"
29622 test_mkdir -i 0 -c1 $DIR/$tdir/ ||
29623 error "fail to create $DIR/$tdir/ on MDT0000"
29625 touch $DIR/$tdir/$tfile-{001..100}
29627 # disable the xattr cache
29628 save_lustre_params client "llite.*.xattr_cache" > $p
29629 lctl set_param llite.*.xattr_cache=0
29630 stack_trap "restore_lustre_params < $p; rm -f $p" EXIT
29632 # clear clients mdc stats
29633 clear_stats $mdc_stat_param ||
29634 error "fail to clear stats on mdc MDT0000"
29636 for file in $DIR/$tdir/$tfile-{001..100}; do
29637 getfattr -n security.selinux $file |&
29638 grep -q "Operation not supported" ||
29639 error "getxattr on security.selinux should return EOPNOTSUPP"
29642 getxattr_count=$(calc_stats $mdc_stat_param "getxattr")
29643 (( getxattr_count < 100 )) ||
29644 error "client sent $getxattr_count getxattr RPCs to the MDS"
29646 run_test 434 "Client should not send RPCs for security.selinux with SElinux disabled"
29649 if [[ -f $LUSTRE/scripts/bash-completion/lustre ]]; then
29650 source $LUSTRE/scripts/bash-completion/lustre
29651 elif [[ -f /usr/share/bash-completion/completions/lustre ]]; then
29652 source /usr/share/bash-completion/completions/lustre
29654 skip "bash completion scripts not found"
29657 local lctl_completions
29658 local lfs_completions
29660 lctl_completions=$(_lustre_cmds lctl)
29661 if [[ ! $lctl_completions =~ "get_param" ]]; then
29662 error "lctl bash completion failed"
29665 lfs_completions=$(_lustre_cmds lfs)
29666 if [[ ! $lfs_completions =~ "setstripe" ]]; then
29667 error "lfs bash completion failed"
29670 run_test 440 "bash completion for lfs, lctl"
29673 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
29674 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
29675 skip "Need server version at least 2.9.55"
29677 start_full_debug_logging
29681 stop_full_debug_logging
29685 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
29686 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
29687 awk '/The barrier for/ { print $7 }')
29690 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
29695 barrier_expired() {
29698 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
29699 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
29700 awk '/will be expired/ { print $7 }')
29702 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
29711 echo "Start barrier_freeze at: $(date)"
29712 #define OBD_FAIL_BARRIER_DELAY 0x2202
29713 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
29714 # Do not reduce barrier time - See LU-11873
29715 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
29718 local b_status=$(barrier_stat)
29719 echo "Got barrier status at: $(date)"
29720 [ "$b_status" = "'freezing_p1'" ] ||
29721 error "(1) unexpected barrier status $b_status"
29723 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
29725 b_status=$(barrier_stat)
29726 [ "$b_status" = "'frozen'" ] ||
29727 error "(2) unexpected barrier status $b_status"
29729 local expired=$(barrier_expired)
29730 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
29731 sleep $((expired + 3))
29733 b_status=$(barrier_stat)
29734 [ "$b_status" = "'expired'" ] ||
29735 error "(3) unexpected barrier status $b_status"
29737 # Do not reduce barrier time - See LU-11873
29738 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
29739 error "(4) fail to freeze barrier"
29741 b_status=$(barrier_stat)
29742 [ "$b_status" = "'frozen'" ] ||
29743 error "(5) unexpected barrier status $b_status"
29745 echo "Start barrier_thaw at: $(date)"
29746 #define OBD_FAIL_BARRIER_DELAY 0x2202
29747 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
29748 do_facet mgs $LCTL barrier_thaw $FSNAME &
29751 b_status=$(barrier_stat)
29752 echo "Got barrier status at: $(date)"
29753 [ "$b_status" = "'thawing'" ] ||
29754 error "(6) unexpected barrier status $b_status"
29756 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
29758 b_status=$(barrier_stat)
29759 [ "$b_status" = "'thawed'" ] ||
29760 error "(7) unexpected barrier status $b_status"
29762 #define OBD_FAIL_BARRIER_FAILURE 0x2203
29763 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
29764 do_facet mgs $LCTL barrier_freeze $FSNAME
29766 b_status=$(barrier_stat)
29767 [ "$b_status" = "'failed'" ] ||
29768 error "(8) unexpected barrier status $b_status"
29770 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
29771 do_facet mgs $LCTL barrier_thaw $FSNAME
29775 run_test 801a "write barrier user interfaces and stat machine"
29780 mkdir $DIR/$tdir || error "(1) fail to mkdir"
29781 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
29782 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
29783 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
29784 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
29786 cancel_lru_locks mdc
29788 # 180 seconds should be long enough
29789 do_facet mgs $LCTL barrier_freeze $FSNAME 180
29791 local b_status=$(barrier_stat)
29792 [ "$b_status" = "'frozen'" ] ||
29793 error "(6) unexpected barrier status $b_status"
29795 mkdir $DIR/$tdir/d0/d10 &
29798 touch $DIR/$tdir/d1/f13 &
29801 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
29804 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
29807 rm -f $DIR/$tdir/d4/f12 &
29810 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
29812 # To guarantee taht the 'stat' is not blocked
29813 b_status=$(barrier_stat)
29814 [ "$b_status" = "'frozen'" ] ||
29815 error "(8) unexpected barrier status $b_status"
29817 # let above commands to run at background
29820 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
29821 ps -p $touch_pid || error "(10) touch should be blocked"
29822 ps -p $ln_pid || error "(11) link should be blocked"
29823 ps -p $mv_pid || error "(12) rename should be blocked"
29824 ps -p $rm_pid || error "(13) unlink should be blocked"
29826 b_status=$(barrier_stat)
29827 [ "$b_status" = "'frozen'" ] ||
29828 error "(14) unexpected barrier status $b_status"
29830 do_facet mgs $LCTL barrier_thaw $FSNAME
29831 b_status=$(barrier_stat)
29832 [ "$b_status" = "'thawed'" ] ||
29833 error "(15) unexpected barrier status $b_status"
29835 wait $mkdir_pid || error "(16) mkdir should succeed"
29836 wait $touch_pid || error "(17) touch should succeed"
29837 wait $ln_pid || error "(18) link should succeed"
29838 wait $mv_pid || error "(19) rename should succeed"
29839 wait $rm_pid || error "(20) unlink should succeed"
29843 run_test 801b "modification will be blocked by write barrier"
29846 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29850 stop mds2 || error "(1) Fail to stop mds2"
29852 do_facet mgs $LCTL barrier_freeze $FSNAME 30
29854 local b_status=$(barrier_stat)
29855 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
29856 do_facet mgs $LCTL barrier_thaw $FSNAME
29857 error "(2) unexpected barrier status $b_status"
29860 do_facet mgs $LCTL barrier_rescan $FSNAME ||
29861 error "(3) Fail to rescan barrier bitmap"
29863 # Do not reduce barrier time - See LU-11873
29864 do_facet mgs $LCTL barrier_freeze $FSNAME 20
29866 b_status=$(barrier_stat)
29867 [ "$b_status" = "'frozen'" ] ||
29868 error "(4) unexpected barrier status $b_status"
29870 do_facet mgs $LCTL barrier_thaw $FSNAME
29871 b_status=$(barrier_stat)
29872 [ "$b_status" = "'thawed'" ] ||
29873 error "(5) unexpected barrier status $b_status"
29875 local devname=$(mdsdevname 2)
29877 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
29879 do_facet mgs $LCTL barrier_rescan $FSNAME ||
29880 error "(7) Fail to rescan barrier bitmap"
29884 run_test 801c "rescan barrier bitmap"
29887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29888 remote_mds_nodsh && skip "remote MDS with nodsh"
29890 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
29891 skip "readonly option not available"
29893 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
29895 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
29896 error "(2) Fail to copy"
29898 # write back all cached data before setting MDT to readonly
29902 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
29903 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
29905 echo "Modify should be refused"
29906 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
29908 echo "Read should be allowed"
29909 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
29910 error "(7) Read should succeed under ro mode"
29913 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
29915 run_test 802b "be able to set MDTs to readonly"
29918 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29919 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
29920 skip "MDS needs to be newer than 2.10.54"
29922 mkdir_on_mdt0 $DIR/$tdir
29923 # Create some objects on all MDTs to trigger related logs objects
29924 for idx in $(seq $MDSCOUNT); do
29925 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
29926 $DIR/$tdir/dir${idx} ||
29927 error "Fail to create $DIR/$tdir/dir${idx}"
29930 wait_delete_completed # ensure old test cleanups are finished
29932 echo "before create:"
29934 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
29936 for i in {1..10}; do
29937 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
29938 error "Fail to create $DIR/$tdir/foo$i"
29941 # sync ZFS-on-MDS to refresh statfs data
29942 wait_zfs_commit mds1
29944 echo "after create:"
29946 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
29948 # allow for an llog to be cleaned up during the test
29949 [ $after_used -ge $((before_used + 10 - 1)) ] ||
29950 error "before ($before_used) + 10 > after ($after_used)"
29952 for i in {1..10}; do
29953 rm -rf $DIR/$tdir/foo$i ||
29954 error "Fail to remove $DIR/$tdir/foo$i"
29957 # sync ZFS-on-MDS to refresh statfs data
29958 wait_zfs_commit mds1
29959 wait_delete_completed
29960 sleep 3 # avoid MDT return cached statfs
29961 echo "after unlink:"
29963 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
29965 # allow for an llog to be created during the test
29966 [ $after_used -le $((before_used + 1)) ] ||
29967 error "after ($after_used) > before ($before_used) + 1"
29969 run_test 803a "verify agent object for remote object"
29972 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
29973 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
29974 skip "MDS needs to be newer than 2.13.56"
29975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
29977 for i in $(seq 0 $((MDSCOUNT - 1))); do
29978 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
29986 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
29987 for i in $(seq 0 $((MDSCOUNT - 1))); do
29988 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
29989 awk '/getattr/ { print $2 }')
29990 before=$((before + tmp))
29992 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
29993 for i in $(seq 0 $((MDSCOUNT - 1))); do
29994 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
29995 awk '/getattr/ { print $2 }')
29996 after=$((after + tmp))
29999 [ $before -eq $after ] || error "getattr count $before != $after"
30001 run_test 803b "remote object can getattr from cache"
30004 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
30005 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
30006 skip "MDS needs to be newer than 2.10.54"
30007 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
30009 mkdir -p $DIR/$tdir
30010 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
30011 error "Fail to create $DIR/$tdir/dir0"
30013 local fid=$($LFS path2fid $DIR/$tdir/dir0)
30014 local dev=$(mdsdevname 2)
30016 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
30017 grep ${fid} || error "NOT found agent entry for dir0"
30019 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
30020 error "Fail to create $DIR/$tdir/dir1"
30022 touch $DIR/$tdir/dir1/foo0 ||
30023 error "Fail to create $DIR/$tdir/dir1/foo0"
30024 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
30027 for idx in $(seq $MDSCOUNT); do
30028 dev=$(mdsdevname $idx)
30029 do_facet mds${idx} \
30030 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
30031 grep ${fid} && rc=$idx
30034 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
30035 error "Fail to rename foo0 to foo1"
30036 if [ $rc -eq 0 ]; then
30037 for idx in $(seq $MDSCOUNT); do
30038 dev=$(mdsdevname $idx)
30039 do_facet mds${idx} \
30040 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
30041 grep ${fid} && rc=$idx
30045 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
30046 error "Fail to rename foo1 to foo2"
30047 if [ $rc -eq 0 ]; then
30048 for idx in $(seq $MDSCOUNT); do
30049 dev=$(mdsdevname $idx)
30050 do_facet mds${idx} \
30051 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
30052 grep ${fid} && rc=$idx
30056 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
30058 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
30059 error "Fail to link to $DIR/$tdir/dir1/foo2"
30060 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
30061 error "Fail to rename foo2 to foo0"
30062 unlink $DIR/$tdir/dir1/foo0 ||
30063 error "Fail to unlink $DIR/$tdir/dir1/foo0"
30064 rm -rf $DIR/$tdir/dir0 ||
30065 error "Fail to rm $DIR/$tdir/dir0"
30067 for idx in $(seq $MDSCOUNT); do
30071 dev=$(mdsdevname $idx)
30072 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
30074 start mds${idx} $dev $MDS_MOUNT_OPTS ||
30075 error "mount mds$idx failed"
30076 df $MOUNT > /dev/null 2>&1
30078 # e2fsck should not return error
30080 error "e2fsck detected error on MDT${idx}: rc=$rc"
30083 run_test 804 "verify agent entry for remote entry"
30086 do_facet $SINGLEMDS zfs set quota=$old $fsset
30087 unlinkmany $DIR/$tdir/f- 1000000
30092 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
30093 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
30094 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
30095 skip "netfree not implemented before 0.7"
30096 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
30097 skip "Need MDS version at least 2.10.57"
30104 local pref="osd-zfs.$FSNAME-MDT0000."
30106 # limit available space on MDS dataset to meet nospace issue
30107 # quickly. then ZFS 0.7.2 can use reserved space if asked
30108 # properly (using netfree flag in osd_declare_destroy()
30109 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
30110 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
30112 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
30113 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
30114 let "usedkb=usedkb-freekb"
30115 let "freekb=freekb/2"
30116 if let "freekb > 5000"; then
30119 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
30120 trap cleanup_805 EXIT
30121 mkdir_on_mdt0 $DIR/$tdir
30122 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
30123 error "Can't set PFL layout"
30124 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
30125 rm -rf $DIR/$tdir || error "not able to remove"
30126 do_facet $SINGLEMDS zfs set quota=$old $fsset
30129 run_test 805 "ZFS can remove from full fs"
30135 local expect=$(stat -c %s $file)
30137 check_lsom_size $1 $expect
30139 local blocks=$($LFS getsom -b $file)
30140 expect=$(stat -c %b $file)
30141 [[ $blocks == $expect ]] ||
30142 error "$file expected blocks: $expect, got: $blocks"
30150 cancel_lru_locks mdc
30152 size=$($LFS getsom -s $1)
30153 [[ $size == $expect ]] ||
30154 error "$file expected size: $expect, got: $size"
30158 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
30159 skip "Need MDS version at least 2.11.52"
30163 $LFS setstripe -c-1 $DIR/$tfile || error "setstripe $tfile failed"
30166 stack_trap "restore_opencache"
30168 # single-threaded write
30169 echo "Test SOM for single-threaded write"
30170 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
30171 error "write $tfile failed"
30172 check_lsom_size $DIR/$tfile $bs
30175 local size=$(($num * $bs))
30179 echo "Test SOM for single client multi-threaded($num) write"
30180 $TRUNCATE $DIR/$tfile 0
30181 for ((i = 0; i < $num; i++)); do
30182 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30184 offset=$((offset + $bs))
30186 for (( i=0; i < $num; i++ )); do
30189 check_lsom_size $DIR/$tfile $size
30191 $TRUNCATE $DIR/$tfile 0
30192 for ((i = 0; i < $num; i++)); do
30193 offset=$((offset - $bs))
30194 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30197 for (( i=0; i < $num; i++ )); do
30200 check_lsom_size $DIR/$tfile $size
30202 # multi-client writes
30203 num=$(get_node_count ${CLIENTS//,/ })
30204 size=$(($num * $bs))
30208 echo "Test SOM for multi-client ($num) writes"
30209 $TRUNCATE $DIR/$tfile 0
30210 for client in ${CLIENTS//,/ }; do
30211 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30214 offset=$((offset + $bs))
30216 for (( i=0; i < $num; i++ )); do
30219 check_lsom_size $DIR/$tfile $offset
30222 $TRUNCATE $DIR/$tfile 0
30223 for client in ${CLIENTS//,/ }; do
30224 offset=$((offset - $bs))
30225 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30229 for (( i=0; i < $num; i++ )); do
30232 check_lsom_size $DIR/$tfile $size
30234 # verify SOM blocks count
30235 echo "Verify SOM block count"
30236 $TRUNCATE $DIR/$tfile 0
30237 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w$((bs))YSc ||
30238 error "failed to write file $tfile with fdatasync and fstat"
30239 check_lsom_data $DIR/$tfile
30241 $TRUNCATE $DIR/$tfile 0
30242 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w$((bs * 2))Yc ||
30243 error "failed to write file $tfile with fdatasync"
30244 check_lsom_data $DIR/$tfile
30246 $TRUNCATE $DIR/$tfile 0
30247 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:O_SYNC:w$((bs * 3))c ||
30248 error "failed to write file $tfile with sync IO"
30249 check_lsom_data $DIR/$tfile
30252 echo "Test SOM for truncate"
30253 # use ftruncate to sync blocks on close request
30254 $MULTIOP $DIR/$tfile oO_WRONLY:T16384c
30255 check_lsom_size $DIR/$tfile 16384
30256 check_lsom_data $DIR/$tfile
30258 $TRUNCATE $DIR/$tfile 1234
30259 check_lsom_size $DIR/$tfile 1234
30260 # sync blocks on the MDT
30261 $MULTIOP $DIR/$tfile oc
30262 check_lsom_data $DIR/$tfile
30264 run_test 806 "Verify Lazy Size on MDS"
30267 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
30268 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
30269 skip "Need MDS version at least 2.11.52"
30271 # Registration step
30272 changelog_register || error "changelog_register failed"
30273 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
30274 changelog_users $SINGLEMDS | grep -q $cl_user ||
30275 error "User $cl_user not found in changelog_users"
30277 rm -rf $DIR/$tdir || error "rm $tdir failed"
30278 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
30279 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
30280 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
30281 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
30282 error "truncate $tdir/trunc failed"
30285 echo "Test SOM for single-threaded write with fsync"
30286 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
30287 error "write $tfile failed"
30290 # multi-client wirtes
30291 local num=$(get_node_count ${CLIENTS//,/ })
30295 echo "Test SOM for multi-client ($num) writes"
30296 touch $DIR/$tfile || error "touch $tfile failed"
30297 $TRUNCATE $DIR/$tfile 0
30298 for client in ${CLIENTS//,/ }; do
30299 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
30302 offset=$((offset + $bs))
30304 for (( i=0; i < $num; i++ )); do
30308 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
30309 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
30310 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
30311 check_lsom_data $DIR/$tdir/trunc
30312 check_lsom_data $DIR/$tdir/single_dd
30313 check_lsom_data $DIR/$tfile
30316 # Deregistration step
30317 changelog_deregister || error "changelog_deregister failed"
30319 run_test 807 "verify LSOM syncing tool"
30321 check_som_nologged()
30323 local lines=$($LFS changelog $FSNAME-MDT0000 |
30324 grep 'x=trusted.som' | wc -l)
30325 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
30329 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
30330 skip "Need MDS version at least 2.11.55"
30332 # Registration step
30333 changelog_register || error "changelog_register failed"
30335 touch $DIR/$tfile || error "touch $tfile failed"
30338 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
30339 error "write $tfile failed"
30342 $TRUNCATE $DIR/$tfile 1234
30345 $TRUNCATE $DIR/$tfile 1048576
30348 # Deregistration step
30349 changelog_deregister || error "changelog_deregister failed"
30351 run_test 808 "Check trusted.som xattr not logged in Changelogs"
30356 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
30360 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
30361 skip "Need MDS version at least 2.11.56"
30363 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
30364 error "failed to create DoM-only file $DIR/$tfile"
30365 touch $DIR/$tfile || error "touch $tfile failed"
30366 check_som_nodata $DIR/$tfile
30368 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
30369 error "write $tfile failed"
30370 check_som_nodata $DIR/$tfile
30372 $TRUNCATE $DIR/$tfile 1234
30373 check_som_nodata $DIR/$tfile
30375 $TRUNCATE $DIR/$tfile 4097
30376 check_som_nodata $DIR/$file
30378 run_test 809 "Verify no SOM xattr store for DoM-only files"
30381 [ $PARALLEL == "yes" ] && skip "skip parallel run"
30382 $GSS && skip_env "could not run with gss"
30383 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
30384 skip "OST < 2.12.58 doesn't align checksum"
30387 stack_trap "set_checksums $ORIG_CSUM" EXIT
30388 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
30393 for csum in $CKSUM_TYPES; do
30394 #define OBD_FAIL_OSC_NO_GRANT 0x411
30395 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
30396 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
30398 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
30399 before=$(md5sum $DIR/$tfile)
30400 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
30401 after=$(md5sum $DIR/$tfile)
30402 [ "$before" == "$after" ] ||
30403 error "$csum: $before != $after bs=$1 seek=$2"
30407 run_test 810 "partial page writes on ZFS (LU-11663)"
30410 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
30411 skip "OST < 2.12.51 doesn't support this fail_loc"
30413 $LFS setstripe -c 1 -i 0 $DIR/$tfile
30414 # ensure ost1 is connected
30415 stat $DIR/$tfile >/dev/null || error "can't stat"
30416 wait_osc_import_state client ost1 FULL
30417 # no locks, no reqs to let the connection idle
30418 cancel_lru_locks osc
30420 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
30421 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
30422 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
30423 wait_osc_import_state client ost1 CONNECTING
30424 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
30426 stat $DIR/$tfile >/dev/null || error "can't stat file"
30428 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
30430 test_812b() { # LU-12378
30431 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
30432 skip "OST < 2.12.51 doesn't support this fail_loc"
30434 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
30435 # ensure ost1 is connected
30436 stat $DIR/$tfile >/dev/null || error "can't stat"
30437 wait_osc_import_state client ost1 FULL
30438 # no locks, no reqs to let the connection idle
30439 cancel_lru_locks osc
30441 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
30442 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
30443 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
30444 wait_osc_import_state client ost1 CONNECTING
30445 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
30447 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
30448 wait_osc_import_state client ost1 IDLE
30450 run_test 812b "do not drop no resend request for idle connect"
30455 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
30457 $LFS setstripe -c 1 -o 0 $DIR/$tfile
30458 $LFS getstripe $DIR/$tfile
30459 $LCTL set_param osc.*.idle_timeout=10
30460 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
30461 # ensure ost1 is connected
30462 stat $DIR/$tfile >/dev/null || error "can't stat"
30463 wait_osc_import_state client ost1 FULL
30464 # no locks, no reqs to let the connection idle
30465 cancel_lru_locks osc
30467 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
30468 $LCTL set_param fail_loc=0x80000533
30470 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
30472 run_test 812c "idle import vs lock enqueue race"
30475 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
30476 [ -z "$file_heat_sav" ] && skip "no file heat support"
30487 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
30488 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
30490 $LCTL set_param -n llite.*.file_heat=1
30491 echo "Turn on file heat"
30492 echo "Period second: $period_second, Decay percentage: $decay_pct"
30494 echo "QQQQ" > $DIR/$tfile
30495 echo "QQQQ" > $DIR/$tfile
30496 echo "QQQQ" > $DIR/$tfile
30497 cat $DIR/$tfile > /dev/null
30498 cat $DIR/$tfile > /dev/null
30499 cat $DIR/$tfile > /dev/null
30500 cat $DIR/$tfile > /dev/null
30502 local out=$($LFS heat_get $DIR/$tfile)
30504 $LFS heat_get $DIR/$tfile
30505 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30506 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30507 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30508 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30510 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
30511 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
30512 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
30513 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
30515 sleep $((period_second + 3))
30516 echo "Sleep $((period_second + 3)) seconds..."
30517 # The recursion formula to calculate the heat of the file f is as
30519 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
30520 # Where Hi is the heat value in the period between time points i*I and
30521 # (i+1)*I; Ci is the access count in the period; the symbol P refers
30522 # to the weight of Ci.
30523 out=$($LFS heat_get $DIR/$tfile)
30524 $LFS heat_get $DIR/$tfile
30525 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30526 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30527 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30528 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30530 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
30531 error "read sample ($readsample) is wrong"
30532 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
30533 error "write sample ($writesample) is wrong"
30534 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
30535 error "read bytes ($readbyte) is wrong"
30536 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
30537 error "write bytes ($writebyte) is wrong"
30539 echo "QQQQ" > $DIR/$tfile
30540 echo "QQQQ" > $DIR/$tfile
30541 echo "QQQQ" > $DIR/$tfile
30542 cat $DIR/$tfile > /dev/null
30543 cat $DIR/$tfile > /dev/null
30544 cat $DIR/$tfile > /dev/null
30545 cat $DIR/$tfile > /dev/null
30547 sleep $((period_second + 3))
30548 echo "Sleep $((period_second + 3)) seconds..."
30550 out=$($LFS heat_get $DIR/$tfile)
30551 $LFS heat_get $DIR/$tfile
30552 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30553 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30554 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30555 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30557 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
30558 4 * $decay_pct) / 100") -eq 1 ] ||
30559 error "read sample ($readsample1) is wrong"
30560 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
30561 3 * $decay_pct) / 100") -eq 1 ] ||
30562 error "write sample ($writesample1) is wrong"
30563 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
30564 20 * $decay_pct) / 100") -eq 1 ] ||
30565 error "read bytes ($readbyte1) is wrong"
30566 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
30567 15 * $decay_pct) / 100") -eq 1 ] ||
30568 error "write bytes ($writebyte1) is wrong"
30570 echo "Turn off file heat for the file $DIR/$tfile"
30571 $LFS heat_set -o $DIR/$tfile
30573 echo "QQQQ" > $DIR/$tfile
30574 echo "QQQQ" > $DIR/$tfile
30575 echo "QQQQ" > $DIR/$tfile
30576 cat $DIR/$tfile > /dev/null
30577 cat $DIR/$tfile > /dev/null
30578 cat $DIR/$tfile > /dev/null
30579 cat $DIR/$tfile > /dev/null
30581 out=$($LFS heat_get $DIR/$tfile)
30582 $LFS heat_get $DIR/$tfile
30583 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30584 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30585 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30586 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30588 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
30589 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
30590 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
30591 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
30593 echo "Trun on file heat for the file $DIR/$tfile"
30594 $LFS heat_set -O $DIR/$tfile
30596 echo "QQQQ" > $DIR/$tfile
30597 echo "QQQQ" > $DIR/$tfile
30598 echo "QQQQ" > $DIR/$tfile
30599 cat $DIR/$tfile > /dev/null
30600 cat $DIR/$tfile > /dev/null
30601 cat $DIR/$tfile > /dev/null
30602 cat $DIR/$tfile > /dev/null
30604 out=$($LFS heat_get $DIR/$tfile)
30605 $LFS heat_get $DIR/$tfile
30606 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30607 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30608 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30609 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30611 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
30612 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
30613 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
30614 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
30616 $LFS heat_set -c $DIR/$tfile
30617 $LCTL set_param -n llite.*.file_heat=0
30618 echo "Turn off file heat support for the Lustre filesystem"
30620 echo "QQQQ" > $DIR/$tfile
30621 echo "QQQQ" > $DIR/$tfile
30622 echo "QQQQ" > $DIR/$tfile
30623 cat $DIR/$tfile > /dev/null
30624 cat $DIR/$tfile > /dev/null
30625 cat $DIR/$tfile > /dev/null
30626 cat $DIR/$tfile > /dev/null
30628 out=$($LFS heat_get $DIR/$tfile)
30629 $LFS heat_get $DIR/$tfile
30630 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
30631 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
30632 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
30633 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
30635 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
30636 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
30637 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
30638 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
30640 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
30643 run_test 813 "File heat verfication"
30647 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
30648 echo -n y >> $DIR/$tfile
30649 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
30650 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
30652 run_test 814 "sparse cp works as expected (LU-12361)"
30656 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
30657 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
30659 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
30662 local ost1_imp=$(get_osc_import_name client ost1)
30663 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
30666 $LFS setstripe -c 1 -i 0 $DIR/$tfile
30667 # ensure ost1 is connected
30669 stat $DIR/$tfile >/dev/null || error "can't stat"
30670 wait_osc_import_state client ost1 FULL
30671 # no locks, no reqs to let the connection idle
30672 cancel_lru_locks osc
30673 lru_resize_disable osc
30676 before=$($LCTL get_param -n \
30677 ldlm.namespaces.$imp_name.lru_size)
30679 wait_osc_import_state client ost1 IDLE
30680 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
30681 now=$($LCTL get_param -n \
30682 ldlm.namespaces.$imp_name.lru_size)
30683 [ $before == $now ] || error "lru_size changed $before != $now"
30685 run_test 816 "do not reset lru_resize on idle reconnect"
30689 exportfs -u localhost:$DIR/nfsexp
30694 systemctl restart nfs-server.service || skip "failed to restart nfsd"
30696 mkdir -p $DIR/nfsexp
30697 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
30698 error "failed to export nfs"
30700 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
30701 stack_trap cleanup_817 EXIT
30703 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
30704 error "failed to mount nfs to $tmpdir"
30706 cp /bin/true $tmpdir
30707 $DIR/nfsexp/true || error "failed to execute 'true' command"
30709 run_test 817 "nfsd won't cache write lock for exec file"
30712 test_mkdir -i0 -c1 $DIR/$tdir
30713 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
30714 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
30717 # restore osp-syn threads
30718 stack_trap "fail $SINGLEMDS"
30720 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
30721 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
30722 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
30723 error "start $SINGLEMDS failed"
30726 local testid=$(echo $TESTNAME | tr '_' ' ')
30728 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
30729 grep "run LFSCK" || error "run LFSCK is not suggested"
30731 run_test 818 "unlink with failed llog"
30734 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
30735 cancel_lru_locks osc
30736 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
30737 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
30738 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
30741 run_test 819a "too big niobuf in read"
30744 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
30745 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
30746 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
30747 cancel_lru_locks osc
30751 run_test 819b "too big niobuf in write"
30754 function test_820_start_ost() {
30757 for num in $(seq $OSTCOUNT); do
30758 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
30763 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
30766 umount_client $MOUNT || error "umount failed"
30767 for num in $(seq $OSTCOUNT); do
30771 # mount client with no active OSTs
30772 # so that the client can't initialize max LOV EA size
30773 # from OSC notifications
30774 mount_client $MOUNT || error "mount failed"
30775 # delay OST starting to keep this 0 max EA size for a while
30776 test_820_start_ost &
30778 # create a directory on MDS2
30779 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
30780 error "Failed to create directory"
30781 # open intent should update default EA size
30782 # see mdc_update_max_ea_from_body()
30783 # notice this is the very first RPC to MDS2
30784 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
30787 # With SSK, this situation can lead to -EPERM being returned.
30788 # In that case, simply retry.
30789 if [ $ret -ne 0 ] && $SHARED_KEY; then
30790 if echo "$out" | grep -q "not permitted"; then
30791 cp /etc/services $DIR/$tdir/mds2
30795 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
30797 run_test 820 "update max EA from open intent"
30800 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
30801 local OST_MAX_PRECREATE=20000
30803 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
30804 skip "Need MDS version at least 2.14.56"
30806 save_lustre_params mds1 \
30807 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
30808 do_facet $SINGLEMDS "$LCTL set_param -n \
30809 osp.$FSNAME-OST*MDT0000.max_create_count=0"
30810 do_facet $SINGLEMDS "$LCTL set_param -n \
30811 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
30813 stack_trap "restore_lustre_params < $p; rm $p"
30815 do_facet $SINGLEMDS "$LCTL set_param -n \
30816 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
30818 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
30819 osp.$FSNAME-OST0000*MDT0000.create_count")
30820 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
30821 osp.$FSNAME-OST0000*MDT0000.max_create_count")
30822 local expect_count=$(((($max/2)/256) * 256))
30824 log "setting create_count to 100200:"
30825 log " -result- count: $count with max: $max, expecting: $expect_count"
30827 [[ $count -eq expect_count ]] ||
30828 error "Create count not set to max precreate."
30830 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
30833 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
30834 skip "Need MDS version 2.14.56"
30836 local sync_changes=$(do_facet $SINGLEMDS \
30837 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
30839 [ "$sync_changes" -gt 100 ] &&
30840 skip "Sync changes $sync_changes > 100 already"
30842 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
30844 $LFS mkdir -i 0 $DIR/$tdir
30845 $LFS setstripe -c 1 -i 0 $DIR/$tdir
30847 save_lustre_params mds1 \
30848 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
30849 save_lustre_params mds1 \
30850 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
30852 do_facet mds1 "$LCTL set_param -n \
30853 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
30854 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
30855 stack_trap "restore_lustre_params < $p" EXIT
30857 createmany -o $DIR/$tdir/f- 1000
30858 unlinkmany $DIR/$tdir/f- 1000 &
30859 local UNLINK_PID=$!
30862 sync_changes=$(do_facet mds1 \
30863 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
30864 # the check in the code is racy, fail the test
30865 # if the value above the limit by 10.
30866 [ $sync_changes -gt 110 ] && {
30867 kill -2 $UNLINK_PID
30869 error "osp changes throttling failed, $sync_changes>110"
30871 kill -0 $UNLINK_PID 2> /dev/null || break
30875 run_test 831 "throttling unlink/setattr queuing on OSP"
30878 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
30879 (( $MDS1_VERSION >= $(version_code 2.15.52) )) ||
30880 skip "Need MDS version 2.15.52+"
30881 is_rmentry_supported || skip "rm_entry not supported"
30883 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
30884 mkdir $DIR/$tdir/local_dir || error "mkdir local_dir failed"
30885 mkdir_on_mdt -i 1 $DIR/$tdir/remote_dir ||
30886 error "mkdir remote_dir failed"
30887 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/striped_dir ||
30888 error "mkdir striped_dir failed"
30889 touch $DIR/$tdir/file || error "touch file failed"
30890 $LFS rm_entry $DIR/$tdir/* || error "lfs rm_entry $tdir/* failed"
30891 [ -z "$(ls -A $DIR/$tdir)" ] || error "$tdir not empty"
30893 run_test 832 "lfs rm_entry"
30896 local file=$DIR/$tfile
30898 stack_trap "rm -f $file" EXIT
30899 dd if=/dev/zero of=$file bs=1M count=50 || error "Write $file failed"
30905 # Buffered I/O write
30907 while [ ! -e $DIR/sanity.833.lck ]; do
30908 dd if=/dev/zero of=$file bs=1M count=50 conv=notrunc ||
30909 error "failed to write $file"
30910 sleep 0.$((RANDOM % 4 + 1))
30915 # Buffered I/O read
30917 while [ ! -e $DIR/sanity.833.lck ]; do
30918 dd if=$file of=/dev/null bs=1M count=50 ||
30919 error "failed to read $file"
30920 sleep 0.$((RANDOM % 4 + 1))
30927 while [ ! -e $DIR/sanity.833.lck ]; do
30928 dd if=$file of=/dev/null bs=1M count=50 iflag=direct ||
30929 error "failed to read $file in direct I/O mode"
30930 sleep 0.$((RANDOM % 4 + 1))
30936 touch $DIR/sanity.833.lck
30937 wait $wpid || error "$?: buffered write failed"
30938 wait $rpid || error "$?: buffered read failed"
30939 wait $rpid2 || error "$?: direct read failed"
30941 run_test 833 "Mixed buffered/direct read and write should not return -EIO"
30944 # tests that do cleanup/setup should be run at the end
30948 [ $PARALLEL == "yes" ] && skip "skip parallel run"
30951 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
30952 $LCTL set_param fail_loc=0x903
30954 cancel_lru_locks MGC
30956 FAIL_ON_ERROR=true cleanup
30957 FAIL_ON_ERROR=true setup
30959 run_test 900 "umount should not race with any mgc requeue thread"
30961 # LUS-6253/LU-11185
30969 [ $PARALLEL == "yes" ] && skip "skip parallel run"
30971 # some get_param have a bug to handle dot in param name
30972 cancel_lru_locks MGC
30973 old=$(mount -t lustre | wc -l)
30981 while [ $old -ne $oldc ]; do
30982 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
30985 if [ $count -ge $TIMEOUT ]; then
30986 error "too large timeout"
30989 umount_client $MOUNT || error "umount failed"
30990 mount_client $MOUNT || error "mount failed"
30991 cancel_lru_locks MGC
30992 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
30994 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
30998 run_test 901 "don't leak a mgc lock on client umount"
31002 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
31003 skip "client does not have LU-13377 fix"
31004 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
31005 $LCTL set_param fail_loc=0x1415
31006 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
31007 cancel_lru_locks osc
31010 run_test 902 "test short write doesn't hang lustre"
31014 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
31015 echo "blah" > $DIR/${tfile}-2
31016 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
31017 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
31018 $LCTL set_param fail_loc=0x417 fail_val=20
31020 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
31021 sleep 1 # To start the destroy
31022 wait_destroy_complete 150 || error "Destroy taking too long"
31023 cat $DIR/$tfile > /dev/null || error "Evicted"
31025 run_test 903 "Test long page discard does not cause evictions"
31028 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
31029 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
31030 grep -q project || skip "skip project quota not supported"
31032 local testfile="$DIR/$tdir/$tfile"
31033 local xattr="trusted.projid"
31035 local mdts=$(comma_list $(mdts_nodes))
31036 local saved=$(do_facet mds1 $LCTL get_param -n \
31037 osd-ldiskfs.*MDT0000.enable_projid_xattr)
31039 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
31040 stack_trap "do_nodes $mdts $LCTL set_param \
31041 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
31043 mkdir -p $DIR/$tdir
31045 #hide projid xattr on server
31046 $LFS project -p 1 $testfile ||
31047 error "set $testfile project id failed"
31048 getfattr -m - $testfile | grep $xattr &&
31049 error "do not show trusted.projid when disabled on server"
31050 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
31051 #should be hidden when projid is 0
31052 $LFS project -p 0 $testfile ||
31053 error "set $testfile project id failed"
31054 getfattr -m - $testfile | grep $xattr &&
31055 error "do not show trusted.projid with project ID 0"
31057 #still can getxattr explicitly
31058 projid=$(getfattr -n $xattr $testfile |
31059 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
31060 [ $projid == "0" ] ||
31061 error "projid expected 0 not $projid"
31063 #set the projid via setxattr
31064 setfattr -n $xattr -v "1000" $testfile ||
31065 error "setattr failed with $?"
31066 projid=($($LFS project $testfile))
31067 [ ${projid[0]} == "1000" ] ||
31068 error "projid expected 1000 not $projid"
31070 #check the new projid via getxattr
31071 $LFS project -p 1001 $testfile ||
31072 error "set $testfile project id failed"
31073 getfattr -m - $testfile | grep $xattr ||
31074 error "should show trusted.projid when project ID != 0"
31075 projid=$(getfattr -n $xattr $testfile |
31076 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
31077 [ $projid == "1001" ] ||
31078 error "projid expected 1001 not $projid"
31080 #try to set invalid projid
31081 setfattr -n $xattr -v "4294967295" $testfile &&
31082 error "set invalid projid should fail"
31084 #remove the xattr means setting projid to 0
31085 setfattr -x $xattr $testfile ||
31086 error "setfattr failed with $?"
31087 projid=($($LFS project $testfile))
31088 [ ${projid[0]} == "0" ] ||
31089 error "projid expected 0 not $projid"
31091 #should be hidden when parent has inherit flag and same projid
31092 $LFS project -srp 1002 $DIR/$tdir ||
31093 error "set $tdir project id failed"
31094 getfattr -m - $testfile | grep $xattr &&
31095 error "do not show trusted.projid with inherit flag"
31097 #still can getxattr explicitly
31098 projid=$(getfattr -n $xattr $testfile |
31099 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
31100 [ $projid == "1002" ] ||
31101 error "projid expected 1002 not $projid"
31103 run_test 904 "virtual project ID xattr"
31107 (( $OST1_VERSION >= $(version_code 2.15.50.220) )) ||
31108 skip "need OST version >= 2.15.50.220 for fail_loc"
31110 remote_ost_nodsh && skip "remote OST with nodsh"
31111 $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
31113 $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
31115 #define OBD_FAIL_OST_OPCODE 0x253
31117 do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
31118 $LFS ladvise -a willread $DIR/$tfile &&
31119 error "unexpected success of ladvise with fault injection"
31120 $LFS ladvise -a willread $DIR/$tfile |&
31121 grep -q "Operation not supported"
31122 (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
31124 run_test 905 "bad or new opcode should not stuck client"
31127 grep -q io_uring_setup /proc/kallsyms ||
31128 skip "Client OS does not support io_uring I/O engine"
31129 io_uring_probe || skip "kernel does not support io_uring fully"
31130 which fio || skip_env "no fio installed"
31131 fio --enghelp | grep -q io_uring ||
31132 skip_env "fio does not support io_uring I/O engine"
31134 local file=$DIR/$tfile
31135 local ioengine="io_uring"
31139 fio --name=seqwrite --ioengine=$ioengine \
31140 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
31141 --iodepth=64 --size=$size --filename=$file --rw=write ||
31142 error "fio seqwrite $file failed"
31144 fio --name=seqread --ioengine=$ioengine \
31145 --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs \
31146 --iodepth=64 --size=$size --filename=$file --rw=read ||
31147 error "fio seqread $file failed"
31149 rm -f $file || error "rm -f $file failed"
31151 run_test 906 "Simple test for io_uring I/O engine via fio"
31154 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
31156 # set stripe size to max rpc size
31157 $LFS setstripe -i 0 -c 2 -S $((max_pages * PAGE_SIZE)) $DIR/$tfile
31158 $LFS getstripe $DIR/$tfile
31159 #define OBD_FAIL_OST_EROFS 0x216
31160 do_facet ost1 "$LCTL set_param fail_val=3 fail_loc=0x80000216"
31162 local bs=$((max_pages * PAGE_SIZE / 16))
31164 # write full one stripe and one block
31165 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=17 || error "dd failed"
31167 rm $DIR/$tfile || error "rm failed"
31169 run_test 907 "write rpc error during unlink"
31171 complete_test $SECONDS
31172 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
31173 check_and_cleanup_lustre
31174 if [ "$I_MOUNTED" != "yes" ]; then
31175 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true