3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
33 LUSTRE=${LUSTRE:-$(dirname $0)/..}
34 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
35 . $LUSTRE/tests/test-framework.sh
40 ALWAYS_EXCEPT="$SANITY_EXCEPT "
41 always_except LU-9693 42a 42c
42 always_except LU-6493 42b
43 always_except LU-14541 277
44 always_except LU-9054 312
45 always_except LU-8411 407
48 always_except LU-14181 64e 64f
51 # skip the grant tests for ARM until they are fixed
52 if [[ $(uname -m) = aarch64 ]]; then
53 always_except LU-11671 45
56 # skip nfs tests on kernels >= 4.12.0 until they are fixed
57 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
58 always_except LU-12661 817
60 # skip cgroup tests on RHEL8.1 kernels until they are fixed
61 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
62 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
63 always_except LU-13063 411
66 #skip ACL tests on RHEL8 and SLES15 until tests changed to use other users
67 if (( $(egrep -cw "^bin|^daemon" /etc/passwd) < 2 )); then
68 always_except LU-15259 103a 125 154a
72 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 60i 64b 68 71 115 135 136 230d 300o"
74 if [ "$mds1_FSTYPE" = "zfs" ]; then
76 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
79 if [ "$ost1_FSTYPE" = "zfs" ]; then
80 always_except LU-1941 130a 130b 130c 130d 130e 130f 130g
83 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
85 # Get the SLES distro version
87 # Returns a version string that should only be used in comparing
88 # strings returned by version_code()
91 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
93 # All SuSE Linux versions have one decimal. version_code expects two
94 local sles_version=$version.0
95 version_code $sles_version
98 # Check if we are running on Ubuntu or SLES so we can make decisions on
100 if [ -r /etc/SuSE-release ]; then
101 sles_version=$(sles_version_code)
102 [ $sles_version -lt $(version_code 11.4.0) ] &&
103 always_except LU-4341 170
105 [ $sles_version -lt $(version_code 12.0.0) ] &&
106 always_except LU-3703 234
107 elif [ -r /etc/os-release ]; then
108 if grep -qi ubuntu /etc/os-release; then
109 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
110 -e 's/^VERSION=//p' \
114 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
115 always_except LU-10334 103a
116 always_except LU-10366 410
126 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
127 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
136 check_swap_layouts_support()
138 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
139 skip "Does not support layout lock."
142 check_swap_layout_no_dom()
145 local SUPP=$(lfs getstripe $FOLDER | grep "pattern: mdt" | wc -l)
146 [ $SUPP -eq 0 ] || skip "layout swap does not support DOM files so far"
149 check_and_setup_lustre
153 MAXFREE=${MAXFREE:-$((300000 * $OSTCOUNT))}
155 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
156 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
157 rm -rf $DIR/[Rdfs][0-9]*
159 # $RUNAS_ID may get set incorrectly somewhere else
160 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
161 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
163 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
165 if [ "${ONLY}" = "MOUNT" ] ; then
166 echo "Lustre is up, please go on"
170 echo "preparing for tests involving mounts"
171 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
173 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
174 echo # add a newline after mke2fs.
178 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
179 lctl set_param debug=-1 2> /dev/null || true
182 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
184 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
186 run_test 0a "touch; rm ====================="
189 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
190 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
192 run_test 0b "chmod 0755 $DIR ============================="
195 $LCTL get_param mdc.*.import | grep "state: FULL" ||
196 error "import not FULL"
197 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
200 run_test 0c "check import proc"
202 test_0d() { # LU-3397
203 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
204 skip "proc exports not supported before 2.10.57"
206 local mgs_exp="mgs.MGS.exports"
207 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
209 local exp_client_version
212 local temp_imp=$DIR/$tfile.import
213 local temp_exp=$DIR/$tfile.export
215 # save mgc import file to $temp_imp
216 $LCTL get_param mgc.*.import | tee $temp_imp
217 # Check if client uuid is found in MGS export
218 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
219 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
223 # save mgs export file to $temp_exp
224 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
226 # Compare the value of field "connect_flags"
227 imp_val=$(grep "connect_flags" $temp_imp)
228 exp_val=$(grep "connect_flags" $temp_exp)
229 [ "$exp_val" == "$imp_val" ] ||
230 error "export flags '$exp_val' != import flags '$imp_val'"
232 # Compare client versions. Only compare top-3 fields for compatibility
233 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
234 exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version))
235 imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3))
236 [ "$exp_val" == "$imp_val" ] ||
237 error "exp version '$exp_client_version'($exp_val) != " \
238 "'$(lustre_build_version client)'($imp_val)"
240 run_test 0d "check export proc ============================="
242 test_0e() { # LU-13417
243 (( $MDSCOUNT > 1 )) ||
244 skip "We need at least 2 MDTs for this test"
246 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
247 skip "Need server version at least 2.14.51"
249 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
250 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
252 [ $default_lmv_count -eq 1 ] ||
253 error "$MOUNT default stripe count $default_lmv_count"
255 [ $default_lmv_index -eq -1 ] ||
256 error "$MOUNT default stripe index $default_lmv_index"
258 mkdir $MOUNT/$tdir.1 || error "mkdir $MOUNT/$tdir.1 failed"
259 mkdir $MOUNT/$tdir.2 || error "mkdir $MOUNT/$tdir.2 failed"
261 local mdt_index1=$($LFS getdirstripe -i $MOUNT/$tdir.1)
262 local mdt_index2=$($LFS getdirstripe -i $MOUNT/$tdir.2)
264 [ $mdt_index1 -eq $mdt_index2 ] &&
265 error "directories are on the same MDT $mdt_index1=$mdt_index2"
267 rmdir $MOUNT/$tdir.1 $MOUNT/$tdir.2
269 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
272 test_mkdir $DIR/$tdir
273 test_mkdir $DIR/$tdir/d2
274 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
275 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
278 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
280 run_test 1 "mkdir; remkdir; rmdir"
283 test_mkdir $DIR/$tdir
284 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
285 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
287 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
289 run_test 2 "mkdir; touch; rmdir; check file"
292 test_mkdir $DIR/$tdir
293 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
294 touch $DIR/$tdir/$tfile
295 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
297 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
299 run_test 3 "mkdir; touch; rmdir; check dir"
301 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
303 test_mkdir -i 1 $DIR/$tdir
305 touch $DIR/$tdir/$tfile ||
306 error "Create file under remote directory failed"
309 error "Expect error removing in-use dir $DIR/$tdir"
311 test -d $DIR/$tdir || error "Remote directory disappeared"
313 rm -rf $DIR/$tdir || error "remove remote dir error"
315 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
318 test_mkdir $DIR/$tdir
319 test_mkdir $DIR/$tdir/d2
320 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
321 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
322 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
324 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
327 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
328 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
329 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
330 error "$tfile does not have perm 0666 or UID $UID"
331 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
332 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
333 error "$tfile should be 0666 and owned by UID $UID"
335 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
338 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
341 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
342 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
343 error "$tfile should be owned by UID $RUNAS_ID"
344 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
345 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
346 error "$tfile should be owned by UID $RUNAS_ID"
348 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
351 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
354 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
355 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
356 error "$tfile should be owned by GID $UID"
357 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
358 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
359 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
361 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
364 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
366 test_mkdir $DIR/$tdir
367 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
368 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
369 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
370 test_mkdir $DIR/$tdir/d/subdir
371 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
372 error "$tdir/d/subdir should be GID $RUNAS_GID"
373 if [[ $MDSCOUNT -gt 1 ]]; then
374 # check remote dir sgid inherite
375 $LFS mkdir -i 0 $DIR/$tdir.local ||
376 error "mkdir $tdir.local failed"
377 chmod g+s $DIR/$tdir.local ||
378 error "chmod $tdir.local failed"
379 chgrp $RUNAS_GID $DIR/$tdir.local ||
380 error "chgrp $tdir.local failed"
381 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
382 error "mkdir $tdir.remote failed"
383 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
384 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
385 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
386 error "$tdir.remote should be mode 02755"
389 run_test 6g "verify new dir in sgid dir inherits group"
391 test_6h() { # bug 7331
392 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
394 touch $DIR/$tfile || error "touch failed"
395 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
396 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
397 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
398 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
399 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
401 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
404 test_mkdir $DIR/$tdir
405 $MCREATE $DIR/$tdir/$tfile
406 chmod 0666 $DIR/$tdir/$tfile
407 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
408 error "$tdir/$tfile should be mode 0666"
410 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
413 if [ ! -d $DIR/$tdir ]; then
414 test_mkdir $DIR/$tdir
416 $MCREATE $DIR/$tdir/$tfile
417 echo -n foo > $DIR/$tdir/$tfile
418 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
419 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
421 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
424 test_mkdir $DIR/$tdir
425 touch $DIR/$tdir/$tfile
426 chmod 0666 $DIR/$tdir/$tfile
427 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
428 error "$tfile mode not 0666"
430 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
433 test_mkdir $DIR/$tdir
434 test_mkdir $DIR/$tdir/d2
435 test_mkdir $DIR/$tdir/d2/d3
436 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
438 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
441 test_mkdir $DIR/$tdir
442 test_mkdir $DIR/$tdir/d2
443 touch $DIR/$tdir/d2/$tfile
444 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
445 error "$tdir/d2/$tfile not a file"
447 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
450 test_mkdir $DIR/$tdir
451 test_mkdir $DIR/$tdir/d2
452 chmod 0666 $DIR/$tdir/d2
453 chmod 0705 $DIR/$tdir/d2
454 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
455 error "$tdir/d2 mode not 0705"
457 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
460 test_mkdir $DIR/$tdir
461 touch $DIR/$tdir/$tfile
462 chmod 0666 $DIR/$tdir/$tfile
463 chmod 0654 $DIR/$tdir/$tfile
464 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
465 error "$tdir/d2 mode not 0654"
467 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
470 test_mkdir $DIR/$tdir
471 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
473 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
474 error "$tdir/$tfile size not 0 after truncate"
476 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
479 test_mkdir $DIR/$tdir
480 touch $DIR/$tdir/$tfile
482 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
484 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
487 test_mkdir $DIR/$tdir
488 touch $DIR/$tdir/$tfile
489 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
490 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
491 error "$tdir/${tfile_2} not a file after rename"
492 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
494 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
497 test_mkdir $DIR/$tdir
498 touch $DIR/$tdir/$tfile
499 rm -rf $DIR/$tdir/$tfile
500 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
502 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
505 test_mkdir $DIR/$tdir
506 touch $DIR/$tdir/$tfile
507 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
509 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
510 error "$tdir/l-exist not a symlink"
511 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
512 error "$tdir/l-exist not referencing a file"
513 rm -f $DIR/$tdir/l-exist
514 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
516 run_test 17a "symlinks: create, remove (real)"
519 test_mkdir $DIR/$tdir
520 ln -s no-such-file $DIR/$tdir/l-dangle
522 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
523 error "$tdir/l-dangle not referencing no-such-file"
524 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
525 error "$tdir/l-dangle not referencing non-existent file"
526 rm -f $DIR/$tdir/l-dangle
527 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
529 run_test 17b "symlinks: create, remove (dangling)"
531 test_17c() { # bug 3440 - don't save failed open RPC for replay
532 test_mkdir $DIR/$tdir
533 ln -s foo $DIR/$tdir/$tfile
534 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
536 run_test 17c "symlinks: open dangling (should return error)"
539 test_mkdir $DIR/$tdir
540 ln -s foo $DIR/$tdir/$tfile
541 touch $DIR/$tdir/$tfile || error "creating to new symlink"
543 run_test 17d "symlinks: create dangling"
546 test_mkdir $DIR/$tdir
547 local foo=$DIR/$tdir/$tfile
548 ln -s $foo $foo || error "create symlink failed"
549 ls -l $foo || error "ls -l failed"
550 ls $foo && error "ls not failed" || true
552 run_test 17e "symlinks: create recursive symlink (should return error)"
555 test_mkdir $DIR/$tdir
556 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
557 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
558 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
559 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
560 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
561 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
564 run_test 17f "symlinks: long and very long symlink name"
566 # str_repeat(S, N) generate a string that is string S repeated N times
571 while [ $((n -= 1)) -ge 0 ]; do
577 # Long symlinks and LU-2241
579 test_mkdir $DIR/$tdir
580 local TESTS="59 60 61 4094 4095"
582 # Fix for inode size boundary in 2.1.4
583 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
586 # Patch not applied to 2.2 or 2.3 branches
587 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
588 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
592 local SYMNAME=$(str_repeat 'x' $i)
593 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
594 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
597 run_test 17g "symlinks: really long symlink name and inode boundaries"
599 test_17h() { #bug 17378
600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
601 remote_mds_nodsh && skip "remote MDS with nodsh"
605 test_mkdir $DIR/$tdir
606 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
607 $LFS setstripe -c -1 $DIR/$tdir
608 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
609 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
610 touch $DIR/$tdir/$tfile || true
612 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
614 test_17i() { #bug 20018
615 [ $PARALLEL == "yes" ] && skip "skip parallel run"
616 remote_mds_nodsh && skip "remote MDS with nodsh"
618 local foo=$DIR/$tdir/$tfile
621 test_mkdir -c1 $DIR/$tdir
622 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
623 ln -s $foo $foo || error "create symlink failed"
624 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
625 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
626 ls -l $foo && error "error not detected"
629 run_test 17i "don't panic on short symlink (should return error)"
631 test_17k() { #bug 22301
632 [ $PARALLEL == "yes" ] && skip "skip parallel run"
633 [[ -z "$(which rsync 2>/dev/null)" ]] &&
634 skip "no rsync command"
635 rsync --help | grep -q xattr ||
636 skip_env "$(rsync --version | head -n1) does not support xattrs"
637 test_mkdir $DIR/$tdir
638 test_mkdir $DIR/$tdir.new
639 touch $DIR/$tdir/$tfile
640 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
641 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
642 error "rsync failed with xattrs enabled"
644 run_test 17k "symlinks: rsync with xattrs enabled"
646 test_17l() { # LU-279
647 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
648 skip "no getfattr command"
650 test_mkdir $DIR/$tdir
651 touch $DIR/$tdir/$tfile
652 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
653 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
654 # -h to not follow symlinks. -m '' to list all the xattrs.
655 # grep to remove first line: '# file: $path'.
656 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
658 lgetxattr_size_check $path $xattr ||
659 error "lgetxattr_size_check $path $xattr failed"
663 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
668 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
669 remote_mds_nodsh && skip "remote MDS with nodsh"
670 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
671 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
672 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
674 local short_sym="0123456789"
675 local wdir=$DIR/$tdir
680 # create a long symlink file
681 for ((i = 0; i < 4; ++i)); do
682 long_sym=${long_sym}${long_sym}
685 echo "create 512 short and long symlink files under $wdir"
686 for ((i = 0; i < 256; ++i)); do
687 ln -sf ${long_sym}"a5a5" $wdir/long-$i
688 ln -sf ${short_sym}"a5a5" $wdir/short-$i
694 wait_delete_completed
696 echo "recreate the 512 symlink files with a shorter string"
697 for ((i = 0; i < 512; ++i)); do
698 # rewrite the symlink file with a shorter string
699 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
700 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
703 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
705 echo "stop and checking mds${mds_index}:"
706 # e2fsck should not return error
708 local devname=$(mdsdevname $mds_index)
709 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
712 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
713 error "start mds${mds_index} failed"
714 df $MOUNT > /dev/null 2>&1
716 error "e2fsck detected error for short/long symlink: rc=$rc"
719 run_test 17m "run e2fsck against MDT which contains short/long symlink"
721 check_fs_consistency_17n() {
725 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
726 # so it only check MDT1/MDT2 instead of all of MDTs.
727 for mdt_index in 1 2; do
728 # e2fsck should not return error
730 local devname=$(mdsdevname $mdt_index)
731 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
734 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
735 error "mount mds$mdt_index failed"
736 df $MOUNT > /dev/null 2>&1
742 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
743 [ $PARALLEL == "yes" ] && skip "skip parallel run"
744 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
745 remote_mds_nodsh && skip "remote MDS with nodsh"
746 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
747 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
748 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
752 test_mkdir $DIR/$tdir
753 for ((i=0; i<10; i++)); do
754 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
755 error "create remote dir error $i"
756 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
757 error "create files under remote dir failed $i"
760 check_fs_consistency_17n ||
761 error "e2fsck report error after create files under remote dir"
763 for ((i = 0; i < 10; i++)); do
764 rm -rf $DIR/$tdir/remote_dir_${i} ||
765 error "destroy remote dir error $i"
768 check_fs_consistency_17n ||
769 error "e2fsck report error after unlink files under remote dir"
771 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
772 skip "lustre < 2.4.50 does not support migrate mv"
774 for ((i = 0; i < 10; i++)); do
775 mkdir -p $DIR/$tdir/remote_dir_${i}
776 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
777 error "create files under remote dir failed $i"
778 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
779 error "migrate remote dir error $i"
781 check_fs_consistency_17n || error "e2fsck report error after migration"
783 for ((i = 0; i < 10; i++)); do
784 rm -rf $DIR/$tdir/remote_dir_${i} ||
785 error "destroy remote dir error $i"
788 check_fs_consistency_17n || error "e2fsck report error after unlink"
790 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
793 remote_mds_nodsh && skip "remote MDS with nodsh"
794 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
795 skip "Need MDS version at least 2.3.64"
797 local wdir=$DIR/${tdir}o
803 mdt_index=$($LFS getstripe -m $wdir/$tfile)
804 mdt_index=$((mdt_index + 1))
807 #fail mds will wait the failover finish then set
808 #following fail_loc to avoid interfer the recovery process.
811 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
812 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
813 ls -l $wdir/$tfile && rc=1
814 do_facet mds${mdt_index} lctl set_param fail_loc=0
815 [[ $rc -eq 0 ]] || error "stat file should fail"
817 run_test 17o "stat file with incompat LMA feature"
820 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
821 ls $DIR || error "Failed to ls $DIR: $?"
823 run_test 18 "touch .../f ; ls ... =============================="
829 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
831 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
834 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
836 run_test 19b "ls -l .../f19 (should return error) =============="
839 [ $RUNAS_ID -eq $UID ] &&
840 skip_env "RUNAS_ID = UID = $UID -- skipping"
842 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
844 run_test 19c "$RUNAS touch .../f19 (should return error) =="
847 cat $DIR/f19 && error || true
849 run_test 19d "cat .../f19 (should return error) =============="
858 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
860 run_test 20 "touch .../f ; ls -l ..."
863 test_mkdir $DIR/$tdir
864 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
865 ln -s dangle $DIR/$tdir/link
866 echo foo >> $DIR/$tdir/link
867 cat $DIR/$tdir/dangle
868 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
869 $CHECKSTAT -f -t file $DIR/$tdir/link ||
870 error "$tdir/link not linked to a file"
872 run_test 21 "write to dangling link"
875 local wdir=$DIR/$tdir
877 chown $RUNAS_ID:$RUNAS_GID $wdir
878 (cd $wdir || error "cd $wdir failed";
879 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
881 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
882 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
883 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
884 error "checkstat -u failed"
886 run_test 22 "unpack tar archive as non-root user"
890 test_mkdir $DIR/$tdir
891 local file=$DIR/$tdir/$tfile
893 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
894 openfile -f O_CREAT:O_EXCL $file &&
895 error "$file recreate succeeded" || true
897 run_test 23a "O_CREAT|O_EXCL in subdir"
899 test_23b() { # bug 18988
900 test_mkdir $DIR/$tdir
901 local file=$DIR/$tdir/$tfile
904 echo foo > $file || error "write filed"
905 echo bar >> $file || error "append filed"
906 $CHECKSTAT -s 8 $file || error "wrong size"
909 run_test 23b "O_APPEND check"
911 # LU-9409, size with O_APPEND and tiny writes
913 local file=$DIR/$tfile
916 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
917 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
921 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
922 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
924 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
927 #racing tiny & normal writes
928 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
929 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
931 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
934 #racing tiny & normal writes 2, ugly numbers
935 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
936 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
938 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
941 run_test 23c "O_APPEND size checks for tiny writes"
943 # LU-11069 file offset is correct after appending writes
945 local file=$DIR/$tfile
948 echo CentaurHauls > $file
949 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
950 if ((offset != 26)); then
951 error "wrong offset, expected 26, got '$offset'"
954 run_test 23d "file offset is correct after appending writes"
958 echo '-- same directory rename'
959 test_mkdir $DIR/$tdir
960 touch $DIR/$tdir/$tfile.1
961 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
962 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
964 run_test 24a "rename file to non-existent target"
967 test_mkdir $DIR/$tdir
968 touch $DIR/$tdir/$tfile.{1,2}
969 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
970 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
971 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
973 run_test 24b "rename file to existing target"
976 test_mkdir $DIR/$tdir
977 test_mkdir $DIR/$tdir/d$testnum.1
978 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
979 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
980 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
982 run_test 24c "rename directory to non-existent target"
985 test_mkdir -c1 $DIR/$tdir
986 test_mkdir -c1 $DIR/$tdir/d$testnum.1
987 test_mkdir -c1 $DIR/$tdir/d$testnum.2
988 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
989 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
990 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
992 run_test 24d "rename directory to existing target"
995 echo '-- cross directory renames --'
999 mv $DIR/R5a/f $DIR/R5b/g
1000 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
1001 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
1003 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
1008 touch $DIR/R6a/f $DIR/R6b/g
1009 mv $DIR/R6a/f $DIR/R6b/g
1010 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
1011 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
1013 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
1018 test_mkdir $DIR/R7a/d
1019 mv $DIR/R7a/d $DIR/R7b/e
1020 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
1021 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
1023 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1026 test_mkdir -c1 $DIR/R8a
1027 test_mkdir -c1 $DIR/R8b
1028 test_mkdir -c1 $DIR/R8a/d
1029 test_mkdir -c1 $DIR/R8b/e
1030 mrename $DIR/R8a/d $DIR/R8b/e
1031 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1032 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1034 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1037 echo "-- rename error cases"
1039 test_mkdir $DIR/R9/a
1041 mrename $DIR/R9/f $DIR/R9/a
1042 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1043 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1044 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1046 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1050 mrename $DIR/R10/f $DIR/R10/g
1051 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1052 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1053 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1055 run_test 24j "source does not exist ============================"
1058 test_mkdir $DIR/R11a
1059 test_mkdir $DIR/R11a/d
1061 mv $DIR/R11a/f $DIR/R11a/d
1062 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1063 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1065 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1067 # bug 2429 - rename foo foo foo creates invalid file
1070 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1072 run_test 24l "Renaming a file to itself ========================"
1076 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1077 # on ext3 this does not remove either the source or target files
1078 # though the "expected" operation would be to remove the source
1079 $CHECKSTAT -t file ${f} || error "${f} missing"
1080 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1082 run_test 24m "Renaming a file to a hard link to itself ========="
1086 # this stats the old file after it was renamed, so it should fail
1088 $CHECKSTAT ${f} || error "${f} missing"
1090 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1091 $CHECKSTAT -a ${f} || error "${f} exists"
1093 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1096 test_mkdir $DIR/$tdir
1097 rename_many -s random -v -n 10 $DIR/$tdir
1099 run_test 24o "rename of files during htree split"
1102 test_mkdir $DIR/R12a
1103 test_mkdir $DIR/R12b
1104 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1105 mrename $DIR/R12a $DIR/R12b
1106 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1107 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1108 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1109 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1111 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1113 cleanup_multiop_pause() {
1115 kill -USR1 $MULTIPID
1119 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1121 test_mkdir $DIR/R13a
1122 test_mkdir $DIR/R13b
1123 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1124 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1127 trap cleanup_multiop_pause EXIT
1128 mrename $DIR/R13a $DIR/R13b
1129 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1130 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1131 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1132 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1133 cleanup_multiop_pause
1134 wait $MULTIPID || error "multiop close failed"
1136 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1138 test_24r() { #bug 3789
1139 test_mkdir $DIR/R14a
1140 test_mkdir $DIR/R14a/b
1141 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1142 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1143 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1145 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1148 test_mkdir $DIR/R15a
1149 test_mkdir $DIR/R15a/b
1150 test_mkdir $DIR/R15a/b/c
1151 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1152 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1153 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1155 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1157 test_mkdir $DIR/R16a
1158 test_mkdir $DIR/R16a/b
1159 test_mkdir $DIR/R16a/b/c
1160 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1161 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1162 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1164 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1166 test_24u() { # bug12192
1167 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1168 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1170 run_test 24u "create stripe file"
1172 simple_cleanup_common() {
1176 [[ -z "$DIR" || -z "$tdir" || ! -d "$DIR/$tdir" ]] && return 0
1178 local start=$SECONDS
1180 [[ -n "$createmany" ]] && unlinkmany $DIR/$tdir/$tfile $createmany
1181 rm -rf $DIR/$tdir || error "cleanup $DIR/$tdir failed"
1183 wait_delete_completed
1184 echo "cleanup time $((SECONDS - start))"
1188 max_pages_per_rpc() {
1189 local mdtname="$(printf "MDT%04x" ${1:-0})"
1190 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1196 local nrfiles=${COUNT:-100000}
1197 local fname="$DIR/$tdir/$tfile"
1199 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1200 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1202 test_mkdir "$(dirname $fname)"
1203 # assume MDT0000 has the fewest inodes
1204 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1205 local free_inodes=$(($(mdt_free_inodes 0) * ${stripes/#0/1}))
1206 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1208 stack_trap "simple_cleanup_common $nrfiles"
1210 createmany -m "$fname" $nrfiles
1212 cancel_lru_locks mdc
1213 lctl set_param mdc.*.stats clear
1215 # was previously test_24D: LU-6101
1216 # readdir() returns correct number of entries after cursor reload
1217 local num_ls=$(ls $DIR/$tdir | wc -l)
1218 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1219 local num_all=$(ls -a $DIR/$tdir | wc -l)
1220 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1221 [ $num_all -ne $((nrfiles + 2)) ]; then
1222 error "Expected $nrfiles files, got $num_ls " \
1223 "($num_uniq unique $num_all .&..)"
1225 # LU-5 large readdir
1226 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1227 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1228 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1229 # take into account of overhead in lu_dirpage header and end mark in
1230 # each page, plus one in rpc_num calculation.
1231 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1232 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1233 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1234 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1235 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1236 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1237 echo "readpages: $mds_readpage rpc_max: $rpc_max-2/+1"
1238 (( $mds_readpage >= $rpc_max - 2 && $mds_readpage <= $rpc_max + 1)) ||
1239 error "large readdir doesn't take effect: " \
1240 "$mds_readpage should be about $rpc_max"
1242 run_test 24v "list large directory (test hash collision, b=17560)"
1244 test_24w() { # bug21506
1246 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1247 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1248 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1249 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1250 [[ "$SZ1" -eq "$SZ2" ]] ||
1251 error "Error reading at the end of the file $tfile"
1253 run_test 24w "Reading a file larger than 4Gb"
1256 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1258 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1259 skip "Need MDS version at least 2.7.56"
1262 local remote_dir=$DIR/$tdir/remote_dir
1264 test_mkdir $DIR/$tdir
1265 $LFS mkdir -i $MDTIDX $remote_dir ||
1266 error "create remote directory failed"
1268 test_mkdir $DIR/$tdir/src_dir
1269 touch $DIR/$tdir/src_file
1270 test_mkdir $remote_dir/tgt_dir
1271 touch $remote_dir/tgt_file
1273 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1274 error "rename dir cross MDT failed!"
1276 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1277 error "rename file cross MDT failed!"
1279 touch $DIR/$tdir/ln_file
1280 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1281 error "ln file cross MDT failed"
1283 rm -rf $DIR/$tdir || error "Can not delete directories"
1285 run_test 24x "cross MDT rename/link"
1288 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1289 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1291 local remote_dir=$DIR/$tdir/remote_dir
1294 test_mkdir $DIR/$tdir
1295 $LFS mkdir -i $mdtidx $remote_dir ||
1296 error "create remote directory failed"
1298 test_mkdir $remote_dir/src_dir
1299 touch $remote_dir/src_file
1300 test_mkdir $remote_dir/tgt_dir
1301 touch $remote_dir/tgt_file
1303 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1304 error "rename subdir in the same remote dir failed!"
1306 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1307 error "rename files in the same remote dir failed!"
1309 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1310 error "link files in the same remote dir failed!"
1312 rm -rf $DIR/$tdir || error "Can not delete directories"
1314 run_test 24y "rename/link on the same dir should succeed"
1317 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1318 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1319 skip "Need MDS version at least 2.12.51"
1323 for index in 0 1; do
1324 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1325 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1328 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1330 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1331 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1333 local mdts=$(comma_list $(mdts_nodes))
1335 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1336 stack_trap "do_nodes $mdts $LCTL \
1337 set_param mdt.*.enable_remote_rename=1" EXIT
1339 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1341 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1342 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1344 run_test 24z "cross-MDT rename is done as cp"
1346 test_24A() { # LU-3182
1349 test_mkdir $DIR/$tdir
1350 stack_trap "simple_cleanup_common $NFILES"
1351 createmany -m $DIR/$tdir/$tfile $NFILES
1352 local t=$(ls $DIR/$tdir | wc -l)
1353 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1354 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1356 (( $t == $NFILES && $u == $NFILES && $v == NFILES + 2 )) ||
1357 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1359 run_test 24A "readdir() returns correct number of entries."
1361 test_24B() { # LU-4805
1362 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1366 test_mkdir $DIR/$tdir
1367 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1368 error "create striped dir failed"
1370 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1371 [ $count -eq 2 ] || error "Expected 2, got $count"
1373 touch $DIR/$tdir/striped_dir/a
1375 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1376 [ $count -eq 3 ] || error "Expected 3, got $count"
1378 touch $DIR/$tdir/striped_dir/.f
1380 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1381 [ $count -eq 4 ] || error "Expected 4, got $count"
1383 rm -rf $DIR/$tdir || error "Can not delete directories"
1385 run_test 24B "readdir for striped dir return correct number of entries"
1388 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1394 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1395 error "create striped dir failed"
1397 cd $DIR/$tdir/d0/striped_dir
1399 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1400 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1401 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1403 [ "$d0_ino" = "$parent_ino" ] ||
1404 error ".. wrong, expect $d0_ino, get $parent_ino"
1406 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1407 error "mv striped dir failed"
1409 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1411 [ "$d1_ino" = "$parent_ino" ] ||
1412 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1414 run_test 24C "check .. in striped dir"
1417 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1418 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1421 mkdir $DIR/$tdir/src_dir
1422 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1423 error "create remote source failed"
1425 touch $DIR/$tdir/src_dir/src_child/a
1427 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1428 error "create remote target dir failed"
1430 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1431 error "create remote target child failed"
1433 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1434 error "rename dir cross MDT failed!"
1438 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1439 error "src_child still exists after rename"
1441 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1442 error "missing file(a) after rename"
1444 rm -rf $DIR/$tdir || error "Can not delete directories"
1446 run_test 24E "cross MDT rename/link"
1449 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1452 [ "$SLOW" = "no" ] && repeats=100
1456 echo "$repeats repeats"
1457 for ((i = 0; i < repeats; i++)); do
1458 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1459 touch $DIR/$tdir/test/a || error "touch fails"
1460 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1461 rm -rf $DIR/$tdir/test || error "rmdir fails"
1466 run_test 24F "hash order vs readdir (LU-11330)"
1469 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1474 $LFS mkdir -i 0 $DIR/$tdir-0 || error "mkdir $tdir-0"
1475 $LFS mkdir -i 1 $DIR/$tdir-1 || error "mkdir $tdir-1"
1476 touch $DIR/$tdir-0/f1 || error "touch f1"
1477 ln -s $DIR/$tdir-0/f1 $DIR/$tdir-0/s1 || error "ln s1"
1478 ino1=$(stat -c%i $DIR/$tdir-0/s1)
1479 mv $DIR/$tdir-0/s1 $DIR/$tdir-1 || error "mv s1"
1480 ino2=$(stat -c%i $DIR/$tdir-1/s1)
1481 [ $ino1 -ne $ino2 ] || error "s1 should be migrated"
1483 run_test 24G "migrate symlink in rename"
1486 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1487 [[ $(hostname) != $(facet_active_host mds2) ]] ||
1488 skip "MDT1 should be on another node"
1490 test_mkdir -i 1 -c 1 $DIR/$tdir
1491 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
1492 do_facet mds2 $LCTL set_param fail_loc=0x80001103
1493 touch $DIR/$tdir/$tfile || error "touch failed"
1495 run_test 24H "repeat FLD_QUERY rpc"
1498 echo '== symlink sanity ============================================='
1502 touch $DIR/s25/foo ||
1503 error "File creation in symlinked directory failed"
1505 run_test 25a "create file in symlinked directory ==============="
1508 [ ! -d $DIR/d25 ] && test_25a
1509 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1511 run_test 25b "lookup file in symlinked directory ==============="
1515 test_mkdir $DIR/d26/d26-2
1516 ln -s d26/d26-2 $DIR/s26
1517 touch $DIR/s26/foo || error "File creation failed"
1519 run_test 26a "multiple component symlink ======================="
1522 test_mkdir -p $DIR/$tdir/d26-2
1523 ln -s $tdir/d26-2/foo $DIR/s26-2
1524 touch $DIR/s26-2 || error "File creation failed"
1526 run_test 26b "multiple component symlink at end of lookup ======"
1529 test_mkdir $DIR/d26.2
1530 touch $DIR/d26.2/foo
1531 ln -s d26.2 $DIR/s26.2-1
1532 ln -s s26.2-1 $DIR/s26.2-2
1533 ln -s s26.2-2 $DIR/s26.2-3
1534 chmod 0666 $DIR/s26.2-3/foo
1536 run_test 26c "chain of symlinks"
1538 # recursive symlinks (bug 439)
1540 ln -s d26-3/foo $DIR/d26-3
1542 run_test 26d "create multiple component recursive symlink"
1545 [ ! -h $DIR/d26-3 ] && test_26d
1548 run_test 26e "unlink multiple component recursive symlink"
1550 # recursive symlinks (bug 7022)
1552 test_mkdir $DIR/$tdir
1553 test_mkdir $DIR/$tdir/$tfile
1554 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1555 test_mkdir -p lndir/bar1
1556 test_mkdir $DIR/$tdir/$tfile/$tfile
1557 cd $tfile || error "cd $tfile failed"
1558 ln -s .. dotdot || error "ln dotdot failed"
1559 ln -s dotdot/lndir lndir || error "ln lndir failed"
1560 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1561 output=`ls $tfile/$tfile/lndir/bar1`
1562 [ "$output" = bar1 ] && error "unexpected output"
1563 rm -r $tfile || error "rm $tfile failed"
1564 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1566 run_test 26f "rm -r of a directory which has recursive symlink"
1569 test_mkdir $DIR/$tdir
1570 $LFS getstripe $DIR/$tdir
1571 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1572 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1573 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1575 run_test 27a "one stripe file"
1578 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1580 test_mkdir $DIR/$tdir
1581 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1582 $LFS getstripe -c $DIR/$tdir/$tfile
1583 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1584 error "two-stripe file doesn't have two stripes"
1586 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1588 run_test 27b "create and write to two stripe file"
1590 # 27c family tests specific striping, setstripe -o
1592 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1593 test_mkdir -p $DIR/$tdir
1596 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1597 $LFS getstripe -i $DIR/$tdir/$tfile
1598 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1599 error "stripe not on specified OST"
1601 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1603 run_test 27ca "one stripe on specified OST"
1606 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1607 test_mkdir -p $DIR/$tdir
1609 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1610 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1613 # Strip getstripe output to a space separated list of OSTs
1614 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1615 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1616 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1617 error "stripes not on specified OSTs"
1619 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1621 run_test 27cb "two stripes on specified OSTs"
1624 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1625 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1626 skip "server does not support overstriping"
1628 test_mkdir -p $DIR/$tdir
1630 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1631 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1634 # Strip getstripe output to a space separated list of OSTs
1635 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1636 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1637 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1638 error "stripes not on specified OSTs"
1640 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1642 run_test 27cc "two stripes on the same OST"
1645 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1646 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1647 skip "server does not support overstriping"
1648 test_mkdir -p $DIR/$tdir
1649 local osts="0,1,1,0"
1650 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1651 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1654 # Strip getstripe output to a space separated list of OSTs
1655 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1656 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1657 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1658 error "stripes not on specified OSTs"
1660 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1662 run_test 27cd "four stripes on two OSTs"
1665 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1666 skip_env "too many osts, skipping"
1667 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1668 skip "server does not support overstriping"
1669 # We do one more stripe than we have OSTs
1670 [ $OSTCOUNT -lt 159 ] || large_xattr_enabled ||
1671 skip_env "ea_inode feature disabled"
1673 test_mkdir -p $DIR/$tdir
1675 for i in $(seq 0 $OSTCOUNT);
1678 if [ $i -ne $OSTCOUNT ]; then
1682 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1683 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1686 # Strip getstripe output to a space separated list of OSTs
1687 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1688 awk '{print $1}' | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
1689 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1690 error "stripes not on specified OSTs"
1692 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1694 run_test 27ce "more stripes than OSTs with -o"
1697 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1700 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1701 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1702 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1703 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1704 error "failed to set $osp_proc=0"
1706 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1709 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1710 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1711 error "failed to set $osp_proc=1"
1714 error "should return error due to $osp_proc=0"
1716 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1719 test_mkdir $DIR/$tdir
1720 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1721 error "setstripe failed"
1722 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1723 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1725 run_test 27d "create file with default settings"
1728 # LU-5839 adds check for existed layout before setting it
1729 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1730 skip "Need MDS version at least 2.7.56"
1732 test_mkdir $DIR/$tdir
1733 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1734 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1735 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1737 run_test 27e "setstripe existing file (should return error)"
1740 test_mkdir $DIR/$tdir
1741 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1742 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1743 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1744 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1745 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1746 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1748 run_test 27f "setstripe with bad stripe size (should return error)"
1751 test_mkdir $DIR/$tdir
1752 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1753 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1754 error "$DIR/$tdir/$tfile has object"
1756 run_test 27g "$LFS getstripe with no objects"
1759 test_mkdir $DIR/$tdir
1760 touch $DIR/$tdir/$tfile || error "touch failed"
1761 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1762 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1764 (( rc == 2 )) || error "getstripe did not return ENOENT"
1766 run_test 27ga "$LFS getstripe with missing file (should return error)"
1769 test_mkdir $DIR/$tdir
1770 touch $DIR/$tdir/$tfile || error "touch failed"
1771 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1772 error "missing objects"
1774 run_test 27i "$LFS getstripe with some objects"
1777 test_mkdir $DIR/$tdir
1778 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1779 error "setstripe failed" || true
1781 run_test 27j "setstripe with bad stripe offset (should return error)"
1783 test_27k() { # bug 2844
1784 test_mkdir $DIR/$tdir
1785 local file=$DIR/$tdir/$tfile
1786 local ll_max_blksize=$((4 * 1024 * 1024))
1787 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1788 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1789 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1790 dd if=/dev/zero of=$file bs=4k count=1
1791 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1792 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1794 run_test 27k "limit i_blksize for broken user apps"
1797 mcreate $DIR/$tfile || error "creating file"
1798 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1799 error "setstripe should have failed" || true
1801 run_test 27l "check setstripe permissions (should return error)"
1804 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1806 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1807 skip_env "multiple clients -- skipping"
1809 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1811 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1812 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1814 stack_trap simple_cleanup_common
1815 test_mkdir $DIR/$tdir
1816 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1817 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1818 error "dd should fill OST0"
1820 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1822 [ $i -gt 256 ] && break
1825 touch $DIR/$tdir/$tfile.$i
1826 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1827 awk '{print $1}'| grep -w "0") ] &&
1828 error "OST0 was full but new created file still use it"
1830 touch $DIR/$tdir/$tfile.$i
1831 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1832 awk '{print $1}'| grep -w "0") ] &&
1833 error "OST0 was full but new created file still use it" || true
1835 run_test 27m "create file while OST0 was full"
1837 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1838 # if the OST isn't full anymore.
1840 local ostidx=${1:-""}
1845 local list=$(comma_list $(osts_nodes))
1846 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1848 do_nodes $list lctl set_param fail_loc=0
1849 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1850 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1851 awk '{print $1 * 2;exit;}')
1852 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1854 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1858 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1860 remote_mds_nodsh && skip "remote MDS with nodsh"
1861 remote_ost_nodsh && skip "remote OST with nodsh"
1864 rm -f $DIR/$tdir/$tfile
1865 exhaust_precreations 0 0x80000215
1866 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1867 touch $DIR/$tdir/$tfile || error "touch failed"
1868 $LFS getstripe $DIR/$tdir/$tfile
1871 run_test 27n "create file with some full OSTs"
1874 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1875 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1876 remote_mds_nodsh && skip "remote MDS with nodsh"
1877 remote_ost_nodsh && skip "remote OST with nodsh"
1880 rm -f $DIR/$tdir/$tfile
1881 exhaust_all_precreations 0x215
1883 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1888 run_test 27o "create file with all full OSTs (should error)"
1890 function create_and_checktime() {
1895 for ((i=0; i < $loops; i++)); do
1896 local start=$SECONDS
1897 multiop $fname-$i Oc
1898 ((SECONDS-start < TIMEOUT)) ||
1899 error "creation took " $((SECONDS-$start)) && return 1
1904 local mdts=$(comma_list $(mdts_nodes))
1906 [ $MDS1_VERSION -lt $(version_code 2.13.57) ] &&
1907 skip "Need MDS version at least 2.13.57"
1909 local f0=$DIR/${tfile}-0
1910 local f1=$DIR/${tfile}-1
1912 wait_delete_completed
1914 # refill precreated objects
1915 $LFS setstripe -i0 -c1 $f0
1917 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1918 # force QoS allocation policy
1919 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1920 stack_trap "do_nodes $mdts $LCTL set_param \
1921 lov.*.qos_threshold_rr=$saved" EXIT
1924 # one OST is unavailable, but still have few objects preallocated
1926 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1927 rm -rf $f1 $DIR/$tdir*" EXIT
1929 for ((i=0; i < 7; i++)); do
1930 mkdir $DIR/$tdir$i || error "can't create dir"
1931 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1932 error "can't set striping"
1934 for ((i=0; i < 7; i++)); do
1935 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1939 run_test 27oo "don't let few threads to reserve too many objects"
1942 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1944 remote_mds_nodsh && skip "remote MDS with nodsh"
1945 remote_ost_nodsh && skip "remote OST with nodsh"
1948 rm -f $DIR/$tdir/$tfile
1949 test_mkdir $DIR/$tdir
1951 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1952 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1953 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1955 exhaust_precreations 0 0x80000215
1956 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1957 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1958 $LFS getstripe $DIR/$tdir/$tfile
1962 run_test 27p "append to a truncated file with some full OSTs"
1965 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1967 remote_mds_nodsh && skip "remote MDS with nodsh"
1968 remote_ost_nodsh && skip "remote OST with nodsh"
1971 rm -f $DIR/$tdir/$tfile
1973 mkdir_on_mdt0 $DIR/$tdir
1974 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1975 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1976 error "truncate $DIR/$tdir/$tfile failed"
1977 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1979 exhaust_all_precreations 0x215
1981 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1982 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1986 run_test 27q "append to truncated file with all OSTs full (should error)"
1989 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1991 remote_mds_nodsh && skip "remote MDS with nodsh"
1992 remote_ost_nodsh && skip "remote OST with nodsh"
1995 rm -f $DIR/$tdir/$tfile
1996 exhaust_precreations 0 0x80000215
1998 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
2002 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
2004 test_27s() { # bug 10725
2005 test_mkdir $DIR/$tdir
2006 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
2007 local stripe_count=0
2008 [ $OSTCOUNT -eq 1 ] || stripe_count=2
2009 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
2010 error "stripe width >= 2^32 succeeded" || true
2013 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
2015 test_27t() { # bug 10864
2020 $WLFS getstripe $tfile
2023 run_test 27t "check that utils parse path correctly"
2025 test_27u() { # bug 4900
2026 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2027 remote_mds_nodsh && skip "remote MDS with nodsh"
2030 local list=$(comma_list $(mdts_nodes))
2032 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
2033 do_nodes $list $LCTL set_param fail_loc=0x139
2034 test_mkdir -p $DIR/$tdir
2035 stack_trap "simple_cleanup_common 1000"
2036 createmany -o $DIR/$tdir/$tfile 1000
2037 do_nodes $list $LCTL set_param fail_loc=0
2039 TLOG=$TMP/$tfile.getstripe
2040 $LFS getstripe $DIR/$tdir > $TLOG
2041 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
2042 [[ $OBJS -gt 0 ]] &&
2043 error "$OBJS objects created on OST-0. See $TLOG" ||
2046 run_test 27u "skip object creation on OSC w/o objects"
2048 test_27v() { # bug 4900
2049 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2050 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2051 remote_mds_nodsh && skip "remote MDS with nodsh"
2052 remote_ost_nodsh && skip "remote OST with nodsh"
2054 exhaust_all_precreations 0x215
2057 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2059 touch $DIR/$tdir/$tfile
2060 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2062 for (( i=1; i < OSTCOUNT; i++ )); do
2063 do_facet ost$i lctl set_param fail_loc=0x705
2065 local START=`date +%s`
2066 createmany -o $DIR/$tdir/$tfile 32
2068 local FINISH=`date +%s`
2069 local TIMEOUT=`lctl get_param -n timeout`
2070 local PROCESS=$((FINISH - START))
2071 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2072 error "$FINISH - $START >= $TIMEOUT / 2"
2073 sleep $((TIMEOUT / 2 - PROCESS))
2076 run_test 27v "skip object creation on slow OST"
2078 test_27w() { # bug 10997
2079 test_mkdir $DIR/$tdir
2080 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2081 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2082 error "stripe size $size != 65536" || true
2083 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2084 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2086 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2089 [[ $OSTCOUNT -lt 2 ]] &&
2090 skip_env "skipping multiple stripe count/offset test"
2092 test_mkdir $DIR/$tdir
2093 for i in $(seq 1 $OSTCOUNT); do
2095 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2096 error "setstripe -c $i -i $offset failed"
2097 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2098 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2099 [ $count -ne $i ] && error "stripe count $count != $i" || true
2100 [ $index -ne $offset ] &&
2101 error "stripe offset $index != $offset" || true
2104 run_test 27wa "check $LFS setstripe -c -i options"
2107 remote_ost_nodsh && skip "remote OST with nodsh"
2108 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2111 OFFSET=$(($OSTCOUNT - 1))
2113 local OST=$(ostname_from_index $OSTIDX)
2115 test_mkdir $DIR/$tdir
2116 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2117 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2119 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2120 for i in $(seq 0 $OFFSET); do
2121 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2122 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2123 error "OST0 was degraded but new created file still use it"
2125 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2127 run_test 27x "create files while OST0 is degraded"
2130 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2131 remote_mds_nodsh && skip "remote MDS with nodsh"
2132 remote_ost_nodsh && skip "remote OST with nodsh"
2133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2135 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2136 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2137 osp.$mdtosc.prealloc_last_id)
2138 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2139 osp.$mdtosc.prealloc_next_id)
2140 local fcount=$((last_id - next_id))
2141 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2142 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2144 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2145 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2146 local OST_DEACTIVE_IDX=-1
2151 for OSC in $MDS_OSCS; do
2152 OST=$(osc_to_ost $OSC)
2153 OSTIDX=$(index_from_ostuuid $OST)
2154 if [ $OST_DEACTIVE_IDX == -1 ]; then
2155 OST_DEACTIVE_IDX=$OSTIDX
2157 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2158 echo $OSC "is Deactivated:"
2159 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2163 OSTIDX=$(index_from_ostuuid $OST)
2164 test_mkdir $DIR/$tdir
2165 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2167 for OSC in $MDS_OSCS; do
2168 OST=$(osc_to_ost $OSC)
2169 OSTIDX=$(index_from_ostuuid $OST)
2170 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2171 echo $OST "is degraded:"
2172 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2173 obdfilter.$OST.degraded=1
2178 createmany -o $DIR/$tdir/$tfile $fcount
2180 for OSC in $MDS_OSCS; do
2181 OST=$(osc_to_ost $OSC)
2182 OSTIDX=$(index_from_ostuuid $OST)
2183 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2184 echo $OST "is recovered from degraded:"
2185 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2186 obdfilter.$OST.degraded=0
2188 do_facet $SINGLEMDS lctl --device %$OSC activate
2192 # all osp devices get activated, hence -1 stripe count restored
2193 local stripe_count=0
2195 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2196 # devices get activated.
2198 $LFS setstripe -c -1 $DIR/$tfile
2199 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2201 [ $stripe_count -ne $OSTCOUNT ] &&
2202 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2205 run_test 27y "create files while OST0 is degraded and the rest inactive"
2211 lmm_count=$($LFS getstripe -c $1)
2212 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2213 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2215 local old_ifs="$IFS"
2217 fid=($($LFS path2fid $1))
2220 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2221 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2223 # compare lmm_seq and lu_fid->f_seq
2224 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2225 # compare lmm_object_id and lu_fid->oid
2226 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2228 # check the trusted.fid attribute of the OST objects of the file
2229 local have_obdidx=false
2231 $LFS getstripe $1 | while read obdidx oid hex seq; do
2232 # skip lines up to and including "obdidx"
2233 [ -z "$obdidx" ] && break
2234 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2235 $have_obdidx || continue
2237 local ost=$((obdidx + 1))
2238 local dev=$(ostdevname $ost)
2241 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2243 seq=$(echo $seq | sed -e "s/^0x//g")
2244 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2245 oid_hex=$(echo $oid)
2247 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2249 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2253 # Don't unmount/remount the OSTs if we don't need to do that.
2254 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2255 # update too, until that use mount/ll_decode_filter_fid/mount.
2256 # Re-enable when debugfs will understand new filter_fid.
2258 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2259 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2260 $dev 2>/dev/null" | grep "parent=")
2262 if [ -z "$ff" ]; then
2264 mount_fstype ost$ost
2265 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2266 $(facet_mntpt ost$ost)/$obj_file)
2267 unmount_fstype ost$ost
2268 start ost$ost $dev $OST_MOUNT_OPTS
2272 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2274 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2276 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2277 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2279 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2280 # stripe_size=1048576 component_id=1 component_start=0 \
2281 # component_end=33554432
2282 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2283 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2284 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2286 if grep -q 'stripe=' <<<$ff; then
2287 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2289 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2290 # into f_ver in this case. See comment on ff_parent.
2291 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2294 # compare lmm_seq and filter_fid->ff_parent.f_seq
2295 [ $ff_pseq = $lmm_seq ] ||
2296 error "FF parent SEQ $ff_pseq != $lmm_seq"
2297 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2298 [ $ff_poid = $lmm_oid ] ||
2299 error "FF parent OID $ff_poid != $lmm_oid"
2300 (($ff_pstripe == $stripe_nr)) ||
2301 error "FF stripe $ff_pstripe != $stripe_nr"
2303 stripe_nr=$((stripe_nr + 1))
2304 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2306 if grep -q 'stripe_count=' <<<$ff; then
2307 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2308 -e 's/ .*//' <<<$ff)
2309 [ $lmm_count = $ff_scnt ] ||
2310 error "FF stripe count $lmm_count != $ff_scnt"
2316 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2317 remote_ost_nodsh && skip "remote OST with nodsh"
2319 test_mkdir $DIR/$tdir
2320 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2321 { error "setstripe -c -1 failed"; return 1; }
2322 # We need to send a write to every object to get parent FID info set.
2323 # This _should_ also work for setattr, but does not currently.
2324 # touch $DIR/$tdir/$tfile-1 ||
2325 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2326 { error "dd $tfile-1 failed"; return 2; }
2327 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2328 { error "setstripe -c -1 failed"; return 3; }
2329 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2330 { error "dd $tfile-2 failed"; return 4; }
2332 # make sure write RPCs have been sent to OSTs
2335 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2336 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2338 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2340 test_27A() { # b=19102
2341 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2343 save_layout_restore_at_exit $MOUNT
2344 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2345 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2346 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2347 local default_size=$($LFS getstripe -S $MOUNT)
2348 local default_offset=$($LFS getstripe -i $MOUNT)
2349 local dsize=$(do_facet $SINGLEMDS \
2350 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2351 [ $default_size -eq $dsize ] ||
2352 error "stripe size $default_size != $dsize"
2353 [ $default_offset -eq -1 ] ||
2354 error "stripe offset $default_offset != -1"
2356 run_test 27A "check filesystem-wide default LOV EA values"
2358 test_27B() { # LU-2523
2359 test_mkdir $DIR/$tdir
2360 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2362 # open f1 with O_LOV_DELAY_CREATE
2364 # call setstripe ioctl on open file descriptor for f1
2366 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2370 # open f1 with O_LOV_DELAY_CREATE
2372 # call setstripe ioctl on open file descriptor for f1
2374 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2376 # Allow multiop to fail in imitation of NFS's busted semantics.
2379 run_test 27B "call setstripe on open unlinked file/rename victim"
2381 # 27C family tests full striping and overstriping
2382 test_27Ca() { #LU-2871
2383 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2391 test_mkdir $DIR/$tdir
2393 for i in $(seq 0 $((OSTCOUNT - 1))); do
2394 # set stripe across all OSTs starting from OST$i
2395 $LFS setstripe -i $i -c -1 $tfile$i
2396 # get striping information
2397 ost_idx=($($LFS getstripe $tfile$i |
2398 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2399 echo "OST Index: ${ost_idx[*]}"
2402 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2403 error "${#ost_idx[@]} != $OSTCOUNT"
2405 for index in $(seq 0 $((OSTCOUNT - 1))); do
2407 for j in "${ost_idx[@]}"; do
2408 if [ $index -eq $j ]; then
2414 error "Can not find $index in ${ost_idx[*]}"
2418 run_test 27Ca "check full striping across all OSTs"
2421 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2422 skip "server does not support overstriping"
2423 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2424 skip_env "too many osts, skipping"
2426 test_mkdir -p $DIR/$tdir
2427 local setcount=$(($OSTCOUNT * 2))
2428 [ $setcount -lt 160 ] || large_xattr_enabled ||
2429 skip_env "ea_inode feature disabled"
2431 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2432 error "setstripe failed"
2434 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2435 [ $count -eq $setcount ] ||
2436 error "stripe count $count, should be $setcount"
2438 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2439 error "overstriped should be set in pattern"
2441 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2444 run_test 27Cb "more stripes than OSTs with -C"
2447 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2448 skip "server does not support overstriping"
2449 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2451 test_mkdir -p $DIR/$tdir
2452 local setcount=$(($OSTCOUNT - 1))
2454 [ $setcount -lt 160 ] || large_xattr_enabled ||
2455 skip_env "ea_inode feature disabled"
2457 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2458 error "setstripe failed"
2460 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2461 [ $count -eq $setcount ] ||
2462 error "stripe count $count, should be $setcount"
2464 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2465 error "overstriped should not be set in pattern"
2467 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2470 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2473 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2474 skip "server does not support overstriping"
2475 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2476 large_xattr_enabled || skip_env "ea_inode feature disabled"
2478 test_mkdir -p $DIR/$tdir
2479 local setcount=$LOV_MAX_STRIPE_COUNT
2481 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2482 error "setstripe failed"
2484 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2485 [ $count -eq $setcount ] ||
2486 error "stripe count $count, should be $setcount"
2488 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2489 error "overstriped should be set in pattern"
2491 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2494 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2496 run_test 27Cd "test maximum stripe count"
2499 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2500 skip "server does not support overstriping"
2501 test_mkdir -p $DIR/$tdir
2503 pool_add $TESTNAME || error "Pool creation failed"
2504 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2508 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2509 error "setstripe failed"
2511 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2512 [ $count -eq $setcount ] ||
2513 error "stripe count $count, should be $setcount"
2515 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2516 error "overstriped should be set in pattern"
2518 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2521 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2523 run_test 27Ce "test pool with overstriping"
2526 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2527 skip "server does not support overstriping"
2528 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2529 skip_env "too many osts, skipping"
2531 test_mkdir -p $DIR/$tdir
2533 local setcount=$(($OSTCOUNT * 2))
2534 [ $setcount -lt 160 ] || large_xattr_enabled ||
2535 skip_env "ea_inode feature disabled"
2537 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2538 error "setstripe failed"
2540 echo 1 > $DIR/$tdir/$tfile
2542 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2543 [ $count -eq $setcount ] ||
2544 error "stripe count $count, should be $setcount"
2546 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2547 error "overstriped should be set in pattern"
2549 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2552 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2554 run_test 27Cf "test default inheritance with overstriping"
2557 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2558 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2559 remote_mds_nodsh && skip "remote MDS with nodsh"
2561 local POOL=${POOL:-testpool}
2563 local last_ost=$(($OSTCOUNT - 1))
2565 local ost_list=$(seq $first_ost $ost_step $last_ost)
2566 local ost_range="$first_ost $last_ost $ost_step"
2568 test_mkdir $DIR/$tdir
2569 pool_add $POOL || error "pool_add failed"
2570 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2573 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2575 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2576 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2577 skip27D+=" -s 30,31"
2578 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2579 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2580 skip27D+=" -s 32,33"
2581 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2583 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2584 error "llapi_layout_test failed"
2586 destroy_test_pools || error "destroy test pools failed"
2588 run_test 27D "validate llapi_layout API"
2590 # Verify that default_easize is increased from its initial value after
2591 # accessing a widely striped file.
2593 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2594 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2595 skip "client does not have LU-3338 fix"
2597 # 72 bytes is the minimum space required to store striping
2598 # information for a file striped across one OST:
2599 # (sizeof(struct lov_user_md_v3) +
2600 # sizeof(struct lov_user_ost_data_v1))
2602 $LCTL set_param -n llite.*.default_easize $min_easize ||
2603 error "lctl set_param failed"
2604 local easize=$($LCTL get_param -n llite.*.default_easize)
2606 [ $easize -eq $min_easize ] ||
2607 error "failed to set default_easize"
2609 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2610 error "setstripe failed"
2611 # In order to ensure stat() call actually talks to MDS we need to
2612 # do something drastic to this file to shake off all lock, e.g.
2613 # rename it (kills lookup lock forcing cache cleaning)
2614 mv $DIR/$tfile $DIR/${tfile}-1
2615 ls -l $DIR/${tfile}-1
2618 easize=$($LCTL get_param -n llite.*.default_easize)
2620 [ $easize -gt $min_easize ] ||
2621 error "default_easize not updated"
2623 run_test 27E "check that default extended attribute size properly increases"
2625 test_27F() { # LU-5346/LU-7975
2626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2627 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2628 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2629 skip "Need MDS version at least 2.8.51"
2630 remote_ost_nodsh && skip "remote OST with nodsh"
2632 test_mkdir $DIR/$tdir
2634 $LFS setstripe -c 2 $DIR/$tdir
2636 # stop all OSTs to reproduce situation for LU-7975 ticket
2637 for num in $(seq $OSTCOUNT); do
2641 # open/create f0 with O_LOV_DELAY_CREATE
2642 # truncate f0 to a non-0 size
2644 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2646 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2647 # open/write it again to force delayed layout creation
2648 cat /etc/hosts > $DIR/$tdir/f0 &
2652 for num in $(seq $OSTCOUNT); do
2653 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2654 error "ost$num failed to start"
2657 wait $catpid || error "cat failed"
2659 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2660 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2661 error "wrong stripecount"
2664 run_test 27F "Client resend delayed layout creation with non-zero size"
2666 test_27G() { #LU-10629
2667 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2668 skip "Need MDS version at least 2.11.51"
2669 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2670 remote_mds_nodsh && skip "remote MDS with nodsh"
2671 local POOL=${POOL:-testpool}
2672 local ostrange="0 0 1"
2674 test_mkdir $DIR/$tdir
2675 touch $DIR/$tdir/$tfile.nopool
2676 pool_add $POOL || error "pool_add failed"
2677 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2678 $LFS setstripe -p $POOL $DIR/$tdir
2680 local pool=$($LFS getstripe -p $DIR/$tdir)
2682 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2683 touch $DIR/$tdir/$tfile.default
2684 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2685 $LFS find $DIR/$tdir -type f --pool $POOL
2686 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2687 [[ "$found" == "2" ]] ||
2688 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2690 $LFS setstripe -d $DIR/$tdir
2692 pool=$($LFS getstripe -p -d $DIR/$tdir)
2694 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2696 run_test 27G "Clear OST pool from stripe"
2699 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2700 skip "Need MDS version newer than 2.11.54"
2701 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2702 test_mkdir $DIR/$tdir
2703 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2704 touch $DIR/$tdir/$tfile
2705 $LFS getstripe -c $DIR/$tdir/$tfile
2706 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2707 error "two-stripe file doesn't have two stripes"
2709 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2710 $LFS getstripe -y $DIR/$tdir/$tfile
2711 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2712 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2713 error "expected l_ost_idx: [02]$ not matched"
2715 # make sure ost list has been cleared
2716 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2717 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2718 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2720 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2722 run_test 27H "Set specific OSTs stripe"
2725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2726 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2727 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2728 skip "Need MDS version newer than 2.12.52"
2729 local pool=$TESTNAME
2730 local ostrange="1 1 1"
2732 save_layout_restore_at_exit $MOUNT
2733 $LFS setstripe -c 2 -i 0 $MOUNT
2734 pool_add $pool || error "pool_add failed"
2735 pool_add_targets $pool $ostrange ||
2736 error "pool_add_targets failed"
2737 test_mkdir $DIR/$tdir
2738 $LFS setstripe -p $pool $DIR/$tdir
2739 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2740 $LFS getstripe $DIR/$tdir/$tfile
2742 run_test 27I "check that root dir striping does not break parent dir one"
2745 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2746 skip "Need MDS version newer than 2.12.51"
2748 test_mkdir $DIR/$tdir
2749 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2750 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2752 # create foreign file (raw way)
2753 ! $LFS setstripe --flags 0xda08 $DIR/$tdir/$tfile ||
2754 error "creating $tfile w/ hex flags w/o --foreign should fail"
2756 ! $LFS setstripe --foreign --flags foo \
2757 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2758 error "creating $tfile with '--flags foo' should fail"
2760 ! $LFS setstripe --foreign --flags 0xffffffff \
2761 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tfile ||
2762 error "creating $tfile w/ 0xffffffff flags should fail"
2764 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2765 -t 1 -F 0xda08 || error "create_foreign_file failed"
2767 # verify foreign file (raw way)
2768 parse_foreign_file -f $DIR/$tdir/$tfile |
2769 grep "lov_foreign_magic: 0x0BD70BD0" ||
2770 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2771 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2772 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2773 parse_foreign_file -f $DIR/$tdir/$tfile |
2774 grep "lov_foreign_size: 73" ||
2775 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2776 parse_foreign_file -f $DIR/$tdir/$tfile |
2777 grep "lov_foreign_type: 1" ||
2778 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2779 parse_foreign_file -f $DIR/$tdir/$tfile |
2780 grep "lov_foreign_flags: 0x0000DA08" ||
2781 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2782 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2783 grep "lov_foreign_value: 0x" |
2784 sed -e 's/lov_foreign_value: 0x//')
2785 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2786 [[ $lov = ${lov2// /} ]] ||
2787 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2789 # create foreign file (lfs + API)
2790 $LFS setstripe --foreign=none --flags 0xda08 \
2791 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2792 error "$DIR/$tdir/${tfile}2: create failed"
2794 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2795 grep "lfm_magic:.*0x0BD70BD0" ||
2796 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2797 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2798 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2799 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2800 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*none" ||
2801 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2802 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2803 grep "lfm_flags:.*0x0000DA08" ||
2804 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2805 $LFS getstripe $DIR/$tdir/${tfile}2 |
2806 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2807 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2809 # modify striping should fail
2810 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2811 error "$DIR/$tdir/$tfile: setstripe should fail"
2812 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2813 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2816 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2817 cat $DIR/$tdir/${tfile}2 &&
2818 error "$DIR/$tdir/${tfile}2: read should fail"
2819 cat /etc/passwd > $DIR/$tdir/$tfile &&
2820 error "$DIR/$tdir/$tfile: write should fail"
2821 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2822 error "$DIR/$tdir/${tfile}2: write should fail"
2825 chmod 222 $DIR/$tdir/$tfile ||
2826 error "$DIR/$tdir/$tfile: chmod failed"
2827 chmod 222 $DIR/$tdir/${tfile}2 ||
2828 error "$DIR/$tdir/${tfile}2: chmod failed"
2831 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2832 error "$DIR/$tdir/$tfile: chown failed"
2833 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2834 error "$DIR/$tdir/${tfile}2: chown failed"
2836 # rename should work
2837 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2838 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2839 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2840 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2842 #remove foreign file
2843 rm $DIR/$tdir/${tfile}.new ||
2844 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2845 rm $DIR/$tdir/${tfile}2.new ||
2846 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2848 run_test 27J "basic ops on file with foreign LOV"
2851 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2852 skip "Need MDS version newer than 2.12.49"
2854 test_mkdir $DIR/$tdir
2855 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2856 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2858 # create foreign dir (raw way)
2859 ! $LFS setdirstripe --flags 0xda08 $DIR/$tdir/$tdir ||
2860 error "creating $tdir w/ hex flags w/o --foreign should fail"
2862 ! $LFS setdirstripe --foreign --flags foo \
2863 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2864 error "creating $tdir with '--flags foo' should fail"
2866 ! $LFS setdirstripe --foreign --flags 0xffffffff \
2867 --xattr ${uuid1}@${uuid2} $DIR/$tdir/$tdir ||
2868 error "creating $tdir w/ 0xffffffff flags should fail"
2870 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2871 error "create_foreign_dir FAILED"
2873 # verify foreign dir (raw way)
2874 parse_foreign_dir -d $DIR/$tdir/$tdir |
2875 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2876 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2877 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2878 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2879 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2880 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2881 parse_foreign_dir -d $DIR/$tdir/$tdir |
2882 grep "lmv_foreign_flags: 55813$" ||
2883 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2884 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2885 grep "lmv_foreign_value: 0x" |
2886 sed 's/lmv_foreign_value: 0x//')
2887 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2889 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2891 # create foreign dir (lfs + API)
2892 $LFS mkdir --foreign=none --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2893 $DIR/$tdir/${tdir}2 ||
2894 error "$DIR/$tdir/${tdir}2: create failed"
2896 $LFS getdirstripe -v $DIR/$tdir/${tdir}2
2898 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2899 grep "lfm_magic:.*0x0CD50CD0" ||
2900 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2901 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2902 # - sizeof(lfm_type) - sizeof(lfm_flags)
2903 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2904 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2905 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*none" ||
2906 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2907 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2908 grep "lfm_flags:.*0x0000DA05" ||
2909 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2910 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2911 grep "lfm_value.*${uuid1}@${uuid2}" ||
2912 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2914 # file create in dir should fail
2915 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
2916 touch $DIR/$tdir/${tdir}2/$tfile &&
2917 error "$DIR/${tdir}2: file create should fail"
2920 chmod 777 $DIR/$tdir/$tdir ||
2921 error "$DIR/$tdir: chmod failed"
2922 chmod 777 $DIR/$tdir/${tdir}2 ||
2923 error "$DIR/${tdir}2: chmod failed"
2926 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2927 error "$DIR/$tdir: chown failed"
2928 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2929 error "$DIR/${tdir}2: chown failed"
2931 # rename should work
2932 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2933 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2934 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2935 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2938 rmdir $DIR/$tdir/${tdir}.new ||
2939 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2940 rmdir $DIR/$tdir/${tdir}2.new ||
2941 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2943 run_test 27K "basic ops on dir with foreign LMV"
2946 remote_mds_nodsh && skip "remote MDS with nodsh"
2948 local POOL=${POOL:-$TESTNAME}
2950 pool_add $POOL || error "pool_add failed"
2952 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2953 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2954 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2956 run_test 27L "lfs pool_list gives correct pool name"
2959 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2960 skip "Need MDS version >= than 2.12.57"
2961 remote_mds_nodsh && skip "remote MDS with nodsh"
2962 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2964 # Set default striping on directory
2967 local mdts=$(comma_list $(mdts_nodes))
2969 # if we run against a 2.12 server which lacks overstring support
2970 # then the connect_flag will not report overstriping, even if client
2972 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
2973 stripe_opt="-C $setcount"
2974 elif (( $OSTCOUNT >= $setcount )); then
2975 stripe_opt="-c $setcount"
2977 skip "server does not support overstriping"
2980 test_mkdir $DIR/$tdir
2982 # Validate existing append_* params and ensure restore
2983 local pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
2984 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
2985 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
2987 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2988 ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count"
2989 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1"
2991 $LFS setstripe $stripe_opt $DIR/$tdir
2993 echo 1 > $DIR/$tdir/${tfile}.1
2994 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2995 [ $count -eq $setcount ] ||
2996 error "(1) stripe count $count, should be $setcount"
2998 local appendcount=$orig_count
2999 echo 1 >> $DIR/$tdir/${tfile}.2_append
3000 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
3001 [ $count -eq $appendcount ] ||
3002 error "(2)stripe count $count, should be $appendcount for append"
3004 # Disable O_APPEND striping, verify it works
3005 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3007 # Should now get the default striping, which is 4
3009 echo 1 >> $DIR/$tdir/${tfile}.3_append
3010 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
3011 [ $count -eq $setcount ] ||
3012 error "(3) stripe count $count, should be $setcount"
3014 # Try changing the stripe count for append files
3015 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3017 # Append striping is now 2 (directory default is still 4)
3019 echo 1 >> $DIR/$tdir/${tfile}.4_append
3020 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
3021 [ $count -eq $appendcount ] ||
3022 error "(4) stripe count $count, should be $appendcount for append"
3024 # Test append stripe count of -1
3025 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
3026 appendcount=$OSTCOUNT
3027 echo 1 >> $DIR/$tdir/${tfile}.5
3028 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
3029 [ $count -eq $appendcount ] ||
3030 error "(5) stripe count $count, should be $appendcount for append"
3032 # Set append striping back to default of 1
3033 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
3035 # Try a new default striping, PFL + DOM
3036 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
3038 # Create normal DOM file, DOM returns stripe count == 0
3040 touch $DIR/$tdir/${tfile}.6
3041 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
3042 [ $count -eq $setcount ] ||
3043 error "(6) stripe count $count, should be $setcount"
3047 echo 1 >> $DIR/$tdir/${tfile}.7_append
3048 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
3049 [ $count -eq $appendcount ] ||
3050 error "(7) stripe count $count, should be $appendcount for append"
3052 # Clean up DOM layout
3053 $LFS setstripe -d $DIR/$tdir
3055 save_layout_restore_at_exit $MOUNT
3056 # Now test that append striping works when layout is from root
3057 $LFS setstripe -c 2 $MOUNT
3058 # Make a special directory for this
3059 mkdir $DIR/${tdir}/${tdir}.2
3061 # Verify for normal file
3063 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
3064 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
3065 [ $count -eq $setcount ] ||
3066 error "(8) stripe count $count, should be $setcount"
3069 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
3070 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
3071 [ $count -eq $appendcount ] ||
3072 error "(9) stripe count $count, should be $appendcount for append"
3074 # Now test O_APPEND striping with pools
3075 pool_add $TESTNAME || error "pool creation failed"
3076 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
3077 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
3079 echo 1 >> $DIR/$tdir/${tfile}.10_append
3081 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
3082 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
3084 # Check that count is still correct
3086 echo 1 >> $DIR/$tdir/${tfile}.11_append
3087 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
3088 [ $count -eq $appendcount ] ||
3089 error "(11) stripe count $count, should be $appendcount for append"
3091 # Disable O_APPEND stripe count, verify pool works separately
3092 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
3094 echo 1 >> $DIR/$tdir/${tfile}.12_append
3096 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
3097 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
3099 # Remove pool setting, verify it's not applied
3100 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3102 echo 1 >> $DIR/$tdir/${tfile}.13_append
3104 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3105 [ "$pool" = "" ] || error "(13) pool found: $pool"
3107 run_test 27M "test O_APPEND striping"
3110 combined_mgs_mds && skip "needs separate MGS/MDT"
3112 pool_add $TESTNAME || error "pool_add failed"
3113 do_facet mgs "$LCTL pool_list $FSNAME" |
3114 grep -Fx "${FSNAME}.${TESTNAME}" ||
3115 error "lctl pool_list on MGS failed"
3117 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3119 clean_foreign_symlink() {
3121 lctl set_param llite/$FSNAME-*/foreign_symlink_enable=0
3122 for i in $DIR/$tdir/* ; do
3123 $LFS unlink_foreign $i || true
3128 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
3129 skip "Need MDS version newer than 2.12.51"
3131 test_mkdir $DIR/$tdir
3132 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3133 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3135 trap clean_foreign_symlink EXIT
3137 # enable foreign_symlink behaviour
3138 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3140 # foreign symlink LOV format is a partial path by default
3142 # create foreign file (lfs + API)
3143 $LFS setstripe --foreign=symlink --flags 0xda05 \
3144 -x "${uuid1}/${uuid2}" --mode 0600 $DIR/$tdir/${tfile} ||
3145 error "$DIR/$tdir/${tfile}: create failed"
3147 $LFS getstripe -v $DIR/$tdir/${tfile} |
3148 grep "lfm_magic:.*0x0BD70BD0" ||
3149 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign magic"
3150 $LFS getstripe -v $DIR/$tdir/${tfile} | grep "lfm_type:.*symlink" ||
3151 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign type"
3152 $LFS getstripe -v $DIR/$tdir/${tfile} |
3153 grep "lfm_flags:.*0x0000DA05" ||
3154 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign flags"
3155 $LFS getstripe $DIR/$tdir/${tfile} |
3156 grep "lfm_value:.*${uuid1}/${uuid2}" ||
3157 error "$DIR/$tdir/${tfile}: invalid LOV EA foreign value"
3159 # modify striping should fail
3160 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
3161 error "$DIR/$tdir/$tfile: setstripe should fail"
3163 # R/W should fail ("/{foreign_symlink_prefix}/${uuid1}/" missing)
3164 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
3165 cat /etc/passwd > $DIR/$tdir/$tfile &&
3166 error "$DIR/$tdir/$tfile: write should fail"
3168 # rename should succeed
3169 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
3170 error "$DIR/$tdir/$tfile: rename has failed"
3172 #remove foreign_symlink file should fail
3173 rm $DIR/$tdir/${tfile}.new &&
3174 error "$DIR/$tdir/${tfile}.new: remove of foreign_symlink file should fail"
3177 mkdir /tmp/${uuid1} ||
3178 error "/tmp/${uuid1}: mkdir has failed"
3179 echo FOOFOO > /tmp/${uuid1}/${uuid2} ||
3180 error "/tmp/${uuid1}/${uuid2}: echo has failed"
3181 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3182 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tfile}.new ||
3183 error "$DIR/$tdir/${tfile}.new: not seen as a symlink"
3184 #read should succeed now
3185 cat $DIR/$tdir/${tfile}.new | grep FOOFOO ||
3186 error "$DIR/$tdir/${tfile}.new: symlink resolution has failed"
3187 #write should succeed now
3188 cat /etc/passwd > $DIR/$tdir/${tfile}.new ||
3189 error "$DIR/$tdir/${tfile}.new: write should succeed"
3190 diff /etc/passwd $DIR/$tdir/${tfile}.new ||
3191 error "$DIR/$tdir/${tfile}.new: diff has failed"
3192 diff /etc/passwd /tmp/${uuid1}/${uuid2} ||
3193 error "/tmp/${uuid1}/${uuid2}: diff has failed"
3195 #check that getstripe still works
3196 $LFS getstripe $DIR/$tdir/${tfile}.new ||
3197 error "$DIR/$tdir/${tfile}.new: getstripe should still work with foreign_symlink enabled"
3199 # chmod should still succeed
3200 chmod 644 $DIR/$tdir/${tfile}.new ||
3201 error "$DIR/$tdir/${tfile}.new: chmod has failed"
3203 # chown should still succeed
3204 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}.new ||
3205 error "$DIR/$tdir/${tfile}.new: chown has failed"
3207 # rename should still succeed
3208 mv $DIR/$tdir/${tfile}.new $DIR/$tdir/${tfile} ||
3209 error "$DIR/$tdir/${tfile}.new: rename has failed"
3211 #remove foreign_symlink file should still fail
3212 rm $DIR/$tdir/${tfile} &&
3213 error "$DIR/$tdir/${tfile}: remove of foreign_symlink file should fail"
3215 #use special ioctl() to unlink foreign_symlink file
3216 $LFS unlink_foreign $DIR/$tdir/${tfile} ||
3217 error "$DIR/$tdir/$tfile: unlink/ioctl failed"
3220 run_test 27O "basic ops on foreign file of symlink type"
3223 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
3224 skip "Need MDS version newer than 2.12.49"
3226 test_mkdir $DIR/$tdir
3227 local uuid1=$(cat /proc/sys/kernel/random/uuid)
3228 local uuid2=$(cat /proc/sys/kernel/random/uuid)
3230 trap clean_foreign_symlink EXIT
3232 # enable foreign_symlink behaviour
3233 $LCTL set_param llite/$FSNAME-*/foreign_symlink_enable=1
3235 # foreign symlink LMV format is a partial path by default
3237 # create foreign dir (lfs + API)
3238 $LFS mkdir --foreign=symlink --xattr="${uuid1}/${uuid2}" \
3239 --flags=0xda05 --mode 0750 $DIR/$tdir/${tdir} ||
3240 error "$DIR/$tdir/${tdir}: create failed"
3242 $LFS getdirstripe -v $DIR/$tdir/${tdir}
3244 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3245 grep "lfm_magic:.*0x0CD50CD0" ||
3246 error "$DIR/$tdir/${tdir}: invalid LMV EA magic"
3247 $LFS getdirstripe -v $DIR/$tdir/${tdir} | grep "lfm_type:.*symlink" ||
3248 error "$DIR/$tdir/${tdir}: invalid LMV EA type"
3249 $LFS getdirstripe -v $DIR/$tdir/${tdir} |
3250 grep "lfm_flags:.*0x0000DA05" ||
3251 error "$DIR/$tdir/${tdir}: invalid LMV EA flags"
3252 $LFS getdirstripe $DIR/$tdir/${tdir} |
3253 grep "lfm_value.*${uuid1}/${uuid2}" ||
3254 error "$DIR/$tdir/${tdir}: invalid LMV EA value"
3256 # file create in dir should fail
3257 # ("/{foreign_symlink_prefix}/${uuid1}/${uuid2}/" missing)
3258 touch $DIR/$tdir/$tdir/$tfile && error "$DIR/$tdir: file create should fail"
3260 # rename should succeed
3261 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
3262 error "$DIR/$tdir/$tdir: rename of foreign_symlink dir has failed"
3264 #remove foreign_symlink dir should fail
3265 rmdir $DIR/$tdir/${tdir}.new &&
3266 error "$DIR/$tdir/${tdir}.new: remove of foreign_symlink dir should fail"
3269 mkdir -p /tmp/${uuid1}/${uuid2} ||
3270 error "/tmp/${uuid1}/${uuid2}: mkdir has failed"
3271 echo FOOFOO > /tmp/${uuid1}/${uuid2}/foo ||
3272 error "/tmp/${uuid1}/${uuid2}/foo: echo has failed"
3273 $LCTL set_param llite/$FSNAME-*/foreign_symlink_prefix=/tmp/
3274 $CHECKSTAT -t link -l /tmp/${uuid1}/${uuid2} $DIR/$tdir/${tdir}.new ||
3275 error "$DIR/$tdir/${tdir}.new: not seen as a symlink"
3276 cat $DIR/$tdir/${tdir}.new/foo | grep FOOFOO ||
3277 error "$DIR/$tdir/${tdir}.new: symlink resolution has failed"
3279 #check that getstripe fails now that foreign_symlink enabled
3280 $LFS getdirstripe $DIR/$tdir/${tdir}.new ||
3281 error "$DIR/$tdir/${tdir}.new: getdirstripe should still work with foreign_symlink enabled"
3283 # file create in dir should work now
3284 cp /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3285 error "$DIR/$tdir/${tdir}.new/$tfile: file create should fail"
3286 diff /etc/passwd $DIR/$tdir/${tdir}.new/$tfile ||
3287 error "$DIR/$tdir/${tdir}.new/$tfile: diff has failed"
3288 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3289 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3291 # chmod should still succeed
3292 chmod 755 $DIR/$tdir/${tdir}.new ||
3293 error "$DIR/$tdir/${tdir}.new: chmod has failed"
3295 # chown should still succeed
3296 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}.new ||
3297 error "$DIR/$tdir/${tdir}.new: chown has failed"
3299 # rename should still succeed
3300 mv $DIR/$tdir/${tdir}.new $DIR/$tdir/${tdir} ||
3301 error "$DIR/$tdir/${tdir}.new: rename of foreign_symlink dir has failed"
3303 #remove foreign_symlink dir should still fail
3304 rmdir $DIR/$tdir/${tdir} &&
3305 error "$DIR/$tdir/${tdir}: remove of foreign_symlink dir should fail"
3307 #use special ioctl() to unlink foreign_symlink file
3308 $LFS unlink_foreign $DIR/$tdir/${tdir} ||
3309 error "$DIR/$tdir/$tdir: unlink/ioctl failed"
3311 #created file should still exist
3312 [[ -f /tmp/${uuid1}/${uuid2}/$tfile ]] ||
3313 error "/tmp/${uuid1}/${uuid2}/$tfile has been removed"
3314 diff /etc/passwd /tmp/${uuid1}/${uuid2}/$tfile ||
3315 error "/tmp/${uuid1}/${uuid2}/$tfile: diff has failed"
3317 run_test 27P "basic ops on foreign dir of foreign_symlink type"
3320 rm -f $TMP/$tfile $TMP/$tfile.loop $TMP/$tfile.none $TMP/$tfile.broken
3321 stack_trap "rm -f $TMP/$tfile*"
3323 test_mkdir $DIR/$tdir-1
3324 test_mkdir $DIR/$tdir-2
3326 echo 'It is what it is' > $DIR/$tdir-1/$tfile
3327 lov_getstripe_old $DIR/$tdir-1/$tfile || error "$DIR/$tdir-1/$tfile: rc = $?"
3329 ln -s $DIR/$tdir-1/$tfile $DIR/$tdir-2/$tfile
3330 lov_getstripe_old $DIR/$tdir-2/$tfile || error "$DIR/$tdir-2/$tfile: rc = $?"
3332 ln -s $DIR/$tdir-1/$tfile $TMP/$tfile
3333 lov_getstripe_old $TMP/$tfile || error "$TMP/$tfile: rc = $?"
3335 # Create some bad symlinks and ensure that we don't loop
3336 # forever or something. These should return ELOOP (40) and
3337 # ENOENT (2) but I don't want to test for that because there's
3338 # always some weirdo architecture that needs to ruin
3339 # everything by defining these error numbers differently.
3341 ln -s $TMP/$tfile.loop $TMP/$tfile.loop
3342 lov_getstripe_old $TMP/$tfile.loop && error "$TMP/$tfile.loop: rc = $?"
3344 ln -s $TMP/$tfile.none $TMP/$tfile.broken
3345 lov_getstripe_old $TMP/$tfile.broken && error "$TMP/$tfile.broken: rc = $?"
3349 run_test 27Q "llapi_file_get_stripe() works on symlinks"
3352 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
3353 skip "need MDS 2.14.55 or later"
3354 (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
3356 local testdir="$DIR/$tdir"
3357 test_mkdir -p $testdir
3358 stack_trap "rm -rf $testdir"
3359 $LFS setstripe -c -1 $testdir || error "setstripe failed"
3361 local f1="$testdir/f1"
3362 touch $f1 || error "failed to touch $f1"
3363 local count=$($LFS getstripe -c $f1)
3364 (( $count == $OSTCOUNT )) || error "wrong stripe count"
3366 do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
3367 (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
3369 local maxcount=$(($OSTCOUNT - 1))
3370 local mdts=$(comma_list $(mdts_nodes))
3371 do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
3372 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
3374 local f2="$testdir/f2"
3375 touch $f2 || error "failed to touch $f2"
3376 local count=$($LFS getstripe -c $f2)
3377 (( $count == $maxcount )) || error "wrong stripe count"
3379 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
3382 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
3383 skip "Need MDS version at least 2.14.54"
3384 [[ "$(facet_host mds1)" != "$(facet_host ost1)" ]] ||
3385 skip "needs different host for mdt1 ost1"
3387 local count=$(precreated_ost_obj_count 0 0)
3389 echo "precreate count $count"
3390 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
3391 $LFS setstripe -i 0 -c 1 $DIR/$tdir || error "setstripe $tdir failed"
3392 #define OBD_FAIL_OSP_GET_LAST_FID 0x2109
3393 do_facet mds1 $LCTL set_param fail_loc=0x2109
3394 #define OBD_FAIL_OST_GET_LAST_FID 0x252
3395 do_facet ost1 $LCTL set_param fail_loc=0x252
3396 createmany -o $DIR/$tdir/f $count &
3398 echo "precreate count $(precreated_ost_obj_count 0 0)"
3399 do_facet mds1 $LCTL set_param fail_loc=0
3400 do_facet ost1 $LCTL set_param fail_loc=0
3401 wait $pid || error "createmany failed"
3402 echo "precreate count $(precreated_ost_obj_count 0 0)"
3404 run_test 27S "don't deactivate OSP on network issue"
3407 [ $(facet_host client) == $(facet_host ost1) ] &&
3408 skip "need ost1 and client on different nodes"
3410 #define OBD_FAIL_OSC_NO_GRANT 0x411
3411 $LCTL set_param fail_loc=0x20000411 fail_val=1
3412 #define OBD_FAIL_OST_ENOSPC 0x215
3413 do_facet ost1 "$LCTL set_param fail_loc=0x80000215"
3414 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3415 $MULTIOP $DIR/$tfile oO_WRONLY:P$((4 * 1024 * 1024 + 10 * 4096))c ||
3416 error "multiop failed"
3418 run_test 27T "no eio on close on partial write due to enosp"
3421 local dir=$DIR/$tdir
3422 local file=$dir/$tfile
3423 local append_pool=${TESTNAME}-append
3424 local normal_pool=${TESTNAME}-normal
3428 local mdts=$(comma_list $(mdts_nodes))
3431 # (( $MDS1_VERSION >= $(version_code 2.15.42) )) ||
3432 # skip "Need MDS version at least 2.15.42"
3434 # Validate existing append_* params and ensure restore
3435 pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
3436 [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
3437 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
3439 stripe_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
3440 ((stripe_count == 1)) || error "expected append_stripe_count != 0, got $stripe_count"
3441 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$stripe_count"
3443 pool_add $append_pool || error "pool creation failed"
3444 pool_add_targets $append_pool 0 1 || error "Pool add targets failed"
3446 pool_add $normal_pool || error "pool creation failed"
3447 pool_add_targets $normal_pool 0 1 || error "Pool add targets failed"
3450 $LFS setstripe -E 1M -c 1 -p $normal_pool -E 2M -c 2 -p $normal_pool -E eof -c -1 $dir
3453 $LFS getstripe $file.1
3455 pool=$($LFS getstripe -p $file.1)
3456 [[ "$pool" == "$normal_pool" ]] || error "got pool '$pool', expected '$normal_pool'"
3458 stripe_count2=$($LFS getstripe -c $file.1)
3459 ((stripe_count2 == stripe_count)) ||
3460 error "got stripe_count '$stripe_count2', expected '$stripe_count'"
3462 do_nodes $mdts $LCTL set_param mdd.*.append_pool=$append_pool
3465 $LFS getstripe $file.2
3467 pool=$($LFS getstripe -p $file.2)
3468 [[ "$pool" == "$append_pool" ]] || error "got pool '$pool', expected '$append_pool'"
3470 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
3473 $LFS getstripe $file.3
3475 stripe_count2=$($LFS getstripe -c $file.3)
3476 ((stripe_count2 == 2)) || error "got stripe_count '$stripe_count2', expected 2"
3478 run_test 27U "append pool and stripe count work with composite default layout"
3480 # createtest also checks that device nodes are created and
3481 # then visible correctly (#2091)
3482 test_28() { # bug 2091
3484 $CREATETEST $DIR/d28/ct || error "createtest failed"
3486 run_test 28 "create/mknod/mkdir with bad file types ============"
3489 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3491 [ $MDS1_VERSION -ge $(version_code 2.14.51) ] && {
3493 stack_trap "restore_opencache"
3496 sync; sleep 1; sync # flush out any dirty pages from previous tests
3503 declare -i LOCKCOUNTORIG=0
3504 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3505 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3507 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3509 declare -i LOCKUNUSEDCOUNTORIG=0
3510 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3511 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3518 declare -i LOCKCOUNTCURRENT=0
3519 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3520 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3523 declare -i LOCKUNUSEDCOUNTCURRENT=0
3524 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3525 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3528 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3529 $LCTL set_param -n ldlm.dump_namespaces ""
3530 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3531 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3532 log "dumped log to $TMP/test_29.dk (bug 5793)"
3535 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3536 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3537 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3538 log "dumped log to $TMP/test_29.dk (bug 5793)"
3542 run_test 29 "IT_GETATTR regression ============================"
3544 test_30a() { # was test_30
3545 cp $(which ls) $DIR || cp /bin/ls $DIR
3546 $DIR/ls / || error "Can't execute binary from lustre"
3549 run_test 30a "execute binary from Lustre (execve) =============="
3552 cp `which ls` $DIR || cp /bin/ls $DIR
3554 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3557 run_test 30b "execute binary from Lustre as non-root ==========="
3559 test_30c() { # b=22376
3560 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3562 cp $(which ls) $DIR || cp /bin/ls $DIR
3564 cancel_lru_locks mdc
3565 cancel_lru_locks osc
3566 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3569 run_test 30c "execute binary from Lustre without read perms ===="
3572 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3574 for i in {1..10}; do
3575 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3578 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3579 wait $PID || error "executing dd from Lustre failed"
3585 run_test 30d "execute binary from Lustre while clear locks"
3588 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3589 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3591 run_test 31a "open-unlink file =================================="
3594 touch $DIR/f31 || error "touch $DIR/f31 failed"
3595 ln $DIR/f31 $DIR/f31b || error "ln failed"
3596 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3597 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3599 run_test 31b "unlink file with multiple links while open ======="
3602 touch $DIR/f31 || error "touch $DIR/f31 failed"
3603 ln $DIR/f31 $DIR/f31c || error "ln failed"
3604 multiop_bg_pause $DIR/f31 O_uc ||
3605 error "multiop_bg_pause for $DIR/f31 failed"
3607 $MULTIOP $DIR/f31c Ouc
3608 kill -USR1 $MULTIPID
3611 run_test 31c "open-unlink file with multiple links ============="
3614 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3615 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3617 run_test 31d "remove of open directory ========================="
3619 test_31e() { # bug 2904
3620 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3622 run_test 31e "remove of open non-empty directory ==============="
3624 test_31f() { # bug 4554
3625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3628 test_mkdir $DIR/d31f
3629 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3630 cp /etc/hosts $DIR/d31f
3632 $LFS getstripe $DIR/d31f/hosts
3633 multiop_bg_pause $DIR/d31f D_c || return 1
3636 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3637 test_mkdir $DIR/d31f
3638 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3639 cp /etc/hosts $DIR/d31f
3641 $LFS getstripe $DIR/d31f/hosts
3642 multiop_bg_pause $DIR/d31f D_c || return 1
3645 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3646 wait $MULTIPID || error "first opendir $MULTIPID failed"
3650 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3651 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3654 run_test 31f "remove of open directory with open-unlink file ==="
3657 echo "-- cross directory link --"
3658 test_mkdir -c1 $DIR/${tdir}ga
3659 test_mkdir -c1 $DIR/${tdir}gb
3660 touch $DIR/${tdir}ga/f
3661 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3662 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3663 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3664 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3665 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3667 run_test 31g "cross directory link==============="
3670 echo "-- cross directory link --"
3671 test_mkdir -c1 $DIR/${tdir}
3672 test_mkdir -c1 $DIR/${tdir}/dir
3673 touch $DIR/${tdir}/f
3674 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3675 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3676 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3677 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3678 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3680 run_test 31h "cross directory link under child==============="
3683 echo "-- cross directory link --"
3684 test_mkdir -c1 $DIR/$tdir
3685 test_mkdir -c1 $DIR/$tdir/dir
3686 touch $DIR/$tdir/dir/f
3687 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3688 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3689 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3690 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3691 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3693 run_test 31i "cross directory link under parent==============="
3696 test_mkdir -c1 -p $DIR/$tdir
3697 test_mkdir -c1 -p $DIR/$tdir/dir1
3698 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3699 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3700 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3701 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3704 run_test 31j "link for directory==============="
3707 test_mkdir -c1 -p $DIR/$tdir
3709 touch $DIR/$tdir/exist
3710 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3711 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3712 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3713 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3714 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3715 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3716 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3719 run_test 31k "link to file: the same, non-existing, dir==============="
3725 touch $DIR/d31m2/exist
3726 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3727 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3728 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3729 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3730 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3731 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3734 run_test 31m "link to file: the same, non-existing, dir==============="
3737 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3738 nlink=$(stat --format=%h $DIR/$tfile)
3739 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3741 local cmd="exec $fd<$DIR/$tfile"
3744 trap "eval $cmd" EXIT
3745 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3746 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3747 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3748 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3749 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3752 run_test 31n "check link count of unlinked file"
3755 local tempfile=$(mktemp $1_XXXXXX)
3756 mlink $tempfile $1 2> /dev/null &&
3757 echo "$BASHPID: link $tempfile to $1 succeeded"
3761 test_31o() { # LU-2901
3762 test_mkdir $DIR/$tdir
3763 for LOOP in $(seq 100); do
3764 rm -f $DIR/$tdir/$tfile*
3765 for THREAD in $(seq 8); do
3766 link_one $DIR/$tdir/$tfile.$LOOP &
3769 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3770 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3771 error "$LINKS duplicate links to $tfile.$LOOP" &&
3775 run_test 31o "duplicate hard links with same filename"
3778 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3780 test_mkdir $DIR/$tdir
3781 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3782 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3784 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3785 error "open unlink test1 failed"
3786 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3787 error "open unlink test2 failed"
3789 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3790 error "test1 still exists"
3791 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3792 error "test2 still exists"
3794 run_test 31p "remove of open striped directory"
3797 [ $MDSCOUNT -lt 3 ] && skip_env "needs >= 3 MDTs"
3799 $LFS mkdir -i 3,1 $DIR/$tdir || error "mkdir failed"
3800 index=$($LFS getdirstripe -i $DIR/$tdir)
3801 [ $index -eq 3 ] || error "first stripe index $index != 3"
3802 index=$($LFS getdirstripe $DIR/$tdir | tail -1 | awk '{print $1}')
3803 [ $index -eq 1 ] || error "second stripe index $index != 1"
3805 # when "-c <stripe_count>" is set, the number of MDTs specified after
3806 # "-i" should equal to the stripe count
3807 $LFS mkdir -i 3,1 -c 3 $DIR/$tdir.2 && error "mkdir should fail" || true
3809 run_test 31q "create striped directory on specific MDTs"
3813 touch $DIR/$tfile.target
3814 touch $DIR/$tfile.source
3816 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
3817 $LCTL set_param fail_loc=0x1419 fail_val=3
3818 cat $DIR/$tfile.target &
3821 # Guarantee open is waiting before we get here
3823 mv $DIR/$tfile.source $DIR/$tfile.target
3827 if [[ $RC -ne 0 ]]; then
3828 error "open with cat failed, rc=$RC"
3831 run_test 31r "open-rename(replace) race"
3833 cleanup_test32_mount() {
3836 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3837 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3838 losetup -d $loopdev || true
3844 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3846 echo "== more mountpoints and symlinks ================="
3847 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3848 trap cleanup_test32_mount EXIT
3849 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3850 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3851 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3852 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3853 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3854 cleanup_test32_mount
3856 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3861 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3862 trap cleanup_test32_mount EXIT
3863 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3864 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3865 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3866 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3867 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3868 cleanup_test32_mount
3870 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3873 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3875 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3876 trap cleanup_test32_mount EXIT
3877 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3878 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3879 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3880 test_mkdir -p $DIR/$tdir/d2/test_dir
3881 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3882 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3883 cleanup_test32_mount
3885 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3890 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3891 trap cleanup_test32_mount EXIT
3892 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3893 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3894 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3895 test_mkdir -p $DIR/$tdir/d2/test_dir
3896 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3897 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3898 cleanup_test32_mount
3900 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3904 test_mkdir -p $DIR/$tdir/tmp
3905 local tmp_dir=$DIR/$tdir/tmp
3906 ln -s $DIR/$tdir $tmp_dir/symlink11
3907 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3908 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3909 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3911 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3915 test_mkdir -p $DIR/$tdir/tmp
3916 local tmp_dir=$DIR/$tdir/tmp
3917 ln -s $DIR/$tdir $tmp_dir/symlink11
3918 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3919 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3920 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3922 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3925 local tmp_dir=$DIR/$tdir/tmp
3926 test_mkdir -p $tmp_dir
3927 test_mkdir $DIR/${tdir}2
3928 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3929 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3930 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3931 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3932 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3933 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3935 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3938 rm -fr $DIR/$tdir $DIR/${tdir}2
3939 tmp_dir=$DIR/$tdir/tmp
3940 test_mkdir -p $tmp_dir
3941 test_mkdir $DIR/${tdir}2
3942 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3943 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3944 ls $tmp_dir/symlink12 || error "listing symlink12"
3945 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3947 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3950 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3952 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3953 trap cleanup_test32_mount EXIT
3954 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3955 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3956 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3957 touch $DIR/$tdir/test_file
3958 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3959 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3960 cleanup_test32_mount
3962 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3965 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3967 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3968 trap cleanup_test32_mount EXIT
3969 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3970 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3971 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3972 touch $DIR/$tdir/test_file
3973 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3974 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3975 cleanup_test32_mount
3977 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3980 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3983 trap cleanup_test32_mount EXIT
3984 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3985 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3986 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3987 test_mkdir -p $DIR/$tdir/d2
3988 touch $DIR/$tdir/d2/test_file || error "touch failed"
3989 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3990 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3991 cleanup_test32_mount
3993 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3996 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3999 trap cleanup_test32_mount EXIT
4000 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4001 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4002 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4003 test_mkdir -p $DIR/$tdir/d2
4004 touch $DIR/$tdir/d2/test_file || error "touch failed"
4005 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
4006 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
4007 cleanup_test32_mount
4009 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
4013 test_mkdir -p $DIR/d32m/tmp
4014 TMP_DIR=$DIR/d32m/tmp
4015 ln -s $DIR $TMP_DIR/symlink11
4016 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4017 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
4018 error "symlink11 not a link"
4019 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
4020 error "symlink01 not a link"
4022 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
4026 test_mkdir -p $DIR/d32n/tmp
4027 TMP_DIR=$DIR/d32n/tmp
4028 ln -s $DIR $TMP_DIR/symlink11
4029 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
4030 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
4031 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
4033 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
4037 test_mkdir -p $DIR/d32o/tmp
4038 TMP_DIR=$DIR/d32o/tmp
4039 ln -s $DIR/$tfile $TMP_DIR/symlink12
4040 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4041 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
4042 error "symlink12 not a link"
4043 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
4044 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
4045 error "$DIR/d32o/tmp/symlink12 not file type"
4046 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
4047 error "$DIR/d32o/symlink02 not file type"
4049 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
4059 test_mkdir -p $DIR/d32p/tmp
4061 TMP_DIR=$DIR/d32p/tmp
4063 ln -s $DIR/$tfile $TMP_DIR/symlink12
4065 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
4067 cat $DIR/d32p/tmp/symlink12 ||
4068 error "Can't open $DIR/d32p/tmp/symlink12"
4070 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
4073 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
4076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4078 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4079 trap cleanup_test32_mount EXIT
4080 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4081 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4082 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4083 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4084 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
4085 cleanup_test32_mount
4087 run_test 32q "stat follows mountpoints in Lustre (should return error)"
4090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4092 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
4093 trap cleanup_test32_mount EXIT
4094 test_mkdir -p $DIR/$tdir/ext2-mountpoint
4095 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
4096 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
4097 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
4098 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
4099 cleanup_test32_mount
4101 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
4106 chmod 444 $DIR/$tfile
4107 chown $RUNAS_ID $DIR/$tfile
4109 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4112 run_test 33aa "write file with mode 444 (should return error)"
4116 test_mkdir $DIR/$tdir
4117 chown $RUNAS_ID $DIR/$tdir
4118 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
4119 error "$RUNAS create $tdir/$tfile failed"
4120 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
4121 error "open RDWR" || true
4123 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
4127 test_mkdir $DIR/$tdir
4128 chown $RUNAS_ID $DIR/$tdir
4129 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
4131 run_test 33b "test open file with malformed flags (No panic)"
4134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4135 remote_ost_nodsh && skip "remote OST with nodsh"
4143 test_mkdir $DIR/$tdir
4144 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
4147 for ostnum in $(seq $OSTCOUNT); do
4148 # test-framework's OST numbering is one-based, while Lustre's
4150 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4151 # check if at least some write_bytes stats are counted
4152 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4153 obdfilter.$ostname.stats |
4154 awk '/^write_bytes/ {print $7}' )
4155 echo "baseline_write_bytes@ost$ostnum/$ostname=$write_bytes"
4156 if (( ${write_bytes:-0} > 0 )); then
4162 $all_zeros || return 0
4165 echo foo > $DIR/$tdir/bar
4169 # Total up write_bytes after writing. We'd better find non-zeros.
4170 for ostnum in $(seq $OSTCOUNT); do
4171 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4172 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
4173 obdfilter/$ostname/stats |
4174 awk '/^write_bytes/ {print $7}' )
4175 echo "write_bytes@ost$ostnum/$ostname=$write_bytes"
4176 if (( ${write_bytes:-0} > 0 )); then
4183 for ostnum in $(seq $OSTCOUNT); do
4184 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
4185 echo "Check write_bytes is in obdfilter.*.stats:"
4186 do_facet ost$ostnum lctl get_param -n \
4187 obdfilter.$ostname.stats
4189 error "OST not keeping write_bytes stats (b=22312)"
4192 run_test 33c "test write_bytes stats"
4195 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4196 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4199 local remote_dir=$DIR/$tdir/remote_dir
4201 test_mkdir $DIR/$tdir
4202 $LFS mkdir -i $MDTIDX $remote_dir ||
4203 error "create remote directory failed"
4205 touch $remote_dir/$tfile
4206 chmod 444 $remote_dir/$tfile
4207 chown $RUNAS_ID $remote_dir/$tfile
4209 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
4211 chown $RUNAS_ID $remote_dir
4212 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
4213 error "create" || true
4214 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
4215 error "open RDWR" || true
4216 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
4218 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
4221 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4225 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4226 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4227 mkdir $DIR/$tdir/local_dir
4229 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4230 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4231 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4233 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4234 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
4236 rmdir $DIR/$tdir/* || error "rmdir failed"
4239 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4240 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4241 mkdir $DIR/$tdir/local_dir
4243 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4244 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4245 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4247 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4248 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
4250 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
4253 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
4254 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
4255 mkdir $DIR/$tdir/local_dir
4257 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
4258 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
4259 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
4261 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
4262 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
4264 run_test 33e "mkdir and striped directory should have same mode"
4268 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
4272 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4273 remote_mds_nodsh && skip "remote MDS with nodsh"
4276 chmod go+rwx $DIR/$tdir
4277 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
4278 trap cleanup_33f EXIT
4280 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4281 error "cannot create striped directory"
4283 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
4284 error "cannot create files in striped directory"
4286 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
4287 error "cannot remove files in striped directory"
4289 $RUNAS rmdir $DIR/$tdir/striped_dir ||
4290 error "cannot remove striped directory"
4294 run_test 33f "nonroot user can create, access, and remove a striped directory"
4297 mkdir -p $DIR/$tdir/dir2
4299 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
4301 [[ $err =~ "exists" ]] || error "Not exists error"
4303 run_test 33g "nonroot user create already existing root created file"
4309 test_mkdir -c $MDSCOUNT -H $hash_type $DIR/$tdir ||
4310 error "lfs mkdir -H $hash_type $tdir failed"
4311 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
4313 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
4317 for fname in $DIR/$tdir/$tfile.bak \
4318 $DIR/$tdir/$tfile.SAV \
4319 $DIR/$tdir/$tfile.orig \
4320 $DIR/$tdir/$tfile~; do
4321 touch $fname || error "touch $fname failed"
4322 index2=$($LFS getstripe -m $fname)
4323 (( $index == $index2 )) ||
4324 error "$fname MDT index mismatch $index != $index2"
4328 local patterns=(".$tfile.XXXXXX" "$tfile.XXXXXXXX")
4331 for pattern in ${patterns[*]}; do
4332 echo "pattern $pattern"
4333 fname=$DIR/$tdir/$pattern
4334 for (( i = 0; i < $count; i++ )); do
4335 fname=$(mktemp $DIR/$tdir/$pattern) ||
4336 error "mktemp $DIR/$tdir/$pattern failed"
4337 index2=$($LFS getstripe -m $fname)
4338 (( $index == $index2 )) && continue
4340 failed=$((failed + 1))
4341 echo "$fname MDT index mismatch $index != $index2"
4345 echo "$failed/$count MDT index mismatches, expect ~2-4"
4346 (( failed < 10 )) || error "MDT index mismatch $failed/$count times"
4351 # verify that "crush" is still broken with all files on same MDT,
4352 # crush2 should have about 1/MDSCOUNT files on each MDT, with margin
4353 [[ "$hash_type" == "crush" ]] && expect=$count ||
4354 expect=$((count / MDSCOUNT))
4356 # crush2 doesn't put all-numeric suffixes on the same MDT,
4357 # filename like $tfile.12345678 should *not* be considered temp
4358 for pattern in ${patterns[*]}; do
4359 local base=${pattern%%X*}
4360 local suff=${pattern#$base}
4362 echo "pattern $pattern"
4363 for (( i = 0; i < $count; i++ )); do
4364 fname=$DIR/$tdir/$base$((${suff//X/1} + i))
4365 touch $fname || error "touch $fname failed"
4366 index2=$($LFS getstripe -m $fname)
4367 (( $index != $index2 )) && continue
4373 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4374 (( same / ${#patterns[*]} < expect * 5 / 4 &&
4375 same / ${#patterns[*]} > expect * 4 / 5 )) ||
4376 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4379 # crush2 doesn't put suffixes with special characters on the same MDT
4380 # filename like $tfile.txt.1234 should *not* be considered temp
4381 for pattern in ${patterns[*]}; do
4382 local base=${pattern%%X*}
4383 local suff=${pattern#$base}
4385 pattern=$base...${suff/XXX}
4386 echo "pattern=$pattern"
4387 for (( i = 0; i < $count; i++ )); do
4388 fname=$(mktemp $DIR/$tdir/$pattern) ||
4389 error "touch $fname failed"
4390 index2=$($LFS getstripe -m $fname)
4391 (( $index != $index2 )) && continue
4397 echo "$((same/${#patterns[*]}))/$count matches, expect ~$expect for $1"
4398 (( same / ${#patterns[*]} < expect * 5 / 4 &&
4399 same / ${#patterns[*]} > expect * 4 / 5 )) ||
4400 error "MDT index match $((same / ${#patterns[*]}))/$count times"
4404 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4405 (( $MDS1_VERSION >= $(version_code 2.13.50) )) ||
4406 skip "Need MDS version at least 2.13.50"
4410 run_test 33h "temp file is located on the same MDT as target (crush)"
4413 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4414 echo "MDS1_VERSION=$MDS1_VERSION version_code=$(version_code 2.15.0)"
4415 (( $MDS1_VERSION > $(version_code 2.15.0) )) ||
4416 skip "Need MDS version at least 2.15.0 for crush2"
4420 run_test 33hh "temp file is located on the same MDT as target (crush2)"
4424 (( MDSCOUNT < 2 )) && skip "needs >= 2 MDTs"
4426 local FNAME=$(str_repeat 'f' 250)
4428 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
4429 createmany -o $DIR/$tdir/$FNAME 1000 || error "createmany failed"
4434 count=$($LFS getstripe -m $DIR/$tdir/* | grep -cw 1)
4436 local MDC=$(lctl dl | awk '/MDT0001-mdc-[^M]/ { print $4 }')
4438 lctl --device %$MDC deactivate
4439 stack_trap "lctl --device %$MDC activate"
4440 ls $DIR/$tdir > /dev/null && error "ls should return an error"
4441 total=$(\ls -l $DIR/$tdir | wc -l)
4442 # "ls -l" will list total in the first line
4443 total=$((total - 1))
4444 (( total + count == 1000 )) ||
4445 error "ls list $total files, $count files on MDT1"
4447 run_test 33i "striped directory can be accessed when one MDT is down"
4449 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
4452 $MCREATE $DIR/f34 || error "mcreate failed"
4453 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4454 error "getstripe failed"
4455 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
4456 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4457 error "getstripe failed"
4458 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4459 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4461 run_test 34a "truncate file that has not been opened ==========="
4464 [ ! -f $DIR/f34 ] && test_34a
4465 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4466 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4467 $OPENFILE -f O_RDONLY $DIR/f34
4468 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
4469 error "getstripe failed"
4470 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4471 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4473 run_test 34b "O_RDONLY opening file doesn't create objects ====="
4476 [ ! -f $DIR/f34 ] && test_34a
4477 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4478 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4479 $OPENFILE -f O_RDWR $DIR/f34
4480 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
4481 error "$LFS getstripe failed"
4482 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4483 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4485 run_test 34c "O_RDWR opening file-with-size works =============="
4488 [ ! -f $DIR/f34 ] && test_34a
4489 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
4491 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
4492 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
4495 run_test 34d "write to sparse file ============================="
4499 $MCREATE $DIR/f34e || error "mcreate failed"
4500 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
4501 $CHECKSTAT -s 1000 $DIR/f34e ||
4502 error "Size of $DIR/f34e not equal to 1000 bytes"
4503 $OPENFILE -f O_RDWR $DIR/f34e
4504 $CHECKSTAT -s 1000 $DIR/f34e ||
4505 error "Size of $DIR/f34e not equal to 1000 bytes"
4507 run_test 34e "create objects, some with size and some without =="
4509 test_34f() { # bug 6242, 6243
4510 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4514 $MCREATE $DIR/f34f || error "mcreate failed"
4515 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
4516 dd if=$DIR/f34f of=$TMP/f34f
4517 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
4518 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
4519 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
4520 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
4521 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
4523 run_test 34f "read from a file with no objects until EOF ======="
4526 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4528 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
4530 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
4531 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4532 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
4533 cancel_lru_locks osc
4534 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
4535 error "wrong size after lock cancel"
4537 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
4538 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4539 error "expanding truncate failed"
4540 cancel_lru_locks osc
4541 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
4542 error "wrong expanded size after lock cancel"
4544 run_test 34g "truncate long file ==============================="
4547 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4552 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
4553 sync # Flush the cache so that multiop below does not block on cache
4554 # flush when getting the group lock
4555 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
4558 # Since just timed wait is not good enough, let's do a sync write
4559 # that way we are sure enough time for a roundtrip + processing
4560 # passed + 2 seconds of extra margin.
4561 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
4565 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
4566 error "Multiop blocked on ftruncate, pid=$MULTIPID"
4570 local nsz=`stat -c %s $DIR/$tfile`
4571 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
4573 run_test 34h "ftruncate file under grouplock should not block"
4576 cp /bin/sh $DIR/f35a
4578 chown $RUNAS_ID $DIR/f35a
4579 $RUNAS $DIR/f35a && error || true
4582 run_test 35a "exec file with mode 444 (should return and not leak)"
4586 utime $DIR/f36 || error "utime failed for MDS"
4588 run_test 36a "MDS utime check (mknod, utime)"
4592 utime $DIR/f36 || error "utime failed for OST"
4594 run_test 36b "OST utime check (open, utime)"
4599 chown $RUNAS_ID $DIR/d36
4600 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4602 run_test 36c "non-root MDS utime check (mknod, utime)"
4605 [ ! -d $DIR/d36 ] && test_36c
4606 echo "" > $DIR/d36/f36
4607 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4609 run_test 36d "non-root OST utime check (open, utime)"
4612 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4614 test_mkdir $DIR/$tdir
4615 touch $DIR/$tdir/$tfile
4616 $RUNAS utime $DIR/$tdir/$tfile &&
4617 error "utime worked, expected failure" || true
4619 run_test 36e "utime on non-owned file (should return error)"
4623 local LANG_SAVE=$LANG
4624 local LC_LANG_SAVE=$LC_LANG
4625 export LANG=C LC_LANG=C # for date language
4627 DATESTR="Dec 20 2000"
4628 test_mkdir $DIR/$tdir
4629 lctl set_param fail_loc=$fl
4631 cp /etc/hosts $DIR/$tdir/$tfile
4632 sync & # write RPC generated with "current" inode timestamp, but delayed
4634 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4635 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4636 cancel_lru_locks $OSC
4637 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4639 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4640 echo "BEFORE: $LS_BEFORE" && \
4641 echo "AFTER : $LS_AFTER" && \
4642 echo "WANT : $DATESTR" && \
4643 error "$DIR/$tdir/$tfile timestamps changed" || true
4645 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4649 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4651 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4652 subr_36fh "0x80000214"
4654 run_test 36f "utime on file racing with OST BRW write =========="
4657 remote_ost_nodsh && skip "remote OST with nodsh"
4658 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4659 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4660 skip "Need MDS version at least 2.12.51"
4665 local tgt="obdfilter"
4667 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4669 test_mkdir $DIR/$tdir
4670 fmd_max_age=$(do_facet $facet \
4671 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4674 echo "FMD max age: ${fmd_max_age}s"
4675 touch $DIR/$tdir/$tfile
4676 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4677 gawk '{cnt=cnt+$1} END{print cnt}')
4678 echo "FMD before: $fmd"
4680 error "FMD wasn't create by touch"
4681 sleep $((fmd_max_age + 12))
4682 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4683 gawk '{cnt=cnt+$1} END{print cnt}')
4684 echo "FMD after: $fmd"
4686 error "FMD wasn't expired by ping"
4688 run_test 36g "FMD cache expiry ====================="
4691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4693 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4694 subr_36fh "0x80000227"
4696 run_test 36h "utime on file racing with OST BRW write =========="
4699 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4701 test_mkdir $DIR/$tdir
4702 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4704 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4705 local new_mtime=$((mtime + 200))
4707 #change Modify time of striped dir
4708 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4709 error "change mtime failed"
4711 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4713 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4715 run_test 36i "change mtime on striped directory"
4717 # test_37 - duplicate with tests 32q 32r
4720 local file=$DIR/$tfile
4722 openfile -f O_DIRECTORY $file
4725 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4726 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4728 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4730 test_39a() { # was test_39
4732 touch $DIR/${tfile}2
4733 # ls -l $DIR/$tfile $DIR/${tfile}2
4734 # ls -lu $DIR/$tfile $DIR/${tfile}2
4735 # ls -lc $DIR/$tfile $DIR/${tfile}2
4737 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4738 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4740 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4742 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4744 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4745 error "O_TRUNC didn't change timestamps"
4748 run_test 39a "mtime changed on create"
4751 test_mkdir -c1 $DIR/$tdir
4752 cp -p /etc/passwd $DIR/$tdir/fopen
4753 cp -p /etc/passwd $DIR/$tdir/flink
4754 cp -p /etc/passwd $DIR/$tdir/funlink
4755 cp -p /etc/passwd $DIR/$tdir/frename
4756 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4759 echo "aaaaaa" >> $DIR/$tdir/fopen
4760 echo "aaaaaa" >> $DIR/$tdir/flink
4761 echo "aaaaaa" >> $DIR/$tdir/funlink
4762 echo "aaaaaa" >> $DIR/$tdir/frename
4764 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4765 local link_new=`stat -c %Y $DIR/$tdir/flink`
4766 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4767 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4769 cat $DIR/$tdir/fopen > /dev/null
4770 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4771 rm -f $DIR/$tdir/funlink2
4772 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4774 for (( i=0; i < 2; i++ )) ; do
4775 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4776 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4777 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4778 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4780 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4781 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4782 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4783 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4785 cancel_lru_locks $OSC
4786 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4789 run_test 39b "mtime change on open, link, unlink, rename ======"
4791 # this should be set to past
4792 TEST_39_MTIME=`date -d "1 year ago" +%s`
4798 local mtime0=`stat -c %Y $DIR1/$tfile`
4800 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4801 local mtime1=`stat -c %Y $DIR1/$tfile`
4802 [ "$mtime1" = $TEST_39_MTIME ] || \
4803 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4806 echo hello >> $DIR1/$tfile
4808 local mtime2=`stat -c %Y $DIR1/$tfile`
4809 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4810 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4812 mv $DIR1/$tfile $DIR1/$tfile-1
4814 for (( i=0; i < 2; i++ )) ; do
4815 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4816 [ "$mtime2" = "$mtime3" ] || \
4817 error "mtime ($mtime2) changed (to $mtime3) on rename"
4819 cancel_lru_locks $OSC
4820 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4823 run_test 39c "mtime change on rename ==========================="
4827 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4830 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4832 for (( i=0; i < 2; i++ )) ; do
4833 local mtime=`stat -c %Y $DIR1/$tfile`
4834 [ $mtime = $TEST_39_MTIME ] || \
4835 error "mtime($mtime) is not set to $TEST_39_MTIME"
4837 cancel_lru_locks $OSC
4838 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4841 run_test 39d "create, utime, stat =============================="
4845 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4848 local mtime1=`stat -c %Y $DIR1/$tfile`
4850 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4852 for (( i=0; i < 2; i++ )) ; do
4853 local mtime2=`stat -c %Y $DIR1/$tfile`
4854 [ $mtime2 = $TEST_39_MTIME ] || \
4855 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4857 cancel_lru_locks $OSC
4858 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4861 run_test 39e "create, stat, utime, stat ========================"
4865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4868 mtime1=`stat -c %Y $DIR1/$tfile`
4871 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4873 for (( i=0; i < 2; i++ )) ; do
4874 local mtime2=`stat -c %Y $DIR1/$tfile`
4875 [ $mtime2 = $TEST_39_MTIME ] || \
4876 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4878 cancel_lru_locks $OSC
4879 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4882 run_test 39f "create, stat, sleep, utime, stat ================="
4886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4888 echo hello >> $DIR1/$tfile
4889 local mtime1=`stat -c %Y $DIR1/$tfile`
4892 chmod o+r $DIR1/$tfile
4894 for (( i=0; i < 2; i++ )) ; do
4895 local mtime2=`stat -c %Y $DIR1/$tfile`
4896 [ "$mtime1" = "$mtime2" ] || \
4897 error "lost mtime: $mtime2, should be $mtime1"
4899 cancel_lru_locks $OSC
4900 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4903 run_test 39g "write, chmod, stat ==============================="
4907 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4913 echo hello >> $DIR1/$tfile
4914 local mtime1=`stat -c %Y $DIR1/$tfile`
4916 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4918 if [ "$d1" != "$d2" ]; then
4919 echo "write and touch not within one second"
4921 for (( i=0; i < 2; i++ )) ; do
4922 local mtime2=`stat -c %Y $DIR1/$tfile`
4923 [ "$mtime2" = $TEST_39_MTIME ] || \
4924 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4926 cancel_lru_locks $OSC
4927 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4931 run_test 39h "write, utime within one second, stat ============="
4934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4939 echo hello >> $DIR1/$tfile
4940 local mtime1=`stat -c %Y $DIR1/$tfile`
4942 mv $DIR1/$tfile $DIR1/$tfile-1
4944 for (( i=0; i < 2; i++ )) ; do
4945 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4947 [ "$mtime1" = "$mtime2" ] || \
4948 error "lost mtime: $mtime2, should be $mtime1"
4950 cancel_lru_locks $OSC
4951 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4954 run_test 39i "write, rename, stat =============================="
4957 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4959 start_full_debug_logging
4963 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4964 lctl set_param fail_loc=0x80000412
4965 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4966 error "multiop failed"
4968 local mtime1=`stat -c %Y $DIR1/$tfile`
4970 mv $DIR1/$tfile $DIR1/$tfile-1
4972 kill -USR1 $multipid
4973 wait $multipid || error "multiop close failed"
4975 for (( i=0; i < 2; i++ )) ; do
4976 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4977 [ "$mtime1" = "$mtime2" ] ||
4978 error "mtime is lost on close: $mtime2, " \
4982 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4984 lctl set_param fail_loc=0
4985 stop_full_debug_logging
4987 run_test 39j "write, rename, close, stat ======================="
4990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4995 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4997 local mtime1=`stat -c %Y $DIR1/$tfile`
4999 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
5001 kill -USR1 $multipid
5002 wait $multipid || error "multiop close failed"
5004 for (( i=0; i < 2; i++ )) ; do
5005 local mtime2=`stat -c %Y $DIR1/$tfile`
5007 [ "$mtime2" = $TEST_39_MTIME ] || \
5008 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
5011 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5014 run_test 39k "write, utime, close, stat ========================"
5016 # this should be set to future
5017 TEST_39_ATIME=`date -d "1 year" +%s`
5020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5021 remote_mds_nodsh && skip "remote MDS with nodsh"
5023 local atime_diff=$(do_facet $SINGLEMDS \
5024 lctl get_param -n mdd.*MDT0000*.atime_diff)
5026 mkdir_on_mdt0 $DIR/$tdir
5028 # test setting directory atime to future
5029 touch -a -d @$TEST_39_ATIME $DIR/$tdir
5030 local atime=$(stat -c %X $DIR/$tdir)
5031 [ "$atime" = $TEST_39_ATIME ] ||
5032 error "atime is not set to future: $atime, $TEST_39_ATIME"
5034 # test setting directory atime from future to now
5035 local now=$(date +%s)
5036 touch -a -d @$now $DIR/$tdir
5038 atime=$(stat -c %X $DIR/$tdir)
5039 [ "$atime" -eq "$now" ] ||
5040 error "atime is not updated from future: $atime, $now"
5042 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
5045 # test setting directory atime when now > dir atime + atime_diff
5046 local d1=$(date +%s)
5048 local d2=$(date +%s)
5049 cancel_lru_locks mdc
5050 atime=$(stat -c %X $DIR/$tdir)
5051 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5052 error "atime is not updated : $atime, should be $d2"
5054 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
5057 # test not setting directory atime when now < dir atime + atime_diff
5059 cancel_lru_locks mdc
5060 atime=$(stat -c %X $DIR/$tdir)
5061 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
5062 error "atime is updated to $atime, should remain $d1<atime<$d2"
5064 do_facet $SINGLEMDS \
5065 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5067 run_test 39l "directory atime update ==========================="
5070 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5074 local far_past_mtime=$(date -d "May 29 1953" +%s)
5075 local far_past_atime=$(date -d "Dec 17 1903" +%s)
5077 touch -m -d @$far_past_mtime $DIR1/$tfile
5078 touch -a -d @$far_past_atime $DIR1/$tfile
5080 for (( i=0; i < 2; i++ )) ; do
5081 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
5082 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
5083 error "atime or mtime set incorrectly"
5085 cancel_lru_locks $OSC
5086 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
5089 run_test 39m "test atime and mtime before 1970"
5091 test_39n() { # LU-3832
5092 remote_mds_nodsh && skip "remote MDS with nodsh"
5094 local atime_diff=$(do_facet $SINGLEMDS \
5095 lctl get_param -n mdd.*MDT0000*.atime_diff)
5100 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
5103 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
5104 atime0=$(stat -c %X $DIR/$tfile)
5107 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5108 atime1=$(stat -c %X $DIR/$tfile)
5111 cancel_lru_locks mdc
5112 cancel_lru_locks osc
5113 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
5114 atime2=$(stat -c %X $DIR/$tfile)
5116 do_facet $SINGLEMDS \
5117 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
5119 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
5120 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
5122 run_test 39n "check that O_NOATIME is honored"
5125 TESTDIR=$DIR/$tdir/$tfile
5126 [ -e $TESTDIR ] && rm -rf $TESTDIR
5133 links2=$(stat -c %h .)
5134 [ $(($links1 + 2)) != $links2 ] &&
5135 error "wrong links count $(($links1 + 2)) != $links2"
5137 links3=$(stat -c %h .)
5138 [ $(($links1 + 1)) != $links3 ] &&
5139 error "wrong links count $links1 != $links3"
5142 run_test 39o "directory cached attributes updated after create"
5145 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
5148 TESTDIR=$DIR/$tdir/$tdir
5149 [ -e $TESTDIR ] && rm -rf $TESTDIR
5150 test_mkdir -p $TESTDIR
5154 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
5155 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
5157 links2=$(stat -c %h .)
5158 [ $(($links1 + 2)) != $links2 ] &&
5159 error "wrong links count $(($links1 + 2)) != $links2"
5161 links3=$(stat -c %h .)
5162 [ $(($links1 + 1)) != $links3 ] &&
5163 error "wrong links count $links1 != $links3"
5166 run_test 39p "remote directory cached attributes updated after create ========"
5169 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
5170 skip "no atime update on old OST"
5171 if [ "$ost1_FSTYPE" != ldiskfs ]; then
5172 skip_env "ldiskfs only test"
5176 saved_adiff=$(do_facet ost1 \
5177 lctl get_param -n obdfilter.*OST0000.atime_diff)
5178 stack_trap "do_facet ost1 \
5179 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
5181 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
5183 $LFS setstripe -i 0 $DIR/$tfile
5184 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
5185 error "can't write initial file"
5186 cancel_lru_locks osc
5188 # exceed atime_diff and access file
5190 dd if=$DIR/$tfile of=/dev/null bs=4k count=1 ||
5191 error "can't udpate atime"
5193 local atime_cli=$(stat -c %X $DIR/$tfile)
5194 echo "client atime: $atime_cli"
5195 # allow atime update to be written to device
5196 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
5199 local ostdev=$(ostdevname 1)
5200 local fid=($(lfs getstripe -y $DIR/$tfile |
5201 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
5202 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
5203 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
5205 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
5206 local atime_ost=$(do_facet ost1 "$cmd" |&
5207 awk -F'[: ]' '/atime:/ { print $4 }')
5208 (( atime_cli == atime_ost )) ||
5209 error "atime on client $atime_cli != ost $atime_ost"
5211 run_test 39r "lazy atime update on OST"
5213 test_39q() { # LU-8041
5214 local testdir=$DIR/$tdir
5216 multiop_bg_pause $testdir D_c || error "multiop failed"
5218 cancel_lru_locks mdc
5219 kill -USR1 $multipid
5220 local atime=$(stat -c %X $testdir)
5221 [ "$atime" -ne 0 ] || error "atime is zero"
5223 run_test 39q "close won't zero out atime"
5226 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
5227 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
5228 error "openfile O_WRONLY:O_TRUNC $tfile failed"
5229 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
5230 error "$tfile is not 4096 bytes in size"
5232 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
5236 small_write $DIR/f41 18
5238 run_test 41 "test small file write + fstat ====================="
5240 count_ost_writes() {
5241 lctl get_param -n ${OSC}.*.stats |
5242 awk -vwrites=0 '/ost_write/ { writes += $2 } \
5243 END { printf("%0.0f", writes) }'
5250 BG_DIRTY_RATIO_SAVE=10
5251 MAX_BG_DIRTY_RATIO=25
5255 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
5256 # dirty_ratio, dirty_background_ratio
5257 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5258 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
5259 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
5260 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
5262 # if file not here, we are a 2.4 kernel
5263 kill -CONT `pidof kupdated`
5268 # setup the trap first, so someone cannot exit the test at the
5269 # exact wrong time and mess up a machine
5270 trap start_writeback EXIT
5271 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
5272 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
5273 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
5274 sysctl -w vm.dirty_writeback_centisecs=0
5275 sysctl -w vm.dirty_writeback_centisecs=0
5276 # save and increase /proc/sys/vm/dirty_ratio
5277 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
5278 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
5279 # save and increase /proc/sys/vm/dirty_background_ratio
5280 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
5281 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
5283 # if file not here, we are a 2.4 kernel
5284 kill -STOP `pidof kupdated`
5288 # ensure that all stripes have some grant before we test client-side cache
5290 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
5291 dd if=/dev/zero of=$i bs=4k count=1
5296 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
5297 # file truncation, and file removal.
5299 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5302 cancel_lru_locks $OSC
5304 sync; sleep 1; sync # just to be safe
5305 BEFOREWRITES=`count_ost_writes`
5306 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
5307 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
5308 AFTERWRITES=`count_ost_writes`
5309 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
5310 error "$BEFOREWRITES < $AFTERWRITES"
5313 run_test 42a "ensure that we don't flush on close"
5316 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5319 cancel_lru_locks $OSC
5322 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
5323 BEFOREWRITES=$(count_ost_writes)
5324 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
5325 AFTERWRITES=$(count_ost_writes)
5326 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5327 error "$BEFOREWRITES < $AFTERWRITES on unlink"
5329 BEFOREWRITES=$(count_ost_writes)
5330 sync || error "sync: $?"
5331 AFTERWRITES=$(count_ost_writes)
5332 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
5333 error "$BEFOREWRITES < $AFTERWRITES on sync"
5335 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
5339 run_test 42b "test destroy of file with cached dirty data ======"
5341 # if these tests just want to test the effect of truncation,
5342 # they have to be very careful. consider:
5343 # - the first open gets a {0,EOF}PR lock
5344 # - the first write conflicts and gets a {0, count-1}PW
5345 # - the rest of the writes are under {count,EOF}PW
5346 # - the open for truncate tries to match a {0,EOF}PR
5347 # for the filesize and cancels the PWs.
5348 # any number of fixes (don't get {0,EOF} on open, match
5349 # composite locks, do smarter file size management) fix
5350 # this, but for now we want these tests to verify that
5351 # the cancellation with truncate intent works, so we
5352 # start the file with a full-file pw lock to match against
5353 # until the truncate.
5358 cancel_lru_locks $OSC
5360 # prime the file with 0,EOF PW to match
5364 # now the real test..
5365 dd if=/dev/zero of=$file bs=1024 count=100
5366 BEFOREWRITES=`count_ost_writes`
5367 $TRUNCATE $file $offset
5368 cancel_lru_locks $OSC
5369 AFTERWRITES=`count_ost_writes`
5374 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5377 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
5378 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
5381 run_test 42c "test partial truncate of file with cached dirty data"
5384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5387 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
5388 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
5391 run_test 42d "test complete truncate of file with cached dirty data"
5393 test_42e() { # bug22074
5394 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5396 local TDIR=$DIR/${tdir}e
5397 local pages=16 # hardcoded 16 pages, don't change it.
5398 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
5399 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
5403 test_mkdir $DIR/${tdir}e
5404 $LFS setstripe -c 1 $TDIR
5405 createmany -o $TDIR/f $files
5407 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
5409 # we assume that with $OSTCOUNT files, at least one of them will
5410 # be allocated on OST0.
5411 warmup_files=$((OSTCOUNT * max_dirty_mb))
5412 createmany -o $TDIR/w $warmup_files
5414 # write a large amount of data into one file and sync, to get good
5415 # avail_grant number from OST.
5416 for ((i=0; i<$warmup_files; i++)); do
5417 idx=$($LFS getstripe -i $TDIR/w$i)
5418 [ $idx -ne 0 ] && continue
5419 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
5422 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
5424 $LCTL get_param $proc_osc0/cur_dirty_bytes
5425 $LCTL get_param $proc_osc0/cur_grant_bytes
5427 # create as much dirty pages as we can while not to trigger the actual
5428 # RPCs directly. but depends on the env, VFS may trigger flush during this
5429 # period, hopefully we are good.
5430 for ((i=0; i<$warmup_files; i++)); do
5431 idx=$($LFS getstripe -i $TDIR/w$i)
5432 [ $idx -ne 0 ] && continue
5433 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
5435 $LCTL get_param $proc_osc0/cur_dirty_bytes
5436 $LCTL get_param $proc_osc0/cur_grant_bytes
5438 # perform the real test
5439 $LCTL set_param $proc_osc0/rpc_stats 0
5440 for ((;i<$files; i++)); do
5441 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
5442 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
5445 $LCTL get_param $proc_osc0/rpc_stats
5448 local have_ppr=false
5449 $LCTL get_param $proc_osc0/rpc_stats |
5450 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
5451 # skip lines until we are at the RPC histogram data
5452 [ "$PPR" == "pages" ] && have_ppr=true && continue
5453 $have_ppr || continue
5455 # we only want the percent stat for < 16 pages
5456 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
5458 percent=$((percent + WPCT))
5459 if [[ $percent -gt 15 ]]; then
5460 error "less than 16-pages write RPCs" \
5467 run_test 42e "verify sub-RPC writes are not done synchronously"
5469 test_43A() { # was test_43
5470 test_mkdir $DIR/$tdir
5471 cp -p /bin/ls $DIR/$tdir/$tfile
5472 $MULTIOP $DIR/$tdir/$tfile Ow_c &
5474 # give multiop a chance to open
5477 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
5479 # Wait for multiop to exit
5482 run_test 43A "execution of file opened for write should return -ETXTBSY"
5485 test_mkdir $DIR/$tdir
5486 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5487 $DIR/$tdir/sleep 60 &
5489 # Make sure exec of $tdir/sleep wins race with truncate
5491 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
5494 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
5497 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5499 test_mkdir $DIR/$tdir
5500 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
5501 $DIR/$tdir/sleep 60 &
5503 # Make sure exec of $tdir/sleep wins race with truncate
5505 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
5508 run_test 43b "truncate of file being executed should return -ETXTBSY"
5511 local testdir="$DIR/$tdir"
5514 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
5515 ( cd $testdir && md5sum -c )
5517 run_test 43c "md5sum of copy into lustre"
5519 test_44A() { # was test_44
5520 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5522 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
5523 dd if=$DIR/f1 bs=4k count=1 > /dev/null
5525 run_test 44A "zero length read from a sparse stripe"
5528 local nstripe=$($LFS getstripe -c -d $DIR)
5529 [ -z "$nstripe" ] && skip "can't get stripe info"
5530 [[ $nstripe -gt $OSTCOUNT ]] &&
5531 skip "Wrong default stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
5533 local stride=$($LFS getstripe -S -d $DIR)
5534 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
5535 nstripe=$($LFS df $DIR | grep OST: | wc -l)
5538 OFFSETS="0 $((stride/2)) $((stride-1))"
5539 for offset in $OFFSETS; do
5540 for i in $(seq 0 $((nstripe-1))); do
5541 local GLOBALOFFSETS=""
5543 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
5544 local myfn=$DIR/d44a-$size
5545 echo "--------writing $myfn at $size"
5546 ll_sparseness_write $myfn $size ||
5547 error "ll_sparseness_write"
5548 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5549 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5550 error "ll_sparseness_verify $GLOBALOFFSETS"
5552 for j in $(seq 0 $((nstripe-1))); do
5554 size=$((((j + $nstripe )*$stride + $offset)))
5555 ll_sparseness_write $myfn $size ||
5556 error "ll_sparseness_write"
5557 GLOBALOFFSETS="$GLOBALOFFSETS $size"
5559 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
5560 error "ll_sparseness_verify $GLOBALOFFSETS"
5565 run_test 44a "test sparse pwrite ==============================="
5569 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
5575 before=`dirty_osc_total`
5576 echo executing "\"$*\""
5578 after=`dirty_osc_total`
5579 echo before $before, after $after
5582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5585 # Obtain grants from OST if it supports it
5586 echo blah > ${f}_grant
5589 do_dirty_record "echo blah > $f"
5590 [[ $before -eq $after ]] && error "write wasn't cached"
5591 do_dirty_record "> $f"
5592 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
5593 do_dirty_record "echo blah > $f"
5594 [[ $before -eq $after ]] && error "write wasn't cached"
5595 do_dirty_record "sync"
5596 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
5597 do_dirty_record "echo blah > $f"
5598 [[ $before -eq $after ]] && error "write wasn't cached"
5599 do_dirty_record "cancel_lru_locks osc"
5600 [[ $before -gt $after ]] ||
5601 error "lock cancellation didn't lower dirty count"
5604 run_test 45 "osc io page accounting ============================"
5606 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5607 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5608 # objects offset and an assert hit when an rpc was built with 1023's mapped
5609 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5611 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5616 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5618 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5619 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5623 run_test 46 "dirtying a previously written page ================"
5625 # test_47 is removed "Device nodes check" is moved to test_28
5627 test_48a() { # bug 2399
5628 [ "$mds1_FSTYPE" = "zfs" ] &&
5629 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5630 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5632 test_mkdir $DIR/$tdir
5634 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5635 test_mkdir $DIR/$tdir
5636 touch foo || error "'touch foo' failed after recreating cwd"
5638 touch .foo || error "'touch .foo' failed after recreating cwd"
5640 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5641 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5642 cd . || error "'cd .' failed after recreating cwd"
5643 mkdir . && error "'mkdir .' worked after recreating cwd"
5644 rmdir . && error "'rmdir .' worked after recreating cwd"
5645 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5646 cd .. || error "'cd ..' failed after recreating cwd"
5648 run_test 48a "Access renamed working dir (should return errors)="
5650 test_48b() { # bug 2399
5652 test_mkdir $DIR/$tdir
5654 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5655 touch foo && error "'touch foo' worked after removing cwd"
5656 mkdir foo && error "'mkdir foo' worked after removing cwd"
5657 touch .foo && error "'touch .foo' worked after removing cwd"
5658 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5659 ls . > /dev/null && error "'ls .' worked after removing cwd"
5660 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5661 mkdir . && error "'mkdir .' worked after removing cwd"
5662 rmdir . && error "'rmdir .' worked after removing cwd"
5663 ln -s . foo && error "'ln -s .' worked after removing cwd"
5664 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5666 run_test 48b "Access removed working dir (should return errors)="
5668 test_48c() { # bug 2350
5669 #lctl set_param debug=-1
5672 test_mkdir -p $DIR/$tdir/dir
5674 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5675 $TRACE touch foo && error "touch foo worked after removing cwd"
5676 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5677 touch .foo && error "touch .foo worked after removing cwd"
5678 mkdir .foo && error "mkdir .foo worked after removing cwd"
5679 $TRACE ls . && error "'ls .' worked after removing cwd"
5680 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5681 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5682 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5683 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5684 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5686 run_test 48c "Access removed working subdir (should return errors)"
5688 test_48d() { # bug 2350
5689 #lctl set_param debug=-1
5692 test_mkdir -p $DIR/$tdir/dir
5694 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5695 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5696 $TRACE touch foo && error "'touch foo' worked after removing parent"
5697 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5698 touch .foo && error "'touch .foo' worked after removing parent"
5699 mkdir .foo && error "mkdir .foo worked after removing parent"
5700 $TRACE ls . && error "'ls .' worked after removing parent"
5701 $TRACE ls .. && error "'ls ..' worked after removing parent"
5702 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5703 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5704 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5707 run_test 48d "Access removed parent subdir (should return errors)"
5709 test_48e() { # bug 4134
5710 #lctl set_param debug=-1
5713 test_mkdir -p $DIR/$tdir/dir
5715 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5716 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5717 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5718 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5719 # On a buggy kernel addition of "touch foo" after cd .. will
5720 # produce kernel oops in lookup_hash_it
5721 touch ../foo && error "'cd ..' worked after recreate parent"
5723 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5725 run_test 48e "Access to recreated parent subdir (should return errors)"
5728 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
5729 skip "need MDS >= 2.13.55"
5730 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
5731 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
5732 skip "needs different host for mdt1 mdt2"
5733 [[ $(facet_fstype mds1) == ldiskfs ]] || skip "ldiskfs only"
5735 $LFS mkdir -i0 $DIR/$tdir
5736 $LFS mkdir -i 1 $DIR/$tdir/sub1 $DIR/$tdir/sub2 $DIR/$tdir/sub3
5738 for d in sub1 sub2 sub3; do
5739 #define OBD_FAIL_OSD_REF_DEL 0x19c
5740 do_facet mds1 $LCTL set_param fail_loc=0x8000019c
5741 rm -rf $DIR/$tdir/$d && error "rm $d should fail"
5744 rm -d --interactive=never $DIR/$tdir || error "rm $tdir fail"
5746 run_test 48f "non-zero nlink dir unlink won't LBUG()"
5748 test_49() { # LU-1030
5749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5750 remote_ost_nodsh && skip "remote OST with nodsh"
5752 # get ost1 size - $FSNAME-OST0000
5753 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5755 # write 800M at maximum
5756 [[ $ost1_size -lt 2 ]] && ost1_size=2
5757 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5759 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5760 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5763 # change max_pages_per_rpc while writing the file
5764 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5765 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5766 # loop until dd process exits
5767 while ps ax -opid | grep -wq $dd_pid; do
5768 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5769 sleep $((RANDOM % 5 + 1))
5771 # restore original max_pages_per_rpc
5772 $LCTL set_param $osc1_mppc=$orig_mppc
5773 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5775 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5779 test_mkdir $DIR/$tdir
5781 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5783 run_test 50 "special situations: /proc symlinks ==============="
5785 test_51a() { # was test_51
5786 # bug 1516 - create an empty entry right after ".." then split dir
5787 test_mkdir -c1 $DIR/$tdir
5788 touch $DIR/$tdir/foo
5789 $MCREATE $DIR/$tdir/bar
5791 createmany -m $DIR/$tdir/longfile 201
5793 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5794 $MCREATE $DIR/$tdir/longfile$FNUM
5799 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5801 run_test 51a "special situations: split htree with empty entry =="
5803 cleanup_print_lfs_df () {
5810 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5812 local dir=$DIR/$tdir
5813 local nrdirs=$((65536 + 100))
5815 # cleanup the directory
5818 mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
5822 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5823 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5824 [[ $numfree -lt $nrdirs ]] &&
5825 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5827 # need to check free space for the directories as well
5828 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5829 numfree=$(( blkfree / $(fs_inode_ksize) ))
5830 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5832 trap cleanup_print_lfs_df EXIT
5835 createmany -d $dir/d $nrdirs || {
5836 unlinkmany $dir/d $nrdirs
5837 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5841 nrdirs=$(ls -U $dir | wc -l)
5843 # unlink all but 100 subdirectories, then check it still works
5845 local delete=$((nrdirs - left))
5850 # for ldiskfs the nlink count should be 1, but this is OSD specific
5851 # and so this is listed for informational purposes only
5852 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5853 unlinkmany -d $dir/d $delete ||
5854 error "unlink of first $delete subdirs failed"
5856 echo "nlink between: $(stat -c %h $dir)"
5857 local found=$(ls -U $dir | wc -l)
5858 [ $found -ne $left ] &&
5859 error "can't find subdirs: found only $found, expected $left"
5861 unlinkmany -d $dir/d $delete $left ||
5862 error "unlink of second $left subdirs failed"
5863 # regardless of whether the backing filesystem tracks nlink accurately
5864 # or not, the nlink count shouldn't be more than "." and ".." here
5865 local after=$(stat -c %h $dir)
5866 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5867 echo "nlink after: $after"
5869 cleanup_print_lfs_df
5871 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5874 local stripecount=$1
5875 local nfiles=$((200 * $OSTCOUNT))
5877 log "create files with stripecount=$stripecount"
5878 $LFS setstripe -C $stripecount $DIR/$tdir
5879 createmany -o $DIR/$tdir/t- $nfiles
5880 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5881 for ((n = 0; n < $OSTCOUNT; n++)); do
5882 objs[$n]=$(awk -vobjs=0 '($1 == '$n') { objs += 1 } \
5883 END { printf("%0.0f", objs) }' $TMP/$tfile)
5884 objs0[$n]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5885 '($1 == '$n') { objs += 1 } \
5886 END { printf("%0.0f", objs) }')
5887 log "OST$n has ${objs[$n]} objects, ${objs0[$n]} are index 0"
5889 unlinkmany $DIR/$tdir/t- $nfiles
5894 local max=6 # allow variance of (1 - $min/$max) = 33% by default
5896 # For some combinations of stripecount and OSTCOUNT current code
5897 # is not ideal, and allocates 50% fewer *first* objects to some OSTs
5898 # than others. Rather than skipping this test entirely, check that
5899 # and keep testing to ensure imbalance does not get worse. LU-15282
5900 (( (OSTCOUNT == 6 && stripecount == 4) ||
5901 (OSTCOUNT == 10 && (stripecount == 4 || stripecount == 8)) ||
5902 (OSTCOUNT == 12 && (stripecount == 8 || stripecount == 9)))) && max=9
5903 for ((nlast=0, n = 1; n < $OSTCOUNT; nlast=n,n++)); do
5904 (( ${objs[$n]} > ${objs[$nlast]} * 4 / 5 )) ||
5905 { $LFS df && $LFS df -i &&
5906 error "OST $n has fewer objects vs. OST $nlast " \
5907 "(${objs[$n]} < ${objs[$nlast]} x 4/5)"; }
5908 (( ${objs[$n]} < ${objs[$nlast]} * 5 / 4 )) ||
5909 { $LFS df && $LFS df -i &&
5910 error "OST $n has fewer objects vs. OST $nlast " \
5911 "(${objs[$n]} > ${objs[$nlast]} x 5/4)"; }
5913 (( ${objs0[$n]} > ${objs0[$nlast]} * $min / $max )) ||
5914 { $LFS df && $LFS df -i &&
5915 error "OST $n has fewer #0 objects vs. OST $nlast " \
5916 "(${objs0[$n]} < ${objs0[$nlast]} x $min/$max)"; }
5917 (( ${objs0[$n]} < ${objs0[$nlast]} * $max / $min )) ||
5918 { $LFS df && $LFS df -i &&
5919 error "OST $n has fewer #0 objects vs. OST $nlast " \
5920 "(${objs0[$n]} > ${objs0[$nlast]} x $max/$min)"; }
5925 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5926 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5929 local qos_old=$(do_facet mds1 \
5930 "$LCTL get_param -n lod.$FSNAME-*.qos_threshold_rr" | head -n 1)
5932 do_nodes $(comma_list $(mdts_nodes)) \
5933 "$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=100"
5934 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
5935 '$LCTL set_param lod.$FSNAME-*.qos_threshold_rr=${qos_old%%%}'"
5937 test_mkdir $DIR/$tdir
5939 for ((stripecount = 3; stripecount <= $OSTCOUNT; stripecount++)); do
5940 test_51d_sub $stripecount
5943 run_test 51d "check object distribution"
5946 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5947 skip_env "ldiskfs only test"
5950 test_mkdir -c1 $DIR/$tdir
5951 test_mkdir -c1 $DIR/$tdir/d0
5953 touch $DIR/$tdir/d0/foo
5954 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5955 error "file exceed 65000 nlink limit!"
5956 unlinkmany $DIR/$tdir/d0/f- 65001
5959 run_test 51e "check file nlink limit"
5962 test_mkdir $DIR/$tdir
5965 local ulimit_old=$(ulimit -n)
5966 local spare=20 # number of spare fd's for scripts/libraries, etc.
5967 local mdt=$($LFS getstripe -m $DIR/$tdir)
5968 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5970 echo "MDT$mdt numfree=$numfree, max=$max"
5971 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5972 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5973 while ! ulimit -n $((numfree + spare)); do
5974 numfree=$((numfree * 3 / 4))
5976 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5978 echo "left ulimit at $ulimit_old"
5981 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5982 unlinkmany $DIR/$tdir/f $numfree
5983 error "create+open $numfree files in $DIR/$tdir failed"
5985 ulimit -n $ulimit_old
5987 # if createmany exits at 120s there will be fewer than $numfree files
5988 unlinkmany $DIR/$tdir/f $numfree || true
5990 run_test 51f "check many open files limit"
5993 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5994 test_mkdir $DIR/$tdir
5995 touch $DIR/$tdir/foo
5996 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5997 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5998 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5999 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6000 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6002 echo foo >> $DIR/$tdir/foo || error "append foo failed"
6003 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6004 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
6006 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
6007 cp -r $DIR/$tdir $TMP/
6008 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
6010 run_test 52a "append-only flag test (should return errors)"
6013 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
6014 test_mkdir $DIR/$tdir
6015 touch $DIR/$tdir/foo
6016 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
6017 cat test > $DIR/$tdir/foo && error "cat test worked"
6018 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
6019 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
6020 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
6022 echo foo >> $DIR/$tdir/foo && error "echo worked"
6023 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
6024 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
6025 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
6026 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
6028 chattr -i $DIR/$tdir/foo || error "chattr failed"
6030 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
6032 run_test 52b "immutable flag test (should return errors) ======="
6035 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6036 remote_mds_nodsh && skip "remote MDS with nodsh"
6037 remote_ost_nodsh && skip "remote OST with nodsh"
6050 local support_last_seq=true
6052 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
6053 support_last_seq=false
6056 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
6058 for value in $(do_facet $SINGLEMDS \
6059 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
6060 param=$(echo ${value[0]} | cut -d "=" -f1)
6061 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
6063 if $support_last_seq; then
6064 param_seq=$(echo $param |
6065 sed -e s/prealloc_last_id/prealloc_last_seq/g)
6066 mds_last_seq=$(do_facet $SINGLEMDS \
6067 $LCTL get_param -n $param_seq)
6069 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
6071 ostnum=$(index_from_ostuuid ${ostname}_UUID)
6072 node=$(facet_active_host ost$((ostnum+1)))
6073 param="obdfilter.$ostname.last_id"
6074 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
6075 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
6076 ost_last_id=$ost_last
6078 if $support_last_seq; then
6079 ost_last_id=$(echo $ost_last |
6080 awk -F':' '{print $2}' |
6082 ost_last_seq=$(echo $ost_last |
6083 awk -F':' '{print $1}')
6084 [[ $ost_last_seq = $mds_last_seq ]] || continue
6087 if [[ $ost_last_id != $mds_last ]]; then
6088 error "$ost_last_id != $mds_last"
6095 $found || error "can not match last_seq/last_id for $mdtosc"
6098 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
6101 perl -MSocket -e ';' || skip "no Socket perl module installed"
6103 $SOCKETSERVER $DIR/socket ||
6104 error "$SOCKETSERVER $DIR/socket failed: $?"
6105 $SOCKETCLIENT $DIR/socket ||
6106 error "$SOCKETCLIENT $DIR/socket failed: $?"
6107 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
6109 run_test 54a "unix domain socket test =========================="
6115 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
6117 run_test 54b "char device works in lustre ======================"
6120 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
6121 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
6122 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
6124 for i in $(seq 3 7); do
6125 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
6134 loopdev="$DIR/loop54c"
6137 $UMOUNT $DIR/$tdir || rc=$?
6138 losetup -d $loopdev || true
6139 losetup -d $LOOPDEV || true
6140 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
6145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6147 loopdev="$DIR/loop54c"
6150 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
6151 trap cleanup_54c EXIT
6152 mknod $loopdev b 7 $LOOPNUM
6153 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
6154 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
6155 losetup $loopdev $DIR/$tfile ||
6156 error "can't set up $loopdev for $DIR/$tfile"
6157 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
6158 test_mkdir $DIR/$tdir
6159 mount -t ext2 $loopdev $DIR/$tdir ||
6160 error "error mounting $loopdev on $DIR/$tdir"
6161 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
6164 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
6168 run_test 54c "block device works in lustre ====================="
6171 local pipe="$DIR/$tfile.pipe"
6172 local string="aaaaaa"
6175 echo -n "$string" > $pipe &
6176 local result=$(cat $pipe)
6177 [[ "$result" == "$string" ]] || error "$result != $string"
6179 run_test 54d "fifo device works in lustre ======================"
6184 cp -aL /dev/console $f
6185 echo $string > $f || error "echo $string to $f failed"
6187 run_test 54e "console/tty device works in lustre ======================"
6192 local dir=$DIR/$tdir
6195 test_mkdir -p $dir/dir
6196 for i in $(seq $numfiles); do
6198 touch $dir/dir/file$i
6201 local numcomp=$($LFS getstripe --component-count $dir)
6203 [[ $numcomp == 0 ]] && numcomp=1
6205 # test lfs getstripe with --recursive
6206 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
6208 [[ $filenum -eq $((numfiles * 2)) ]] ||
6209 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
6210 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
6211 [[ $filenum -eq $numfiles ]] ||
6212 error "$LFS getstripe $dir: found $filenum, not $numfiles"
6213 echo "$LFS getstripe showed obdidx or l_ost_idx"
6215 # test lfs getstripe with file instead of dir
6216 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
6217 [[ $filenum -eq 1 ]] ||
6218 error "$LFS getstripe $dir/file1: found $filenum, not 1"
6219 echo "$LFS getstripe file1 passed"
6221 #test lfs getstripe with --verbose
6222 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
6223 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
6224 error "$LFS getstripe --verbose $dir: "\
6225 "got $filenum want $((numfiles * numcomp)) lmm_magic"
6226 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
6227 error "$LFS getstripe $dir: showed lmm_magic"
6229 #test lfs getstripe with -v prints lmm_fid
6230 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
6231 local countfids=$((numdirs + numfiles * numcomp))
6232 [[ $filenum -eq $countfids ]] ||
6233 error "$LFS getstripe -v $dir: "\
6234 "got $filenum want $countfids lmm_fid"
6235 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
6236 error "$LFS getstripe $dir: showed lmm_fid by default"
6237 echo "$LFS getstripe --verbose passed"
6239 #check for FID information
6240 local fid1=$($LFS getstripe --fid $dir/file1)
6241 local fid2=$($LFS getstripe --verbose $dir/file1 |
6242 awk '/lmm_fid: / { print $2; exit; }')
6243 local fid3=$($LFS path2fid $dir/file1)
6245 [ "$fid1" != "$fid2" ] &&
6246 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
6247 [ "$fid1" != "$fid3" ] &&
6248 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
6249 echo "$LFS getstripe --fid passed"
6251 #test lfs getstripe with --obd
6252 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
6253 error "$LFS getstripe --obd wrong_uuid: should return error"
6255 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6258 local obduuid=$(ostuuid_from_index $ostidx)
6259 local found=$($LFS getstripe -r --obd $obduuid $dir |
6260 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
6262 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
6263 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
6265 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
6268 [[ $found -eq $filenum ]] ||
6269 error "$LFS getstripe --obd: found $found expect $filenum"
6270 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
6271 sed '/^[ ]*'${ostidx}'[ ]/d' |
6272 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
6273 error "$LFS getstripe --obd: should not show file on other obd"
6274 echo "$LFS getstripe --obd passed"
6276 run_test 56a "check $LFS getstripe"
6279 local dir=$DIR/$tdir
6283 for i in $(seq $numdirs); do
6284 test_mkdir $dir/dir$i
6287 # test lfs getdirstripe default mode is non-recursion, which is
6288 # different from lfs getstripe
6289 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
6291 [[ $dircnt -eq 1 ]] ||
6292 error "$LFS getdirstripe: found $dircnt, not 1"
6293 dircnt=$($LFS getdirstripe --recursive $dir |
6294 grep -c lmv_stripe_count)
6295 [[ $dircnt -eq $((numdirs + 1)) ]] ||
6296 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
6298 run_test 56b "check $LFS getdirstripe"
6301 remote_ost_nodsh && skip "remote OST with nodsh"
6304 local ost_name=$(ostname_from_index $ost_idx)
6305 local old_status=$(ost_dev_status $ost_idx)
6306 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6308 [[ -z "$old_status" ]] ||
6309 skip_env "OST $ost_name is in $old_status status"
6311 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
6312 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6313 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
6314 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6315 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
6316 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
6319 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
6320 error "$LFS df -v showing inactive devices"
6323 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
6325 [[ "$new_status" =~ "D" ]] ||
6326 error "$ost_name status is '$new_status', missing 'D'"
6327 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
6328 [[ "$new_status" =~ "N" ]] ||
6329 error "$ost_name status is '$new_status', missing 'N'"
6331 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
6332 [[ "$new_status" =~ "f" ]] ||
6333 error "$ost_name status is '$new_status', missing 'f'"
6336 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
6337 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
6338 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
6339 [[ -z "$p" ]] && restore_lustre_params < $p || true
6342 new_status=$(ost_dev_status $ost_idx)
6343 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
6344 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
6345 # can't check 'f' as devices may actually be on flash
6347 run_test 56c "check 'lfs df' showing device status"
6350 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
6351 local osts=$($LFS df -v $MOUNT | grep -c OST)
6355 (( mdts == MDSCOUNT )) ||
6356 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
6357 (( osts == OSTCOUNT )) ||
6358 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
6360 run_test 56d "'lfs df -v' prints only configured devices"
6363 err_enoent=2 # No such file or directory
6364 err_eopnotsupp=95 # Operation not supported
6366 enoent_mnt=/pmt1 # Invalid dentry. Path not present
6367 notsup_mnt=/tmp # Valid dentry, but Not a lustreFS
6369 # Check for handling of path not exists
6370 output=$($LFS df $enoent_mnt 2>&1)
6373 fs=$(echo $output | awk -F: '{print $2}' | awk '{print $3}' | tr -d \')
6374 [[ $fs = $enoent_mnt && $ret -eq $err_enoent ]] ||
6375 error "expect failure $err_enoent, not $ret"
6377 # Check for handling of non-Lustre FS
6378 output=$($LFS df $notsup_mnt)
6381 fs=$(echo $output | awk '{print $1}' | awk -F: '{print $2}')
6382 [[ $fs = $notsup_mnt && $ret -eq $err_eopnotsupp ]] ||
6383 error "expect success $err_eopnotsupp, not $ret"
6385 # Check for multiple LustreFS argument
6386 output=$($LFS df $MOUNT $MOUNT $MOUNT | grep -c "filesystem_summary:")
6389 [[ $output -eq 3 && $ret -eq 0 ]] ||
6390 error "expect success 3, not $output, rc = $ret"
6392 # Check for correct non-Lustre FS handling among multiple
6394 output=$($LFS df $MOUNT $notsup_mnt $MOUNT |
6395 grep -c "filesystem_summary:"; exit ${PIPESTATUS[0]})
6398 [[ $output -eq 2 && $ret -eq $err_eopnotsupp ]] ||
6399 error "expect success 2, not $output, rc = $ret"
6401 run_test 56e "'lfs df' Handle non LustreFS & multiple LustreFS"
6406 local local_tdir="$1"
6407 local local_numfiles="$2"
6408 local local_numdirs="$3"
6409 local dir_params="$4"
6410 local dir_stripe_params="$5"
6412 if [ ! -d "$local_tdir" ] ; then
6413 test_mkdir -p $dir_stripe_params $local_tdir
6414 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
6415 for i in $(seq $local_numfiles) ; do
6416 touch $local_tdir/file$i
6418 for i in $(seq $local_numdirs) ; do
6419 test_mkdir $dir_stripe_params $local_tdir/dir$i
6420 for j in $(seq $local_numfiles) ; do
6421 touch $local_tdir/dir$i/file$j
6427 setup_56_special() {
6429 local local_numfiles=$2
6430 local local_numdirs=$3
6432 setup_56 $local_tdir $local_numfiles $local_numdirs
6434 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
6435 for i in $(seq $local_numfiles) ; do
6436 mknod $local_tdir/loop${i}b b 7 $i
6437 mknod $local_tdir/null${i}c c 1 3
6438 ln -s $local_tdir/file1 $local_tdir/link${i}
6440 for i in $(seq $local_numdirs) ; do
6441 mknod $local_tdir/dir$i/loop${i}b b 7 $i
6442 mknod $local_tdir/dir$i/null${i}c c 1 3
6443 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
6449 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6450 local expected=$(($NUMDIRS + 2))
6452 setup_56 $dir $NUMFILES $NUMDIRS
6454 # test lfs find with -name
6455 for i in $(seq $NUMFILES) ; do
6456 local nums=$($LFS find -name "*$i" $dir | wc -l)
6458 [ $nums -eq $expected ] ||
6459 error "lfs find -name '*$i' $dir wrong: "\
6460 "found $nums, expected $expected"
6463 run_test 56g "check lfs find -name"
6466 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6467 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
6469 setup_56 $dir $NUMFILES $NUMDIRS
6471 # test lfs find with ! -name
6472 for i in $(seq $NUMFILES) ; do
6473 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
6475 [ $nums -eq $expected ] ||
6476 error "lfs find ! -name '*$i' $dir wrong: "\
6477 "found $nums, expected $expected"
6480 run_test 56h "check lfs find ! -name"
6483 local dir=$DIR/$tdir
6487 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
6490 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
6492 run_test 56i "check 'lfs find -ost UUID' skips directories"
6495 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6497 setup_56_special $dir $NUMFILES $NUMDIRS
6499 local expected=$((NUMDIRS + 1))
6500 local cmd="$LFS find -type d $dir"
6501 local nums=$($cmd | wc -l)
6503 [ $nums -eq $expected ] ||
6504 error "'$cmd' wrong: found $nums, expected $expected"
6506 run_test 56j "check lfs find -type d"
6509 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6511 setup_56_special $dir $NUMFILES $NUMDIRS
6513 local expected=$(((NUMDIRS + 1) * NUMFILES))
6514 local cmd="$LFS find -type f $dir"
6515 local nums=$($cmd | wc -l)
6517 [ $nums -eq $expected ] ||
6518 error "'$cmd' wrong: found $nums, expected $expected"
6520 run_test 56k "check lfs find -type f"
6523 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6525 setup_56_special $dir $NUMFILES $NUMDIRS
6527 local expected=$((NUMDIRS + NUMFILES))
6528 local cmd="$LFS find -type b $dir"
6529 local nums=$($cmd | wc -l)
6531 [ $nums -eq $expected ] ||
6532 error "'$cmd' wrong: found $nums, expected $expected"
6534 run_test 56l "check lfs find -type b"
6537 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6539 setup_56_special $dir $NUMFILES $NUMDIRS
6541 local expected=$((NUMDIRS + NUMFILES))
6542 local cmd="$LFS find -type c $dir"
6543 local nums=$($cmd | wc -l)
6544 [ $nums -eq $expected ] ||
6545 error "'$cmd' wrong: found $nums, expected $expected"
6547 run_test 56m "check lfs find -type c"
6550 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
6551 setup_56_special $dir $NUMFILES $NUMDIRS
6553 local expected=$((NUMDIRS + NUMFILES))
6554 local cmd="$LFS find -type l $dir"
6555 local nums=$($cmd | wc -l)
6557 [ $nums -eq $expected ] ||
6558 error "'$cmd' wrong: found $nums, expected $expected"
6560 run_test 56n "check lfs find -type l"
6563 local dir=$DIR/$tdir
6565 setup_56 $dir $NUMFILES $NUMDIRS
6566 utime $dir/file1 > /dev/null || error "utime (1)"
6567 utime $dir/file2 > /dev/null || error "utime (2)"
6568 utime $dir/dir1 > /dev/null || error "utime (3)"
6569 utime $dir/dir2 > /dev/null || error "utime (4)"
6570 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
6571 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
6574 local nums=$($LFS find -mtime +0 $dir | wc -l)
6576 [ $nums -eq $expected ] ||
6577 error "lfs find -mtime +0 $dir: found $nums expect $expected"
6580 cmd="$LFS find -mtime 0 $dir"
6581 nums=$($cmd | wc -l)
6582 [ $nums -eq $expected ] ||
6583 error "'$cmd' wrong: found $nums, expected $expected"
6585 run_test 56o "check lfs find -mtime for old files"
6588 local dir=$DIR/$tdir
6592 # just to make sure there is something that won't be found
6594 touch $dir/$tfile.now
6596 for age in year week day hour min; do
6597 count=$((count + 1))
6599 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
6600 touch --date="$count $age ago" -a $dir/$tfile-a.$age
6601 touch --date="$count $age ago" -m $dir/$tfile-m.$age
6603 local cmd="$LFS find $dir -mtime $count${age:0:1}"
6604 local nums=$($cmd | wc -l)
6605 [ $nums -eq $expected ] ||
6606 error "'$cmd' wrong: found $nums, expected $expected"
6608 cmd="$LFS find $dir -atime $count${age:0:1}"
6609 nums=$($cmd | wc -l)
6610 [ $nums -eq $expected ] ||
6611 error "'$cmd' wrong: found $nums, expected $expected"
6615 cmd="$LFS find $dir -ctime +1s -type f"
6616 nums=$($cmd | wc -l)
6617 (( $nums == $count * 2 + 1)) ||
6618 error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))"
6620 run_test 56ob "check lfs find -atime -mtime -ctime with units"
6622 test_newerXY_base() {
6625 local dir=$DIR/$tdir
6629 if [ $y == "t" ]; then
6630 if [ $x == "b" ]; then
6631 ref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6633 ref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6636 ref=$DIR/$tfile.newer.$x$y
6637 touch $ref || error "touch $ref failed"
6640 echo "before = $ref"
6642 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6644 if [ $y == "t" ]; then
6645 if [ $x == "b" ]; then
6646 negref=\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\"
6648 negref=\"$(date +"%Y-%m-%d %H:%M:%S")\"
6651 negref=$DIR/$tfile.negnewer.$x$y
6652 touch $negref || error "touch $negref failed"
6655 echo "after = $negref"
6656 local cmd="$LFS find $dir -newer$x$y $ref"
6657 local nums=$(eval $cmd | wc -l)
6658 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
6660 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6661 error "'$cmd' wrong: found $nums newer, expected $expected" ; }
6663 cmd="$LFS find $dir ! -newer$x$y $negref"
6664 nums=$(eval $cmd | wc -l)
6665 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6666 error "'$cmd' wrong: found $nums older, expected $expected" ; }
6668 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
6669 nums=$(eval $cmd | wc -l)
6670 [ $nums -eq $expected ] || { ls -lauR --full-time $dir ;
6671 error "'$cmd' wrong: found $nums between, expected $expected"; }
6677 test_newerXY_base "a" "a"
6678 test_newerXY_base "a" "m"
6679 test_newerXY_base "a" "c"
6680 test_newerXY_base "m" "a"
6681 test_newerXY_base "m" "m"
6682 test_newerXY_base "m" "c"
6683 test_newerXY_base "c" "a"
6684 test_newerXY_base "c" "m"
6685 test_newerXY_base "c" "c"
6687 [[ -n "$sles_version" ]] &&
6688 echo "skip timestamp tests on SLES, LU-13665" && return 0
6690 test_newerXY_base "a" "t"
6691 test_newerXY_base "m" "t"
6692 test_newerXY_base "c" "t"
6694 [[ $MDS1_VERSION -lt $(version_code 2.13.54) ||
6695 $CLIENT_VERSION -lt $(version_code 2.13.54) ]] &&
6696 ! btime_supported && echo "btime unsupported" && return 0
6698 test_newerXY_base "b" "b"
6699 test_newerXY_base "b" "t"
6701 run_test 56oc "check lfs find -newerXY work"
6704 local dir=$DIR/$tdir
6709 $LFS find $dir -btime -1d -type f
6716 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6717 ! btime_supported && skip "btime unsupported on MDS"
6719 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6720 ! btime_supported && skip "btime unsupported on clients"
6722 local dir=$DIR/$tdir
6723 local ref=$DIR/$tfile.ref
6724 local negref=$DIR/$tfile.negref
6726 mkdir $dir || error "mkdir $dir failed"
6727 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6728 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6729 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6730 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6731 touch $ref || error "touch $ref failed"
6732 # sleep 3 seconds at least
6735 local before=$(do_facet mds1 date +%s)
6736 local skew=$(($(date +%s) - before + 1))
6738 if (( skew < 0 && skew > -5 )); then
6739 sleep $((0 - skew + 1))
6743 # Set the dir stripe params to limit files all on MDT0,
6744 # otherwise we need to calc the max clock skew between
6745 # the client and MDTs.
6746 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6748 touch $negref || error "touch $negref failed"
6750 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6751 local nums=$($cmd | wc -l)
6752 local expected=$(((NUMFILES + 1) * NUMDIRS))
6754 [ $nums -eq $expected ] ||
6755 error "'$cmd' wrong: found $nums, expected $expected"
6757 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6758 nums=$($cmd | wc -l)
6759 expected=$((NUMFILES + 1))
6760 [ $nums -eq $expected ] ||
6761 error "'$cmd' wrong: found $nums, expected $expected"
6763 [ $skew -lt 0 ] && return
6765 local after=$(do_facet mds1 date +%s)
6766 local age=$((after - before + 1 + skew))
6768 cmd="$LFS find $dir -btime -${age}s -type f"
6769 nums=$($cmd | wc -l)
6770 expected=$(((NUMFILES + 1) * NUMDIRS))
6772 echo "Clock skew between client and server: $skew, age:$age"
6773 [ $nums -eq $expected ] ||
6774 error "'$cmd' wrong: found $nums, expected $expected"
6776 expected=$(($NUMDIRS + 1))
6777 cmd="$LFS find $dir -btime -${age}s -type d"
6778 nums=$($cmd | wc -l)
6779 [ $nums -eq $expected ] ||
6780 error "'$cmd' wrong: found $nums, expected $expected"
6781 rm -f $ref $negref || error "Failed to remove $ref $negref"
6783 run_test 56od "check lfs find -btime with units"
6786 [ $RUNAS_ID -eq $UID ] &&
6787 skip_env "RUNAS_ID = UID = $UID -- skipping"
6789 local dir=$DIR/$tdir
6791 setup_56 $dir $NUMFILES $NUMDIRS
6792 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6794 local expected=$NUMFILES
6795 local cmd="$LFS find -uid $RUNAS_ID $dir"
6796 local nums=$($cmd | wc -l)
6798 [ $nums -eq $expected ] ||
6799 error "'$cmd' wrong: found $nums, expected $expected"
6801 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6802 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6803 nums=$($cmd | wc -l)
6804 [ $nums -eq $expected ] ||
6805 error "'$cmd' wrong: found $nums, expected $expected"
6807 run_test 56p "check lfs find -uid and ! -uid"
6810 [ $RUNAS_ID -eq $UID ] &&
6811 skip_env "RUNAS_ID = UID = $UID -- skipping"
6813 local dir=$DIR/$tdir
6815 setup_56 $dir $NUMFILES $NUMDIRS
6816 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6818 local expected=$NUMFILES
6819 local cmd="$LFS find -gid $RUNAS_GID $dir"
6820 local nums=$($cmd | wc -l)
6822 [ $nums -eq $expected ] ||
6823 error "'$cmd' wrong: found $nums, expected $expected"
6825 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6826 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6827 nums=$($cmd | wc -l)
6828 [ $nums -eq $expected ] ||
6829 error "'$cmd' wrong: found $nums, expected $expected"
6831 run_test 56q "check lfs find -gid and ! -gid"
6834 local dir=$DIR/$tdir
6836 setup_56 $dir $NUMFILES $NUMDIRS
6839 local cmd="$LFS find -size 0 -type f -lazy $dir"
6840 local nums=$($cmd | wc -l)
6842 [ $nums -eq $expected ] ||
6843 error "'$cmd' wrong: found $nums, expected $expected"
6844 cmd="$LFS find -size 0 -type f $dir"
6845 nums=$($cmd | wc -l)
6846 [ $nums -eq $expected ] ||
6847 error "'$cmd' wrong: found $nums, expected $expected"
6850 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6851 nums=$($cmd | wc -l)
6852 [ $nums -eq $expected ] ||
6853 error "'$cmd' wrong: found $nums, expected $expected"
6854 cmd="$LFS find ! -size 0 -type f $dir"
6855 nums=$($cmd | wc -l)
6856 [ $nums -eq $expected ] ||
6857 error "'$cmd' wrong: found $nums, expected $expected"
6859 echo "test" > $dir/$tfile
6860 echo "test2" > $dir/$tfile.2 && sync
6862 cmd="$LFS find -size 5 -type f -lazy $dir"
6863 nums=$($cmd | wc -l)
6864 [ $nums -eq $expected ] ||
6865 error "'$cmd' wrong: found $nums, expected $expected"
6866 cmd="$LFS find -size 5 -type f $dir"
6867 nums=$($cmd | wc -l)
6868 [ $nums -eq $expected ] ||
6869 error "'$cmd' wrong: found $nums, expected $expected"
6872 cmd="$LFS find -size +5 -type f -lazy $dir"
6873 nums=$($cmd | wc -l)
6874 [ $nums -eq $expected ] ||
6875 error "'$cmd' wrong: found $nums, expected $expected"
6876 cmd="$LFS find -size +5 -type f $dir"
6877 nums=$($cmd | wc -l)
6878 [ $nums -eq $expected ] ||
6879 error "'$cmd' wrong: found $nums, expected $expected"
6882 cmd="$LFS find -size +0 -type f -lazy $dir"
6883 nums=$($cmd | wc -l)
6884 [ $nums -eq $expected ] ||
6885 error "'$cmd' wrong: found $nums, expected $expected"
6886 cmd="$LFS find -size +0 -type f $dir"
6887 nums=$($cmd | wc -l)
6888 [ $nums -eq $expected ] ||
6889 error "'$cmd' wrong: found $nums, expected $expected"
6892 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6893 nums=$($cmd | wc -l)
6894 [ $nums -eq $expected ] ||
6895 error "'$cmd' wrong: found $nums, expected $expected"
6896 cmd="$LFS find ! -size -5 -type f $dir"
6897 nums=$($cmd | wc -l)
6898 [ $nums -eq $expected ] ||
6899 error "'$cmd' wrong: found $nums, expected $expected"
6902 cmd="$LFS find -size -5 -type f -lazy $dir"
6903 nums=$($cmd | wc -l)
6904 [ $nums -eq $expected ] ||
6905 error "'$cmd' wrong: found $nums, expected $expected"
6906 cmd="$LFS find -size -5 -type f $dir"
6907 nums=$($cmd | wc -l)
6908 [ $nums -eq $expected ] ||
6909 error "'$cmd' wrong: found $nums, expected $expected"
6911 run_test 56r "check lfs find -size works"
6918 cancel_lru_locks $OSC
6920 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6921 local nums=$($cmd | wc -l)
6923 [ $nums -eq $expected ] ||
6924 error "'$cmd' wrong: found $nums, expected $expected"
6926 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6928 if (( rpcs_before + glimpses != rpcs_after )); then
6929 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6930 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6932 if [[ $glimpses == 0 ]]; then
6933 error "'$cmd' should not send glimpse RPCs to OST"
6935 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6941 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6942 skip "MDS < 2.12.58 doesn't return LSOM data"
6943 local dir=$DIR/$tdir
6944 local old_agl=$($LCTL get_param -n llite.*.statahead_agl)
6946 [[ $OSC == "mdc" ]] && skip "statahead not needed for DoM files"
6948 # statahead_agl may cause extra glimpse which confuses results. LU-13017
6949 $LCTL set_param -n llite.*.statahead_agl=0
6950 stack_trap "$LCTL set_param -n llite.*.statahead_agl=$old_agl"
6952 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6953 # open and close all files to ensure LSOM is updated
6954 cancel_lru_locks $OSC
6955 find $dir -type f | xargs cat > /dev/null
6957 # expect_found glimpse_rpcs command_to_run
6958 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6959 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6960 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6961 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6963 echo "test" > $dir/$tfile
6964 echo "test2" > $dir/$tfile.2 && sync
6965 cancel_lru_locks $OSC
6966 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6968 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6969 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6970 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6971 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6973 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6974 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6975 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6976 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6977 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6978 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6980 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6983 local dir=$DIR/$tdir
6984 local tmp=$TMP/$tfile.log
6987 test_mkdir -p $dir || error "failed to mkdir $dir"
6988 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6989 error "failed to setstripe $dir/$tfile"
6990 mdt_idx=$($LFS getdirstripe -i $dir)
6991 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6993 stack_trap "rm -f $tmp" EXIT
6994 $LFS find --size +100K --ost 0 $dir |& tee $tmp
6995 ! grep -q obd_uuid $tmp ||
6996 error "failed to find --size +100K --ost 0 $dir"
6997 $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp
6998 ! grep -q obd_uuid $tmp ||
6999 error "failed to find --size +100K --mdt $mdt_idx $dir"
7001 run_test 56rb "check lfs find --size --ost/--mdt works"
7004 (( MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
7005 local dir=$DIR/$tdir
7008 test_mkdir -c 2 -H all_char $dir || error "failed to mkdir $dir"
7009 $LFS mkdir -c 2 --mdt-hash all_char $dir/$tdir-all{1..10}
7010 (( $MDSCOUNT > 2 )) &&
7011 $LFS mkdir -c 3 --mdt-hash fnv_1a_64 $dir/$tdir-fnv{1..10}
7012 mkdir $dir/$tdir-{1..10}
7013 touch $dir/$tfile-{1..10}
7015 found=$($LFS find $dir --mdt-count 2 | wc -l)
7017 (( $found == $expect )) || error "found $found 2-stripe, expect $expect"
7019 found=$($LFS find $dir -T +1 | wc -l)
7020 (( $MDSCOUNT > 2 )) && expect=$((expect + 10))
7021 (( $found == $expect )) || error "found $found 2+stripe, expect $expect"
7023 found=$($LFS find $dir --mdt-hash all_char | wc -l)
7025 (( $found == $expect )) || error "found $found all_char, expect $expect"
7027 found=$($LFS find $dir --mdt-hash fnv_1a_64 | wc -l)
7028 (( $MDSCOUNT > 2 )) && expect=10 || expect=0
7029 (( $found == $expect )) || error "found $found all_char, expect $expect"
7031 run_test 56rc "check lfs find --mdt-count/--mdt-hash works"
7033 test_56s() { # LU-611 #LU-9369
7034 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
7036 local dir=$DIR/$tdir
7037 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
7039 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
7040 for i in $(seq $NUMDIRS); do
7041 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
7044 local expected=$NUMDIRS
7045 local cmd="$LFS find -c $OSTCOUNT $dir"
7046 local nums=$($cmd | wc -l)
7048 [ $nums -eq $expected ] || {
7049 $LFS getstripe -R $dir
7050 error "'$cmd' wrong: found $nums, expected $expected"
7053 expected=$((NUMDIRS + onestripe))
7054 cmd="$LFS find -stripe-count +0 -type f $dir"
7055 nums=$($cmd | wc -l)
7056 [ $nums -eq $expected ] || {
7057 $LFS getstripe -R $dir
7058 error "'$cmd' wrong: found $nums, expected $expected"
7062 cmd="$LFS find -stripe-count 1 -type f $dir"
7063 nums=$($cmd | wc -l)
7064 [ $nums -eq $expected ] || {
7065 $LFS getstripe -R $dir
7066 error "'$cmd' wrong: found $nums, expected $expected"
7069 cmd="$LFS find -stripe-count -2 -type f $dir"
7070 nums=$($cmd | wc -l)
7071 [ $nums -eq $expected ] || {
7072 $LFS getstripe -R $dir
7073 error "'$cmd' wrong: found $nums, expected $expected"
7077 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
7078 nums=$($cmd | wc -l)
7079 [ $nums -eq $expected ] || {
7080 $LFS getstripe -R $dir
7081 error "'$cmd' wrong: found $nums, expected $expected"
7084 run_test 56s "check lfs find -stripe-count works"
7086 test_56t() { # LU-611 #LU-9369
7087 local dir=$DIR/$tdir
7089 setup_56 $dir 0 $NUMDIRS
7090 for i in $(seq $NUMDIRS); do
7091 $LFS setstripe -S 8M $dir/dir$i/$tfile
7094 local expected=$NUMDIRS
7095 local cmd="$LFS find -S 8M $dir"
7096 local nums=$($cmd | wc -l)
7098 [ $nums -eq $expected ] || {
7099 $LFS getstripe -R $dir
7100 error "'$cmd' wrong: found $nums, expected $expected"
7104 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
7106 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
7108 expected=$(((NUMDIRS + 1) * NUMFILES))
7109 cmd="$LFS find -stripe-size 512k -type f $dir"
7110 nums=$($cmd | wc -l)
7111 [ $nums -eq $expected ] ||
7112 error "'$cmd' wrong: found $nums, expected $expected"
7114 cmd="$LFS find -stripe-size +320k -type f $dir"
7115 nums=$($cmd | wc -l)
7116 [ $nums -eq $expected ] ||
7117 error "'$cmd' wrong: found $nums, expected $expected"
7119 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
7120 cmd="$LFS find -stripe-size +200k -type f $dir"
7121 nums=$($cmd | wc -l)
7122 [ $nums -eq $expected ] ||
7123 error "'$cmd' wrong: found $nums, expected $expected"
7125 cmd="$LFS find -stripe-size -640k -type f $dir"
7126 nums=$($cmd | wc -l)
7127 [ $nums -eq $expected ] ||
7128 error "'$cmd' wrong: found $nums, expected $expected"
7131 cmd="$LFS find -stripe-size 256k -type f $dir"
7132 nums=$($cmd | wc -l)
7133 [ $nums -eq $expected ] ||
7134 error "'$cmd' wrong: found $nums, expected $expected"
7136 cmd="$LFS find -stripe-size -320k -type f $dir"
7137 nums=$($cmd | wc -l)
7138 [ $nums -eq $expected ] ||
7139 error "'$cmd' wrong: found $nums, expected $expected"
7142 cmd="$LFS find -stripe-size 1024k -type f $dir"
7143 nums=$($cmd | wc -l)
7144 [ $nums -eq $expected ] ||
7145 error "'$cmd' wrong: found $nums, expected $expected"
7147 run_test 56t "check lfs find -stripe-size works"
7149 test_56u() { # LU-611
7150 local dir=$DIR/$tdir
7152 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
7154 if [[ $OSTCOUNT -gt 1 ]]; then
7155 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
7161 local expected=$(((NUMDIRS + 1) * NUMFILES))
7162 local cmd="$LFS find -stripe-index 0 -type f $dir"
7163 local nums=$($cmd | wc -l)
7165 [ $nums -eq $expected ] ||
7166 error "'$cmd' wrong: found $nums, expected $expected"
7169 cmd="$LFS find -stripe-index 1 -type f $dir"
7170 nums=$($cmd | wc -l)
7171 [ $nums -eq $expected ] ||
7172 error "'$cmd' wrong: found $nums, expected $expected"
7174 cmd="$LFS find ! -stripe-index 0 -type f $dir"
7175 nums=$($cmd | wc -l)
7176 [ $nums -eq $expected ] ||
7177 error "'$cmd' wrong: found $nums, expected $expected"
7180 # This should produce an error and not return any files
7181 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
7182 nums=$($cmd 2>/dev/null | wc -l)
7183 [ $nums -eq $expected ] ||
7184 error "'$cmd' wrong: found $nums, expected $expected"
7186 if [[ $OSTCOUNT -gt 1 ]]; then
7187 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
7188 cmd="$LFS find -stripe-index 0,1 -type f $dir"
7189 nums=$($cmd | wc -l)
7190 [ $nums -eq $expected ] ||
7191 error "'$cmd' wrong: found $nums, expected $expected"
7194 run_test 56u "check lfs find -stripe-index works"
7198 local dir=$DIR/$tdir
7200 setup_56 $dir $NUMFILES $NUMDIRS
7202 UUID=$(mdtuuid_from_index $mdt_idx $dir)
7203 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
7205 for file in $($LFS find -m $UUID $dir); do
7206 file_midx=$($LFS getstripe -m $file)
7207 [ $file_midx -eq $mdt_idx ] ||
7208 error "lfs find -m $UUID != getstripe -m $file_midx"
7211 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
7214 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7215 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7217 local dir=$DIR/$tdir
7219 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
7221 local stripe_size=$($LFS getstripe -S -d $dir) ||
7222 error "$LFS getstripe -S -d $dir failed"
7223 stripe_size=${stripe_size%% *}
7225 local file_size=$((stripe_size * OSTCOUNT))
7226 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
7227 local required_space=$((file_num * file_size))
7228 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
7230 [[ $free_space -le $((required_space / 1024)) ]] &&
7231 skip_env "need $required_space, have $free_space kbytes"
7234 local dd_count=$((file_size / dd_bs))
7236 # write data into the files
7241 for i in $(seq $NUMFILES); do
7243 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7244 error "write data into $file failed"
7246 for i in $(seq $NUMDIRS); do
7247 for j in $(seq $NUMFILES); do
7248 file=$dir/dir$i/file$j
7249 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
7250 error "write data into $file failed"
7254 # $LFS_MIGRATE will fail if hard link migration is unsupported
7255 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
7256 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
7257 error "creating links to $dir/dir1/file1 failed"
7262 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
7265 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
7268 eval $cmd || error "$cmd failed"
7270 check_stripe_count $dir/file1 $expected
7272 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
7274 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
7275 # OST 1 if it is on OST 0. This file is small enough to
7276 # be on only one stripe.
7277 file=$dir/migr_1_ost
7278 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
7279 error "write data into $file failed"
7280 local obdidx=$($LFS getstripe -i $file)
7281 local oldmd5=$(md5sum $file)
7284 [[ $obdidx -eq 0 ]] && newobdidx=1
7285 cmd="$LFS migrate -i $newobdidx $file"
7287 eval $cmd || error "$cmd failed"
7289 local realobdix=$($LFS getstripe -i $file)
7290 local newmd5=$(md5sum $file)
7292 [[ $newobdidx -ne $realobdix ]] &&
7293 error "new OST is different (was=$obdidx, "\
7294 "wanted=$newobdidx, got=$realobdix)"
7295 [[ "$oldmd5" != "$newmd5" ]] &&
7296 error "md5sum differ: $oldmd5, $newmd5"
7300 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
7302 eval $cmd || error "$cmd failed"
7304 for j in $(seq $NUMFILES); do
7305 check_stripe_count $dir/dir1/file$j $expected
7308 # lfs_migrate works with lfs find
7309 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
7310 $LFS_MIGRATE -y -c $expected"
7312 eval $cmd || error "$cmd failed"
7314 for i in $(seq 2 $NUMFILES); do
7315 check_stripe_count $dir/file$i $expected
7317 for i in $(seq 2 $NUMDIRS); do
7318 for j in $(seq $NUMFILES); do
7319 check_stripe_count $dir/dir$i/file$j $expected
7323 run_test 56w "check lfs_migrate -c stripe_count works"
7326 local file1=$DIR/$tdir/file1
7327 local create_pool=false
7328 local initial_pool=$($LFS getstripe -p $DIR)
7332 echo -n "Creating test dir..."
7333 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7336 echo -n "Creating test file..."
7337 touch $file1 || error "cannot create file"
7340 echo -n "Detecting existing pools..."
7341 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
7343 if [ ${#pool_list[@]} -gt 0 ]; then
7344 echo "${pool_list[@]}"
7345 for thispool in "${pool_list[@]}"; do
7346 if [[ -z "$initial_pool" ||
7347 "$initial_pool" != "$thispool" ]]; then
7349 echo "Using existing pool '$pool'"
7354 echo "none detected."
7356 if [ -z "$pool" ]; then
7357 pool=${POOL:-testpool}
7358 [ "$initial_pool" = "$pool" ] && pool="testpool2"
7359 echo -n "Creating pool '$pool'..."
7361 pool_add $pool &> /dev/null ||
7362 error "pool_add failed"
7365 echo -n "Adding target to pool..."
7366 pool_add_targets $pool 0 0 1 &> /dev/null ||
7367 error "pool_add_targets failed"
7371 echo -n "Setting pool using -p option..."
7372 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
7373 error "migrate failed rc = $?"
7376 echo -n "Verifying test file is in pool after migrating..."
7377 [ "$($LFS getstripe -p $file1)" = $pool ] ||
7378 error "file was not migrated to pool $pool"
7381 echo -n "Removing test file from pool '$pool'..."
7382 # "lfs migrate $file" won't remove the file from the pool
7383 # until some striping information is changed.
7384 $LFS migrate -c 1 $file1 &> /dev/null ||
7385 error "cannot remove from pool"
7386 [ "$($LFS getstripe -p $file1)" ] &&
7387 error "pool still set"
7390 echo -n "Setting pool using --pool option..."
7391 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
7392 error "migrate failed rc = $?"
7397 if $create_pool; then
7398 destroy_test_pools 2> /dev/null ||
7399 error "destroy test pools failed"
7402 run_test 56wb "check lfs_migrate pool support"
7405 local file1="$DIR/$tdir/file1"
7412 echo -n "Creating test dir..."
7413 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
7414 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
7415 error "cannot set stripe by '-S 1M -c 1'"
7418 echo -n "Setting initial stripe for test file..."
7419 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
7420 error "cannot set stripe"
7421 cur_ssize=$($LFS getstripe -S "$file1")
7422 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
7425 # File currently set to -S 512K -c 1
7427 # Ensure -c and -S options are rejected when -R is set
7428 echo -n "Verifying incompatible options are detected..."
7429 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
7430 error "incompatible -c and -R options not detected"
7431 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
7432 error "incompatible -S and -R options not detected"
7435 # Ensure unrecognized options are passed through to 'lfs migrate'
7436 echo -n "Verifying -S option is passed through to lfs migrate..."
7437 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
7438 error "migration failed"
7439 cur_ssize=$($LFS getstripe -S "$file1")
7440 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
7443 # File currently set to -S 1M -c 1
7445 # Ensure long options are supported
7446 echo -n "Verifying long options supported..."
7447 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
7448 error "long option without argument not supported"
7449 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
7450 error "long option with argument not supported"
7451 cur_ssize=$($LFS getstripe -S "$file1")
7452 [ $cur_ssize -eq 524288 ] ||
7453 error "migrate --stripe-size $cur_ssize != 524288"
7456 # File currently set to -S 512K -c 1
7458 if [ "$OSTCOUNT" -gt 1 ]; then
7459 echo -n "Verifying explicit stripe count can be set..."
7460 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
7461 error "migrate failed"
7462 cur_scount=$($LFS getstripe -c "$file1")
7463 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
7467 # File currently set to -S 512K -c 1 or -S 512K -c 2
7469 # Ensure parent striping is used if -R is set, and no stripe
7470 # count or size is specified
7471 echo -n "Setting stripe for parent directory..."
7472 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7473 error "cannot set stripe '-S 2M -c 1'"
7476 echo -n "Verifying restripe option uses parent stripe settings..."
7477 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
7478 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
7479 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
7480 error "migrate failed"
7481 cur_ssize=$($LFS getstripe -S "$file1")
7482 [ $cur_ssize -eq $parent_ssize ] ||
7483 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
7484 cur_scount=$($LFS getstripe -c "$file1")
7485 [ $cur_scount -eq $parent_scount ] ||
7486 error "migrate -R stripe_count $cur_scount != $parent_scount"
7489 # File currently set to -S 1M -c 1
7491 # Ensure striping is preserved if -R is not set, and no stripe
7492 # count or size is specified
7493 echo -n "Verifying striping size preserved when not specified..."
7494 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
7495 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
7496 error "cannot set stripe on parent directory"
7497 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7498 error "migrate failed"
7499 cur_ssize=$($LFS getstripe -S "$file1")
7500 [ $cur_ssize -eq $orig_ssize ] ||
7501 error "migrate by default $cur_ssize != $orig_ssize"
7504 # Ensure file name properly detected when final option has no argument
7505 echo -n "Verifying file name properly detected..."
7506 $LFS_MIGRATE -y "$file1" &> /dev/null ||
7507 error "file name interpreted as option argument"
7513 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
7516 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7518 local file1=$DIR/$tdir/file1
7520 echo -n "Creating test dir..."
7521 test_mkdir $DIR/$tdir || error "cannot create dir"
7524 echo -n "Creating test file..."
7528 # Ensure 'lfs migrate' will fail by using a non-existent option,
7529 # and make sure rsync is not called to recover
7530 echo -n "Make sure --no-rsync option works..."
7531 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
7532 grep -q 'refusing to fall back to rsync' ||
7533 error "rsync was called with --no-rsync set"
7536 # Ensure rsync is called without trying 'lfs migrate' first
7537 echo -n "Make sure --rsync option works..."
7538 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
7539 grep -q 'falling back to rsync' &&
7540 error "lfs migrate was called with --rsync set"
7543 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
7544 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
7545 grep -q 'at the same time' ||
7546 error "--rsync and --no-rsync accepted concurrently"
7552 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
7558 test_mkdir $td || error "cannot create $td"
7559 touch $tf || error "cannot touch $tf"
7561 echo -n "Make sure --non-direct|-D works..."
7562 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
7563 grep -q "lfs migrate --non-direct" ||
7564 error "--non-direct option cannot work correctly"
7565 $LFS_MIGRATE -y -D -v $tf 2>&1 |
7566 grep -q "lfs migrate -D" ||
7567 error "-D option cannot work correctly"
7570 run_test 56we "check lfs_migrate --non-direct|-D support"
7573 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7574 check_swap_layouts_support
7576 local dir=$DIR/$tdir
7577 local ref1=/etc/passwd
7578 local file1=$dir/file1
7580 test_mkdir $dir || error "creating dir $dir"
7581 $LFS setstripe -c 2 $file1
7583 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
7584 stripe=$($LFS getstripe -c $file1)
7585 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7586 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7591 run_test 56x "lfs migration support"
7594 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7595 check_swap_layouts_support
7597 local dir=$DIR/$tdir/$testnum
7601 local ref1=/etc/passwd
7602 local file1=$dir/file1
7604 $LFS setstripe -c 2 $file1
7606 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
7608 local stripe=$($LFS getstripe -c $file1)
7610 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
7611 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
7616 run_test 56xa "lfs migration --block support"
7618 check_migrate_links() {
7620 local file1="$dir/file1"
7624 local total_count=$(($begin + $count - 1))
7625 local symlink_count=10
7628 if [ ! -f "$file1" ]; then
7629 echo -n "creating initial file..."
7630 $LFS setstripe -c 1 -S "512k" "$file1" ||
7631 error "cannot setstripe initial file"
7634 echo -n "creating symlinks..."
7635 for s in $(seq 1 $symlink_count); do
7636 ln -s "$file1" "$dir/slink$s" ||
7637 error "cannot create symlinks"
7641 echo -n "creating nonlinked files..."
7642 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
7643 error "cannot create nonlinked files"
7648 if [ ! -f "$dir/file$total_count" ]; then
7649 echo -n "creating hard links $begin:$total_count..."
7650 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
7651 /dev/null || error "cannot create hard links"
7655 echo -n "checking number of hard links listed in xattrs..."
7656 local fid=$($LFS getstripe -F "$file1")
7657 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
7660 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
7661 skip "hard link list has unexpected size, skipping test"
7663 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
7664 error "link names should exceed xattrs size"
7667 echo -n "migrating files..."
7668 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
7670 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
7673 # make sure all links have been properly migrated
7674 echo -n "verifying files..."
7675 fid=$($LFS getstripe -F "$file1") ||
7676 error "cannot get fid for file $file1"
7677 for i in $(seq 2 $total_count); do
7678 local fid2=$($LFS getstripe -F $dir/file$i)
7680 [ "$fid2" == "$fid" ] ||
7681 error "migrated hard link has mismatched FID"
7684 # make sure hard links were properly detected, and migration was
7685 # performed only once for the entire link set; nonlinked files should
7687 local actual=$(grep -c 'done' <<< "$migrate_out")
7688 local expected=$(($uniq_count + 1))
7690 [ "$actual" -eq "$expected" ] ||
7691 error "hard links individually migrated ($actual != $expected)"
7693 # make sure the correct number of hard links are present
7694 local hardlinks=$(stat -c '%h' "$file1")
7696 [ $hardlinks -eq $total_count ] ||
7697 error "num hard links $hardlinks != $total_count"
7704 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7705 skip "Need MDS version at least 2.10.55"
7707 local dir="$DIR/$tdir"
7709 test_mkdir "$dir" || error "cannot create dir $dir"
7711 echo "testing lfs migrate mode when all links fit within xattrs"
7712 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
7714 echo "testing rsync mode when all links fit within xattrs"
7715 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
7717 echo "testing lfs migrate mode when all links do not fit within xattrs"
7718 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
7720 echo "testing rsync mode when all links do not fit within xattrs"
7721 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
7723 chown -R $RUNAS_ID $dir
7724 echo "testing non-root lfs migrate mode when not all links are in xattr"
7725 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
7730 run_test 56xb "lfs migration hard link support"
7733 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7735 local dir="$DIR/$tdir"
7737 test_mkdir "$dir" || error "cannot create dir $dir"
7739 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7740 echo -n "Setting initial stripe for 20MB test file..."
7741 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7742 error "cannot setstripe 20MB file"
7744 echo -n "Sizing 20MB test file..."
7745 $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7747 echo -n "Verifying small file autostripe count is 1..."
7748 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7749 error "cannot migrate 20MB file"
7750 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7751 error "cannot get stripe for $dir/20mb"
7752 [ $stripe_count -eq 1 ] ||
7753 error "unexpected stripe count $stripe_count for 20MB file"
7757 # Test 2: File is small enough to fit within the available space on
7758 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7759 # have at least an additional 1KB for each desired stripe for test 3
7760 echo -n "Setting stripe for 1GB test file..."
7761 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7763 echo -n "Sizing 1GB test file..."
7764 # File size is 1GB + 3KB
7765 $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7768 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7769 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7770 if (( avail > 524288 * OSTCOUNT )); then
7771 echo -n "Migrating 1GB file..."
7772 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7773 error "cannot migrate 1GB file"
7775 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7776 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7777 error "cannot getstripe for 1GB file"
7778 [ $stripe_count -eq 2 ] ||
7779 error "unexpected stripe count $stripe_count != 2"
7783 # Test 3: File is too large to fit within the available space on
7784 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7785 if [ $OSTCOUNT -ge 3 ]; then
7786 # The required available space is calculated as
7787 # file size (1GB + 3KB) / OST count (3).
7788 local kb_per_ost=349526
7790 echo -n "Migrating 1GB file with limit..."
7791 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7792 error "cannot migrate 1GB file with limit"
7795 stripe_count=$($LFS getstripe -c "$dir/1gb")
7796 echo -n "Verifying 1GB autostripe count with limited space..."
7797 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7798 error "unexpected stripe count $stripe_count (min 3)"
7805 run_test 56xc "lfs migration autostripe"
7808 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7810 local dir=$DIR/$tdir
7811 local f_mgrt=$dir/$tfile.mgrt
7812 local f_yaml=$dir/$tfile.yaml
7813 local f_copy=$dir/$tfile.copy
7814 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7815 local layout_copy="-c 2 -S 2M -i 1"
7816 local yamlfile=$dir/yamlfile
7817 local layout_before;
7820 test_mkdir "$dir" || error "cannot create dir $dir"
7821 $LFS setstripe $layout_yaml $f_yaml ||
7822 error "cannot setstripe $f_yaml with layout $layout_yaml"
7823 $LFS getstripe --yaml $f_yaml > $yamlfile
7824 $LFS setstripe $layout_copy $f_copy ||
7825 error "cannot setstripe $f_copy with layout $layout_copy"
7827 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7829 # 1. test option --yaml
7830 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7831 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7832 layout_before=$(get_layout_param $f_yaml)
7833 layout_after=$(get_layout_param $f_mgrt)
7834 [ "$layout_after" == "$layout_before" ] ||
7835 error "lfs_migrate --yaml: $layout_after != $layout_before"
7837 # 2. test option --copy
7838 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7839 error "cannot migrate $f_mgrt with --copy $f_copy"
7840 layout_before=$(get_layout_param $f_copy)
7841 layout_after=$(get_layout_param $f_mgrt)
7842 [ "$layout_after" == "$layout_before" ] ||
7843 error "lfs_migrate --copy: $layout_after != $layout_before"
7845 run_test 56xd "check lfs_migrate --yaml and --copy support"
7848 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7850 local dir=$DIR/$tdir
7851 local f_comp=$dir/$tfile
7852 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7853 local layout_before=""
7854 local layout_after=""
7856 test_mkdir "$dir" || error "cannot create dir $dir"
7857 $LFS setstripe $layout $f_comp ||
7858 error "cannot setstripe $f_comp with layout $layout"
7859 layout_before=$(get_layout_param $f_comp)
7860 dd if=/dev/zero of=$f_comp bs=1M count=4
7862 # 1. migrate a comp layout file by lfs_migrate
7863 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7864 layout_after=$(get_layout_param $f_comp)
7865 [ "$layout_before" == "$layout_after" ] ||
7866 error "lfs_migrate: $layout_before != $layout_after"
7868 # 2. migrate a comp layout file by lfs migrate
7869 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7870 layout_after=$(get_layout_param $f_comp)
7871 [ "$layout_before" == "$layout_after" ] ||
7872 error "lfs migrate: $layout_before != $layout_after"
7874 run_test 56xe "migrate a composite layout file"
7877 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7879 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7880 skip "Need server version at least 2.13.53"
7882 local dir=$DIR/$tdir
7883 local f_comp=$dir/$tfile
7884 local layout="-E 1M -c1 -E -1 -c2"
7888 test_mkdir "$dir" || error "cannot create dir $dir"
7889 $LFS setstripe $layout $f_comp ||
7890 error "cannot setstripe $f_comp with layout $layout"
7891 fid_before=$($LFS getstripe --fid $f_comp)
7892 dd if=/dev/zero of=$f_comp bs=1M count=4
7894 # 1. migrate a comp layout file to a comp layout
7895 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7896 fid_after=$($LFS getstripe --fid $f_comp)
7897 [ "$fid_before" == "$fid_after" ] ||
7898 error "comp-to-comp migrate: $fid_before != $fid_after"
7900 # 2. migrate a comp layout file to a plain layout
7901 $LFS migrate -c2 $f_comp ||
7902 error "cannot migrate $f_comp by lfs migrate"
7903 fid_after=$($LFS getstripe --fid $f_comp)
7904 [ "$fid_before" == "$fid_after" ] ||
7905 error "comp-to-plain migrate: $fid_before != $fid_after"
7907 # 3. migrate a plain layout file to a comp layout
7908 $LFS migrate $layout $f_comp ||
7909 error "cannot migrate $f_comp by lfs migrate"
7910 fid_after=$($LFS getstripe --fid $f_comp)
7911 [ "$fid_before" == "$fid_after" ] ||
7912 error "plain-to-comp migrate: $fid_before != $fid_after"
7914 run_test 56xf "FID is not lost during migration of a composite layout file"
7916 check_file_ost_range() {
7923 file_range=($($LFS getstripe -y "$file" |
7924 awk '/l_ost_idx:/ { print $NF }'))
7926 if [[ "${#file_range[@]}" = 0 ]]; then
7927 echo "No osts found for $file"
7931 for idx in "${file_range[@]}"; do
7932 [[ " $range " =~ " $idx " ]] ||
7940 local stripe_opt="$1"
7943 local pool_ostidx="$(seq $* | tr '\n' ' ')"
7945 $LFS migrate $stripe_opt -p $pool $DIR/$tfile ||
7946 error "Fail to migrate $tfile on $pool"
7947 [[ "$($LFS getstripe -p $DIR/$tfile)" = "$pool" ]] ||
7948 error "$tfile is not in pool $pool"
7949 check_file_ost_range "$DIR/$tfile" $pool_ostidx ||
7950 error "$tfile osts mismatch with pool $pool (osts $pool_ostidx)"
7954 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7955 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
7956 [[ $MDS1_VERSION -gt $(version_code 2.14.52) ]] ||
7957 skip "Need MDS version newer than 2.14.52"
7959 local -a pool_names=("${TESTNAME}_0" "${TESTNAME}_1" "${TESTNAME}_2")
7960 local -a pool_ranges=("0 0" "1 1" "0 1")
7963 for i in "${!pool_names[@]}"; do
7964 pool_add ${pool_names[$i]} ||
7965 error "pool_add failed (pool: ${pool_names[$i]})"
7966 pool_add_targets ${pool_names[$i]} ${pool_ranges[$i]} ||
7967 error "pool_add_targets failed (pool: ${pool_names[$i]})"
7970 # init the file to migrate
7971 $LFS setstripe -c1 -i1 $DIR/$tfile ||
7972 error "Unable to create $tfile on OST1"
7973 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=4 status=none ||
7974 error "Unable to write on $tfile"
7976 echo "1. migrate $tfile on pool ${pool_names[0]}"
7977 sub_test_56xg "-c-1" "${pool_names[0]}" ${pool_ranges[0]}
7979 echo "2. migrate $tfile on pool ${pool_names[2]}"
7980 sub_test_56xg "-c-1 -S2M" "${pool_names[2]}" ${pool_ranges[2]}
7982 echo "3. migrate $tfile on pool ${pool_names[1]}"
7983 sub_test_56xg "-n -c-1" "${pool_names[1]}" ${pool_ranges[1]}
7985 echo "4. migrate $tfile on pool ${pool_names[2]} with default stripe parameters"
7986 sub_test_56xg "" "${pool_names[2]}" ${pool_ranges[2]}
7990 destroy_test_pools ||
7991 error "pool_destroy failed"
7993 run_test 56xg "lfs migrate pool support"
7996 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
7997 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
8000 local dir=$DIR/$tdir
8004 test_mkdir -p $dir || error "creating dir $dir"
8005 touch $f1 || error "creating std file $f1"
8006 $MULTIOP $f2 H2c || error "creating released file $f2"
8008 # a directory can be raid0, so ask only for files
8009 res=$($LFS find $dir -L raid0 -type f | wc -l)
8010 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
8012 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
8013 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
8015 # only files can be released, so no need to force file search
8016 res=$($LFS find $dir -L released)
8017 [[ $res == $f2 ]] || error "search released: found $res != $f2"
8019 res=$($LFS find $dir -type f \! -L released)
8020 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
8022 run_test 56y "lfs find -L raid0|released"
8024 test_56z() { # LU-4824
8025 # This checks to make sure 'lfs find' continues after errors
8026 # There are two classes of errors that should be caught:
8027 # - If multiple paths are provided, all should be searched even if one
8029 # - If errors are encountered during the search, it should not terminate
8031 local dir=$DIR/$tdir
8035 for i in d{0..9}; do
8037 touch $dir/$i/$tfile
8039 $LFS find $DIR/non_existent_dir $dir &&
8040 error "$LFS find did not return an error"
8041 # Make a directory unsearchable. This should NOT be the last entry in
8042 # directory order. Arbitrarily pick the 6th entry
8043 chmod 700 $($LFS find $dir -type d | sed '6!d')
8045 $RUNAS $LFS find $DIR/non_existent $dir
8046 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
8048 # The user should be able to see 10 directories and 9 files
8049 (( count == 19 )) ||
8050 error "$LFS find found $count != 19 entries after error"
8052 run_test 56z "lfs find should continue after an error"
8054 test_56aa() { # LU-5937
8055 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
8057 local dir=$DIR/$tdir
8060 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
8062 createmany -o $dir/striped_dir/${tfile}- 1024
8063 local dirs=$($LFS find --size +8k $dir/)
8065 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
8067 run_test 56aa "lfs find --size under striped dir"
8069 test_56ab() { # LU-10705
8070 test_mkdir $DIR/$tdir
8071 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
8072 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
8073 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
8074 # Flush writes to ensure valid blocks. Need to be more thorough for
8075 # ZFS, since blocks are not allocated/returned to client immediately.
8077 wait_zfs_commit ost1 2
8078 cancel_lru_locks osc
8081 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
8083 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
8085 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
8086 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
8088 rm -f $DIR/$tdir/$tfile.[123]
8090 run_test 56ab "lfs find --blocks"
8094 local dir="$DIR/$tdir"
8095 local perms=(001 002 003 004 005 006 007
8096 010 020 030 040 050 060 070
8097 100 200 300 400 500 600 700
8098 111 222 333 444 555 666 777)
8099 local perm_minus=(8 8 4 8 4 4 2
8103 local perm_slash=(8 8 12 8 12 12 14
8106 16 16 24 16 24 24 28)
8109 for perm in ${perms[*]}; do
8110 touch "$dir/$tfile.$perm"
8111 chmod $perm "$dir/$tfile.$perm"
8114 for ((i = 0; i < ${#perms[*]}; i++)); do
8115 local num=$($LFS find $dir -perm ${perms[i]} | wc -l)
8117 error "lfs find -perm ${perms[i]}:"\
8120 num=$($LFS find $dir -perm -${perms[i]} -type f| wc -l)
8121 (( $num == ${perm_minus[i]} )) ||
8122 error "lfs find -perm -${perms[i]}:"\
8123 "$num != ${perm_minus[i]}"
8125 num=$($LFS find $dir -perm /${perms[i]} -type f| wc -l)
8126 (( $num == ${perm_slash[i]} )) ||
8127 error "lfs find -perm /${perms[i]}:"\
8128 "$num != ${perm_slash[i]}"
8131 run_test 56aca "check lfs find -perm with octal representation"
8134 local dir=$DIR/$tdir
8135 # p is the permission of write and execute for user, group and other
8136 # without the umask. It is used to test +wx.
8137 local p=$(printf "%o" "$((0333 & ~$(umask)))")
8138 local perms=(1000 000 2000 4000 $p 644 111 110 100 004)
8139 local symbolic=(+t a+t u+t g+t o+t
8145 o=r,ug+o,u+w u=r,a+u,u+w
8146 g=r,ugo=g,u+w u+x,+X +X
8147 u+x,u+X u+X u+x,g+X o+r,+X
8151 for perm in ${perms[*]}; do
8152 touch "$dir/$tfile.$perm"
8153 chmod $perm "$dir/$tfile.$perm"
8156 for (( i = 0; i < ${#symbolic[*]}; i++ )); do
8157 local num=$($LFS find $dir -perm ${symbolic[i]} | wc -l)
8160 error "lfs find $dir -perm ${symbolic[i]}: $num != 1"
8163 run_test 56acb "check lfs find -perm with symbolic representation"
8166 local dir=$DIR/$tdir
8167 local tests="17777 787 789 abcd
8168 ug=uu ug=a ug=gu uo=ou urw
8172 for err in $tests; do
8173 if $LFS find $dir -perm $err 2>/dev/null; then
8174 error "lfs find -perm $err: parsing should have failed"
8178 run_test 56acc "check parsing error for lfs find -perm"
8181 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
8182 skip "Need MDS version at least 2.10.50"
8184 # Create composite files with one component
8185 local dir=$DIR/$tdir
8187 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
8188 # Create composite files with three components
8189 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
8190 # Create non-composite files
8191 createmany -o $dir/${tfile}- 10
8193 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
8195 [[ $nfiles == 10 ]] ||
8196 error "lfs find -E 1M found $nfiles != 10 files"
8198 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
8199 [[ $nfiles == 25 ]] ||
8200 error "lfs find ! -E 1M found $nfiles != 25 files"
8202 # All files have a component that starts at 0
8203 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
8204 [[ $nfiles == 35 ]] ||
8205 error "lfs find --component-start 0 - $nfiles != 35 files"
8207 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
8208 [[ $nfiles == 15 ]] ||
8209 error "lfs find --component-start 2M - $nfiles != 15 files"
8211 # All files created here have a componenet that does not starts at 2M
8212 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
8213 [[ $nfiles == 35 ]] ||
8214 error "lfs find ! --component-start 2M - $nfiles != 35 files"
8216 # Find files with a specified number of components
8217 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
8218 [[ $nfiles == 15 ]] ||
8219 error "lfs find --component-count 3 - $nfiles != 15 files"
8221 # Remember non-composite files have a component count of zero
8222 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
8223 [[ $nfiles == 10 ]] ||
8224 error "lfs find --component-count 0 - $nfiles != 10 files"
8226 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
8227 [[ $nfiles == 20 ]] ||
8228 error "lfs find ! --component-count 3 - $nfiles != 20 files"
8230 # All files have a flag called "init"
8231 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
8232 [[ $nfiles == 35 ]] ||
8233 error "lfs find --component-flags init - $nfiles != 35 files"
8235 # Multi-component files will have a component not initialized
8236 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
8237 [[ $nfiles == 15 ]] ||
8238 error "lfs find !--component-flags init - $nfiles != 15 files"
8243 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
8246 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
8247 skip "Need MDS version at least 2.10.57"
8257 # create mirrored directories and mirrored files
8258 mkdir $td || error "mkdir $td failed"
8259 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
8260 createmany -o $tf- 10 || error "create $tf- failed"
8262 for i in $(seq 2); do
8264 mkdir $dir || error "mkdir $dir failed"
8265 $LFS mirror create -N$((3 + i)) $dir ||
8266 error "create mirrored dir $dir failed"
8267 createmany -o $dir/$tfile- 10 ||
8268 error "create $dir/$tfile- failed"
8271 # change the states of some mirrored files
8273 for i in $(seq 2); do
8275 for j in $(seq 4 9); do
8276 echo foo > $dir/$tfile-$j
8280 # find mirrored files with specific mirror count
8281 cmd="$LFS find --mirror-count 3 --type f $td"
8282 nfiles=$($cmd | wc -l)
8283 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
8285 cmd="$LFS find ! --mirror-count 3 --type f $td"
8286 nfiles=$($cmd | wc -l)
8287 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
8289 cmd="$LFS find --mirror-count +2 --type f $td"
8290 nfiles=$($cmd | wc -l)
8291 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8293 cmd="$LFS find --mirror-count -6 --type f $td"
8294 nfiles=$($cmd | wc -l)
8295 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8297 # find mirrored files with specific file state
8298 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
8299 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
8301 cmd="$LFS find --mirror-state=ro --type f $td"
8302 nfiles=$($cmd | wc -l)
8303 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
8305 cmd="$LFS find ! --mirror-state=ro --type f $td"
8306 nfiles=$($cmd | wc -l)
8307 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8309 cmd="$LFS find --mirror-state=wp --type f $td"
8310 nfiles=$($cmd | wc -l)
8311 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
8313 cmd="$LFS find ! --mirror-state=sp --type f $td"
8314 nfiles=$($cmd | wc -l)
8315 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
8317 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
8319 test_56da() { # LU-14179
8320 local path=$DIR/$tdir
8325 local longdir=$(str_repeat 'a' 255)
8327 for i in {1..15}; do
8334 local lastdir=$(str_repeat 'a' $((4096 - 1 - $len - 1)))
8339 (( ${#PWD} == 4095 )) || error "bad PWD length ${#PWD}, expect 4095"
8342 touch $(str_repeat 'f' 255)
8344 $LFS find $DIR/$tdir --type d |& grep "lfs find: error" &&
8345 error "lfs find reported an error"
8349 run_test 56da "test lfs find with long paths"
8351 test_56ea() { #LU-10378
8352 local path=$DIR/$tdir
8353 local pool=$TESTNAME
8356 pool_add $pool || error "pool_add $pool failed"
8357 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8358 error "adding targets to $pool failed"
8360 # Set default pool on directory before creating file
8361 mkdir $path || error "mkdir $path failed"
8362 $LFS setstripe -p $pool $path ||
8363 error "set OST pool on $pool failed"
8364 touch $path/$tfile || error "touch $path/$tfile failed"
8366 # Compare basic file attributes from -printf and stat
8367 local attr_printf=$($LFS find $path/$tfile -printf "%A@ %T@ %C@ %U %G")
8368 local attr_stat=$(stat -c "%X %Y %Z %u %g" $path/$tfile)
8370 [[ "${attr_printf}" == "${attr_stat}" ]] ||
8371 error "Attrs from lfs find and stat don't match"
8373 # Compare Lustre attributes from lfs find and lfs getstripe
8374 local lattr_printf=$($LFS find $path/$tfile -printf "%Lc %LS %Li %Lp")
8375 local str_cnt=$($LFS getstripe --stripe-count $path/$tfile)
8376 local str_size=$($LFS getstripe --stripe-size $path/$tfile)
8377 local str_idx=$($LFS getstripe --stripe-index $path/$tfile)
8378 local fpool=$($LFS getstripe --pool $path/$tfile)
8379 local lattr_getstr="${str_cnt} ${str_size} ${str_idx} ${fpool}"
8381 [[ "${lattr_printf}" == "${lattr_getstr}" ]] ||
8382 error "Attrs from lfs find and lfs getstripe don't match"
8384 # Verify behavior for unknown escape/format sequences
8385 local esc_printf=$($LFS find $path/$tfile -printf '\\ %% \Q %Q')
8387 [[ "${esc_printf}" == '\ % \Q %Q' ]] ||
8388 error "Escape/format codes don't match"
8390 run_test 56ea "test lfs find -printf option"
8393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8394 # note test will not do anything if MDS is not local
8395 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8396 skip_env "ldiskfs only test"
8398 remote_mds_nodsh && skip "remote MDS with nodsh"
8400 local MNTDEV="osd*.*MDT*.mntdev"
8401 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
8402 [ -z "$DEV" ] && error "can't access $MNTDEV"
8403 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
8404 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
8405 error "can't access $DEV"
8406 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
8407 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
8411 run_test 57a "verify MDS filesystem created with large inodes =="
8414 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8415 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8416 skip_env "ldiskfs only test"
8418 remote_mds_nodsh && skip "remote MDS with nodsh"
8420 local dir=$DIR/$tdir
8423 local fileN=$dir/f$filecount
8425 rm -rf $dir || error "removing $dir"
8427 local mdtidx=$($LFS getstripe -m $dir)
8428 local mdtname=MDT$(printf %04x $mdtidx)
8429 local facet=mds$((mdtidx + 1))
8431 echo "mcreating $filecount files"
8432 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
8434 # verify that files do not have EAs yet
8435 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
8436 error "$file1 has an EA"
8437 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
8438 error "$fileN has an EA"
8442 df $dir #make sure we get new statfs data
8443 local mdsfree=$(do_facet $facet \
8444 lctl get_param -n osd*.*$mdtname.kbytesfree)
8445 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8448 echo "opening files to create objects/EAs"
8449 for file in $(seq -f $dir/f%g 1 $filecount); do
8450 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
8451 error "opening $file"
8454 # verify that files have EAs now
8455 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
8456 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
8458 sleep 1 #make sure we get new statfs data
8460 local mdsfree2=$(do_facet $facet \
8461 lctl get_param -n osd*.*$mdtname.kbytesfree)
8462 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
8464 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
8465 if [ "$mdsfree" != "$mdsfree2" ]; then
8466 error "MDC before $mdcfree != after $mdcfree2"
8468 echo "MDC before $mdcfree != after $mdcfree2"
8469 echo "unable to confirm if MDS has large inodes"
8474 run_test 57b "default LOV EAs are stored inside large inodes ==="
8477 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8478 [ -z "$(which wiretest 2>/dev/null)" ] &&
8479 skip_env "could not find wiretest"
8483 run_test 58 "verify cross-platform wire constants =============="
8486 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8488 echo "touch 130 files"
8489 createmany -o $DIR/f59- 130
8491 unlinkmany $DIR/f59- 130
8493 # wait for commitment of removal
8494 wait_delete_completed
8496 run_test 59 "verify cancellation of llog records async ========="
8498 TEST60_HEAD="test_60 run $RANDOM"
8500 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8501 remote_mgs_nodsh && skip "remote MGS with nodsh"
8502 do_facet mgs "! which run-llog.sh &> /dev/null" &&
8503 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
8504 skip_env "missing subtest run-llog.sh"
8506 log "$TEST60_HEAD - from kernel mode"
8507 do_facet mgs "$LCTL dk > /dev/null"
8508 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
8509 do_facet mgs $LCTL dk > $TMP/$tfile
8511 # LU-6388: test llog_reader
8512 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
8513 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
8514 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
8515 skip_env "missing llog_reader"
8516 local fstype=$(facet_fstype mgs)
8517 [ $fstype != ldiskfs -a $fstype != zfs ] &&
8518 skip_env "Only for ldiskfs or zfs type mgs"
8520 local mntpt=$(facet_mntpt mgs)
8521 local mgsdev=$(mgsdevname 1)
8533 #get fid and record list
8534 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
8536 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
8538 #remount mgs as ldiskfs or zfs type
8539 stop mgs || error "stop mgs failed"
8540 mount_fstype mgs || error "remount mgs failed"
8541 for ((i = 0; i < ${#fid_list[@]}; i++)); do
8544 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
8545 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
8550 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
8552 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
8554 echo "obj_file is $obj_file"
8555 do_facet mgs $llog_reader $obj_file
8557 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
8558 awk '{ print $3 }' | sed -e "s/^type=//g")
8559 if [ $rec_type != $rec ]; then
8560 echo "FAILED test_60a wrong record type $rec_type," \
8566 #check obj path if record type is LLOG_LOGID_MAGIC
8567 if [ "$rec" == "1064553b" ]; then
8568 path=$(do_facet mgs $llog_reader $obj_file |
8569 grep "path=" | awk '{ print $NF }' |
8570 sed -e "s/^path=//g")
8571 if [ $obj_file != $mntpt/$path ]; then
8572 echo "FAILED test_60a wrong obj path" \
8573 "$montpt/$path, should be $obj_file"
8580 #restart mgs before "error", otherwise it will block the next test
8581 stop mgs || error "stop mgs failed"
8582 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
8583 $pass || error "test failed, see FAILED test_60a messages for specifics"
8585 run_test 60a "llog_test run from kernel module and test llog_reader"
8587 test_60b() { # bug 6411
8588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8591 LLOG_COUNT=$(do_facet mgs dmesg |
8592 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
8593 /llog_[a-z]*.c:[0-9]/ {
8605 [[ $LLOG_COUNT -gt 120 ]] &&
8606 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
8608 run_test 60b "limit repeated messages from CERROR/CWARN"
8611 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8613 echo "create 5000 files"
8614 createmany -o $DIR/f60c- 5000
8615 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
8616 lctl set_param fail_loc=0x80000137
8617 unlinkmany $DIR/f60c- 5000
8618 lctl set_param fail_loc=0
8620 run_test 60c "unlink file when mds full"
8623 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8625 SAVEPRINTK=$(lctl get_param -n printk)
8626 # verify "lctl mark" is even working"
8627 MESSAGE="test message ID $RANDOM $$"
8628 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8629 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
8631 lctl set_param printk=0 || error "set lnet.printk failed"
8632 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
8633 MESSAGE="new test message ID $RANDOM $$"
8634 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
8635 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
8636 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
8638 lctl set_param -n printk="$SAVEPRINTK"
8640 run_test 60d "test printk console message masking"
8643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8644 remote_mds_nodsh && skip "remote MDS with nodsh"
8647 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
8648 do_facet mds1 lctl set_param fail_loc=0x15b
8651 run_test 60e "no space while new llog is being created"
8654 local old_path=$($LCTL get_param -n debug_path)
8656 stack_trap "$LCTL set_param debug_path=$old_path"
8657 stack_trap "rm -f $TMP/$tfile*"
8658 rm -f $TMP/$tfile* 2> /dev/null
8659 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8660 $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e
8661 test_mkdir $DIR/$tdir
8662 # retry in case the open is cached and not released
8663 for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do
8664 echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i
8668 (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped"
8670 run_test 60f "change debug_path works"
8676 test_mkdir -c $MDSCOUNT $DIR/$tdir
8681 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
8682 -c $MDSCOUNT $DIR/$tdir/subdir$index \
8684 mkdir $DIR/$tdir/subdir$index 2>/dev/null
8685 rmdir $DIR/$tdir/subdir$index 2>/dev/null
8686 index=$((index + 1))
8692 for i in {0..100}; do
8693 # define OBD_FAIL_OSD_TXN_START 0x19a
8694 local index=$((i % MDSCOUNT + 1))
8696 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
8703 for i in $(seq $MDSCOUNT); do
8704 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
8707 mkdir $DIR/$tdir/new || error "mkdir failed"
8708 rmdir $DIR/$tdir/new || error "rmdir failed"
8710 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
8712 for i in $(seq $MDSCOUNT); do
8713 wait_update_facet mds$i "$LCTL get_param -n \
8714 mdd.$(facet_svc mds$i).lfsck_namespace |
8715 awk '/^status/ { print \\\$2 }'" "completed"
8719 rm -rf $DIR/$tdir || error "rmdir failed"
8721 run_test 60g "transaction abort won't cause MDT hung"
8724 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
8725 skip "Need MDS version at least 2.12.52"
8726 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
8730 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
8731 #define OBD_FAIL_MDS_STRIPE_FID 0x189
8732 for fail_loc in 0x80000188 0x80000189; do
8733 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
8734 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
8735 error "mkdir $dir-$fail_loc failed"
8736 for i in {0..10}; do
8737 # create may fail on missing stripe
8738 echo $i > $DIR/$tdir-$fail_loc/$i
8740 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8741 error "getdirstripe $tdir-$fail_loc failed"
8742 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
8743 error "migrate $tdir-$fail_loc failed"
8744 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
8745 error "getdirstripe $tdir-$fail_loc failed"
8746 pushd $DIR/$tdir-$fail_loc
8748 echo $f | cmp $f - || error "$f data mismatch"
8751 rm -rf $DIR/$tdir-$fail_loc
8754 run_test 60h "striped directory with missing stripes can be accessed"
8756 function t60i_load() {
8758 #define OBD_FAIL_LLOG_PAUSE_AFTER_PAD 0x131c
8759 $LCTL set_param fail_loc=0x131c fail_val=1
8760 for ((i=0; i<5000; i++)); do
8761 touch $DIR/$tdir/f$i
8766 changelog_register || error "changelog_register failed"
8767 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
8768 changelog_users $SINGLEMDS | grep -q $cl_user ||
8769 error "User $cl_user not found in changelog_users"
8770 changelog_chmask "ALL"
8773 for((i=0; i<100; i++)); do
8774 changelog_dump >/dev/null ||
8775 error "can't read changelog"
8779 changelog_deregister || error "changelog_deregister failed"
8780 $LCTL set_param fail_loc=0
8782 run_test 60i "llog: new record vs reader race"
8785 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8788 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
8789 cancel_lru_locks osc
8790 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
8793 run_test 61a "mmap() writes don't make sync hang ================"
8796 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
8798 run_test 61b "mmap() of unstriped file is successful"
8800 # bug 2330 - insufficient obd_match error checking causes LBUG
8802 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8806 cancel_lru_locks osc
8807 lctl set_param fail_loc=0x405
8808 cat $f && error "cat succeeded, expect -EIO"
8809 lctl set_param fail_loc=0
8811 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
8812 # match every page all of the time.
8813 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
8815 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
8816 # Though this test is irrelevant anymore, it helped to reveal some
8817 # other grant bugs (LU-4482), let's keep it.
8818 test_63a() { # was test_63
8819 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8821 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
8823 for i in `seq 10` ; do
8824 dd if=/dev/zero of=$DIR/f63 bs=8k &
8830 rm -f $DIR/f63 || true
8832 run_test 63a "Verify oig_wait interruption does not crash ======="
8834 # bug 2248 - async write errors didn't return to application on sync
8835 # bug 3677 - async write errors left page locked
8837 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8840 lctl set_param debug=-1
8842 # ensure we have a grant to do async writes
8843 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
8846 sync # sync lest earlier test intercept the fail_loc
8848 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8849 lctl set_param fail_loc=0x80000406
8850 $MULTIOP $DIR/$tfile Owy && \
8851 error "sync didn't return ENOMEM"
8852 sync; sleep 2; sync # do a real sync this time to flush page
8853 lctl get_param -n llite.*.dump_page_cache | grep locked && \
8854 error "locked page left in cache after async error" || true
8857 run_test 63b "async write errors should be returned to fsync ==="
8860 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8863 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
8865 run_test 64a "verify filter grant calculations (in kernel) ====="
8868 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8870 bash oos.sh $MOUNT || error "oos.sh failed: $?"
8872 run_test 64b "check out-of-space detection on client"
8875 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
8877 run_test 64c "verify grant shrink"
8883 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
8886 # this does exactly what osc_request.c:osc_announce_cached() does in
8887 # order to calculate max amount of grants to ask from server
8891 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
8892 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
8894 ((rpc_in_flight++));
8895 nrpages=$((nrpages * rpc_in_flight))
8897 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
8899 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
8901 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
8902 local undirty=$((nrpages * PAGE_SIZE))
8904 local max_extent_pages
8905 max_extent_pages=$(import_param $tgt grant_max_extent_size)
8906 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
8907 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
8908 local grant_extent_tax
8909 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8911 undirty=$((undirty + nrextents * grant_extent_tax))
8916 # this is size of unit for grant allocation. It should be equal to
8917 # what tgt_grant.c:tgt_grant_chunk() calculates
8921 local grant_extent_tax
8923 max_brw_size=$(import_param $tgt max_brw_size)
8925 grant_extent_tax=$(import_param $tgt grant_extent_tax)
8927 echo $(((max_brw_size + grant_extent_tax) * 2))
8931 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
8932 skip "OST < 2.10.55 doesn't limit grants enough"
8934 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
8936 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
8937 skip "no grant_param connect flag"
8939 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
8941 $LCTL set_param -n -n debug="$OLDDEBUG" || true
8942 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
8945 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
8946 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
8948 $LFS setstripe $DIR/$tfile -i 0 -c 1
8949 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
8952 while kill -0 $ddpid; do
8953 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8955 if [[ $cur_grant -gt $max_cur_granted ]]; then
8957 error "cur_grant $cur_grant > $max_cur_granted"
8963 run_test 64d "check grant limit exceed"
8969 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
8971 ((cur_grants == expected)) ||
8972 error "$msg: grants mismatch: $cur_grants, expected $expected"
8976 echo $((($1 + $2 - 1) & ~($2 - 1)))
8980 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8981 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
8982 skip "Need OSS version at least 2.11.56"
8984 # Remount client to reset grant
8985 remount_client $MOUNT || error "failed to remount client"
8986 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
8988 local init_grants=$(import_param $osc_tgt initial_grant)
8990 check_grants $osc_tgt $init_grants "init grants"
8992 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
8993 local max_brw_size=$(import_param $osc_tgt max_brw_size)
8994 local gbs=$(import_param $osc_tgt grant_block_size)
8996 # write random number of bytes from max_brw_size / 4 to max_brw_size
8997 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
8998 # align for direct io
8999 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9000 # round to grant consumption unit
9001 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9003 local grants=$((wb_round_up + extent_tax))
9005 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9007 # define OBD_FAIL_TGT_NO_GRANT 0x725
9008 # make the server not grant more back
9009 do_facet ost1 $LCTL set_param fail_loc=0x725
9010 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
9012 do_facet ost1 $LCTL set_param fail_loc=0
9014 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
9016 rm -f $DIR/$tfile || error "rm failed"
9018 # Remount client to reset grant
9019 remount_client $MOUNT || error "failed to remount client"
9020 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9022 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9024 # define OBD_FAIL_TGT_NO_GRANT 0x725
9025 # make the server not grant more back
9026 do_facet ost1 $LCTL set_param fail_loc=0x725
9027 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
9028 do_facet ost1 $LCTL set_param fail_loc=0
9030 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
9032 run_test 64e "check grant consumption (no grant allocation)"
9035 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9037 # Remount client to reset grant
9038 remount_client $MOUNT || error "failed to remount client"
9039 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9041 local init_grants=$(import_param $osc_tgt initial_grant)
9042 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
9043 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9044 local gbs=$(import_param $osc_tgt grant_block_size)
9045 local chunk=$(grant_chunk $osc_tgt)
9047 # write random number of bytes from max_brw_size / 4 to max_brw_size
9048 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
9049 # align for direct io
9050 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
9051 # round to grant consumption unit
9052 local wb_round_up=$(round_up_p2 $write_bytes gbs)
9054 local grants=$((wb_round_up + extent_tax))
9056 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9057 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
9058 error "error writing to $DIR/$tfile"
9060 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9061 "direct io with grant allocation"
9063 rm -f $DIR/$tfile || error "rm failed"
9065 # Remount client to reset grant
9066 remount_client $MOUNT || error "failed to remount client"
9067 osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9069 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
9071 local cmd="oO_WRONLY:w${write_bytes}_yc"
9073 $MULTIOP $DIR/$tfile $cmd &
9077 check_grants $osc_tgt $((init_grants - grants)) \
9078 "buffered io, not write rpc"
9080 kill -USR1 $MULTIPID
9083 check_grants $osc_tgt $((init_grants - grants + chunk)) \
9084 "buffered io, one RPC"
9086 run_test 64f "check grant consumption (with grant allocation)"
9089 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
9090 skip "Need MDS version at least 2.14.56"
9092 local mdts=$(comma_list $(mdts_nodes))
9094 local old=$($LCTL get_param mdc.$FSNAME-*.grant_shrink_interval |
9096 stack_trap "$LCTL set_param $old"
9098 # generate dirty pages and increase dirty granted on MDT
9099 stack_trap "rm -f $DIR/$tfile-*"
9100 for (( i = 0; i < 10; i++)); do
9101 $LFS setstripe -E 1M -L mdt $DIR/$tfile-$i ||
9102 error "can't set stripe"
9103 dd if=/dev/zero of=$DIR/$tfile-$i bs=128k count=1 ||
9105 $LFS getstripe $DIR/$tfile-$i | grep -q pattern.*mdt || {
9106 $LFS getstripe $DIR/$tfile-$i
9107 error "not DoM file"
9114 # wait until grant shrink reset grant dirty on MDTs
9115 for ((i = 0; i < 120; i++)); do
9116 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9117 awk '{sum=sum+$1} END {print sum}')
9118 vm_dirty=$(awk '/Dirty:/{print $2}' /proc/meminfo)
9119 echo "$grant_dirty grants, $vm_dirty pages"
9120 (( grant_dirty + vm_dirty == 0 )) && break
9121 (( i == 3 )) && sync &&
9122 $LCTL set_param mdc.$FSNAME-*.grant_shrink_interval=5
9126 grant_dirty=$(do_nodes $mdts $LCTL get_param -n mdt.*.tot_dirty |
9127 awk '{sum=sum+$1} END {print sum}')
9128 (( grant_dirty == 0 )) || error "$grant_dirty on MDT"
9130 run_test 64g "grant shrink on MDT"
9133 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9134 skip "need OST at least 2.14.56 to avoid grant shrink on read"
9136 local instance=$($LFS getname -i $DIR)
9137 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9138 local num_exps=$(do_facet ost1 \
9139 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
9140 local max_brw_size=$(import_param $osc_tgt max_brw_size)
9141 local avail=$($LCTL get_param -n osc.*OST0000-osc-$instance.kbytesavail)
9142 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9144 # 10MiB is for file to be written, max_brw_size * 16 *
9145 # num_exps is space reserve so that tgt_grant_shrink() decided
9147 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
9148 (( avail * 1024 < expect )) &&
9149 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
9151 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
9152 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
9153 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
9154 $LCTL set_param osc.*OST0000*.grant_shrink=1
9155 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
9157 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9158 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
9160 # drop cache so that coming read would do rpc
9161 cancel_lru_locks osc
9163 # shrink interval is set to 10, pause for 7 seconds so that
9164 # grant thread did not wake up yet but coming read entered
9165 # shrink mode for rpc (osc_should_shrink_grant())
9168 declare -a cur_grant_bytes
9169 declare -a tot_granted
9170 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9171 tot_granted[0]=$(do_facet ost1 \
9172 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9174 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
9176 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
9177 tot_granted[1]=$(do_facet ost1 \
9178 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
9180 # grant change should be equal on both sides
9181 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
9182 tot_granted[0] - tot_granted[1])) ||
9183 error "grant change mismatch, " \
9184 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
9185 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
9187 run_test 64h "grant shrink on read"
9190 (( $OST1_VERSION >= $(version_code 2.14.56) )) ||
9191 skip "need OST at least 2.14.56 to avoid grant shrink on replay"
9193 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9194 remote_ost_nodsh && skip "remote OSTs with nodsh"
9196 $LFS setstripe -c 1 -i 0 $DIR/$tfile
9198 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
9200 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
9201 local instance=$($LFS getname -i $DIR)
9203 local osc_tgt="$FSNAME-OST0000-osc-$instance"
9204 local cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
9206 # shrink grants and simulate rpc loss
9207 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
9208 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
9209 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))B
9213 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
9215 local testid=$(echo $TESTNAME | tr '_' ' ')
9217 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
9218 grep "GRANT, real grant" &&
9219 error "client has more grants then it owns" || true
9221 run_test 64i "shrink on reconnect"
9223 # bug 1414 - set/get directories' stripe info
9225 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9227 test_mkdir $DIR/$tdir
9229 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
9231 run_test 65a "directory with no stripe info"
9234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9236 test_mkdir $DIR/$tdir
9237 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9239 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9242 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
9244 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
9247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9248 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
9250 test_mkdir $DIR/$tdir
9251 local stripesize=$($LFS getstripe -S $DIR/$tdir)
9253 $LFS setstripe -S $((stripesize * 4)) -i 1 \
9254 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
9256 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
9258 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
9261 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9263 test_mkdir $DIR/$tdir
9264 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
9265 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9267 if [[ $STRIPECOUNT -le 0 ]]; then
9269 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
9270 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
9271 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
9273 sc=$(($STRIPECOUNT - 1))
9275 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
9276 touch $DIR/$tdir/f4 $DIR/$tdir/f5
9277 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
9278 error "lverify failed"
9280 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
9283 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9285 test_mkdir $DIR/$tdir
9287 $LFS setstripe $DIR/$tdir || error "setstripe"
9288 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9289 error "no stripe info failed"
9291 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
9293 run_test 65e "directory setstripe defaults"
9296 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9298 test_mkdir $DIR/${tdir}f
9299 $RUNAS $LFS setstripe $DIR/${tdir}f &&
9300 error "setstripe succeeded" || true
9302 run_test 65f "dir setstripe permission (should return error) ==="
9305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9307 test_mkdir $DIR/$tdir
9308 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9310 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9311 error "setstripe -S failed"
9312 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
9313 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
9314 error "delete default stripe failed"
9316 run_test 65g "directory setstripe -d"
9319 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9321 test_mkdir $DIR/$tdir
9322 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
9324 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
9325 error "setstripe -S failed"
9326 test_mkdir $DIR/$tdir/dd1
9327 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
9328 error "stripe info inherit failed"
9330 run_test 65h "directory stripe info inherit ===================="
9333 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9335 save_layout_restore_at_exit $MOUNT
9337 # bug6367: set non-default striping on root directory
9338 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
9340 # bug12836: getstripe on -1 default directory striping
9341 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
9343 # bug12836: getstripe -v on -1 default directory striping
9344 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
9346 # bug12836: new find on -1 default directory striping
9347 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
9349 run_test 65i "various tests to set root directory striping"
9351 test_65j() { # bug6367
9352 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9356 # if we aren't already remounting for each test, do so for this test
9357 if [ "$I_MOUNTED" = "yes" ]; then
9358 cleanup || error "failed to unmount"
9362 save_layout_restore_at_exit $MOUNT
9364 $LFS setstripe -d $MOUNT || error "setstripe failed"
9366 run_test 65j "set default striping on root directory (bug 6367)="
9370 wait_delete_completed
9371 do_facet $SINGLEMDS "lctl set_param -n \
9372 osp.$ost*MDT0000.max_create_count=$max_count"
9373 do_facet $SINGLEMDS "lctl set_param -n \
9374 osp.$ost*MDT0000.create_count=$count"
9375 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9376 echo $INACTIVE_OSC "is Activate"
9378 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9381 test_65k() { # bug11679
9382 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9383 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9384 remote_mds_nodsh && skip "remote MDS with nodsh"
9386 local disable_precreate=true
9387 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
9388 disable_precreate=false
9390 echo "Check OST status: "
9391 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
9392 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
9394 for OSC in $MDS_OSCS; do
9395 echo $OSC "is active"
9396 do_facet $SINGLEMDS lctl --device %$OSC activate
9399 for INACTIVE_OSC in $MDS_OSCS; do
9400 local ost=$(osc_to_ost $INACTIVE_OSC)
9401 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
9402 lov.*md*.target_obd |
9403 awk -F: /$ost/'{ print $1 }' | head -n 1)
9406 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
9407 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
9409 echo "Deactivate: " $INACTIVE_OSC
9410 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
9412 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
9413 osp.$ost*MDT0000.create_count")
9414 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
9415 osp.$ost*MDT0000.max_create_count")
9416 $disable_precreate &&
9417 do_facet $SINGLEMDS "lctl set_param -n \
9418 osp.$ost*MDT0000.max_create_count=0"
9420 for idx in $(seq 0 $((OSTCOUNT - 1))); do
9421 [ -f $DIR/$tdir/$idx ] && continue
9422 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
9423 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
9425 error "setstripe $idx should succeed"; }
9426 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
9428 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
9431 do_facet $SINGLEMDS "lctl set_param -n \
9432 osp.$ost*MDT0000.max_create_count=$max_count"
9433 do_facet $SINGLEMDS "lctl set_param -n \
9434 osp.$ost*MDT0000.create_count=$count"
9435 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
9436 echo $INACTIVE_OSC "is Activate"
9438 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
9441 run_test 65k "validate manual striping works properly with deactivated OSCs"
9443 test_65l() { # bug 12836
9444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9446 test_mkdir -p $DIR/$tdir/test_dir
9447 $LFS setstripe -c -1 $DIR/$tdir/test_dir
9448 $LFS find -mtime -1 $DIR/$tdir >/dev/null
9450 run_test 65l "lfs find on -1 stripe dir ========================"
9453 local layout=$(save_layout $MOUNT)
9454 $RUNAS $LFS setstripe -c 2 $MOUNT && {
9455 restore_layout $MOUNT $layout
9456 error "setstripe should fail by non-root users"
9460 run_test 65m "normal user can't set filesystem default stripe"
9463 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
9464 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
9465 skip "Need MDS version at least 2.12.50"
9466 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
9468 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
9469 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
9470 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
9472 save_layout_restore_at_exit $MOUNT
9474 # new subdirectory under root directory should not inherit
9475 # the default layout from root
9476 local dir1=$MOUNT/$tdir-1
9477 mkdir $dir1 || error "mkdir $dir1 failed"
9478 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
9479 error "$dir1 shouldn't have LOV EA"
9481 # delete the default layout on root directory
9482 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
9484 local dir2=$MOUNT/$tdir-2
9485 mkdir $dir2 || error "mkdir $dir2 failed"
9486 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
9487 error "$dir2 shouldn't have LOV EA"
9489 # set a new striping pattern on root directory
9490 local def_stripe_size=$($LFS getstripe -S $MOUNT)
9491 local new_def_stripe_size=$((def_stripe_size * 2))
9492 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
9493 error "set stripe size on $MOUNT failed"
9495 # new file created in $dir2 should inherit the new stripe size from
9496 # the filesystem default
9497 local file2=$dir2/$tfile-2
9498 touch $file2 || error "touch $file2 failed"
9500 local file2_stripe_size=$($LFS getstripe -S $file2)
9501 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
9503 echo "file2_stripe_size: '$file2_stripe_size'"
9504 echo "new_def_stripe_size: '$new_def_stripe_size'"
9505 error "$file2 didn't inherit stripe size $new_def_stripe_size"
9508 local dir3=$MOUNT/$tdir-3
9509 mkdir $dir3 || error "mkdir $dir3 failed"
9510 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
9511 # the root layout, which is the actual default layout that will be used
9512 # when new files are created in $dir3.
9513 local dir3_layout=$(get_layout_param $dir3)
9514 local root_dir_layout=$(get_layout_param $MOUNT)
9515 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
9517 echo "dir3_layout: '$dir3_layout'"
9518 echo "root_dir_layout: '$root_dir_layout'"
9519 error "$dir3 should show the default layout from $MOUNT"
9522 # set OST pool on root directory
9523 local pool=$TESTNAME
9524 pool_add $pool || error "add $pool failed"
9525 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
9526 error "add targets to $pool failed"
9528 $LFS setstripe -p $pool $MOUNT ||
9529 error "set OST pool on $MOUNT failed"
9531 # new file created in $dir3 should inherit the pool from
9532 # the filesystem default
9533 local file3=$dir3/$tfile-3
9534 touch $file3 || error "touch $file3 failed"
9536 local file3_pool=$($LFS getstripe -p $file3)
9537 [[ "$file3_pool" = "$pool" ]] ||
9538 error "$file3 ('$file3_pool') didn't inherit OST pool '$pool'"
9540 local dir4=$MOUNT/$tdir-4
9541 mkdir $dir4 || error "mkdir $dir4 failed"
9542 local dir4_layout=$(get_layout_param $dir4)
9543 root_dir_layout=$(get_layout_param $MOUNT)
9544 echo "$LFS getstripe -d $dir4"
9545 $LFS getstripe -d $dir4
9546 echo "$LFS getstripe -d $MOUNT"
9547 $LFS getstripe -d $MOUNT
9548 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
9550 echo "dir4_layout: '$dir4_layout'"
9551 echo "root_dir_layout: '$root_dir_layout'"
9552 error "$dir4 should show the default layout from $MOUNT"
9555 # new file created in $dir4 should inherit the pool from
9556 # the filesystem default
9557 local file4=$dir4/$tfile-4
9558 touch $file4 || error "touch $file4 failed"
9560 local file4_pool=$($LFS getstripe -p $file4)
9561 [[ "$file4_pool" = "$pool" ]] ||
9562 error "$file4 ('$file4_pool') didn't inherit OST pool $pool"
9564 # new subdirectory under non-root directory should inherit
9565 # the default layout from its parent directory
9566 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
9567 error "set directory layout on $dir4 failed"
9569 local dir5=$dir4/$tdir-5
9570 mkdir $dir5 || error "mkdir $dir5 failed"
9572 dir4_layout=$(get_layout_param $dir4)
9573 local dir5_layout=$(get_layout_param $dir5)
9574 [[ "$dir4_layout" = "$dir5_layout" ]] ||
9576 echo "dir4_layout: '$dir4_layout'"
9577 echo "dir5_layout: '$dir5_layout'"
9578 error "$dir5 should inherit the default layout from $dir4"
9581 # though subdir under ROOT doesn't inherit default layout, but
9582 # its sub dir/file should be created with default layout.
9583 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
9584 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
9585 skip "Need MDS version at least 2.12.59"
9587 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
9588 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
9589 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
9591 if [ $default_lmv_hash == "none" ]; then
9592 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
9594 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
9595 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
9598 $LFS setdirstripe -D -c 2 $MOUNT ||
9599 error "setdirstripe -D -c 2 failed"
9600 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
9601 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
9602 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
9604 # $dir4 layout includes pool
9605 $LFS setstripe -S $((new_def_stripe_size * 2)) $dir4
9606 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9607 error "pool lost on setstripe"
9608 $LFS setstripe -E -1 -S $new_def_stripe_size $dir4
9609 [[ "$pool" = $($LFS getstripe -p -d $dir4) ]] ||
9610 error "pool lost on compound layout setstripe"
9612 run_test 65n "don't inherit default layout from root for new subdirectories"
9614 # bug 2543 - update blocks count on client
9616 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9619 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
9620 sync; sync_all_data; sync; sync_all_data
9621 cancel_lru_locks osc
9622 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
9623 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
9625 run_test 66 "update inode blocks count on client ==============="
9628 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
9632 swapon -s | awk '($1 == "'$1'") { print $4 }'
9635 # bug5265, obdfilter oa2dentry return -ENOENT
9636 # #define OBD_FAIL_SRV_ENOENT 0x217
9638 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9639 remote_ost_nodsh && skip "remote OST with nodsh"
9642 $LFS setstripe -c 1 -i 0 $f
9644 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
9646 do_facet ost1 lctl set_param fail_loc=0x217
9647 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
9648 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
9650 do_facet ost1 lctl set_param fail_loc=0
9651 $DIRECTIO write $f 0 2 || error "write error"
9653 cancel_lru_locks osc
9654 $DIRECTIO read $f 0 1 || error "read error"
9656 do_facet ost1 lctl set_param fail_loc=0x217
9657 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
9659 do_facet ost1 lctl set_param fail_loc=0
9662 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
9665 test_mkdir $DIR/$tdir
9666 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
9667 bash rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
9669 run_test 71 "Running dbench on lustre (don't segment fault) ===="
9671 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
9672 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9673 [ "$RUNAS_ID" = "$UID" ] &&
9674 skip_env "RUNAS_ID = UID = $UID -- skipping"
9675 # Check that testing environment is properly set up. Skip if not
9676 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
9677 skip_env "User $RUNAS_ID does not exist - skipping"
9680 chmod 777 $DIR/$tfile
9681 chmod ug+s $DIR/$tfile
9682 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
9683 error "$RUNAS dd $DIR/$tfile failed"
9684 # See if we are still setuid/sgid
9685 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9686 error "S/gid is not dropped on write"
9687 # Now test that MDS is updated too
9688 cancel_lru_locks mdc
9689 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
9690 error "S/gid is not dropped on MDS"
9693 run_test 72a "Test that remove suid works properly (bug5695) ===="
9695 test_72b() { # bug 24226 -- keep mode setting when size is not changing
9698 [ "$RUNAS_ID" = "$UID" ] &&
9699 skip_env "RUNAS_ID = UID = $UID -- skipping"
9700 [ "$RUNAS_ID" -eq 0 ] &&
9701 skip_env "RUNAS_ID = 0 -- skipping"
9702 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9703 # Check that testing environment is properly set up. Skip if not
9704 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
9705 skip_env "User $RUNAS_ID does not exist - skipping"
9707 touch $DIR/${tfile}-f{g,u}
9708 test_mkdir $DIR/${tfile}-dg
9709 test_mkdir $DIR/${tfile}-du
9710 chmod 770 $DIR/${tfile}-{f,d}{g,u}
9711 chmod g+s $DIR/${tfile}-{f,d}g
9712 chmod u+s $DIR/${tfile}-{f,d}u
9713 for perm in 777 2777 4777; do
9714 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
9715 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
9716 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
9717 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
9721 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
9723 # bug 3462 - multiple simultaneous MDC requests
9725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9727 test_mkdir $DIR/d73-1
9728 test_mkdir $DIR/d73-2
9729 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
9732 lctl set_param fail_loc=0x80000129
9733 $MULTIOP $DIR/d73-1/f73-2 Oc &
9735 lctl set_param fail_loc=0
9737 $MULTIOP $DIR/d73-2/f73-3 Oc &
9741 wait $pid1 || return 1
9745 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
9746 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
9747 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
9751 run_test 73 "multiple MDC requests (should not deadlock)"
9753 test_74a() { # bug 6149, 6184
9754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9757 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9759 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9760 # will spin in a tight reconnection loop
9761 $LCTL set_param fail_loc=0x8000030e
9762 # get any lock that won't be difficult - lookup works.
9764 $LCTL set_param fail_loc=0
9768 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
9770 test_74b() { # bug 13310
9771 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9773 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
9775 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
9776 # will spin in a tight reconnection loop
9777 $LCTL set_param fail_loc=0x8000030e
9778 # get a "difficult" lock
9780 $LCTL set_param fail_loc=0
9784 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
9787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9789 #define OBD_FAIL_LDLM_NEW_LOCK
9790 $LCTL set_param fail_loc=0x319
9791 touch $DIR/$tfile && error "touch successful"
9792 $LCTL set_param fail_loc=0
9795 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
9797 slab_lic=/sys/kernel/slab/lustre_inode_cache
9799 [ -f $slab_lic/shrink ] && echo 1 > $slab_lic/shrink
9800 [ -f $slab_lic/objects ] && awk '{ print $1 }' $slab_lic/objects ||
9801 awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
9804 test_76a() { # Now for b=20433, added originally in b=1443
9805 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9807 cancel_lru_locks osc
9808 # there may be some slab objects cached per core
9809 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
9810 local before=$(num_objects)
9811 local count=$((512 * cpus))
9812 [ "$SLOW" = "no" ] && count=$((128 * cpus))
9813 local margin=$((count / 10))
9814 if [[ -f $slab_lic/aliases ]]; then
9815 local aliases=$(cat $slab_lic/aliases)
9816 (( aliases > 0 )) && margin=$((margin * aliases))
9819 echo "before slab objects: $before"
9820 for i in $(seq $count); do
9824 cancel_lru_locks osc
9825 local after=$(num_objects)
9826 echo "created: $count, after slab objects: $after"
9827 # shared slab counts are not very accurate, allow significant margin
9828 # the main goal is that the cache growth is not permanently > $count
9829 while (( after > before + margin )); do
9831 after=$(num_objects)
9833 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9834 if (( wait > 60 )); then
9835 error "inode slab grew from $before+$margin to $after"
9839 run_test 76a "confirm clients recycle inodes properly ===="
9842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9843 [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported"
9846 local before=$(num_objects)
9848 for i in $(seq $count); do
9853 local after=$(num_objects)
9856 while (( after > before )); do
9858 after=$(num_objects)
9860 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
9861 if (( wait > 60 )); then
9862 error "inode slab grew from $before to $after"
9866 echo "slab objects before: $before, after: $after"
9868 run_test 76b "confirm clients recycle directory inodes properly ===="
9873 # Note: in sptlrpc modes which enable its own bulk checksum, the
9874 # original crc32_le bulk checksum will be automatically disabled,
9875 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
9876 # will be checked by sptlrpc code against sptlrpc bulk checksum.
9877 # In this case set_checksums() will not be no-op, because sptlrpc
9878 # bulk checksum will be enabled all through the test.
9880 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
9881 lctl set_param -n osc.*.checksums $1
9885 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9886 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
9887 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
9888 tr -d [] | head -n1)}
9891 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
9893 log "set checksum type to $1, rc = $rc"
9897 get_osc_checksum_type()
9899 # arugment 1: OST name, like OST0000
9901 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
9902 sed 's/.*\[\(.*\)\].*/\1/g')
9904 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
9908 F77_TMP=$TMP/f77-temp
9911 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
9912 error "error writing to $F77_TMP"
9915 test_77a() { # bug 10889
9916 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9917 $GSS && skip_env "could not run with gss"
9919 [ ! -f $F77_TMP ] && setup_f77
9921 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
9925 run_test 77a "normal checksum read/write operation"
9927 test_77b() { # bug 10889
9928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9929 $GSS && skip_env "could not run with gss"
9931 [ ! -f $F77_TMP ] && setup_f77
9932 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
9933 $LCTL set_param fail_loc=0x80000409
9936 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9937 error "dd error: $?"
9938 $LCTL set_param fail_loc=0
9940 for algo in $CKSUM_TYPES; do
9941 cancel_lru_locks osc
9942 set_checksum_type $algo
9943 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
9944 $LCTL set_param fail_loc=0x80000408
9945 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
9946 $LCTL set_param fail_loc=0
9949 set_checksum_type $ORIG_CSUM_TYPE
9952 run_test 77b "checksum error on client write, read"
9957 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
9959 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
9960 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
9961 $check_ost && [ -n "$ost_file_prefix" ] &&
9962 do_facet ost1 rm -f ${ost_file_prefix}\*
9966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9967 $GSS && skip_env "could not run with gss"
9968 remote_ost_nodsh && skip "remote OST with nodsh"
9971 local osc_file_prefix
9973 local check_ost=false
9974 local ost_file_prefix
9980 # ensure corruption will occur on first OSS/OST
9981 $LFS setstripe -i 0 $DIR/$tfile
9983 [ ! -f $F77_TMP ] && setup_f77
9984 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
9985 error "dd write error: $?"
9986 fid=$($LFS path2fid $DIR/$tfile)
9988 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
9991 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
9992 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
9994 echo "OSS do not support bulk pages dump upon error"
9997 osc_file_prefix=$($LCTL get_param -n debug_path)
9998 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
10000 trap cleanup_77c EXIT
10003 # enable bulk pages dump upon error on Client
10004 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
10005 # enable bulk pages dump upon error on OSS
10007 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
10009 # flush Client cache to allow next read to reach OSS
10010 cancel_lru_locks osc
10012 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10013 $LCTL set_param fail_loc=0x80000408
10014 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
10015 $LCTL set_param fail_loc=0
10019 # check cksum dump on Client
10020 osc_file=$(ls ${osc_file_prefix}*)
10021 [ -n "$osc_file" ] || error "no checksum dump file on Client"
10022 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
10023 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
10024 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
10025 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
10027 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
10028 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10029 error "dump content does not match on Client"
10031 $check_ost || skip "No need to check cksum dump on OSS"
10033 # check cksum dump on OSS
10034 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
10035 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
10036 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
10037 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
10038 [[ "$orig_cksum" == "$dump_cksum" ]] ||
10039 error "dump content does not match on OSS"
10043 run_test 77c "checksum error on client read with debug"
10045 test_77d() { # bug 10889
10046 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10047 $GSS && skip_env "could not run with gss"
10049 stack_trap "rm -f $DIR/$tfile"
10050 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10051 $LCTL set_param fail_loc=0x80000409
10053 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10054 error "direct write: rc=$?"
10055 $LCTL set_param fail_loc=0
10058 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
10059 $LCTL set_param fail_loc=0x80000408
10061 cancel_lru_locks osc
10062 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
10063 error "direct read: rc=$?"
10064 $LCTL set_param fail_loc=0
10067 run_test 77d "checksum error on OST direct write, read"
10069 test_77f() { # bug 10889
10070 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10071 $GSS && skip_env "could not run with gss"
10074 stack_trap "rm -f $DIR/$tfile"
10075 for algo in $CKSUM_TYPES; do
10076 cancel_lru_locks osc
10077 set_checksum_type $algo
10078 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
10079 $LCTL set_param fail_loc=0x409
10080 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
10081 error "direct write succeeded"
10082 $LCTL set_param fail_loc=0
10084 set_checksum_type $ORIG_CSUM_TYPE
10087 run_test 77f "repeat checksum error on write (expect error)"
10089 test_77g() { # bug 10889
10090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10091 $GSS && skip_env "could not run with gss"
10092 remote_ost_nodsh && skip "remote OST with nodsh"
10094 [ ! -f $F77_TMP ] && setup_f77
10096 local file=$DIR/$tfile
10097 stack_trap "rm -f $file" EXIT
10099 $LFS setstripe -c 1 -i 0 $file
10100 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
10101 do_facet ost1 lctl set_param fail_loc=0x8000021a
10103 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
10104 error "write error: rc=$?"
10105 do_facet ost1 lctl set_param fail_loc=0
10108 cancel_lru_locks osc
10109 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
10110 do_facet ost1 lctl set_param fail_loc=0x8000021b
10112 cmp $F77_TMP $file || error "file compare failed"
10113 do_facet ost1 lctl set_param fail_loc=0
10116 run_test 77g "checksum error on OST write, read"
10118 test_77k() { # LU-10906
10119 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10120 $GSS && skip_env "could not run with gss"
10122 local cksum_param="osc.$FSNAME*.checksums"
10123 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
10127 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
10128 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true"
10129 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM"
10132 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
10133 error "failed to set checksum=$i on MGS"
10134 wait_update $HOSTNAME "$get_checksum" $i
10136 echo "remount client, checksum should be $i"
10137 remount_client $MOUNT || error "failed to remount client"
10138 checksum=$(eval $get_checksum)
10139 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10141 # remove persistent param to avoid races with checksum mountopt below
10142 do_facet mgs $LCTL set_param -P -d $cksum_param ||
10143 error "failed to delete checksum on MGS"
10145 for opt in "checksum" "nochecksum"; do
10146 #remount with mount option
10147 echo "remount client with option $opt, checksum should be $i"
10148 umount_client $MOUNT || error "failed to umount client"
10149 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
10150 error "failed to mount client with option '$opt'"
10151 checksum=$(eval $get_checksum)
10152 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
10156 remount_client $MOUNT || error "failed to remount client"
10158 run_test 77k "enable/disable checksum correctly"
10161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10162 $GSS && skip_env "could not run with gss"
10165 stack_trap "set_checksums $ORIG_CSUM" EXIT
10166 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10168 set_checksum_type invalid && error "unexpected success of invalid checksum type"
10170 $LFS setstripe -c 1 -i 0 $DIR/$tfile
10171 for algo in $CKSUM_TYPES; do
10172 set_checksum_type $algo || error "fail to set checksum type $algo"
10173 osc_algo=$(get_osc_checksum_type OST0000)
10174 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
10176 # no locks, no reqs to let the connection idle
10177 cancel_lru_locks osc
10178 lru_resize_disable osc
10179 wait_osc_import_state client ost1 IDLE
10181 # ensure ost1 is connected
10182 stat $DIR/$tfile >/dev/null || error "can't stat"
10183 wait_osc_import_state client ost1 FULL
10185 osc_algo=$(get_osc_checksum_type OST0000)
10186 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
10190 run_test 77l "preferred checksum type is remembered after reconnected"
10192 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
10197 (( $CLIENT_VERSION >= $(version_code 2.14.52) )) ||
10198 skip "Need at least version 2.14.52"
10199 local param=checksum_speed
10201 $LCTL get_param $param || error "reading $param failed"
10203 csum_speeds=$($LCTL get_param -n $param)
10205 [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] ||
10206 error "known checksum types are missing"
10208 run_test 77m "Verify checksum_speed is correctly read"
10210 check_filefrag_77n() {
10215 while read extidx a b start end rest; do
10216 if [[ "${extidx}" =~ ^[0-9]+: ]]; then
10217 nr_ext=$(( $nr_ext + 1 ))
10218 starts+=( ${start%..} )
10221 done < <( filefrag -sv $1 )
10223 [[ $nr_ext -eq 2 ]] && [[ "${starts[-1]}" == $(( ${ends[0]} + 1 )) ]] && return 0
10228 [[ "$CKSUM_TYPES" =~ t10 ]] || skip "no T10 checksum support on osc"
10231 $TRUNCATE $DIR/$tfile 0
10232 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=0
10233 dd if=/dev/urandom of=$DIR/$tfile bs=4k conv=notrunc count=1 seek=2
10234 check_filefrag_77n $DIR/$tfile ||
10235 skip "$tfile blocks not contiguous around hole"
10238 stack_trap "set_checksums $ORIG_CSUM" EXIT
10239 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
10240 stack_trap "rm -f $DIR/$tfile"
10242 for algo in $CKSUM_TYPES; do
10243 if [[ "$algo" =~ ^t10 ]]; then
10244 set_checksum_type $algo ||
10245 error "fail to set checksum type $algo"
10246 dd if=$DIR/$tfile of=/dev/null bs=12k count=1 iflag=direct ||
10247 error "fail to read $tfile with $algo"
10253 run_test 77n "Verify read from a hole inside contiguous blocks with T10PI"
10256 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
10257 skip "Need MDS version at least 2.14.55"
10258 (( $OST1_VERSION >= $(version_code 2.14.55) )) ||
10259 skip "Need OST version at least 2.14.55"
10260 local ofd=obdfilter
10263 # print OST checksum_type
10264 echo "$ofd.$FSNAME-*.checksum_type:"
10265 do_nodes $(comma_list $(osts_nodes)) \
10266 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type
10268 # print MDT checksum_type
10269 echo "$mdt.$FSNAME-*.checksum_type:"
10270 do_nodes $(comma_list $(mdts_nodes)) \
10271 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type
10273 local o_count=$(do_nodes $(comma_list $(osts_nodes)) \
10274 $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l)
10276 (( $o_count == $OSTCOUNT )) ||
10277 error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT"
10279 local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \
10280 $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l)
10282 (( $m_count == $MDSCOUNT )) ||
10283 error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT"
10285 run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))"
10287 cleanup_test_78() {
10292 test_78() { # bug 10901
10293 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10294 remote_ost || skip_env "local OST"
10297 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
10298 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
10299 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
10300 echo "MemTotal: $MEMTOTAL"
10302 # reserve 256MB of memory for the kernel and other running processes,
10303 # and then take 1/2 of the remaining memory for the read/write buffers.
10304 if [ $MEMTOTAL -gt 512 ] ;then
10305 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
10307 # for those poor memory-starved high-end clusters...
10308 MEMTOTAL=$((MEMTOTAL / 2))
10310 echo "Mem to use for directio: $MEMTOTAL"
10312 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
10313 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
10314 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
10315 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
10317 echo "Smallest OST: $SMALLESTOST"
10318 [[ $SMALLESTOST -lt 10240 ]] &&
10319 skip "too small OSTSIZE, useless to run large O_DIRECT test"
10321 trap cleanup_test_78 EXIT
10323 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
10324 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
10326 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
10327 echo "File size: $F78SIZE"
10328 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
10329 for i in $(seq 1 $NSEQ); do
10330 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
10331 echo directIO rdwr round $i of $NSEQ
10332 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
10337 run_test 78 "handle large O_DIRECT writes correctly ============"
10339 test_79() { # bug 12743
10340 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10342 wait_delete_completed
10344 BKTOTAL=$(calc_osc_kbytes kbytestotal)
10345 BKFREE=$(calc_osc_kbytes kbytesfree)
10346 BKAVAIL=$(calc_osc_kbytes kbytesavail)
10348 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
10349 DFTOTAL=`echo $STRING | cut -d, -f1`
10350 DFUSED=`echo $STRING | cut -d, -f2`
10351 DFAVAIL=`echo $STRING | cut -d, -f3`
10352 DFFREE=$(($DFTOTAL - $DFUSED))
10354 ALLOWANCE=$((64 * $OSTCOUNT))
10356 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
10357 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
10358 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
10360 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
10361 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
10362 error "df free($DFFREE) mismatch OST free($BKFREE)"
10364 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
10365 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
10366 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
10369 run_test 79 "df report consistency check ======================="
10371 test_80() { # bug 10718
10372 remote_ost_nodsh && skip "remote OST with nodsh"
10373 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10375 # relax strong synchronous semantics for slow backends like ZFS
10376 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
10377 local soc="obdfilter.*.sync_lock_cancel"
10378 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10380 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
10381 if [ -z "$save" ]; then
10382 soc="obdfilter.*.sync_on_lock_cancel"
10383 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
10386 if [ "$save" != "never" ]; then
10387 local hosts=$(comma_list $(osts_nodes))
10389 do_nodes $hosts $LCTL set_param $soc=never
10390 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
10394 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
10395 sync; sleep 1; sync
10396 local before=$(date +%s)
10397 cancel_lru_locks osc
10398 local after=$(date +%s)
10399 local diff=$((after - before))
10400 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
10404 run_test 80 "Page eviction is equally fast at high offsets too"
10406 test_81a() { # LU-456
10407 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10408 remote_ost_nodsh && skip "remote OST with nodsh"
10410 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10411 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
10412 do_facet ost1 lctl set_param fail_loc=0x80000228
10414 # write should trigger a retry and success
10415 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10416 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10418 if [ $RC -ne 0 ] ; then
10419 error "write should success, but failed for $RC"
10422 run_test 81a "OST should retry write when get -ENOSPC ==============="
10424 test_81b() { # LU-456
10425 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10426 remote_ost_nodsh && skip "remote OST with nodsh"
10428 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
10429 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
10430 do_facet ost1 lctl set_param fail_loc=0x228
10432 # write should retry several times and return -ENOSPC finally
10433 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10434 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10437 if [ $RC -ne $ENOSPC ] ; then
10438 error "dd should fail for -ENOSPC, but succeed."
10441 run_test 81b "OST should return -ENOSPC when retry still fails ======="
10444 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
10446 test_mkdir $DIR/$tdir.cvsroot
10447 chown $RUNAS_ID $DIR/$tdir.cvsroot
10450 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
10453 # some versions of cvs import exit(1) when asked to import links or
10454 # files they can't read. ignore those files.
10455 local toignore=$(find . -type l -printf '-I %f\n' -o \
10456 ! -perm /4 -printf '-I %f\n')
10457 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
10458 $tdir.reposname vtag rtag
10461 test_mkdir $DIR/$tdir.reposname
10462 chown $RUNAS_ID $DIR/$tdir.reposname
10463 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
10465 cd $DIR/$tdir.reposname
10467 $RUNAS cvs add -m 'addmsg' foo99
10469 $RUNAS cvs commit -m 'nomsg' foo99
10470 rm -fr $DIR/$tdir.cvsroot
10472 run_test 99 "cvs strange file/directory operations"
10475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10476 [[ "$NETTYPE" =~ tcp ]] ||
10477 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
10478 remote_ost_nodsh && skip "remote OST with nodsh"
10479 remote_mds_nodsh && skip "remote MDS with nodsh"
10481 skip "useless for local single node setup"
10483 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
10484 [ "$PROT" != "tcp" ] && continue
10485 RPORT=$(echo $REMOTE | cut -d: -f2)
10486 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
10489 LPORT=`echo $LOCAL | cut -d: -f2`
10490 if [ $LPORT -ge 1024 ]; then
10491 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
10493 error_exit "local: $LPORT > 1024, remote: $RPORT"
10496 [ "$rc" = 0 ] || error_exit "privileged port not found" )
10498 run_test 100 "check local port using privileged port ==========="
10500 function get_named_value()
10504 grep -w "$tag" | sed "s/^$tag *\([0-9]*\) *.*/\1/"
10507 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
10508 awk '/^max_cached_mb/ { print $2 }')
10511 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
10516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10521 local cache_limit=32
10523 $LCTL set_param -n osc.*-osc*.rpc_stats=0
10524 trap cleanup_101a EXIT
10525 $LCTL set_param -n llite.*.read_ahead_stats=0
10526 $LCTL set_param -n llite.*.max_cached_mb=$cache_limit
10529 # randomly read 10000 of 64K chunks from file 3x 32MB in size
10531 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
10532 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
10535 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
10536 get_named_value 'read.but.discarded'); do
10537 discard=$(($discard + $s))
10541 $LCTL get_param osc.*-osc*.rpc_stats
10542 $LCTL get_param llite.*.read_ahead_stats
10544 # Discard is generally zero, but sometimes a few random reads line up
10545 # and trigger larger readahead, which is wasted & leads to discards.
10546 if [[ $(($discard)) -gt $nreads ]]; then
10547 error "too many ($discard) discarded pages"
10549 rm -f $DIR/$tfile || true
10551 run_test 101a "check read-ahead for random reads"
10553 setup_test101bc() {
10554 test_mkdir $DIR/$tdir
10556 local FILE_LENGTH=$2
10559 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
10561 local list=$(comma_list $(osts_nodes))
10562 set_osd_param $list '' read_cache_enable 0
10563 set_osd_param $list '' writethrough_cache_enable 0
10565 trap cleanup_test101bc EXIT
10566 # prepare the read-ahead file
10567 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
10569 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
10570 count=$FILE_SIZE_MB 2> /dev/null
10574 cleanup_test101bc() {
10579 local list=$(comma_list $(osts_nodes))
10580 set_osd_param $list '' read_cache_enable 1
10581 set_osd_param $list '' writethrough_cache_enable 1
10585 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
10590 local stripe_size=$2
10591 local stride_length=$((stripe_size / read_size))
10592 local stride_width=$((stride_length * OSTCOUNT))
10593 local discard_limit=$(( ((stride_length - 1) * 3 / stride_width) *
10594 (stride_width - stride_length) ))
10595 local discard=$($LCTL get_param -n llite.*.read_ahead_stats |
10596 get_named_value 'read.but.discarded' | calc_total)
10598 if [[ $discard -gt $discard_limit ]]; then
10599 $LCTL get_param llite.*.read_ahead_stats
10600 error "($discard) discarded pages with size (${read_size})"
10602 echo "Read-ahead success for size ${read_size}"
10607 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10608 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10610 local STRIPE_SIZE=1048576
10611 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
10613 if [ $SLOW == "yes" ]; then
10614 local FILE_LENGTH=$((STRIDE_SIZE * 64))
10616 local FILE_LENGTH=$((STRIDE_SIZE * 8))
10619 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
10621 # prepare the read-ahead file
10622 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10623 cancel_lru_locks osc
10624 for BIDX in 2 4 8 16 32 64 128 256
10626 local BSIZE=$((BIDX*4096))
10627 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
10628 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
10629 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
10630 $LCTL set_param -n llite.*.read_ahead_stats=0
10631 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
10632 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
10633 cancel_lru_locks osc
10634 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
10639 run_test 101b "check stride-io mode read-ahead ================="
10642 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10644 local STRIPE_SIZE=1048576
10645 local FILE_LENGTH=$((STRIPE_SIZE*100))
10648 local osc_rpc_stats
10650 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
10652 cancel_lru_locks osc
10653 $LCTL set_param osc.*.rpc_stats=0
10654 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
10655 $LCTL get_param osc.*.rpc_stats
10656 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
10657 local stats=$($LCTL get_param -n $osc_rpc_stats)
10658 local lines=$(echo "$stats" | awk 'END {print NR;}')
10661 if [ $lines -le 20 ]; then
10662 echo "continue debug"
10665 for size in 1 2 4 8; do
10666 local rpc=$(echo "$stats" |
10667 awk '($1 == "'$size':") {print $2; exit; }')
10668 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
10669 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
10671 echo "$osc_rpc_stats check passed!"
10676 run_test 101c "check stripe_size aligned read-ahead"
10679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10681 local file=$DIR/$tfile
10682 local sz_MB=${FILESIZE_101d:-80}
10683 local ra_MB=${READAHEAD_MB:-40}
10685 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
10686 [ $free_MB -lt $sz_MB ] &&
10687 skip "Need free space ${sz_MB}M, have ${free_MB}M"
10689 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
10690 $LFS setstripe -c -1 $file || error "setstripe failed"
10692 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
10693 echo Cancel LRU locks on lustre client to flush the client cache
10694 cancel_lru_locks osc
10696 echo Disable read-ahead
10697 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10698 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10699 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb=$old_RA" EXIT
10700 $LCTL get_param -n llite.*.max_read_ahead_mb
10702 echo "Reading the test file $file with read-ahead disabled"
10703 local sz_KB=$((sz_MB * 1024 / 4))
10704 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
10705 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
10706 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10707 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10709 echo "Cancel LRU locks on lustre client to flush the client cache"
10710 cancel_lru_locks osc
10711 echo Enable read-ahead with ${ra_MB}MB
10712 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
10714 echo "Reading the test file $file with read-ahead enabled"
10715 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
10716 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
10718 echo "read-ahead disabled time read $raOFF"
10719 echo "read-ahead enabled time read $raON"
10722 wait_delete_completed
10724 # use awk for this check instead of bash because it handles decimals
10725 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
10726 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
10728 run_test 101d "file read with and without read-ahead enabled"
10731 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10733 local file=$DIR/$tfile
10734 local size_KB=500 #KB
10738 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
10739 local need_KB=$((count * size_KB))
10740 [[ $free_KB -le $need_KB ]] &&
10741 skip_env "Need free space $need_KB, have $free_KB"
10743 echo "Creating $count ${size_KB}K test files"
10744 for ((i = 0; i < $count; i++)); do
10745 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
10748 echo "Cancel LRU locks on lustre client to flush the client cache"
10749 cancel_lru_locks $OSC
10751 echo "Reset readahead stats"
10752 $LCTL set_param -n llite.*.read_ahead_stats=0
10754 for ((i = 0; i < $count; i++)); do
10755 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
10758 $LCTL get_param llite.*.max_cached_mb
10759 $LCTL get_param llite.*.read_ahead_stats
10760 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10761 get_named_value 'misses' | calc_total)
10763 for ((i = 0; i < $count; i++)); do
10764 rm -rf $file.$i 2>/dev/null
10767 #10000 means 20% reads are missing in readahead
10768 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
10770 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
10773 which iozone || skip_env "no iozone installed"
10775 local old_debug=$($LCTL get_param debug)
10776 old_debug=${old_debug#*=}
10777 $LCTL set_param debug="reada mmap"
10779 # create a test file
10780 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
10782 echo Cancel LRU locks on lustre client to flush the client cache
10783 cancel_lru_locks osc
10785 echo Reset readahead stats
10786 $LCTL set_param -n llite.*.read_ahead_stats=0
10788 echo mmap read the file with small block size
10789 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
10792 echo checking missing pages
10793 $LCTL get_param llite.*.read_ahead_stats
10794 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10795 get_named_value 'misses' | calc_total)
10797 $LCTL set_param debug="$old_debug"
10798 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
10801 run_test 101f "check mmap read performance"
10803 test_101g_brw_size_test() {
10805 local pages=$((mb * 1048576 / PAGE_SIZE))
10806 local file=$DIR/$tfile
10808 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
10809 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
10810 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
10811 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
10815 stack_trap "rm -f $file" EXIT
10816 $LCTL set_param -n osc.*.rpc_stats=0
10818 # 10 RPCs should be enough for the test
10820 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
10821 { error "dd write ${mb} MB blocks failed"; return 3; }
10822 cancel_lru_locks osc
10823 dd of=/dev/null if=$file bs=${mb}M count=$count ||
10824 { error "dd write ${mb} MB blocks failed"; return 4; }
10826 # calculate number of full-sized read and write RPCs
10827 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
10828 sed -n '/pages per rpc/,/^$/p' |
10829 awk '/'$pages':/ { reads += $2; writes += $6 }; \
10830 END { print reads,writes }'))
10831 # allow one extra full-sized read RPC for async readahead
10832 [[ ${rpcs[0]} == $count || ${rpcs[0]} == $((count + 1)) ]] ||
10833 { error "${rpcs[0]} != $count read RPCs"; return 5; }
10834 [[ ${rpcs[1]} == $count ]] ||
10835 { error "${rpcs[1]} != $count write RPCs"; return 6; }
10839 remote_ost_nodsh && skip "remote OST with nodsh"
10842 local osts=$(get_facets OST)
10843 local list=$(comma_list $(osts_nodes))
10844 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10845 local brw_size="obdfilter.*.brw_size"
10847 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10849 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
10851 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
10852 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
10853 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
10854 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
10855 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
10856 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
10858 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
10861 if [[ $orig_mb -lt 16 ]]; then
10862 save_lustre_params $osts "$brw_size" > $p
10863 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
10864 error "set 16MB RPC size failed"
10866 echo "remount client to enable new RPC size"
10867 remount_client $MOUNT || error "remount_client failed"
10870 test_101g_brw_size_test 16 || error "16MB RPC test failed"
10871 # should be able to set brw_size=12, but no rpc_stats for that
10872 test_101g_brw_size_test 8 || error "8MB RPC test failed"
10875 test_101g_brw_size_test 4 || error "4MB RPC test failed"
10877 if [[ $orig_mb -lt 16 ]]; then
10878 restore_lustre_params < $p
10879 remount_client $MOUNT || error "remount_client restore failed"
10882 rm -f $p $DIR/$tfile
10884 run_test 101g "Big bulk(4/16 MiB) readahead"
10887 $LFS setstripe -i 0 -c 1 $DIR/$tfile
10889 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
10890 error "dd 70M file failed"
10891 echo Cancel LRU locks on lustre client to flush the client cache
10892 cancel_lru_locks osc
10894 echo "Reset readahead stats"
10895 $LCTL set_param -n llite.*.read_ahead_stats 0
10897 echo "Read 10M of data but cross 64M bundary"
10898 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
10899 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10900 get_named_value 'misses' | calc_total)
10901 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
10902 rm -f $p $DIR/$tfile
10904 run_test 101h "Readahead should cover current read window"
10907 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
10908 error "dd 10M file failed"
10910 local max_per_file_mb=$($LCTL get_param -n \
10911 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
10912 cancel_lru_locks osc
10913 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
10914 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
10915 error "set max_read_ahead_per_file_mb to 1 failed"
10917 echo "Reset readahead stats"
10918 $LCTL set_param llite.*.read_ahead_stats=0
10920 dd if=$DIR/$tfile of=/dev/null bs=2M
10922 $LCTL get_param llite.*.read_ahead_stats
10923 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10924 awk '/misses/ { print $2 }')
10925 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
10928 run_test 101i "allow current readahead to exceed reservation"
10931 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
10932 error "setstripe $DIR/$tfile failed"
10933 local file_size=$((1048576 * 16))
10934 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
10935 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
10937 echo Disable read-ahead
10938 $LCTL set_param -n llite.*.max_read_ahead_mb=0
10940 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
10941 for blk in $PAGE_SIZE 1048576 $file_size; do
10942 cancel_lru_locks osc
10943 echo "Reset readahead stats"
10944 $LCTL set_param -n llite.*.read_ahead_stats=0
10945 local count=$(($file_size / $blk))
10946 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
10947 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
10948 get_named_value 'failed.to.fast.read' | calc_total)
10949 $LCTL get_param -n llite.*.read_ahead_stats
10950 [ $miss -eq $count ] || error "expected $count got $miss"
10953 rm -f $p $DIR/$tfile
10955 run_test 101j "A complete read block should be submitted when no RA"
10958 test_mkdir $DIR/$tdir
10959 chown $RUNAS_ID $DIR/$tdir
10962 STRIPE_COUNT=$OSTCOUNT
10963 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
10965 trap cleanup_test102 EXIT
10967 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
10969 for num in 1 2 3 4; do
10970 for count in $(seq 1 $STRIPE_COUNT); do
10971 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
10972 local size=`expr $STRIPE_SIZE \* $num`
10973 local file=file"$num-$idx-$count"
10974 $1 $LFS setstripe -S $size -i $idx -c $count $file
10980 $1 tar cf $TMP/f102.tar $tdir --xattrs
10983 cleanup_test102() {
10985 rm -f $TMP/f102.tar
10986 rm -rf $DIR/d0.sanity/d102
10990 [ "$UID" != 0 ] && skip "must run as root"
10991 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
10992 skip_env "must have user_xattr"
10994 [ -z "$(which setfattr 2>/dev/null)" ] &&
10995 skip_env "could not find setfattr"
10997 local testfile=$DIR/$tfile
11000 echo "set/get xattr..."
11001 setfattr -n trusted.name1 -v value1 $testfile ||
11002 error "setfattr -n trusted.name1=value1 $testfile failed"
11003 getfattr -n trusted.name1 $testfile 2> /dev/null |
11004 grep "trusted.name1=.value1" ||
11005 error "$testfile missing trusted.name1=value1"
11007 setfattr -n user.author1 -v author1 $testfile ||
11008 error "setfattr -n user.author1=author1 $testfile failed"
11009 getfattr -n user.author1 $testfile 2> /dev/null |
11010 grep "user.author1=.author1" ||
11011 error "$testfile missing trusted.author1=author1"
11013 echo "listxattr..."
11014 setfattr -n trusted.name2 -v value2 $testfile ||
11015 error "$testfile unable to set trusted.name2"
11016 setfattr -n trusted.name3 -v value3 $testfile ||
11017 error "$testfile unable to set trusted.name3"
11018 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
11019 grep "trusted.name" | wc -l) -eq 3 ] ||
11020 error "$testfile missing 3 trusted.name xattrs"
11022 setfattr -n user.author2 -v author2 $testfile ||
11023 error "$testfile unable to set user.author2"
11024 setfattr -n user.author3 -v author3 $testfile ||
11025 error "$testfile unable to set user.author3"
11026 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
11027 grep "user.author" | wc -l) -eq 3 ] ||
11028 error "$testfile missing 3 user.author xattrs"
11030 echo "remove xattr..."
11031 setfattr -x trusted.name1 $testfile ||
11032 error "$testfile error deleting trusted.name1"
11033 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
11034 error "$testfile did not delete trusted.name1 xattr"
11036 setfattr -x user.author1 $testfile ||
11037 error "$testfile error deleting user.author1"
11038 echo "set lustre special xattr ..."
11039 $LFS setstripe -c1 $testfile
11040 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
11041 awk -F "=" '/trusted.lov/ { print $2 }' )
11042 setfattr -n "trusted.lov" -v $lovea $testfile ||
11043 error "$testfile doesn't ignore setting trusted.lov again"
11044 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
11045 error "$testfile allow setting invalid trusted.lov"
11048 run_test 102a "user xattr test =================================="
11050 check_102b_layout() {
11052 local testfile=$DIR/$tfile
11054 echo "test layout '$layout'"
11055 $LFS setstripe $layout $testfile || error "setstripe failed"
11056 $LFS getstripe -y $testfile
11058 echo "get/set/list trusted.lov xattr ..." # b=10930
11059 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
11060 [[ "$value" =~ "trusted.lov" ]] ||
11061 error "can't get trusted.lov from $testfile"
11062 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
11063 error "getstripe failed"
11065 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
11067 value=$(cut -d= -f2 <<<$value)
11068 # LU-13168: truncated xattr should fail if short lov_user_md header
11069 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
11070 lens="${#value}" || lens="$(seq 4 2 ${#value})"
11071 for len in $lens; do
11072 echo "setfattr $len $testfile.2"
11073 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
11074 [ $len -lt 66 ] && error "short xattr len=$len worked"
11076 local stripe_size=$($LFS getstripe -S $testfile.2)
11077 local stripe_count=$($LFS getstripe -c $testfile.2)
11078 [[ $stripe_size -eq 65536 ]] ||
11079 error "stripe size $stripe_size != 65536"
11080 [[ $stripe_count -eq $stripe_count_orig ]] ||
11081 error "stripe count $stripe_count != $stripe_count_orig"
11082 rm $testfile $testfile.2
11086 [ -z "$(which setfattr 2>/dev/null)" ] &&
11087 skip_env "could not find setfattr"
11088 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11090 # check plain layout
11091 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
11093 # and also check composite layout
11094 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
11097 run_test 102b "getfattr/setfattr for trusted.lov EAs"
11100 [ -z "$(which setfattr 2>/dev/null)" ] &&
11101 skip_env "could not find setfattr"
11102 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11104 # b10930: get/set/list lustre.lov xattr
11105 echo "get/set/list lustre.lov xattr ..."
11106 test_mkdir $DIR/$tdir
11107 chown $RUNAS_ID $DIR/$tdir
11108 local testfile=$DIR/$tdir/$tfile
11109 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
11110 error "setstripe failed"
11111 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
11112 error "getstripe failed"
11113 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
11114 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
11116 local testfile2=${testfile}2
11117 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
11118 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
11120 $RUNAS $MCREATE $testfile2
11121 $RUNAS setfattr -n lustre.lov -v $value $testfile2
11122 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
11123 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
11124 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
11125 [ $stripe_count -eq $STRIPECOUNT ] ||
11126 error "stripe count $stripe_count != $STRIPECOUNT"
11128 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
11130 compare_stripe_info1() {
11131 local stripe_index_all_zero=true
11133 for num in 1 2 3 4; do
11134 for count in $(seq 1 $STRIPE_COUNT); do
11135 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
11136 local size=$((STRIPE_SIZE * num))
11137 local file=file"$num-$offset-$count"
11138 stripe_size=$($LFS getstripe -S $PWD/$file)
11139 [[ $stripe_size -ne $size ]] &&
11140 error "$file: size $stripe_size != $size"
11141 stripe_count=$($LFS getstripe -c $PWD/$file)
11142 # allow fewer stripes to be created, ORI-601
11143 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
11144 error "$file: count $stripe_count != $count"
11145 stripe_index=$($LFS getstripe -i $PWD/$file)
11146 [[ $stripe_index -ne 0 ]] &&
11147 stripe_index_all_zero=false
11151 $stripe_index_all_zero &&
11152 error "all files are being extracted starting from OST index 0"
11156 have_xattrs_include() {
11157 tar --help | grep -q xattrs-include &&
11158 echo --xattrs-include="lustre.*"
11162 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11163 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11165 XINC=$(have_xattrs_include)
11167 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11168 cd $DIR/$tdir/$tdir
11169 compare_stripe_info1
11171 run_test 102d "tar restore stripe info from tarfile,not keep osts"
11174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11175 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11177 XINC=$(have_xattrs_include)
11179 test_mkdir $DIR/$tdir.restore
11181 tar cf - --xattrs $tdir | tar xf - \
11182 -C $DIR/$tdir.restore --xattrs $XINC
11183 cd $DIR/$tdir.restore/$tdir
11184 compare_stripe_info1
11186 run_test 102f "tar copy files, not keep osts"
11189 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
11190 skip "must have user_xattr"
11191 [ -z "$(which setfattr 2>/dev/null)" ] &&
11192 skip_env "could not find setfattr"
11193 [ -z "$(which getfattr 2>/dev/null)" ] &&
11194 skip_env "could not find getfattr"
11196 local xsize=${1:-1024} # in bytes
11197 local file=$DIR/$tfile
11198 local value="$(generate_string $xsize)"
11199 local xbig=trusted.big
11203 log "save $xbig on $file"
11204 if [ -z "$toobig" ]
11206 setfattr -n $xbig -v $value $file ||
11207 error "saving $xbig on $file failed"
11209 setfattr -n $xbig -v $value $file &&
11210 error "saving $xbig on $file succeeded"
11214 local orig=$(get_xattr_value $xbig $file)
11215 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
11217 local xsml=trusted.sml
11218 log "save $xsml on $file"
11219 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
11221 local new=$(get_xattr_value $xbig $file)
11222 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
11224 log "grow $xsml on $file"
11225 setfattr -n $xsml -v "$value" $file ||
11226 error "growing $xsml on $file failed"
11228 new=$(get_xattr_value $xbig $file)
11229 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
11230 log "$xbig still valid after growing $xsml"
11235 test_102h() { # bug 15777
11238 run_test 102h "grow xattr from inside inode to external block"
11241 large_xattr_enabled || skip_env "ea_inode feature disabled"
11243 echo "setting xattr of max xattr size: $(max_xattr_size)"
11244 grow_xattr $(max_xattr_size)
11246 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
11247 echo "This should fail:"
11248 grow_xattr $(($(max_xattr_size) + 10)) 1
11250 run_test 102ha "grow xattr from inside inode to external inode"
11252 test_102i() { # bug 17038
11253 [ -z "$(which getfattr 2>/dev/null)" ] &&
11254 skip "could not find getfattr"
11257 ln -s $DIR/$tfile $DIR/${tfile}link
11258 getfattr -n trusted.lov $DIR/$tfile ||
11259 error "lgetxattr on $DIR/$tfile failed"
11260 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
11261 grep -i "no such attr" ||
11262 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
11263 rm -f $DIR/$tfile $DIR/${tfile}link
11265 run_test 102i "lgetxattr test on symbolic link ============"
11268 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11269 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11271 XINC=$(have_xattrs_include)
11272 setup_test102 "$RUNAS"
11273 chown $RUNAS_ID $DIR/$tdir
11274 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
11275 cd $DIR/$tdir/$tdir
11276 compare_stripe_info1 "$RUNAS"
11278 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
11281 [ -z "$(which setfattr 2>/dev/null)" ] &&
11282 skip "could not find setfattr"
11285 # b22187 just check that does not crash for regular file.
11286 setfattr -n trusted.lov $DIR/$tfile
11287 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
11288 local test_kdir=$DIR/$tdir
11289 test_mkdir $test_kdir
11290 local default_size=$($LFS getstripe -S $test_kdir)
11291 local default_count=$($LFS getstripe -c $test_kdir)
11292 local default_offset=$($LFS getstripe -i $test_kdir)
11293 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
11294 error 'dir setstripe failed'
11295 setfattr -n trusted.lov $test_kdir
11296 local stripe_size=$($LFS getstripe -S $test_kdir)
11297 local stripe_count=$($LFS getstripe -c $test_kdir)
11298 local stripe_offset=$($LFS getstripe -i $test_kdir)
11299 [ $stripe_size -eq $default_size ] ||
11300 error "stripe size $stripe_size != $default_size"
11301 [ $stripe_count -eq $default_count ] ||
11302 error "stripe count $stripe_count != $default_count"
11303 [ $stripe_offset -eq $default_offset ] ||
11304 error "stripe offset $stripe_offset != $default_offset"
11305 rm -rf $DIR/$tfile $test_kdir
11307 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
11310 [ -z "$(which getfattr 2>/dev/null)" ] &&
11311 skip "could not find getfattr"
11313 # LU-532 trusted. xattr is invisible to non-root
11314 local testfile=$DIR/$tfile
11318 echo "listxattr as user..."
11319 chown $RUNAS_ID $testfile
11320 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
11321 grep -q "trusted" &&
11322 error "$testfile trusted xattrs are user visible"
11326 run_test 102l "listxattr size test =================================="
11328 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
11329 local path=$DIR/$tfile
11332 listxattr_size_check $path || error "listattr_size_check $path failed"
11334 run_test 102m "Ensure listxattr fails on small bufffer ========"
11338 getxattr() { # getxattr path name
11339 # Return the base64 encoding of the value of xattr name on path.
11343 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
11345 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11347 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
11349 getfattr --absolute-names --encoding=base64 --name=$name $path |
11350 awk -F= -v name=$name '$1 == name {
11351 print substr($0, index($0, "=") + 1);
11355 test_102n() { # LU-4101 mdt: protect internal xattrs
11356 [ -z "$(which setfattr 2>/dev/null)" ] &&
11357 skip "could not find setfattr"
11358 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
11360 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
11363 local file0=$DIR/$tfile.0
11364 local file1=$DIR/$tfile.1
11365 local xattr0=$TMP/$tfile.0
11366 local xattr1=$TMP/$tfile.1
11367 local namelist="lov lma lmv link fid version som hsm"
11371 rm -rf $file0 $file1 $xattr0 $xattr1
11372 touch $file0 $file1
11374 # Get 'before' xattrs of $file1.
11375 getfattr --absolute-names --dump --match=- $file1 > $xattr0
11377 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
11378 namelist+=" lfsck_namespace"
11379 for name in $namelist; do
11380 # Try to copy xattr from $file0 to $file1.
11381 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11383 setfattr --name=trusted.$name --value="$value" $file1 ||
11384 error "setxattr 'trusted.$name' failed"
11386 # Try to set a garbage xattr.
11387 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11389 if [[ x$name == "xlov" ]]; then
11390 setfattr --name=trusted.lov --value="$value" $file1 &&
11391 error "setxattr invalid 'trusted.lov' success"
11393 setfattr --name=trusted.$name --value="$value" $file1 ||
11394 error "setxattr invalid 'trusted.$name' failed"
11397 # Try to remove the xattr from $file1. We don't care if this
11398 # appears to succeed or fail, we just don't want there to be
11399 # any changes or crashes.
11400 setfattr --remove=$trusted.$name $file1 2> /dev/null
11403 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
11406 # Try to copy xattr from $file0 to $file1.
11407 value=$(getxattr $file0 trusted.$name 2> /dev/null)
11409 setfattr --name=trusted.$name --value="$value" $file1 ||
11410 error "setxattr 'trusted.$name' failed"
11412 # Try to set a garbage xattr.
11413 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
11415 setfattr --name=trusted.$name --value="$value" $file1 ||
11416 error "setxattr 'trusted.$name' failed"
11418 # Try to remove the xattr from $file1. We don't care if this
11419 # appears to succeed or fail, we just don't want there to be
11420 # any changes or crashes.
11421 setfattr --remove=$trusted.$name $file1 2> /dev/null
11424 # Get 'after' xattrs of file1.
11425 getfattr --absolute-names --dump --match=- $file1 > $xattr1
11427 if ! diff $xattr0 $xattr1; then
11428 error "before and after xattrs of '$file1' differ"
11431 rm -rf $file0 $file1 $xattr0 $xattr1
11435 run_test 102n "silently ignore setxattr on internal trusted xattrs"
11437 test_102p() { # LU-4703 setxattr did not check ownership
11438 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
11439 skip "MDS needs to be at least 2.5.56"
11441 local testfile=$DIR/$tfile
11445 echo "setfacl as user..."
11446 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
11447 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
11449 echo "setfattr as user..."
11450 setfacl -m "u:$RUNAS_ID:---" $testfile
11451 $RUNAS setfattr -x system.posix_acl_access $testfile
11452 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
11454 run_test 102p "check setxattr(2) correctly fails without permission"
11457 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
11458 skip "MDS needs to be at least 2.6.92"
11460 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
11462 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
11465 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
11466 skip "MDS needs to be at least 2.6.93"
11468 touch $DIR/$tfile || error "touch"
11469 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
11470 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
11471 rm $DIR/$tfile || error "rm"
11474 mkdir -p $DIR/$tdir || error "mkdir"
11475 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11476 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11477 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11478 error "$testfile error deleting user.author1"
11479 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11480 grep "user.$(basename $tdir)" &&
11481 error "$tdir did not delete user.$(basename $tdir)"
11482 rmdir $DIR/$tdir || error "rmdir"
11485 test_mkdir $DIR/$tdir
11486 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
11487 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
11488 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
11489 error "$testfile error deleting user.author1"
11490 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
11491 grep "user.$(basename $tdir)" &&
11492 error "$tdir did not delete user.$(basename $tdir)"
11493 rmdir $DIR/$tdir || error "rm striped dir"
11495 run_test 102r "set EAs with empty values"
11498 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11499 skip "MDS needs to be at least 2.11.52"
11501 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11503 save_lustre_params client "llite.*.xattr_cache" > $save
11505 for cache in 0 1; do
11506 lctl set_param llite.*.xattr_cache=$cache
11509 touch $DIR/$tfile || error "touch"
11510 for prefix in lustre security system trusted user; do
11511 # Note getxattr() may fail with 'Operation not
11512 # supported' or 'No such attribute' depending
11513 # on prefix and cache.
11514 getfattr -n $prefix.n102s $DIR/$tfile &&
11515 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
11519 restore_lustre_params < $save
11521 run_test 102s "getting nonexistent xattrs should fail"
11524 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
11525 skip "MDS needs to be at least 2.11.52"
11527 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11529 save_lustre_params client "llite.*.xattr_cache" > $save
11531 for cache in 0 1; do
11532 lctl set_param llite.*.xattr_cache=$cache
11534 for buf_size in 0 256; do
11536 touch $DIR/$tfile || error "touch"
11537 setfattr -n user.multiop $DIR/$tfile
11538 $MULTIOP $DIR/$tfile oa$buf_size ||
11539 error "cannot get zero length xattr value (buf_size = $buf_size)"
11543 restore_lustre_params < $save
11545 run_test 102t "zero length xattr values handled correctly"
11549 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
11554 [ "$UID" != 0 ] && skip "must run as root"
11555 $GSS && skip_env "could not run under gss"
11556 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
11557 skip_env "must have acl enabled"
11558 [ -z "$(which setfacl 2>/dev/null)" ] &&
11559 skip_env "could not find setfacl"
11560 remote_mds_nodsh && skip "remote MDS with nodsh"
11562 gpasswd -a daemon bin # LU-5641
11563 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
11565 declare -a identity_old
11567 for num in $(seq $MDSCOUNT); do
11568 switch_identity $num true || identity_old[$num]=$?
11571 SAVE_UMASK=$(umask)
11573 mkdir -p $DIR/$tdir
11576 echo "performing cp ..."
11577 run_acl_subtest cp || error "run_acl_subtest cp failed"
11578 echo "performing getfacl-noacl..."
11579 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
11580 echo "performing misc..."
11581 run_acl_subtest misc || error "misc test failed"
11582 echo "performing permissions..."
11583 run_acl_subtest permissions || error "permissions failed"
11584 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
11585 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
11586 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
11587 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
11589 echo "performing permissions xattr..."
11590 run_acl_subtest permissions_xattr ||
11591 error "permissions_xattr failed"
11593 echo "performing setfacl..."
11594 run_acl_subtest setfacl || error "setfacl test failed"
11596 # inheritance test got from HP
11597 echo "performing inheritance..."
11598 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
11599 chmod +x make-tree || error "chmod +x failed"
11600 run_acl_subtest inheritance || error "inheritance test failed"
11603 echo "LU-974 ignore umask when acl is enabled..."
11604 run_acl_subtest 974 || error "LU-974 umask test failed"
11605 if [ $MDSCOUNT -ge 2 ]; then
11606 run_acl_subtest 974_remote ||
11607 error "LU-974 umask test failed under remote dir"
11610 echo "LU-2561 newly created file is same size as directory..."
11611 if [ "$mds1_FSTYPE" != "zfs" ]; then
11612 run_acl_subtest 2561 || error "LU-2561 test failed"
11614 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
11617 run_acl_subtest 4924 || error "LU-4924 test failed"
11622 for num in $(seq $MDSCOUNT); do
11623 if [ "${identity_old[$num]}" = 1 ]; then
11624 switch_identity $num false || identity_old[$num]=$?
11628 run_test 103a "acl test"
11634 for U in {0..511}; do
11636 local O=$(printf "%04o" $U)
11638 umask $(printf "%04o" $((511 ^ $O)))
11639 $LFS setstripe -c 1 $DIR/$tfile.s$O
11640 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
11642 (( $S == ($O & 0666) )) ||
11643 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
11645 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
11646 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
11647 (( $S == ($O & 0666) )) ||
11648 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
11650 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
11651 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
11652 (( $S == ($O & 0666) )) ||
11653 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
11654 rm -f $DIR/$tfile.[smp]$0
11658 # limit the concurrently running threads to 64. LU-11878
11659 local idx=$((U % 64))
11660 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
11665 run_test 103b "umask lfs setstripe"
11668 mkdir -p $DIR/$tdir
11669 cp -rp $DIR/$tdir $DIR/$tdir.bak
11671 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
11672 error "$DIR/$tdir shouldn't contain default ACL"
11673 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
11674 error "$DIR/$tdir.bak shouldn't contain default ACL"
11677 run_test 103c "'cp -rp' won't set empty acl"
11682 local saved_debug=$($LCTL get_param -n debug)
11684 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
11685 skip "MDS needs to be at least 2.14.52"
11687 large_xattr_enabled || skip_env "ea_inode feature disabled"
11689 mkdir -p $DIR/$tdir
11690 # add big LOV EA to cause reply buffer overflow earlier
11691 $LFS setstripe -C 1000 $DIR/$tdir
11692 lctl set_param mdc.*-mdc*.stats=clear
11694 $LCTL set_param debug=0
11695 stack_trap "$LCTL set_param debug=\"$saved_debug\"" EXIT
11696 stack_trap "$LCTL get_param mdc.*-mdc*.stats" EXIT
11698 # add a large number of default ACLs (expect 8000+ for 2.13+)
11699 for U in {2..7000}; do
11700 setfacl -d -m user:$U:rwx $DIR/$tdir ||
11701 error "Able to add just $U default ACLs"
11703 numacl=$(getfacl $DIR/$tdir |& grep -c "default:user")
11704 echo "$numacl default ACLs created"
11706 stat $DIR/$tdir || error "Cannot stat directory"
11707 # check file creation
11708 touch $DIR/$tdir/$tfile ||
11709 error "failed to create $tfile with $numacl default ACLs"
11710 stat $DIR/$tdir/$tfile || error "Cannot stat file"
11711 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11712 echo "$fileacl ACLs were inherited"
11713 (( $fileacl == $numacl )) ||
11714 error "Not all default ACLs were inherited: $numacl != $fileacl"
11715 # check that new ACLs creation adds new ACLs to inherited ACLs
11716 setfacl -m user:19000:rwx $DIR/$tdir/$tfile ||
11717 error "Cannot set new ACL"
11718 numacl=$((numacl + 1))
11719 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11720 (( $fileacl == $numacl )) ||
11721 error "failed to add new ACL: $fileacl != $numacl as expected"
11722 # adds more ACLs to a file to reach their maximum at 8000+
11724 for U in {20000..25000}; do
11725 setfacl -m user:$U:rwx $DIR/$tdir/$tfile || break
11726 numacl=$((numacl + 1))
11728 echo "Added $numacl more ACLs to the file"
11729 fileacl=$(getfacl $DIR/$tdir/$tfile |& grep -c "user:")
11730 echo "Total $fileacl ACLs in file"
11731 stat $DIR/$tdir/$tfile > /dev/null || error "Cannot stat file"
11732 rm -f $DIR/$tdir/$tfile || error "Cannot remove file"
11733 rmdir $DIR/$tdir || error "Cannot remove directory"
11735 run_test 103e "inheritance of big amount of default ACLs"
11738 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
11739 skip "MDS needs to be at least 2.14.51"
11741 large_xattr_enabled || skip_env "ea_inode feature disabled"
11743 # enable changelog to consume more internal MDD buffers
11746 mkdir -p $DIR/$tdir
11748 $LFS setstripe -C 1000 $DIR/$tdir
11749 setfacl -d -m user:$U:rwx $DIR/$tdir || error "Cannot add default ACLs"
11750 mkdir $DIR/$tdir/inherited || error "failed to create subdirectory"
11751 rmdir $DIR/$tdir/inherited || error "Cannot remove subdirectory"
11752 rmdir $DIR/$tdir || error "Cannot remove directory"
11754 run_test 103f "changelog doesn't interfere with default ACLs buffers"
11757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11760 lfs df || error "lfs df failed"
11761 lfs df -ih || error "lfs df -ih failed"
11762 lfs df -h $DIR || error "lfs df -h $DIR failed"
11763 lfs df -i $DIR || error "lfs df -i $DIR failed"
11764 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
11765 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
11767 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
11768 lctl --device %$OSC deactivate
11769 lfs df || error "lfs df with deactivated OSC failed"
11770 lctl --device %$OSC activate
11771 # wait the osc back to normal
11772 wait_osc_import_ready client ost
11774 lfs df || error "lfs df with reactivated OSC failed"
11777 run_test 104a "lfs df [-ih] [path] test ========================="
11780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11781 [ $RUNAS_ID -eq $UID ] &&
11782 skip_env "RUNAS_ID = UID = $UID -- skipping"
11784 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
11785 grep "Permission denied" | wc -l)))
11786 if [ $denied_cnt -ne 0 ]; then
11787 error "lfs check servers test failed"
11790 run_test 104b "$RUNAS lfs check servers test ===================="
11793 # Verify $1 is within range of $2.
11794 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
11795 # $1 is <= 2% of $2. Else Fail.
11798 # Strip all units (M, G, T)
11799 actual=$(echo $1 | tr -d A-Z)
11800 expect=$(echo $2 | tr -d A-Z)
11802 expect_lo=$(($expect * 98 / 100)) # 2% below
11803 expect_hi=$(($expect * 102 / 100)) # 2% above
11805 # permit 2% drift above and below
11806 (( $actual >= $expect_lo && $actual <= $expect_hi ))
11810 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11811 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
11813 local ost_param="osd-zfs.$FSNAME-OST0000."
11814 local mdt_param="osd-zfs.$FSNAME-MDT0000."
11815 local ofacets=$(get_facets OST)
11816 local mfacets=$(get_facets MDS)
11817 local saved_ost_blocks=
11818 local saved_mdt_blocks=
11820 echo "Before recordsize change"
11821 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
11822 df=($(df -h | grep "$MOUNT"$))
11825 echo "lfs output : ${lfs_df[*]}"
11826 echo "df output : ${df[*]}"
11828 for facet in ${ofacets//,/ }; do
11829 if [ -z $saved_ost_blocks ]; then
11830 saved_ost_blocks=$(do_facet $facet \
11831 lctl get_param -n $ost_param.blocksize)
11832 echo "OST Blocksize: $saved_ost_blocks"
11834 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11835 do_facet $facet zfs set recordsize=32768 $ost
11838 # BS too small. Sufficient for functional testing.
11839 for facet in ${mfacets//,/ }; do
11840 if [ -z $saved_mdt_blocks ]; then
11841 saved_mdt_blocks=$(do_facet $facet \
11842 lctl get_param -n $mdt_param.blocksize)
11843 echo "MDT Blocksize: $saved_mdt_blocks"
11845 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11846 do_facet $facet zfs set recordsize=32768 $mdt
11849 # Give new values chance to reflect change
11852 echo "After recordsize change"
11853 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
11854 df_after=($(df -h | grep "$MOUNT"$))
11857 echo "lfs output : ${lfs_df_after[*]}"
11858 echo "df output : ${df_after[*]}"
11861 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
11862 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
11863 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
11864 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
11865 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
11866 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
11869 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
11870 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
11871 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
11872 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
11873 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
11874 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
11876 # Restore MDT recordize back to original
11877 for facet in ${mfacets//,/ }; do
11878 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
11879 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
11882 # Restore OST recordize back to original
11883 for facet in ${ofacets//,/ }; do
11884 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
11885 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
11890 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
11893 # doesn't work on 2.4 kernels
11895 if $(flock_is_enabled); then
11896 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
11898 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
11902 run_test 105a "flock when mounted without -o flock test ========"
11906 if $(flock_is_enabled); then
11907 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
11909 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
11913 run_test 105b "fcntl when mounted without -o flock test ========"
11917 if $(flock_is_enabled); then
11918 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
11920 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
11924 run_test 105c "lockf when mounted without -o flock test"
11926 test_105d() { # bug 15924
11927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11929 test_mkdir $DIR/$tdir
11930 flock_is_enabled || skip_env "mount w/o flock enabled"
11931 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
11932 $LCTL set_param fail_loc=0x80000315
11933 flocks_test 2 $DIR/$tdir
11935 run_test 105d "flock race (should not freeze) ========"
11937 test_105e() { # bug 22660 && 22040
11938 flock_is_enabled || skip_env "mount w/o flock enabled"
11941 flocks_test 3 $DIR/$tfile
11943 run_test 105e "Two conflicting flocks from same process"
11945 test_106() { #bug 10921
11946 test_mkdir $DIR/$tdir
11947 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
11948 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
11950 run_test 106 "attempt exec of dir followed by chown of that dir"
11953 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11961 local save_pattern=$(sysctl -n kernel.core_pattern)
11962 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
11963 sysctl -w kernel.core_pattern=$file
11964 sysctl -w kernel.core_uses_pid=0
11966 ulimit -c unlimited
11972 kill -s 11 $SLEEPPID
11974 if [ -e $file ]; then
11975 size=`stat -c%s $file`
11976 [ $size -eq 0 ] && error "Fail to create core file $file"
11978 error "Fail to create core file $file"
11981 sysctl -w kernel.core_pattern=$save_pattern
11982 sysctl -w kernel.core_uses_pid=$save_uses_pid
11985 run_test 107 "Coredump on SIG"
11988 test_mkdir $DIR/$tdir
11989 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
11990 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
11991 error "mkdir with 256 char should fail, but did not"
11992 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
11993 error "create with 255 char failed"
11994 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
11995 error "create with 256 char should fail, but did not"
12000 run_test 110 "filename length checking"
12003 # Purpose: To verify dynamic thread (OSS) creation.
12006 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12007 remote_ost_nodsh && skip "remote OST with nodsh"
12009 # Lustre does not stop service threads once they are started.
12010 # Reset number of running threads to default.
12015 local save_params="$TMP/sanity-$TESTNAME.parameters"
12017 # Get ll_ost_io count before I/O
12018 OSTIO_pre=$(do_facet ost1 \
12019 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
12020 # Exit if lustre is not running (ll_ost_io not running).
12021 [ -z "$OSTIO_pre" ] && error "no OSS threads"
12023 echo "Starting with $OSTIO_pre threads"
12024 local thread_max=$((OSTIO_pre * 2))
12025 local rpc_in_flight=$((thread_max * 2))
12026 # this is limited to OSC_MAX_RIF_MAX (256)
12027 [ $rpc_in_flight -gt 256 ] && rpc_in_flight=256
12028 thread_max=$((rpc_in_flight / 2))
12029 [ $thread_max -le $OSTIO_pre ] && skip "Too many ost_io threads" &&
12032 # Number of I/O Process proposed to be started.
12034 local facets=$(get_facets OST)
12036 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
12037 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
12039 # Set in_flight to $rpc_in_flight
12040 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
12041 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
12042 nfiles=${rpc_in_flight}
12043 # Set ost thread_max to $thread_max
12044 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
12046 # 5 Minutes should be sufficient for max number of OSS
12047 # threads(thread_max) to be created.
12051 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
12052 test_mkdir $DIR/$tdir
12053 for i in $(seq $nfiles); do
12054 local file=$DIR/$tdir/${tfile}-$i
12055 $LFS setstripe -c -1 -i 0 $file
12056 ($WTL $file $timeout)&
12059 # I/O Started - Wait for thread_started to reach thread_max or report
12060 # error if thread_started is more than thread_max.
12061 echo "Waiting for thread_started to reach thread_max"
12062 local thread_started=0
12063 local end_time=$((SECONDS + timeout))
12065 while [ $SECONDS -le $end_time ] ; do
12067 # Get ost i/o thread_started count.
12068 thread_started=$(do_facet ost1 \
12070 ost.OSS.ost_io.threads_started | cut -d= -f2")
12071 # Break out if thread_started is equal/greater than thread_max
12072 if [[ $thread_started -ge $thread_max ]]; then
12073 echo ll_ost_io thread_started $thread_started, \
12074 equal/greater than thread_max $thread_max
12080 # Cleanup - We have the numbers, Kill i/o jobs if running.
12081 jobcount=($(jobs -p))
12082 for i in $(seq 0 $((${#jobcount[@]}-1)))
12084 kill -9 ${jobcount[$i]}
12085 if [ $? -ne 0 ] ; then
12087 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
12091 # Cleanup files left by WTL binary.
12092 for i in $(seq $nfiles); do
12093 local file=$DIR/$tdir/${tfile}-$i
12095 if [ $? -ne 0 ] ; then
12096 echo "Warning: Failed to delete file $file"
12100 restore_lustre_params <$save_params
12101 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
12103 # Error out if no new thread has started or Thread started is greater
12105 if [[ $thread_started -le $OSTIO_pre ||
12106 $thread_started -gt $thread_max ]]; then
12107 error "ll_ost_io: thread_started $thread_started" \
12108 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
12109 "No new thread started or thread started greater " \
12113 run_test 115 "verify dynamic thread creation===================="
12115 test_116a() { # was previously test_116()
12116 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12117 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12118 remote_mds_nodsh && skip "remote MDS with nodsh"
12120 echo -n "Free space priority "
12121 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
12126 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
12127 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
12128 stack_trap simple_cleanup_common
12130 # Check if we need to generate uneven OSTs
12131 test_mkdir -p $DIR/$tdir/OST${MINI}
12132 local FILL=$((MINV / 4))
12133 local DIFF=$((MAXV - MINV))
12134 local DIFF2=$((DIFF * 100 / MINV))
12136 local threshold=$(do_facet $SINGLEMDS \
12137 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
12138 threshold=${threshold%%%}
12139 echo -n "Check for uneven OSTs: "
12140 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
12142 if [[ $DIFF2 -gt $threshold ]]; then
12144 echo "Don't need to fill OST$MINI"
12146 # generate uneven OSTs. Write 2% over the QOS threshold value
12148 DIFF=$((threshold - DIFF2 + 2))
12149 DIFF2=$((MINV * DIFF / 100))
12150 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
12151 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
12152 error "setstripe failed"
12153 DIFF=$((DIFF2 / 2048))
12155 while [ $i -lt $DIFF ]; do
12157 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
12158 bs=2M count=1 2>/dev/null
12167 DIFF=$((MAXV - MINV))
12168 DIFF2=$((DIFF * 100 / MINV))
12169 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
12170 if [ $DIFF2 -gt $threshold ]; then
12173 skip "QOS imbalance criteria not met"
12181 # now fill using QOS
12182 $LFS setstripe -c 1 $DIR/$tdir
12183 FILL=$((FILL / 200))
12184 if [ $FILL -gt 600 ]; then
12187 echo "writing $FILL files to QOS-assigned OSTs"
12189 while [ $i -lt $FILL ]; do
12191 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
12192 count=1 2>/dev/null
12195 echo "wrote $i 200k files"
12199 echo "Note: free space may not be updated, so measurements might be off"
12201 DIFF2=$((MAXV - MINV))
12202 echo "free space delta: orig $DIFF final $DIFF2"
12203 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
12204 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
12205 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
12206 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
12207 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
12208 if [[ $DIFF -gt 0 ]]; then
12209 FILL=$((DIFF2 * 100 / DIFF - 100))
12210 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
12213 # Figure out which files were written where
12214 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12215 awk '/'$MINI1': / {print $2; exit}')
12217 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12218 echo "$MINC files created on smaller OST $MINI1"
12219 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
12220 awk '/'$MAXI1': / {print $2; exit}')
12222 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
12223 echo "$MAXC files created on larger OST $MAXI1"
12224 if [[ $MINC -gt 0 ]]; then
12225 FILL=$((MAXC * 100 / MINC - 100))
12226 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
12228 [[ $MAXC -gt $MINC ]] ||
12229 error_ignore LU-9 "stripe QOS didn't balance free space"
12231 run_test 116a "stripe QOS: free space balance ==================="
12233 test_116b() { # LU-2093
12234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12235 remote_mds_nodsh && skip "remote MDS with nodsh"
12237 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
12238 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
12239 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
12240 [ -z "$old_rr" ] && skip "no QOS"
12241 do_facet $SINGLEMDS lctl set_param \
12242 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
12243 mkdir -p $DIR/$tdir
12244 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
12245 createmany -o $DIR/$tdir/f- 20 || error "can't create"
12246 do_facet $SINGLEMDS lctl set_param fail_loc=0
12248 do_facet $SINGLEMDS lctl set_param \
12249 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
12251 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
12253 test_117() # bug 10891
12255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12257 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
12258 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
12259 lctl set_param fail_loc=0x21e
12260 > $DIR/$tfile || error "truncate failed"
12261 lctl set_param fail_loc=0
12262 echo "Truncate succeeded."
12265 run_test 117 "verify osd extend =========="
12267 NO_SLOW_RESENDCOUNT=4
12268 export OLD_RESENDCOUNT=""
12269 set_resend_count () {
12270 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
12271 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
12272 lctl set_param -n $PROC_RESENDCOUNT $1
12273 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
12276 # for reduce test_118* time (b=14842)
12277 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12279 # Reset async IO behavior after error case
12281 FILE=$DIR/reset_async
12283 # Ensure all OSCs are cleared
12284 $LFS setstripe -c -1 $FILE
12285 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
12290 test_118a() #bug 11710
12292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12296 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12297 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12298 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12300 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12301 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12306 run_test 118a "verify O_SYNC works =========="
12310 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12311 remote_ost_nodsh && skip "remote OST with nodsh"
12315 #define OBD_FAIL_SRV_ENOENT 0x217
12316 set_nodes_failloc "$(osts_nodes)" 0x217
12317 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12319 set_nodes_failloc "$(osts_nodes)" 0
12320 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12321 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12324 if [[ $RC -eq 0 ]]; then
12325 error "Must return error due to dropped pages, rc=$RC"
12329 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12330 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12334 echo "Dirty pages not leaked on ENOENT"
12336 # Due to the above error the OSC will issue all RPCs syncronously
12337 # until a subsequent RPC completes successfully without error.
12338 $MULTIOP $DIR/$tfile Ow4096yc
12343 run_test 118b "Reclaim dirty pages on fatal error =========="
12347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12349 # for 118c, restore the original resend count, LU-1940
12350 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
12351 set_resend_count $OLD_RESENDCOUNT
12352 remote_ost_nodsh && skip "remote OST with nodsh"
12356 #define OBD_FAIL_OST_EROFS 0x216
12357 set_nodes_failloc "$(osts_nodes)" 0x216
12359 # multiop should block due to fsync until pages are written
12360 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12364 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12365 error "Multiop failed to block on fsync, pid=$MULTIPID"
12368 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12370 if [[ $WRITEBACK -eq 0 ]]; then
12371 error "No page in writeback, writeback=$WRITEBACK"
12374 set_nodes_failloc "$(osts_nodes)" 0
12377 if [[ $RC -ne 0 ]]; then
12378 error "Multiop fsync failed, rc=$RC"
12381 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12382 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12384 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12385 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12389 echo "Dirty pages flushed via fsync on EROFS"
12392 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
12394 # continue to use small resend count to reduce test_118* time (b=14842)
12395 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
12399 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12400 remote_ost_nodsh && skip "remote OST with nodsh"
12404 #define OBD_FAIL_OST_BRW_PAUSE_BULK
12405 set_nodes_failloc "$(osts_nodes)" 0x214
12406 # multiop should block due to fsync until pages are written
12407 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12411 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
12412 error "Multiop failed to block on fsync, pid=$MULTIPID"
12415 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12417 if [[ $WRITEBACK -eq 0 ]]; then
12418 error "No page in writeback, writeback=$WRITEBACK"
12421 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
12422 set_nodes_failloc "$(osts_nodes)" 0
12424 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12425 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12427 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12428 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12432 echo "Dirty pages gaurenteed flushed via fsync"
12435 run_test 118d "Fsync validation inject a delay of the bulk =========="
12438 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12442 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
12443 lctl set_param fail_loc=0x8000040a
12445 # Should simulate EINVAL error which is fatal
12446 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12448 if [[ $RC -eq 0 ]]; then
12449 error "Must return error due to dropped pages, rc=$RC"
12452 lctl set_param fail_loc=0x0
12454 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12455 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12456 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12458 if [[ $LOCKED -ne 0 ]]; then
12459 error "Locked pages remain in cache, locked=$LOCKED"
12462 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12463 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12467 echo "No pages locked after fsync"
12472 run_test 118f "Simulate unrecoverable OSC side error =========="
12475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12479 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
12480 lctl set_param fail_loc=0x406
12482 # simulate local -ENOMEM
12483 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12486 lctl set_param fail_loc=0
12487 if [[ $RC -eq 0 ]]; then
12488 error "Must return error due to dropped pages, rc=$RC"
12491 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12492 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12493 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12495 if [[ $LOCKED -ne 0 ]]; then
12496 error "Locked pages remain in cache, locked=$LOCKED"
12499 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12500 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12504 echo "No pages locked after fsync"
12509 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
12512 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12513 remote_ost_nodsh && skip "remote OST with nodsh"
12517 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12518 set_nodes_failloc "$(osts_nodes)" 0x20e
12519 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12520 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12523 set_nodes_failloc "$(osts_nodes)" 0
12524 if [[ $RC -eq 0 ]]; then
12525 error "Must return error due to dropped pages, rc=$RC"
12528 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12529 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12530 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
12532 if [[ $LOCKED -ne 0 ]]; then
12533 error "Locked pages remain in cache, locked=$LOCKED"
12536 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12537 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12541 echo "No pages locked after fsync"
12545 run_test 118h "Verify timeout in handling recoverables errors =========="
12547 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12550 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12551 remote_ost_nodsh && skip "remote OST with nodsh"
12555 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12556 set_nodes_failloc "$(osts_nodes)" 0x20e
12558 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
12559 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
12562 set_nodes_failloc "$(osts_nodes)" 0
12566 if [[ $RC -ne 0 ]]; then
12567 error "got error, but should be not, rc=$RC"
12570 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12571 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12572 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12573 if [[ $LOCKED -ne 0 ]]; then
12574 error "Locked pages remain in cache, locked=$LOCKED"
12577 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12578 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12582 echo "No pages locked after fsync"
12586 run_test 118i "Fix error before timeout in recoverable error =========="
12588 [ "$SLOW" = "no" ] && set_resend_count 4
12591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12592 remote_ost_nodsh && skip "remote OST with nodsh"
12596 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
12597 set_nodes_failloc "$(osts_nodes)" 0x220
12599 # return -EIO from OST
12600 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
12602 set_nodes_failloc "$(osts_nodes)" 0x0
12603 if [[ $RC -eq 0 ]]; then
12604 error "Must return error due to dropped pages, rc=$RC"
12607 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
12608 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
12609 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
12610 if [[ $LOCKED -ne 0 ]]; then
12611 error "Locked pages remain in cache, locked=$LOCKED"
12614 # in recoverable error on OST we want resend and stay until it finished
12615 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
12616 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
12620 echo "No pages locked after fsync"
12624 run_test 118j "Simulate unrecoverable OST side error =========="
12628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12629 remote_ost_nodsh && skip "remote OSTs with nodsh"
12631 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
12632 set_nodes_failloc "$(osts_nodes)" 0x20e
12633 test_mkdir $DIR/$tdir
12635 for ((i=0;i<10;i++)); do
12636 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
12637 error "dd to $DIR/$tdir/$tfile-$i failed" )&
12644 set_nodes_failloc "$(osts_nodes)" 0
12647 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
12649 test_118l() # LU-646
12651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12653 test_mkdir $DIR/$tdir
12654 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
12657 run_test 118l "fsync dir"
12659 test_118m() # LU-3066
12661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12663 test_mkdir $DIR/$tdir
12664 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
12667 run_test 118m "fdatasync dir ========="
12669 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
12676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12677 remote_ost_nodsh && skip "remote OSTs with nodsh"
12679 # Sleep to avoid a cached response.
12680 #define OBD_STATFS_CACHE_SECONDS 1
12683 # Inject a 10 second delay in the OST_STATFS handler.
12684 #define OBD_FAIL_OST_STATFS_DELAY 0x242
12685 set_nodes_failloc "$(osts_nodes)" 0x242
12688 stat --file-system $MOUNT > /dev/null
12691 set_nodes_failloc "$(osts_nodes)" 0
12693 if ((end - begin > 20)); then
12694 error "statfs took $((end - begin)) seconds, expected 10"
12697 run_test 118n "statfs() sends OST_STATFS requests in parallel"
12699 test_119a() # bug 11737
12701 BSIZE=$((512 * 1024))
12702 directio write $DIR/$tfile 0 1 $BSIZE
12703 # We ask to read two blocks, which is more than a file size.
12704 # directio will indicate an error when requested and actual
12705 # sizes aren't equeal (a normal situation in this case) and
12706 # print actual read amount.
12707 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
12708 if [ "$NOB" != "$BSIZE" ]; then
12709 error "read $NOB bytes instead of $BSIZE"
12713 run_test 119a "Short directIO read must return actual read amount"
12715 test_119b() # bug 11737
12717 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12719 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
12720 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
12722 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
12723 error "direct read failed"
12726 run_test 119b "Sparse directIO read must return actual read amount"
12728 test_119c() # bug 13099
12731 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
12732 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
12735 run_test 119c "Testing for direct read hitting hole"
12737 test_119d() # bug 15950
12739 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12741 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
12742 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
12744 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
12745 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
12746 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
12747 lctl set_param fail_loc=0x40d
12748 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
12751 cat $DIR/$tfile > /dev/null &
12752 lctl set_param fail_loc=0
12755 log "the DIO writes have completed, now wait for the reads (should not block very long)"
12757 [ -n "`ps h -p $pid_reads -o comm`" ] && \
12758 error "the read rpcs have not completed in 2s"
12760 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
12762 run_test 119d "The DIO path should try to send a new rpc once one is completed"
12765 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12766 remote_mds_nodsh && skip "remote MDS with nodsh"
12767 test_mkdir -i0 -c1 $DIR/$tdir
12768 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12769 skip_env "no early lock cancel on server"
12771 lru_resize_disable mdc
12772 lru_resize_disable osc
12773 cancel_lru_locks mdc
12774 # asynchronous object destroy at MDT could cause bl ast to client
12775 cancel_lru_locks osc
12777 stat $DIR/$tdir > /dev/null
12778 can1=$(do_facet mds1 \
12779 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12780 awk '/ldlm_cancel/ {print $2}')
12781 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12782 awk '/ldlm_bl_callback/ {print $2}')
12783 test_mkdir -i0 -c1 $DIR/$tdir/d1
12784 can2=$(do_facet mds1 \
12785 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12786 awk '/ldlm_cancel/ {print $2}')
12787 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12788 awk '/ldlm_bl_callback/ {print $2}')
12789 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12790 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12791 lru_resize_enable mdc
12792 lru_resize_enable osc
12794 run_test 120a "Early Lock Cancel: mkdir test"
12797 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12798 remote_mds_nodsh && skip "remote MDS with nodsh"
12799 test_mkdir $DIR/$tdir
12800 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12801 skip_env "no early lock cancel on server"
12803 lru_resize_disable mdc
12804 lru_resize_disable osc
12805 cancel_lru_locks mdc
12806 stat $DIR/$tdir > /dev/null
12807 can1=$(do_facet $SINGLEMDS \
12808 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12809 awk '/ldlm_cancel/ {print $2}')
12810 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12811 awk '/ldlm_bl_callback/ {print $2}')
12812 touch $DIR/$tdir/f1
12813 can2=$(do_facet $SINGLEMDS \
12814 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12815 awk '/ldlm_cancel/ {print $2}')
12816 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12817 awk '/ldlm_bl_callback/ {print $2}')
12818 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12819 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12820 lru_resize_enable mdc
12821 lru_resize_enable osc
12823 run_test 120b "Early Lock Cancel: create test"
12826 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12827 remote_mds_nodsh && skip "remote MDS with nodsh"
12828 test_mkdir -i0 -c1 $DIR/$tdir
12829 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12830 skip "no early lock cancel on server"
12832 lru_resize_disable mdc
12833 lru_resize_disable osc
12834 test_mkdir -i0 -c1 $DIR/$tdir/d1
12835 test_mkdir -i0 -c1 $DIR/$tdir/d2
12836 touch $DIR/$tdir/d1/f1
12837 cancel_lru_locks mdc
12838 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
12839 can1=$(do_facet mds1 \
12840 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12841 awk '/ldlm_cancel/ {print $2}')
12842 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12843 awk '/ldlm_bl_callback/ {print $2}')
12844 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12845 can2=$(do_facet mds1 \
12846 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12847 awk '/ldlm_cancel/ {print $2}')
12848 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12849 awk '/ldlm_bl_callback/ {print $2}')
12850 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12851 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12852 lru_resize_enable mdc
12853 lru_resize_enable osc
12855 run_test 120c "Early Lock Cancel: link test"
12858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12859 remote_mds_nodsh && skip "remote MDS with nodsh"
12860 test_mkdir -i0 -c1 $DIR/$tdir
12861 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12862 skip_env "no early lock cancel on server"
12864 lru_resize_disable mdc
12865 lru_resize_disable osc
12867 cancel_lru_locks mdc
12868 stat $DIR/$tdir > /dev/null
12869 can1=$(do_facet mds1 \
12870 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12871 awk '/ldlm_cancel/ {print $2}')
12872 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12873 awk '/ldlm_bl_callback/ {print $2}')
12874 chmod a+x $DIR/$tdir
12875 can2=$(do_facet mds1 \
12876 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12877 awk '/ldlm_cancel/ {print $2}')
12878 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12879 awk '/ldlm_bl_callback/ {print $2}')
12880 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12881 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12882 lru_resize_enable mdc
12883 lru_resize_enable osc
12885 run_test 120d "Early Lock Cancel: setattr test"
12888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12889 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12890 skip_env "no early lock cancel on server"
12891 remote_mds_nodsh && skip "remote MDS with nodsh"
12893 local dlmtrace_set=false
12895 test_mkdir -i0 -c1 $DIR/$tdir
12896 lru_resize_disable mdc
12897 lru_resize_disable osc
12898 ! $LCTL get_param debug | grep -q dlmtrace &&
12899 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
12900 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
12901 cancel_lru_locks mdc
12902 cancel_lru_locks osc
12903 dd if=$DIR/$tdir/f1 of=/dev/null
12904 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
12905 # XXX client can not do early lock cancel of OST lock
12906 # during unlink (LU-4206), so cancel osc lock now.
12908 cancel_lru_locks osc
12909 can1=$(do_facet mds1 \
12910 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12911 awk '/ldlm_cancel/ {print $2}')
12912 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12913 awk '/ldlm_bl_callback/ {print $2}')
12914 unlink $DIR/$tdir/f1
12916 can2=$(do_facet mds1 \
12917 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12918 awk '/ldlm_cancel/ {print $2}')
12919 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12920 awk '/ldlm_bl_callback/ {print $2}')
12921 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
12922 $LCTL dk $TMP/cancel.debug.txt
12923 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
12924 $LCTL dk $TMP/blocking.debug.txt
12925 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
12926 lru_resize_enable mdc
12927 lru_resize_enable osc
12929 run_test 120e "Early Lock Cancel: unlink test"
12932 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12933 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12934 skip_env "no early lock cancel on server"
12935 remote_mds_nodsh && skip "remote MDS with nodsh"
12937 test_mkdir -i0 -c1 $DIR/$tdir
12938 lru_resize_disable mdc
12939 lru_resize_disable osc
12940 test_mkdir -i0 -c1 $DIR/$tdir/d1
12941 test_mkdir -i0 -c1 $DIR/$tdir/d2
12942 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
12943 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
12944 cancel_lru_locks mdc
12945 cancel_lru_locks osc
12946 dd if=$DIR/$tdir/d1/f1 of=/dev/null
12947 dd if=$DIR/$tdir/d2/f2 of=/dev/null
12948 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
12949 # XXX client can not do early lock cancel of OST lock
12950 # during rename (LU-4206), so cancel osc lock now.
12952 cancel_lru_locks osc
12953 can1=$(do_facet mds1 \
12954 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12955 awk '/ldlm_cancel/ {print $2}')
12956 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12957 awk '/ldlm_bl_callback/ {print $2}')
12958 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
12960 can2=$(do_facet mds1 \
12961 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12962 awk '/ldlm_cancel/ {print $2}')
12963 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12964 awk '/ldlm_bl_callback/ {print $2}')
12965 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
12966 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
12967 lru_resize_enable mdc
12968 lru_resize_enable osc
12970 run_test 120f "Early Lock Cancel: rename test"
12973 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12974 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
12975 skip_env "no early lock cancel on server"
12976 remote_mds_nodsh && skip "remote MDS with nodsh"
12978 lru_resize_disable mdc
12979 lru_resize_disable osc
12981 echo create $count files
12982 test_mkdir $DIR/$tdir
12983 cancel_lru_locks mdc
12984 cancel_lru_locks osc
12987 can0=$(do_facet $SINGLEMDS \
12988 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12989 awk '/ldlm_cancel/ {print $2}')
12990 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12991 awk '/ldlm_bl_callback/ {print $2}')
12992 createmany -o $DIR/$tdir/f $count
12994 can1=$(do_facet $SINGLEMDS \
12995 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
12996 awk '/ldlm_cancel/ {print $2}')
12997 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
12998 awk '/ldlm_bl_callback/ {print $2}')
13000 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
13001 echo rm $count files
13004 can2=$(do_facet $SINGLEMDS \
13005 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
13006 awk '/ldlm_cancel/ {print $2}')
13007 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
13008 awk '/ldlm_bl_callback/ {print $2}')
13010 echo total: $count removes in $((t2-t1))
13011 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
13013 # wait for commitment of removal
13014 lru_resize_enable mdc
13015 lru_resize_enable osc
13017 run_test 120g "Early Lock Cancel: performance test"
13019 test_121() { #bug #10589
13020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13023 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
13024 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
13025 lctl set_param fail_loc=0x310
13026 cancel_lru_locks osc > /dev/null
13027 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
13028 lctl set_param fail_loc=0
13029 [[ $reads -eq $writes ]] ||
13030 error "read $reads blocks, must be $writes blocks"
13032 run_test 121 "read cancel race ========="
13034 test_123a_base() { # was test 123, statahead(bug 11401)
13038 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
13039 log "testing UP system. Performance may be lower than expected."
13042 running_in_vm && SLOWOK=1
13045 test_mkdir $DIR/$tdir
13046 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
13047 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
13049 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
13050 createmany -o $DIR/$tdir/$tfile $j $((i - j))
13052 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
13053 lctl set_param -n llite.*.statahead_max 0
13054 lctl get_param llite.*.statahead_max
13055 cancel_lru_locks mdc
13056 cancel_lru_locks osc
13058 time $lsx $DIR/$tdir | wc -l
13060 delta=$((etime - stime))
13061 log "$lsx $i files without statahead: $delta sec"
13062 lctl set_param llite.*.statahead_max=$max
13064 swrong=$(lctl get_param -n llite.*.statahead_stats |
13065 grep "statahead wrong:" | awk '{print $3}')
13066 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
13067 cancel_lru_locks mdc
13068 cancel_lru_locks osc
13070 time $lsx $DIR/$tdir | wc -l
13072 delta_sa=$((etime - stime))
13073 log "$lsx $i files with statahead: $delta_sa sec"
13074 lctl get_param -n llite.*.statahead_stats
13075 ewrong=$(lctl get_param -n llite.*.statahead_stats |
13076 grep "statahead wrong:" | awk '{print $3}')
13078 [[ $swrong -lt $ewrong ]] &&
13079 log "statahead was stopped, maybe too many locks held!"
13080 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
13082 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
13083 max=$(lctl get_param -n llite.*.statahead_max |
13085 lctl set_param -n llite.*.statahead_max 0
13086 lctl get_param llite.*.statahead_max
13087 cancel_lru_locks mdc
13088 cancel_lru_locks osc
13090 time $lsx $DIR/$tdir | wc -l
13092 delta=$((etime - stime))
13093 log "$lsx $i files again without statahead: $delta sec"
13094 lctl set_param llite.*.statahead_max=$max
13095 if [ $((delta_sa * 100 > delta * 105 && delta_sa > delta + 2)) ]; then
13096 if [ $SLOWOK -eq 0 ]; then
13097 error "$lsx $i files is slower with statahead!"
13099 log "$lsx $i files is slower with statahead!"
13105 [ $delta -gt 20 ] && break
13106 [ $delta -gt 8 ] && MULT=$((50 / delta))
13107 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
13115 delta=$((etime - stime))
13116 log "rm -r $DIR/$tdir/: $delta seconds"
13118 lctl get_param -n llite.*.statahead_stats
13122 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13124 test_123a_base "ls -l"
13126 run_test 123aa "verify statahead work"
13129 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13131 statx_supported || skip_env "Test must be statx() syscall supported"
13133 test_123a_base "$STATX -l"
13135 run_test 123ab "verify statahead work by using statx"
13138 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13140 statx_supported || skip_env "Test must be statx() syscall supported"
13147 cancel_lru_locks $OSC
13148 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13149 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
13150 awk '/agl.total:/ {print $3}')
13151 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
13152 test_123a_base "$STATX --cached=always -D"
13153 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
13154 awk '/agl.total:/ {print $3}')
13155 [ $agl_before -eq $agl_after ] ||
13156 error "Should not trigger AGL thread - $agl_before:$agl_after"
13157 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
13158 [ $rpcs_after -eq $rpcs_before ] ||
13159 error "$STATX should not send glimpse RPCs to $OSC"
13161 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
13163 test_123b () { # statahead(bug 15027)
13164 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13166 test_mkdir $DIR/$tdir
13167 createmany -o $DIR/$tdir/$tfile-%d 1000
13169 cancel_lru_locks mdc
13170 cancel_lru_locks osc
13172 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
13173 lctl set_param fail_loc=0x80000803
13174 ls -lR $DIR/$tdir > /dev/null
13176 lctl set_param fail_loc=0x0
13177 lctl get_param -n llite.*.statahead_stats
13182 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
13185 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
13187 test_mkdir -i 0 -c 1 $DIR/$tdir.0
13188 test_mkdir -i 1 -c 1 $DIR/$tdir.1
13189 touch $DIR/$tdir.1/{1..3}
13190 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
13192 remount_client $MOUNT
13194 $MULTIOP $DIR/$tdir.0 Q
13196 # let statahead to complete
13197 ls -l $DIR/$tdir.0 > /dev/null
13199 testid=$(echo $TESTNAME | tr '_' ' ')
13200 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
13201 error "statahead warning" || true
13203 run_test 123c "Can not initialize inode warning on DNE statahead"
13206 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13207 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13208 skip_env "no lru resize on server"
13212 test_mkdir $DIR/$tdir
13214 log "create $NR files at $DIR/$tdir"
13215 createmany -o $DIR/$tdir/f $NR ||
13216 error "failed to create $NR files in $DIR/$tdir"
13218 cancel_lru_locks mdc
13219 ls -l $DIR/$tdir > /dev/null
13223 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
13224 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
13225 LRU_SIZE=$($LCTL get_param -n $PARAM)
13226 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
13227 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
13229 log "NS=$(basename $NSDIR)"
13234 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
13235 skip "Not enough cached locks created!"
13237 log "LRU=$LRU_SIZE"
13241 # We know that lru resize allows one client to hold $LIMIT locks
13242 # for 10h. After that locks begin to be killed by client.
13244 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
13246 if [ $LIMIT -lt $LRU_SIZE ]; then
13247 skip "Limit is too small $LIMIT"
13250 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
13251 # killing locks. Some time was spent for creating locks. This means
13252 # that up to the moment of sleep finish we must have killed some of
13253 # them (10-100 locks). This depends on how fast ther were created.
13254 # Many of them were touched in almost the same moment and thus will
13255 # be killed in groups.
13256 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE * 100))
13258 # Use $LRU_SIZE_B here to take into account real number of locks
13259 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
13260 local LRU_SIZE_B=$LRU_SIZE
13262 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
13263 log "OLD_LVF=$OLD_LVF"
13264 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
13266 # Let's make sure that we really have some margin. Client checks
13267 # cached locks every 10 sec.
13268 SLEEP=$((SLEEP+20))
13269 log "Sleep ${SLEEP} sec"
13271 while ((SEC<$SLEEP)); do
13275 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
13276 echo -n "$LRU_SIZE"
13279 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
13280 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
13282 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
13283 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
13284 unlinkmany $DIR/$tdir/f $NR
13288 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
13289 log "unlink $NR files at $DIR/$tdir"
13290 unlinkmany $DIR/$tdir/f $NR
13292 run_test 124a "lru resize ======================================="
13294 get_max_pool_limit()
13296 local limit=$($LCTL get_param \
13297 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
13299 for l in $limit; do
13300 if [[ $l -gt $max ]]; then
13308 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13309 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13310 skip_env "no lru resize on server"
13312 LIMIT=$(get_max_pool_limit)
13314 NR=$(($(default_lru_size)*20))
13315 if [[ $NR -gt $LIMIT ]]; then
13316 log "Limit lock number by $LIMIT locks"
13320 IFree=$(mdsrate_inodes_available)
13321 if [ $IFree -lt $NR ]; then
13322 log "Limit lock number by $IFree inodes"
13326 lru_resize_disable mdc
13327 test_mkdir -p $DIR/$tdir/disable_lru_resize
13329 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
13330 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
13331 cancel_lru_locks mdc
13334 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13337 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13340 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
13344 nolruresize_delta=$((etime-stime))
13345 log "ls -la time: $nolruresize_delta seconds"
13346 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13347 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
13349 lru_resize_enable mdc
13350 test_mkdir -p $DIR/$tdir/enable_lru_resize
13352 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
13353 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
13354 cancel_lru_locks mdc
13357 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13360 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13363 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
13367 lruresize_delta=$((etime-stime))
13368 log "ls -la time: $lruresize_delta seconds"
13369 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
13371 if [ $lruresize_delta -gt $nolruresize_delta ]; then
13372 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
13373 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
13374 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
13376 log "lru resize performs the same with no lru resize"
13378 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
13380 run_test 124b "lru resize (performance test) ======================="
13383 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13384 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13385 skip_env "no lru resize on server"
13387 # cache ununsed locks on client
13389 cancel_lru_locks mdc
13390 test_mkdir $DIR/$tdir
13391 createmany -o $DIR/$tdir/f $nr ||
13392 error "failed to create $nr files in $DIR/$tdir"
13393 ls -l $DIR/$tdir > /dev/null
13395 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13396 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13397 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13398 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13399 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13401 # set lru_max_age to 1 sec
13402 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13403 echo "sleep $((recalc_p * 2)) seconds..."
13404 sleep $((recalc_p * 2))
13406 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13407 # restore lru_max_age
13408 $LCTL set_param -n $nsdir.lru_max_age $max_age
13409 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13410 unlinkmany $DIR/$tdir/f $nr
13412 run_test 124c "LRUR cancel very aged locks"
13415 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13416 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
13417 skip_env "no lru resize on server"
13419 # cache ununsed locks on client
13422 lru_resize_disable mdc
13423 stack_trap "lru_resize_enable mdc" EXIT
13425 cancel_lru_locks mdc
13427 # asynchronous object destroy at MDT could cause bl ast to client
13428 test_mkdir $DIR/$tdir
13429 createmany -o $DIR/$tdir/f $nr ||
13430 error "failed to create $nr files in $DIR/$tdir"
13431 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
13433 ls -l $DIR/$tdir > /dev/null
13435 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13436 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13437 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
13438 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
13440 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
13442 # set lru_max_age to 1 sec
13443 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
13444 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
13446 echo "sleep $((recalc_p * 2)) seconds..."
13447 sleep $((recalc_p * 2))
13449 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
13451 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
13453 run_test 124d "cancel very aged locks if lru-resize diasbaled"
13455 test_125() { # 13358
13456 $LCTL get_param -n llite.*.client_type | grep -q local ||
13457 skip "must run as local client"
13458 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
13459 skip_env "must have acl enabled"
13460 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13462 test_mkdir $DIR/$tdir
13463 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
13464 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
13465 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
13467 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
13469 test_126() { # bug 12829/13455
13470 $GSS && skip_env "must run as gss disabled"
13471 $LCTL get_param -n llite.*.client_type | grep -q local ||
13472 skip "must run as local client"
13473 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
13475 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
13476 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
13478 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
13480 run_test 126 "check that the fsgid provided by the client is taken into account"
13482 test_127a() { # bug 15521
13483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13484 local name count samp unit min max sum sumsq
13486 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
13487 echo "stats before reset"
13488 $LCTL get_param osc.*.stats
13489 $LCTL set_param osc.*.stats=0
13490 local fsize=$((2048 * 1024))
13492 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
13493 cancel_lru_locks osc
13494 dd if=$DIR/$tfile of=/dev/null bs=$fsize
13496 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
13497 stack_trap "rm -f $TMP/$tfile.tmp"
13498 while read name count samp unit min max sum sumsq; do
13499 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13500 [ ! $min ] && error "Missing min value for $name proc entry"
13501 eval $name=$count || error "Wrong proc format"
13504 read_bytes|write_bytes)
13505 [[ "$unit" =~ "bytes" ]] ||
13506 error "unit is not 'bytes': $unit"
13507 (( $min >= 4096 )) || error "min is too small: $min"
13508 (( $min <= $fsize )) || error "min is too big: $min"
13509 (( $max >= 4096 )) || error "max is too small: $max"
13510 (( $max <= $fsize )) || error "max is too big: $max"
13511 (( $sum == $fsize )) || error "sum is wrong: $sum"
13512 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
13513 error "sumsquare is too small: $sumsq"
13514 (( $sumsq <= $fsize * $fsize )) ||
13515 error "sumsquare is too big: $sumsq"
13517 ost_read|ost_write)
13518 [[ "$unit" =~ "usec" ]] ||
13519 error "unit is not 'usec': $unit"
13523 done < $DIR/$tfile.tmp
13525 #check that we actually got some stats
13526 [ "$read_bytes" ] || error "Missing read_bytes stats"
13527 [ "$write_bytes" ] || error "Missing write_bytes stats"
13528 [ "$read_bytes" != 0 ] || error "no read done"
13529 [ "$write_bytes" != 0 ] || error "no write done"
13531 run_test 127a "verify the client stats are sane"
13533 test_127b() { # bug LU-333
13534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13535 local name count samp unit min max sum sumsq
13537 echo "stats before reset"
13538 $LCTL get_param llite.*.stats
13539 $LCTL set_param llite.*.stats=0
13541 # perform 2 reads and writes so MAX is different from SUM.
13542 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13543 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
13544 cancel_lru_locks osc
13545 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13546 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
13548 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
13549 stack_trap "rm -f $TMP/$tfile.tmp"
13550 while read name count samp unit min max sum sumsq; do
13551 echo "got name=$name count=$count unit=$unit min=$min max=$max"
13552 eval $name=$count || error "Wrong proc format"
13555 read_bytes|write_bytes)
13556 [[ "$unit" =~ "bytes" ]] ||
13557 error "unit is not 'bytes': $unit"
13558 (( $count == 2 )) || error "count is not 2: $count"
13559 (( $min == $PAGE_SIZE )) ||
13560 error "min is not $PAGE_SIZE: $min"
13561 (( $max == $PAGE_SIZE )) ||
13562 error "max is not $PAGE_SIZE: $max"
13563 (( $sum == $PAGE_SIZE * 2 )) ||
13564 error "sum is not $((PAGE_SIZE * 2)): $sum"
13567 [[ "$unit" =~ "usec" ]] ||
13568 error "unit is not 'usec': $unit"
13572 done < $TMP/$tfile.tmp
13574 #check that we actually got some stats
13575 [ "$read_bytes" ] || error "Missing read_bytes stats"
13576 [ "$write_bytes" ] || error "Missing write_bytes stats"
13577 [ "$read_bytes" != 0 ] || error "no read done"
13578 [ "$write_bytes" != 0 ] || error "no write done"
13580 run_test 127b "verify the llite client stats are sane"
13582 test_127c() { # LU-12394
13583 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13590 $LCTL set_param llite.*.extents_stats=1
13591 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
13593 # Use two stripes so there is enough space in default config
13594 $LFS setstripe -c 2 $DIR/$tfile
13596 # Extent stats start at 0-4K and go in power of two buckets
13597 # LL_HIST_START = 12 --> 2^12 = 4K
13598 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
13599 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
13601 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
13603 # Write and read, 2x each, second time at a non-zero offset
13604 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
13605 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
13606 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
13607 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
13611 $LCTL get_param llite.*.extents_stats
13614 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
13616 local bucket=$($LCTL get_param -n llite.*.extents_stats |
13618 reads=$(echo $bucket | awk '{print $5}')
13619 writes=$(echo $bucket | awk '{print $9}')
13620 [ "$reads" -eq $count ] ||
13621 error "$reads reads in < $bsize bucket, expect $count"
13622 [ "$writes" -eq $count ] ||
13623 error "$writes writes in < $bsize bucket, expect $count"
13626 # Test mmap write and read
13627 $LCTL set_param llite.*.extents_stats=c
13629 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
13630 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
13631 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
13633 $LCTL get_param llite.*.extents_stats
13635 count=$(((size*1024) / PAGE_SIZE))
13637 bsize=$((2 * PAGE_SIZE / 1024))K
13639 bucket=$($LCTL get_param -n llite.*.extents_stats |
13641 reads=$(echo $bucket | awk '{print $5}')
13642 writes=$(echo $bucket | awk '{print $9}')
13643 # mmap writes fault in the page first, creating an additonal read
13644 [ "$reads" -eq $((2 * count)) ] ||
13645 error "$reads reads in < $bsize bucket, expect $count"
13646 [ "$writes" -eq $count ] ||
13647 error "$writes writes in < $bsize bucket, expect $count"
13649 run_test 127c "test llite extent stats with regular & mmap i/o"
13651 test_128() { # bug 15212
13653 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
13658 result=$(grep error $TMP/$tfile.log)
13659 rm -f $DIR/$tfile $TMP/$tfile.log
13660 [ -z "$result" ] ||
13661 error "consecutive find's under interactive lfs failed"
13663 run_test 128 "interactive lfs for 2 consecutive find's"
13665 set_dir_limits () {
13670 local ldproc=/proc/fs/ldiskfs
13671 local facets=$(get_facets MDS)
13673 for facet in ${facets//,/ }; do
13674 canondev=$(ldiskfs_canon \
13675 *.$(convert_facet2label $facet).mntdev $facet)
13676 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
13677 ldproc=/sys/fs/ldiskfs
13678 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
13679 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
13683 check_mds_dmesg() {
13684 local facets=$(get_facets MDS)
13685 for facet in ${facets//,/ }; do
13686 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
13692 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13693 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
13694 skip "Need MDS version with at least 2.5.56"
13695 if [ "$mds1_FSTYPE" != ldiskfs ]; then
13696 skip_env "ldiskfs only test"
13698 remote_mds_nodsh && skip "remote MDS with nodsh"
13701 local has_warning=false
13704 mkdir -p $DIR/$tdir
13706 # block size of mds1
13707 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
13708 set_dir_limits $maxsize $((maxsize * 6 / 8))
13709 stack_trap "set_dir_limits 0 0"
13710 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
13711 local dirsize=$(stat -c%s "$DIR/$tdir")
13713 while (( $dirsize <= $maxsize )); do
13714 $MCREATE $DIR/$tdir/file_base_$nfiles
13716 # check two errors:
13717 # ENOSPC for ext4 max_dir_size, which has been used since
13718 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
13719 if (( rc == ENOSPC )); then
13721 echo "rc=$rc returned as expected after $nfiles files"
13723 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
13724 error "create failed w/o dir size limit"
13726 # messages may be rate limited if test is run repeatedly
13727 check_mds_dmesg '"is approaching max"' ||
13728 echo "warning message should be output"
13729 check_mds_dmesg '"has reached max"' ||
13730 echo "reached message should be output"
13732 dirsize=$(stat -c%s "$DIR/$tdir")
13734 [[ $dirsize -ge $maxsize ]] && return 0
13735 error "dirsize $dirsize < $maxsize after $nfiles files"
13736 elif (( rc != 0 )); then
13739 nfiles=$((nfiles + 1))
13740 dirsize=$(stat -c%s "$DIR/$tdir")
13743 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
13745 run_test 129 "test directory size limit ========================"
13754 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13755 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13757 trap cleanup_130 EXIT RETURN
13759 local fm_file=$DIR/$tfile
13760 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
13761 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
13762 error "dd failed for $fm_file"
13764 # LU-1795: test filefrag/FIEMAP once, even if unsupported
13765 filefrag -ves $fm_file
13767 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13768 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13769 [ $RC != 0 ] && error "filefrag $fm_file failed"
13771 filefrag_op=$(filefrag -ve -k $fm_file |
13772 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13773 lun=$($LFS getstripe -i $fm_file)
13775 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
13778 for line in $filefrag_op
13780 frag_lun=`echo $line | cut -d: -f5`
13781 ext_len=`echo $line | cut -d: -f4`
13782 if (( $frag_lun != $lun )); then
13784 error "FIEMAP on 1-stripe file($fm_file) failed"
13787 (( tot_len += ext_len ))
13790 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
13792 error "FIEMAP on 1-stripe file($fm_file) failed;"
13798 echo "FIEMAP on single striped file succeeded"
13800 run_test 130a "FIEMAP (1-stripe file)"
13803 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
13805 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13806 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13808 trap cleanup_130 EXIT RETURN
13810 local fm_file=$DIR/$tfile
13811 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13812 error "setstripe on $fm_file"
13813 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13814 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13816 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
13817 error "dd failed on $fm_file"
13819 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13820 filefrag_op=$(filefrag -ve -k $fm_file |
13821 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13823 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13824 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13829 for line in $filefrag_op
13831 frag_lun=$(echo $line | cut -d: -f5 |
13832 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13833 ext_len=$(echo $line | cut -d: -f4)
13834 if (( $frag_lun != $last_lun )); then
13835 if (( tot_len != 1024 )); then
13837 error "FIEMAP on $fm_file failed; returned " \
13838 "len $tot_len for OST $last_lun instead of 1024"
13841 (( num_luns += 1 ))
13845 (( tot_len += ext_len ))
13848 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
13850 error "FIEMAP on $fm_file failed; returned wrong number of " \
13851 "luns or wrong len for OST $last_lun"
13857 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
13859 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
13862 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13864 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13865 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13867 trap cleanup_130 EXIT RETURN
13869 local fm_file=$DIR/$tfile
13870 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
13871 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13872 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13874 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
13875 error "dd failed on $fm_file"
13877 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13878 filefrag_op=$(filefrag -ve -k $fm_file |
13879 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13881 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13882 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13887 for line in $filefrag_op
13889 frag_lun=$(echo $line | cut -d: -f5 |
13890 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13891 ext_len=$(echo $line | cut -d: -f4)
13892 if (( $frag_lun != $last_lun )); then
13893 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
13894 if (( logical != 512 )); then
13896 error "FIEMAP on $fm_file failed; returned " \
13897 "logical start for lun $logical instead of 512"
13900 if (( tot_len != 512 )); then
13902 error "FIEMAP on $fm_file failed; returned " \
13903 "len $tot_len for OST $last_lun instead of 1024"
13906 (( num_luns += 1 ))
13910 (( tot_len += ext_len ))
13913 if (( num_luns != 2 || tot_len != 512 )); then
13915 error "FIEMAP on $fm_file failed; returned wrong number of " \
13916 "luns or wrong len for OST $last_lun"
13922 echo "FIEMAP on 2-stripe file with hole succeeded"
13924 run_test 130c "FIEMAP (2-stripe file with hole)"
13927 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
13929 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13930 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
13932 trap cleanup_130 EXIT RETURN
13934 local fm_file=$DIR/$tfile
13935 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
13936 error "setstripe on $fm_file"
13937 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
13938 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
13940 local actual_stripe_count=$($LFS getstripe -c $fm_file)
13941 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
13942 error "dd failed on $fm_file"
13944 filefrag -ves $fm_file || error "filefrag $fm_file failed"
13945 filefrag_op=$(filefrag -ve -k $fm_file |
13946 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
13948 last_lun=$(echo $filefrag_op | cut -d: -f5 |
13949 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13954 for line in $filefrag_op
13956 frag_lun=$(echo $line | cut -d: -f5 |
13957 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
13958 ext_len=$(echo $line | cut -d: -f4)
13959 if (( $frag_lun != $last_lun )); then
13960 if (( tot_len != 1024 )); then
13962 error "FIEMAP on $fm_file failed; returned " \
13963 "len $tot_len for OST $last_lun instead of 1024"
13966 (( num_luns += 1 ))
13970 (( tot_len += ext_len ))
13973 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
13975 error "FIEMAP on $fm_file failed; returned wrong number of " \
13976 "luns or wrong len for OST $last_lun"
13982 echo "FIEMAP on N-stripe file succeeded"
13984 run_test 130d "FIEMAP (N-stripe file)"
13987 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
13989 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
13990 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
13992 trap cleanup_130 EXIT RETURN
13994 local fm_file=$DIR/$tfile
13995 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
13998 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
13999 for ((i = 0; i < $NUM_BLKS; i++)); do
14000 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) \
14001 conv=notrunc > /dev/null 2>&1
14004 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14005 filefrag_op=$(filefrag -ve -k $fm_file |
14006 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
14008 last_lun=$(echo $filefrag_op | cut -d: -f5)
14013 for line in $filefrag_op; do
14014 frag_lun=$(echo $line | cut -d: -f5)
14015 ext_len=$(echo $line | cut -d: -f4)
14016 if [[ "$frag_lun" != "$last_lun" ]]; then
14017 if (( tot_len != $EXPECTED_LEN )); then
14019 error "OST$last_lun $tot_len != $EXPECTED_LEN"
14021 (( num_luns += 1 ))
14025 (( tot_len += ext_len ))
14028 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
14030 error "OST$last_lun $num_luns != 2, $tot_len != $EXPECTED_LEN"
14033 echo "FIEMAP with continuation calls succeeded"
14035 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
14038 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
14039 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
14041 local fm_file=$DIR/$tfile
14042 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
14043 error "multiop create with lov_delay_create on $fm_file"
14045 filefrag -ves $fm_file || error "filefrag $fm_file failed"
14046 filefrag_extents=$(filefrag -vek $fm_file |
14047 awk '/extents? found/ { print $2 }')
14048 if [[ "$filefrag_extents" != "0" ]]; then
14049 error "$fm_file: filefrag_extents=$filefrag_extents != 0"
14054 run_test 130f "FIEMAP (unstriped file)"
14057 local file=$DIR/$tfile
14058 local nr=$((OSTCOUNT * 100))
14060 $LFS setstripe -C $nr $file ||
14061 error "failed to setstripe -C $nr $file"
14063 dd if=/dev/zero of=$file count=$nr bs=1M
14065 nr=$($LFS getstripe -c $file)
14067 local extents=$(filefrag -v $file |
14068 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}' | wc -l)
14070 echo "filefrag list $extents extents in file with stripecount $nr"
14071 if (( extents < nr )); then
14072 $LFS getstripe $file
14074 error "filefrag printed $extents < $nr extents"
14079 run_test 130g "FIEMAP (overstripe file)"
14081 # Test for writev/readv
14083 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
14084 error "writev test failed"
14085 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
14086 error "readv failed"
14089 run_test 131a "test iov's crossing stripe boundary for writev/readv"
14092 local fsize=$((524288 + 1048576 + 1572864))
14093 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
14094 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14095 error "append writev test failed"
14097 ((fsize += 1572864 + 1048576))
14098 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
14099 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
14100 error "append writev test failed"
14103 run_test 131b "test append writev"
14106 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
14109 run_test 131c "test read/write on file w/o objects"
14112 rwv -f $DIR/$tfile -w -n 1 1572864
14113 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
14114 if [ "$NOB" != 1572864 ]; then
14115 error "Short read filed: read $NOB bytes instead of 1572864"
14119 run_test 131d "test short read"
14122 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
14123 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
14124 error "read hitting hole failed"
14127 run_test 131e "test read hitting hole"
14136 mds*) res=$(do_facet $facet \
14137 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
14139 ost*) res=$(do_facet $facet \
14140 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
14142 *) error "Wrong facet '$facet'" ;;
14144 [ "$res" ] || error "The counter for $op on $facet was not incremented"
14145 # if the argument $3 is zero, it means any stat increment is ok.
14146 if [[ $want -gt 0 ]]; then
14147 local count=$(echo $res | awk '{ print $2 }')
14148 [[ $count -ne $want ]] &&
14149 error "The $op counter on $facet is $count, not $want"
14154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14155 remote_ost_nodsh && skip "remote OST with nodsh"
14156 remote_mds_nodsh && skip "remote MDS with nodsh"
14157 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14158 skip_env "MDS doesn't support rename stats"
14160 local testdir=$DIR/${tdir}/stats_testdir
14162 mkdir -p $DIR/${tdir}
14165 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14166 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14168 # verify mdt stats first.
14169 mkdir ${testdir} || error "mkdir failed"
14170 check_stats $SINGLEMDS "mkdir" 1
14171 touch ${testdir}/${tfile} || error "touch failed"
14172 check_stats $SINGLEMDS "open" 1
14173 check_stats $SINGLEMDS "close" 1
14174 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
14175 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
14176 check_stats $SINGLEMDS "mknod" 2
14178 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
14179 check_stats $SINGLEMDS "unlink" 1
14180 rm -f ${testdir}/${tfile} || error "file remove failed"
14181 check_stats $SINGLEMDS "unlink" 2
14183 # remove working dir and check mdt stats again.
14184 rmdir ${testdir} || error "rmdir failed"
14185 check_stats $SINGLEMDS "rmdir" 1
14187 local testdir1=$DIR/${tdir}/stats_testdir1
14188 mkdir -p ${testdir}
14189 mkdir -p ${testdir1}
14190 touch ${testdir1}/test1
14191 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
14192 check_stats $SINGLEMDS "crossdir_rename" 1
14194 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
14195 check_stats $SINGLEMDS "samedir_rename" 1
14197 rm -rf $DIR/${tdir}
14199 run_test 133a "Verifying MDT stats ========================================"
14204 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14205 remote_ost_nodsh && skip "remote OST with nodsh"
14206 remote_mds_nodsh && skip "remote MDS with nodsh"
14208 local testdir=$DIR/${tdir}/stats_testdir
14210 mkdir -p ${testdir} || error "mkdir failed"
14211 touch ${testdir}/${tfile} || error "touch failed"
14212 cancel_lru_locks mdc
14215 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14216 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14218 # extra mdt stats verification.
14219 chmod 444 ${testdir}/${tfile} || error "chmod failed"
14220 check_stats $SINGLEMDS "setattr" 1
14221 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14222 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
14224 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
14225 check_stats $SINGLEMDS "getattr" 1
14227 rm -rf $DIR/${tdir}
14229 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
14230 # so the check below is not reliable
14231 [ $MDSCOUNT -eq 1 ] || return 0
14233 # Sleep to avoid a cached response.
14234 #define OBD_STATFS_CACHE_SECONDS 1
14236 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14237 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14238 $LFS df || error "lfs failed"
14239 check_stats $SINGLEMDS "statfs" 1
14241 # check aggregated statfs (LU-10018)
14242 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
14244 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
14247 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14248 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
14250 check_stats $SINGLEMDS "statfs" 1
14252 # We want to check that the client didn't send OST_STATFS to
14253 # ost1 but the MDT also uses OST_STATFS for precreate. So some
14254 # extra care is needed here.
14255 if remote_mds; then
14256 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
14257 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
14259 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
14260 [ "$res" ] && error "OST got STATFS"
14265 run_test 133b "Verifying extra MDT stats =================================="
14268 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14269 remote_ost_nodsh && skip "remote OST with nodsh"
14270 remote_mds_nodsh && skip "remote MDS with nodsh"
14272 local testdir=$DIR/$tdir/stats_testdir
14274 test_mkdir -p $testdir
14276 # verify obdfilter stats.
14277 $LFS setstripe -c 1 -i 0 $testdir/$tfile
14279 cancel_lru_locks osc
14280 wait_delete_completed
14283 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
14284 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
14286 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
14289 cancel_lru_locks osc
14290 check_stats ost1 "write" 1
14292 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
14293 check_stats ost1 "read" 1
14295 > $testdir/$tfile || error "truncate failed"
14296 check_stats ost1 "punch" 1
14298 rm -f $testdir/$tfile || error "file remove failed"
14299 wait_delete_completed
14300 check_stats ost1 "destroy" 1
14304 run_test 133c "Verifying OST stats ========================================"
14311 while [ $value -ge 2 ]; do
14316 if [ $orig -gt $order ]; then
14324 local size=('K' 'M' 'G' 'T');
14326 local size_string=$value
14328 while [ $value -ge 1024 ]; do
14329 if [ $i -gt 3 ]; then
14330 #T is the biggest unit we get here, if that is bigger,
14332 size_string=${value}T
14335 value=$((value >> 10))
14336 if [ $value -lt 1024 ]; then
14337 size_string=${value}${size[$i]}
14346 get_rename_size() {
14348 local context=${2:-.}
14349 local sample=$(do_facet $SINGLEMDS $LCTL \
14350 get_param mdt.$FSNAME-MDT0000.rename_stats |
14351 grep -A1 $context |
14352 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
14357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14358 remote_ost_nodsh && skip "remote OST with nodsh"
14359 remote_mds_nodsh && skip "remote MDS with nodsh"
14360 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
14361 skip_env "MDS doesn't support rename stats"
14363 local testdir1=$DIR/${tdir}/stats_testdir1
14364 local testdir2=$DIR/${tdir}/stats_testdir2
14365 mkdir -p $DIR/${tdir}
14367 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14369 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
14370 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
14372 createmany -o $testdir1/test 512 || error "createmany failed"
14374 # check samedir rename size
14375 mv ${testdir1}/test0 ${testdir1}/test_0
14377 local testdir1_size=$(ls -l $DIR/${tdir} |
14378 awk '/stats_testdir1/ {print $5}')
14379 local testdir2_size=$(ls -l $DIR/${tdir} |
14380 awk '/stats_testdir2/ {print $5}')
14382 testdir1_size=$(order_2 $testdir1_size)
14383 testdir2_size=$(order_2 $testdir2_size)
14385 testdir1_size=$(size_in_KMGT $testdir1_size)
14386 testdir2_size=$(size_in_KMGT $testdir2_size)
14388 echo "source rename dir size: ${testdir1_size}"
14389 echo "target rename dir size: ${testdir2_size}"
14391 local cmd="do_facet $SINGLEMDS $LCTL "
14392 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
14394 eval $cmd || error "$cmd failed"
14395 local samedir=$($cmd | grep 'same_dir')
14396 local same_sample=$(get_rename_size $testdir1_size)
14397 [ -z "$samedir" ] && error "samedir_rename_size count error"
14398 [[ $same_sample -eq 1 ]] ||
14399 error "samedir_rename_size error $same_sample"
14400 echo "Check same dir rename stats success"
14402 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
14404 # check crossdir rename size
14405 mv ${testdir1}/test_0 ${testdir2}/test_0
14407 testdir1_size=$(ls -l $DIR/${tdir} |
14408 awk '/stats_testdir1/ {print $5}')
14409 testdir2_size=$(ls -l $DIR/${tdir} |
14410 awk '/stats_testdir2/ {print $5}')
14412 testdir1_size=$(order_2 $testdir1_size)
14413 testdir2_size=$(order_2 $testdir2_size)
14415 testdir1_size=$(size_in_KMGT $testdir1_size)
14416 testdir2_size=$(size_in_KMGT $testdir2_size)
14418 echo "source rename dir size: ${testdir1_size}"
14419 echo "target rename dir size: ${testdir2_size}"
14421 eval $cmd || error "$cmd failed"
14422 local crossdir=$($cmd | grep 'crossdir')
14423 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
14424 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
14425 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
14426 [[ $src_sample -eq 1 ]] ||
14427 error "crossdir_rename_size error $src_sample"
14428 [[ $tgt_sample -eq 1 ]] ||
14429 error "crossdir_rename_size error $tgt_sample"
14430 echo "Check cross dir rename stats success"
14431 rm -rf $DIR/${tdir}
14433 run_test 133d "Verifying rename_stats ========================================"
14436 remote_mds_nodsh && skip "remote MDS with nodsh"
14437 remote_ost_nodsh && skip "remote OST with nodsh"
14438 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14440 local testdir=$DIR/${tdir}/stats_testdir
14441 local ctr f0 f1 bs=32768 count=42 sum
14443 mkdir -p ${testdir} || error "mkdir failed"
14445 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
14447 for ctr in {write,read}_bytes; do
14449 cancel_lru_locks osc
14451 do_facet ost1 $LCTL set_param -n \
14452 "obdfilter.*.exports.clear=clear"
14454 if [ $ctr = write_bytes ]; then
14456 f1=${testdir}/${tfile}
14458 f0=${testdir}/${tfile}
14462 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
14465 cancel_lru_locks osc
14467 sum=$(do_facet ost1 $LCTL get_param \
14468 "obdfilter.*.exports.*.stats" |
14469 awk -v ctr=$ctr 'BEGIN { sum = 0 }
14470 $1 == ctr { sum += $7 }
14471 END { printf("%0.0f", sum) }')
14473 if ((sum != bs * count)); then
14474 error "Bad $ctr sum, expected $((bs * count)), got $sum"
14478 rm -rf $DIR/${tdir}
14480 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
14483 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
14484 skip "too old lustre for get_param -R ($facet_ver)"
14486 # verifying readability.
14487 $LCTL get_param -R '*' &> /dev/null
14489 # Verifing writability with badarea_io.
14490 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14491 local skipped_params='force_lbug|changelog_mask|daemon_file'
14492 $LCTL list_param -FR '*' | grep '=' | tr -d = |
14493 egrep -v "$skipped_params" |
14494 xargs -n 1 find $proc_dirs -name |
14495 xargs -n 1 badarea_io ||
14496 error "client badarea_io failed"
14498 # remount the FS in case writes/reads /proc break the FS
14499 cleanup || error "failed to unmount"
14500 setup || error "failed to setup"
14502 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
14505 remote_mds_nodsh && skip "remote MDS with nodsh"
14506 remote_ost_nodsh && skip "remote OST with nodsh"
14508 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
14509 local skipped_params="'force_lbug|changelog_mask|daemon_file'"
14511 for facet in mds1 ost1; do
14512 local facet_ver=$(lustre_version_code $facet)
14513 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
14514 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
14516 log "$facet: too old lustre for get_param -R"
14518 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
14519 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
14520 tr -d = | egrep -v $skipped_params |
14521 xargs -n 1 find $proc_dirs -name |
14522 xargs -n 1 badarea_io" ||
14523 error "$facet badarea_io failed"
14525 skip_noexit "$facet: too old lustre for get_param -R"
14529 # remount the FS in case writes/reads /proc break the FS
14530 cleanup || error "failed to unmount"
14531 setup || error "failed to setup"
14533 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
14536 remote_mds_nodsh && skip "remote MDS with nodsh"
14537 remote_ost_nodsh && skip "remote OST with nodsh"
14538 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
14539 skip "Need MDS version at least 2.9.54"
14542 for facet in client mds1 ost1; do
14543 # Get the list of files that are missing the terminating newline
14544 local plist=$(do_facet $facet
14545 $LCTL list_param -FR '*' | grep '=' | tr -d =)
14547 for ent in $plist; do
14548 local missing=$(do_facet $facet $LCTL get_param $ent \|\
14549 awk -v FS='\v' -v RS='\v\v' \
14550 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
14551 print FILENAME}'" 2>/dev/null)
14552 [ -z $missing ] || {
14553 do_facet $facet $LCTL get_param $ent | od -An -tx1
14554 error "file does not end with newline: $facet-$ent"
14559 run_test 133h "Proc files should end with newlines"
14562 remote_mds_nodsh && skip "remote MDS with nodsh"
14563 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14564 skip "Need MDS version at least 2.7.54"
14566 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14567 cancel_lru_locks mdc
14569 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
14570 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14571 [ $unused -eq 0 ] || error "$unused locks are not cleared"
14574 createmany -o $DIR/$tdir/f $nr ||
14575 error "failed to create $nr files in $DIR/$tdir"
14576 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
14578 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
14579 do_facet mds1 $LCTL set_param fail_loc=0x327
14580 do_facet mds1 $LCTL set_param fail_val=500
14583 echo "sleep 10 seconds ..."
14585 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
14587 do_facet mds1 $LCTL set_param fail_loc=0
14588 do_facet mds1 $LCTL set_param fail_val=0
14589 [ $lck_cnt -lt $unused ] ||
14590 error "No locks reclaimed, before:$unused, after:$lck_cnt"
14593 unlinkmany $DIR/$tdir/f $nr
14595 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
14598 remote_mds_nodsh && skip "remote MDS with nodsh"
14599 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
14600 skip "Need MDS version at least 2.7.54"
14602 mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
14603 cancel_lru_locks mdc
14605 local low_wm=$(do_facet mds1 $LCTL get_param -n \
14606 ldlm.lock_reclaim_threshold_mb)
14607 # disable reclaim temporarily
14608 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
14610 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
14611 do_facet mds1 $LCTL set_param fail_loc=0x328
14612 do_facet mds1 $LCTL set_param fail_val=500
14614 $LCTL set_param debug=+trace
14617 createmany -o $DIR/$tdir/f $nr &
14618 local create_pid=$!
14620 echo "Sleep $TIMEOUT seconds ..."
14622 if ! ps -p $create_pid > /dev/null 2>&1; then
14623 do_facet mds1 $LCTL set_param fail_loc=0
14624 do_facet mds1 $LCTL set_param fail_val=0
14625 do_facet mds1 $LCTL set_param \
14626 ldlm.lock_reclaim_threshold_mb=${low_wm}m
14627 error "createmany finished incorrectly!"
14629 do_facet mds1 $LCTL set_param fail_loc=0
14630 do_facet mds1 $LCTL set_param fail_val=0
14631 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
14632 wait $create_pid || return 1
14634 unlinkmany $DIR/$tdir/f $nr
14636 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
14639 remote_mds_nodsh && skip "remote MDS with nodsh"
14640 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14641 skip "Need MDS version at least 2.13.50"
14644 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14646 #define OBD_FAIL_PLAIN_RECORDS 0x1319
14647 #set only one record at plain llog
14648 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
14650 #fill already existed plain llog each 64767
14651 #wrapping whole catalog
14652 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14654 createmany -o $DIR/$tdir/$tfile_ 64700
14655 for (( i = 0; i < 64700; i = i + 2 ))
14657 rm $DIR/$tdir/$tfile_$i &
14658 rm $DIR/$tdir/$tfile_$((i + 1)) &
14663 #waiting osp synchronization
14664 wait_delete_completed
14666 run_test 135 "Race catalog processing"
14669 remote_mds_nodsh && skip "remote MDS with nodsh"
14670 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
14671 skip "Need MDS version at least 2.13.50"
14674 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
14675 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
14676 #set only one record at plain llog
14677 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
14678 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
14680 #fill already existed 2 plain llogs each 64767
14681 #wrapping whole catalog
14682 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
14683 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
14684 wait_delete_completed
14686 createmany -o $DIR/$tdir/$tfile_ 10
14689 do_facet $SINGLEMDS $LCTL set_param fail_val=3
14690 for (( i = 0; i < 10; i = i + 3 ))
14692 rm $DIR/$tdir/$tfile_$i &
14693 rm $DIR/$tdir/$tfile_$((i + 1)) &
14697 rm $DIR/$tdir/$tfile_$((i + 2)) &
14700 #waiting osp synchronization
14701 wait_delete_completed
14703 run_test 136 "Race catalog processing 2"
14705 test_140() { #bug-17379
14706 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14708 test_mkdir $DIR/$tdir
14709 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
14710 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
14712 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
14713 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
14715 while i=$((i + 1)); do
14717 cd $i || error "Changing to $i"
14718 ln -s ../stat stat || error "Creating stat symlink"
14719 # Read the symlink until ELOOP present,
14720 # not LBUGing the system is considered success,
14721 # we didn't overrun the stack.
14722 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
14723 if [ $ret -ne 0 ]; then
14724 if [ $ret -eq 40 ]; then
14727 error "Open stat symlink"
14733 echo "The symlink depth = $i"
14734 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
14735 error "Invalid symlink depth"
14737 # Test recursive symlink
14738 ln -s symlink_self symlink_self
14739 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
14740 echo "open symlink_self returns $ret"
14741 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
14743 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
14746 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14748 local TF="$TMP/$tfile"
14750 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14751 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
14753 cancel_lru_locks $OSC
14754 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
14755 remount_client $MOUNT
14757 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
14760 $TRUNCATE $DIR/$tfile 6000
14761 cancel_lru_locks $OSC
14762 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
14765 echo "12345" >>$DIR/$tfile
14766 cancel_lru_locks $OSC
14767 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
14770 echo "12345" >>$DIR/$tfile
14771 cancel_lru_locks $OSC
14772 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
14774 run_test 150a "truncate/append tests"
14777 check_set_fallocate_or_skip
14780 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14781 check_fallocate $DIR/$tfile || skip_eopnotsupp "fallocate failed"
14783 run_test 150b "Verify fallocate (prealloc) functionality"
14786 check_set_fallocate_or_skip
14789 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14790 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed"
14792 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14793 # precomputed md5sum for 20MB of zeroes
14794 local expect="8f4e33f3dc3e414ff94e5fb6905cba8c"
14795 local sum=($(md5sum $DIR/$tfile))
14797 [[ "${sum[0]}" == "$expect" ]] || error "fallocate unwritten is not zero"
14799 check_set_fallocate 1
14802 fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed"
14803 sum=($(md5sum $DIR/$tfile))
14805 [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero"
14807 run_test 150bb "Verify fallocate modes both zero space"
14810 check_set_fallocate_or_skip
14811 local striping="-c2"
14813 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14814 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed"
14815 fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed"
14816 local bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14817 local want=$((OSTCOUNT * 1048576))
14819 # Must allocate all requested space, not more than 5% extra
14820 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14821 error "bytes $bytes is not $want"
14825 echo "verify fallocate on PFL file"
14827 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14829 $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile ||
14830 error "Create $DIR/$tfile failed"
14831 fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed"
14832 bytes=$(($(stat -c '%b * %B' $DIR/$tfile)))
14833 want=$((512 * 1048576))
14835 # Must allocate all requested space, not more than 5% extra
14836 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14837 error "bytes $bytes is not $want"
14839 run_test 150c "Verify fallocate Size and Blocks"
14842 check_set_fallocate_or_skip
14843 local striping="-c2"
14845 [[ "x$DOM" == "xyes" ]] && striping="-L mdt"
14847 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14848 $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir ||
14849 error "setstripe failed"
14850 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
14851 local bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
14852 local want=$((OSTCOUNT * 1048576))
14854 # Must allocate all requested space, not more than 5% extra
14855 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
14856 error "bytes $bytes is not $want"
14858 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
14861 check_set_fallocate_or_skip
14865 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14866 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
14867 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
14869 # Find OST with Minimum Size
14870 min_size_ost=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
14871 sort -un | head -1)
14873 # Get 100MB per OST of the available space to reduce run time
14874 # else 60% of the available space if we are running SLOW tests
14875 if [ $SLOW == "no" ]; then
14876 local space=$((1024 * 100 * OSTCOUNT))
14878 local space=$(((min_size_ost * 60)/100 * OSTCOUNT))
14881 fallocate -l${space}k $DIR/$tfile ||
14882 error "fallocate ${space}k $DIR/$tfile failed"
14883 echo "'fallocate -l ${space}k $DIR/$tfile' succeeded"
14885 # get size immediately after fallocate. This should be correctly
14887 local size=$(stat -c '%s' $DIR/$tfile)
14888 local used=$(( $(stat -c '%b * %B' $DIR/$tfile) / 1024))
14890 # Sleep for a while for statfs to get updated. And not pull from cache.
14893 echo "df after fallocate:"
14896 (( size / 1024 == space )) || error "size $size != requested $space"
14897 [ "$ost1_FSTYPE" != ldiskfs ] || (( used >= space )) ||
14898 error "used $used < space $space"
14900 rm $DIR/$tfile || error "rm failed"
14902 wait_delete_completed
14904 echo "df after unlink:"
14907 run_test 150e "Verify 60% of available OST space consumed by fallocate"
14912 local want_size_before=20480 # in bytes
14913 local want_blocks_before=40 # 512 sized blocks
14914 local want_blocks_after=24 # 512 sized blocks
14915 local length=$(((want_blocks_before - want_blocks_after) * 512))
14917 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14918 skip "need at least 2.14.0 for fallocate punch"
14920 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14921 skip "LU-14160: punch mode is not implemented on OSD ZFS"
14924 check_set_fallocate_or_skip
14925 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
14927 [[ "x$DOM" == "xyes" ]] &&
14928 $LFS setstripe -E1M -L mdt -E eof $DIR/$tfile
14930 echo "Verify fallocate punch: Range within the file range"
14931 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14932 error "dd failed for bs 4096 and count 5"
14934 # Call fallocate with punch range which is within the file range
14935 out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) ||
14936 skip_eopnotsupp "$out|fallocate: offset 4096 and length $length"
14937 # client must see changes immediately after fallocate
14938 size=$(stat -c '%s' $DIR/$tfile)
14939 blocks=$(stat -c '%b' $DIR/$tfile)
14941 # Verify punch worked.
14942 (( blocks == want_blocks_after )) ||
14943 error "punch failed: blocks $blocks != $want_blocks_after"
14945 (( size == want_size_before )) ||
14946 error "punch failed: size $size != $want_size_before"
14948 # Verify there is hole in file
14949 local data_off=$(lseek_test -d 4096 $DIR/$tfile)
14950 # precomputed md5sum
14951 local expect="4a9a834a2db02452929c0a348273b4aa"
14953 cksum=($(md5sum $DIR/$tfile))
14954 [[ "${cksum[0]}" == "$expect" ]] ||
14955 error "unexpected MD5SUM after punch: ${cksum[0]}"
14957 # Start second sub-case for fallocate punch.
14958 echo "Verify fallocate punch: Range overlapping and less than blocksize"
14959 yes 'A' | dd of=$DIR/$tfile bs=4096 count=5 ||
14960 error "dd failed for bs 4096 and count 5"
14962 # Punch range less than block size will have no change in block count
14963 want_blocks_after=40 # 512 sized blocks
14965 # Punch overlaps two blocks and less than blocksize
14966 out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) ||
14967 skip_eopnotsupp "$out|fallocate: offset 4000 length 3000"
14968 size=$(stat -c '%s' $DIR/$tfile)
14969 blocks=$(stat -c '%b' $DIR/$tfile)
14971 # Verify punch worked.
14972 (( blocks == want_blocks_after )) ||
14973 error "punch failed: blocks $blocks != $want_blocks_after"
14975 (( size == want_size_before )) ||
14976 error "punch failed: size $size != $want_size_before"
14978 # Verify if range is really zero'ed out. We expect Zeros.
14979 # precomputed md5sum
14980 expect="c57ec5d769c3dbe3426edc3f7d7e11d3"
14981 cksum=($(md5sum $DIR/$tfile))
14982 [[ "${cksum[0]}" == "$expect" ]] ||
14983 error "unexpected MD5SUM after punch: ${cksum[0]}"
14985 run_test 150f "Verify fallocate punch functionality"
14993 local BS=4096 # Block size in bytes
14995 [[ $OST1_VERSION -ge $(version_code 2.14.0) ]] ||
14996 skip "need at least 2.14.0 for fallocate punch"
14998 if [ "$ost1_FSTYPE" = "zfs" ] || [ "$mds1_FSTYPE" = "zfs" ]; then
14999 skip "LU-14160: punch mode is not implemented on OSD ZFS"
15002 check_set_fallocate_or_skip
15003 stack_trap "rm -f $DIR/$tfile; wait_delete_completed"
15005 if [[ "x$DOM" == "xyes" ]]; then
15006 $LFS setstripe -E2M -L mdt -E eof -c${OSTCOUNT} $DIR/$tfile ||
15007 error "$LFS setstripe DoM + ${OSTCOUNT} OST failed"
15009 $LFS setstripe -c${OSTCOUNT} $DIR/$tfile ||
15010 error "$LFS setstripe -c${OSTCOUNT} $DIR/$tfile failed"
15013 # Get 100MB per OST of the available space to reduce run time
15014 # else 60% of the available space if we are running SLOW tests
15015 if [ $SLOW == "no" ]; then
15016 space=$((1024 * 100 * OSTCOUNT))
15018 # Find OST with Minimum Size
15019 space=$($LFS df | awk "/$FSNAME-OST/ { print \$4 }" |
15020 sort -un | head -1)
15021 echo "min size OST: $space"
15022 space=$(((space * 60)/100 * OSTCOUNT))
15024 # space in 1k units, round to 4k blocks
15025 local blkcount=$((space * 1024 / $BS))
15027 echo "Verify fallocate punch: Very large Range"
15028 fallocate -l${space}k $DIR/$tfile ||
15029 error "fallocate ${space}k $DIR/$tfile failed"
15030 # write 1M at the end, start and in the middle
15031 yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 ||
15032 error "dd failed: bs $BS count 256"
15033 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount - 256)) count=256 ||
15034 error "dd failed: bs $BS count 256 seek $((blkcount - 256))"
15035 yes 'A' | dd of=$DIR/$tfile bs=$BS seek=$((blkcount / 2)) count=1024 ||
15036 error "dd failed: bs $BS count 256 seek $((blkcount / 2))"
15039 size=$(stat -c '%s' $DIR/$tfile)
15041 # gather punch length.
15042 local punch_size=$((size - (BS * 2)))
15044 echo "punch_size = $punch_size"
15045 echo "size - punch_size: $((size - punch_size))"
15046 echo "size - punch_size in blocks: $(((size - punch_size)/BS))"
15048 # Call fallocate to punch all except 2 blocks. We leave the
15049 # first and the last block
15050 echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile"
15051 out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) ||
15052 skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size"
15054 size_after=$(stat -c '%s' $DIR/$tfile)
15055 blocks_after=$(stat -c '%b' $DIR/$tfile)
15057 # Verify punch worked.
15058 # Size should be kept
15059 (( size == size_after )) ||
15060 error "punch failed: size $size != $size_after"
15062 # two 4k data blocks to remain plus possible 1 extra extent block
15063 (( blocks_after <= ((BS / 512) * 3) )) ||
15064 error "too many blocks remains: $blocks_after"
15066 # Verify that file has hole between the first and the last blocks
15067 local hole_start=$(lseek_test -l 0 $DIR/$tfile)
15068 local hole_end=$(lseek_test -d $BS $DIR/$tfile)
15070 echo "Hole at [$hole_start, $hole_end)"
15071 (( hole_start == BS )) ||
15072 error "no hole at offset $BS after punch"
15074 (( hole_end == BS + punch_size )) ||
15075 error "data at offset $hole_end < $((BS + punch_size))"
15077 run_test 150g "Verify fallocate punch on large range"
15079 #LU-2902 roc_hit was not able to read all values from lproc
15080 function roc_hit_init() {
15081 local list=$(comma_list $(osts_nodes))
15082 local dir=$DIR/$tdir-check
15083 local file=$dir/$tfile
15089 #use setstripe to do a write to every ost
15090 for i in $(seq 0 $((OSTCOUNT-1))); do
15091 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
15092 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
15093 idx=$(printf %04x $i)
15094 BEFORE=$(get_osd_param $list *OST*$idx stats |
15095 awk '$1 == "cache_access" {sum += $7}
15096 END { printf("%0.0f", sum) }')
15098 cancel_lru_locks osc
15099 cat $file >/dev/null
15101 AFTER=$(get_osd_param $list *OST*$idx stats |
15102 awk '$1 == "cache_access" {sum += $7}
15103 END { printf("%0.0f", sum) }')
15105 echo BEFORE:$BEFORE AFTER:$AFTER
15106 if ! let "AFTER - BEFORE == 4"; then
15108 error "roc_hit is not safe to use"
15116 function roc_hit() {
15117 local list=$(comma_list $(osts_nodes))
15118 echo $(get_osd_param $list '' stats |
15119 awk '$1 == "cache_hit" {sum += $7}
15120 END { printf("%0.0f", sum) }')
15123 function set_cache() {
15126 if [ "$2" == "off" ]; then
15129 local list=$(comma_list $(osts_nodes))
15130 set_osd_param $list '' $1_cache_enable $on
15132 cancel_lru_locks osc
15136 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15137 remote_ost_nodsh && skip "remote OST with nodsh"
15140 local list=$(comma_list $(osts_nodes))
15142 # check whether obdfilter is cache capable at all
15143 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
15144 skip "not cache-capable obdfilter"
15147 # check cache is enabled on all obdfilters
15148 if get_osd_param $list '' read_cache_enable | grep 0; then
15149 skip "oss cache is disabled"
15152 set_osd_param $list '' writethrough_cache_enable 1
15154 # check write cache is enabled on all obdfilters
15155 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
15156 skip "oss write cache is NOT enabled"
15161 #define OBD_FAIL_OBD_NO_LRU 0x609
15162 do_nodes $list $LCTL set_param fail_loc=0x609
15164 # pages should be in the case right after write
15165 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
15168 local BEFORE=$(roc_hit)
15169 cancel_lru_locks osc
15170 cat $DIR/$tfile >/dev/null
15171 local AFTER=$(roc_hit)
15173 do_nodes $list $LCTL set_param fail_loc=0
15175 if ! let "AFTER - BEFORE == CPAGES"; then
15176 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
15179 cancel_lru_locks osc
15180 # invalidates OST cache
15181 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
15182 set_osd_param $list '' read_cache_enable 0
15183 cat $DIR/$tfile >/dev/null
15185 # now data shouldn't be found in the cache
15187 cancel_lru_locks osc
15188 cat $DIR/$tfile >/dev/null
15190 if let "AFTER - BEFORE != 0"; then
15191 error "IN CACHE: before: $BEFORE, after: $AFTER"
15194 set_osd_param $list '' read_cache_enable 1
15197 run_test 151 "test cache on oss and controls ==============================="
15200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15202 local TF="$TMP/$tfile"
15204 # simulate ENOMEM during write
15205 #define OBD_FAIL_OST_NOMEM 0x226
15206 lctl set_param fail_loc=0x80000226
15207 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
15209 sync || error "sync failed"
15210 lctl set_param fail_loc=0
15212 # discard client's cache
15213 cancel_lru_locks osc
15215 # simulate ENOMEM during read
15216 lctl set_param fail_loc=0x80000226
15217 cmp $TF $DIR/$tfile || error "cmp failed"
15218 lctl set_param fail_loc=0
15222 run_test 152 "test read/write with enomem ============================"
15225 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
15227 run_test 153 "test if fdatasync does not crash ======================="
15229 dot_lustre_fid_permission_check() {
15231 local ffid=$MOUNT/.lustre/fid/$fid
15234 echo "stat fid $fid"
15235 stat $ffid > /dev/null || error "stat $ffid failed."
15236 echo "touch fid $fid"
15237 touch $ffid || error "touch $ffid failed."
15238 echo "write to fid $fid"
15239 cat /etc/hosts > $ffid || error "write $ffid failed."
15240 echo "read fid $fid"
15241 diff /etc/hosts $ffid || error "read $ffid failed."
15242 echo "append write to fid $fid"
15243 cat /etc/hosts >> $ffid || error "append write $ffid failed."
15244 echo "rename fid $fid"
15245 mv $ffid $test_dir/$tfile.1 &&
15246 error "rename $ffid to $tfile.1 should fail."
15247 touch $test_dir/$tfile.1
15248 mv $test_dir/$tfile.1 $ffid &&
15249 error "rename $tfile.1 to $ffid should fail."
15250 rm -f $test_dir/$tfile.1
15251 echo "truncate fid $fid"
15252 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
15253 echo "link fid $fid"
15254 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
15255 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
15256 echo "setfacl fid $fid"
15257 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
15258 echo "getfacl fid $fid"
15259 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
15261 echo "unlink fid $fid"
15262 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
15263 echo "mknod fid $fid"
15264 mknod $ffid c 1 3 && error "mknod $ffid should fail."
15266 fid=[0xf00000400:0x1:0x0]
15267 ffid=$MOUNT/.lustre/fid/$fid
15269 echo "stat non-exist fid $fid"
15270 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
15271 echo "write to non-exist fid $fid"
15272 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
15273 echo "link new fid $fid"
15274 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
15276 mkdir -p $test_dir/$tdir
15277 touch $test_dir/$tdir/$tfile
15278 fid=$($LFS path2fid $test_dir/$tdir)
15281 error "error: could not get fid for $test_dir/$dir/$tfile."
15283 ffid=$MOUNT/.lustre/fid/$fid
15286 ls $ffid > /dev/null || error "ls $ffid failed."
15287 echo "touch $fid/$tfile.1"
15288 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
15290 echo "touch $MOUNT/.lustre/fid/$tfile"
15291 touch $MOUNT/.lustre/fid/$tfile && \
15292 error "touch $MOUNT/.lustre/fid/$tfile should fail."
15294 echo "setxattr to $MOUNT/.lustre/fid"
15295 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
15297 echo "listxattr for $MOUNT/.lustre/fid"
15298 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
15300 echo "delxattr from $MOUNT/.lustre/fid"
15301 setfattr -x trusted.name1 $MOUNT/.lustre/fid
15303 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
15304 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
15305 error "touch invalid fid should fail."
15307 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
15308 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
15309 error "touch non-normal fid should fail."
15311 echo "rename $tdir to $MOUNT/.lustre/fid"
15312 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
15313 error "rename to $MOUNT/.lustre/fid should fail."
15315 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
15317 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
15318 local new_obf_mode=777
15320 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
15321 chmod $new_obf_mode $DIR/.lustre/fid ||
15322 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
15324 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
15325 [ $obf_mode -eq $new_obf_mode ] ||
15326 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
15328 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
15329 chmod $old_obf_mode $DIR/.lustre/fid ||
15330 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
15333 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
15334 fid=$($LFS path2fid $test_dir/$tfile-2)
15336 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
15338 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
15339 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
15340 error "create lov data thru .lustre failed"
15342 echo "cp /etc/passwd $test_dir/$tfile-2"
15343 cp /etc/passwd $test_dir/$tfile-2 ||
15344 error "copy to $test_dir/$tfile-2 failed."
15345 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
15346 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
15347 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
15349 rm -rf $test_dir/tfile.lnk
15350 rm -rf $test_dir/$tfile-2
15354 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15355 skip "Need MDS version at least 2.4.1"
15357 local tf=$DIR/$tfile
15360 local fid=$($LFS path2fid $tf)
15361 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
15363 # check that we get the same pathname back
15366 for rootpath in "$MOUNT" "$MOUNT///" "$MOUNT/$tfile"; do
15367 echo "$rootpath $fid"
15368 found=$($LFS fid2path $rootpath "$fid")
15369 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
15370 [ "$found" == "$tf" ] || error "fid2path $found != $tf"
15373 # check wrong root path format
15374 rootpath=$MOUNT"_wrong"
15375 found=$($LFS fid2path $rootpath "$fid")
15376 [ -z "$found" ] || error "should fail ($rootpath != $MOUNT)"
15378 run_test 154A "lfs path2fid and fid2path basic checks"
15381 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15382 skip "Need MDS version at least 2.4.1"
15384 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
15385 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
15386 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
15387 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
15389 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
15390 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
15392 # check that we get the same pathname
15393 echo "PFID: $PFID, name: $name"
15394 local FOUND=$($LFS fid2path $MOUNT "$PFID")
15395 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
15396 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
15397 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
15399 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
15401 run_test 154B "verify the ll_decode_linkea tool"
15404 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15405 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15406 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15407 skip "Need MDS version at least 2.2.51"
15408 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
15410 cp /etc/hosts $DIR/$tfile
15412 fid=$($LFS path2fid $DIR/$tfile)
15414 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
15416 dot_lustre_fid_permission_check "$fid" $DIR ||
15417 error "dot lustre permission check $fid failed"
15419 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
15421 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
15423 touch $MOUNT/.lustre/file &&
15424 error "creation is not allowed under .lustre"
15426 mkdir $MOUNT/.lustre/dir &&
15427 error "mkdir is not allowed under .lustre"
15431 run_test 154a "Open-by-FID"
15434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15435 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15436 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15437 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
15438 skip "Need MDS version at least 2.2.51"
15440 local remote_dir=$DIR/$tdir/remote_dir
15444 mkdir -p $DIR/$tdir
15445 $LFS mkdir -i $MDTIDX $remote_dir ||
15446 error "create remote directory failed"
15448 cp /etc/hosts $remote_dir/$tfile
15450 fid=$($LFS path2fid $remote_dir/$tfile)
15452 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
15454 dot_lustre_fid_permission_check "$fid" $remote_dir ||
15455 error "dot lustre permission check $fid failed"
15458 run_test 154b "Open-by-FID for remote directory"
15461 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
15462 skip "Need MDS version at least 2.4.1"
15464 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
15465 local FID1=$($LFS path2fid $DIR/$tfile.1)
15466 local FID2=$($LFS path2fid $DIR/$tfile.2)
15467 local FID3=$($LFS path2fid $DIR/$tfile.3)
15470 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
15471 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
15472 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
15474 [ "$FID" = "${!want}" ] ||
15475 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
15479 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
15481 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
15482 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
15486 run_test 154c "lfs path2fid and fid2path multiple arguments"
15489 remote_mds_nodsh && skip "remote MDS with nodsh"
15490 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
15491 skip "Need MDS version at least 2.5.53"
15493 if remote_mds; then
15494 nid=$($LCTL list_nids | sed "s/\./\\\./g")
15498 local proc_ofile="mdt.*.exports.'$nid'.open_files"
15505 local fid=$($LFS path2fid $DIR/$tfile)
15508 cmd="exec $fd<$DIR/$tfile"
15510 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
15511 echo "$fid_list" | grep "$fid"
15514 cmd="exec $fd>/dev/null"
15516 if [ $rc -ne 0 ]; then
15517 error "FID $fid not found in open files list $fid_list"
15520 run_test 154d "Verify open file fid"
15524 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
15525 skip "Need MDS version at least 2.6.50"
15527 if ls -a $MOUNT | grep -q '^\.lustre$'; then
15528 error ".lustre returned by readdir"
15531 run_test 154e ".lustre is not returned by readdir"
15534 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15536 # create parent directory on a single MDT to avoid cross-MDT hardlinks
15537 mkdir_on_mdt0 $DIR/$tdir
15538 # test dirs inherit from its stripe
15539 mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
15540 mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
15541 cp /etc/hosts $DIR/$tdir/foo1/$tfile
15542 ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
15545 # get fid of parents
15546 local FID0=$($LFS path2fid $DIR/$tdir)
15547 local FID1=$($LFS path2fid $DIR/$tdir/foo1)
15548 local FID2=$($LFS path2fid $DIR/$tdir/foo2)
15549 local FID3=$($LFS path2fid $DIR)
15551 # check that path2fid --parents returns expected <parent_fid>/name
15552 # 1) test for a directory (single parent)
15553 local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
15554 [ "$parent" == "$FID0/foo1" ] ||
15555 error "expected parent: $FID0/foo1, got: $parent"
15557 # 2) test for a file with nlink > 1 (multiple parents)
15558 parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
15559 echo "$parent" | grep -F "$FID1/$tfile" ||
15560 error "$FID1/$tfile not returned in parent list"
15561 echo "$parent" | grep -F "$FID2/link" ||
15562 error "$FID2/link not returned in parent list"
15564 # 3) get parent by fid
15565 local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
15566 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15567 echo "$parent" | grep -F "$FID1/$tfile" ||
15568 error "$FID1/$tfile not returned in parent list (by fid)"
15569 echo "$parent" | grep -F "$FID2/link" ||
15570 error "$FID2/link not returned in parent list (by fid)"
15572 # 4) test for entry in root directory
15573 parent=$($LFS path2fid --parents $DIR/f)
15574 echo "$parent" | grep -F "$FID3/f" ||
15575 error "$FID3/f not returned in parent list"
15577 # 5) test it on root directory
15578 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
15579 error "$MOUNT should not have parents"
15581 # enable xattr caching and check that linkea is correctly updated
15582 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
15583 save_lustre_params client "llite.*.xattr_cache" > $save
15584 lctl set_param llite.*.xattr_cache 1
15586 # 6.1) linkea update on rename
15587 mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
15589 # get parents by fid
15590 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15591 # foo1 should no longer be returned in parent list
15592 echo "$parent" | grep -F "$FID1" &&
15593 error "$FID1 should no longer be in parent list"
15594 # the new path should appear
15595 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
15596 error "$FID2/$tfile.moved is not in parent list"
15598 # 6.2) linkea update on unlink
15599 rm -f $DIR/$tdir/foo2/link
15600 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
15601 # foo2/link should no longer be returned in parent list
15602 echo "$parent" | grep -F "$FID2/link" &&
15603 error "$FID2/link should no longer be in parent list"
15607 restore_lustre_params < $save
15610 run_test 154f "get parent fids by reading link ea"
15614 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15615 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
15616 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
15617 skip "Need MDS version at least 2.6.92"
15619 mkdir_on_mdt0 $DIR/$tdir
15620 llapi_fid_test -d $DIR/$tdir
15622 run_test 154g "various llapi FID tests"
15624 test_155_small_load() {
15625 local temp=$TMP/$tfile
15626 local file=$DIR/$tfile
15628 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
15629 error "dd of=$temp bs=6096 count=1 failed"
15631 cancel_lru_locks $OSC
15632 cmp $temp $file || error "$temp $file differ"
15634 $TRUNCATE $temp 6000
15635 $TRUNCATE $file 6000
15636 cmp $temp $file || error "$temp $file differ (truncate1)"
15638 echo "12345" >>$temp
15639 echo "12345" >>$file
15640 cmp $temp $file || error "$temp $file differ (append1)"
15642 echo "12345" >>$temp
15643 echo "12345" >>$file
15644 cmp $temp $file || error "$temp $file differ (append2)"
15650 test_155_big_load() {
15651 remote_ost_nodsh && skip "remote OST with nodsh"
15653 local temp=$TMP/$tfile
15654 local file=$DIR/$tfile
15657 local cache_size=$(do_facet ost$((MAXI+1)) \
15658 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
15659 local large_file_size=$((cache_size * 2))
15661 echo "OSS cache size: $cache_size KB"
15662 echo "Large file size: $large_file_size KB"
15664 [ $MAXV -le $large_file_size ] &&
15665 skip_env "max available OST size needs > $large_file_size KB"
15667 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
15669 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
15670 error "dd of=$temp bs=$large_file_size count=1k failed"
15673 cancel_lru_locks osc
15674 cmp $temp $file || error "$temp $file differ"
15680 save_writethrough() {
15681 local facets=$(get_facets OST)
15683 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
15687 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15689 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15691 save_writethrough $p
15694 set_cache writethrough on
15695 test_155_small_load
15696 restore_lustre_params < $p
15699 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
15702 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15704 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15706 save_writethrough $p
15709 set_cache writethrough off
15710 test_155_small_load
15711 restore_lustre_params < $p
15714 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
15717 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15719 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15721 save_writethrough $p
15724 set_cache writethrough on
15725 test_155_small_load
15726 restore_lustre_params < $p
15729 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
15732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15734 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15736 save_writethrough $p
15739 set_cache writethrough off
15740 test_155_small_load
15741 restore_lustre_params < $p
15744 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
15747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15749 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15751 save_writethrough $p
15754 set_cache writethrough on
15756 restore_lustre_params < $p
15759 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
15762 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15764 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15766 save_writethrough $p
15769 set_cache writethrough off
15771 restore_lustre_params < $p
15774 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
15777 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15779 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15781 save_writethrough $p
15784 set_cache writethrough on
15786 restore_lustre_params < $p
15789 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
15792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15794 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15796 save_writethrough $p
15799 set_cache writethrough off
15801 restore_lustre_params < $p
15804 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
15807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15808 remote_ost_nodsh && skip "remote OST with nodsh"
15809 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
15810 skip "stats not implemented on old servers"
15811 [ "$ost1_FSTYPE" = "zfs" ] &&
15812 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
15817 local file="$DIR/$tfile"
15818 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15820 save_writethrough $p
15823 log "Turn on read and write cache"
15825 set_cache writethrough on
15827 log "Write data and read it back."
15828 log "Read should be satisfied from the cache."
15829 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15831 cancel_lru_locks osc
15832 cat $file >/dev/null
15834 if ! let "AFTER - BEFORE == CPAGES"; then
15835 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
15837 log "cache hits: before: $BEFORE, after: $AFTER"
15840 log "Read again; it should be satisfied from the cache."
15842 cancel_lru_locks osc
15843 cat $file >/dev/null
15845 if ! let "AFTER - BEFORE == CPAGES"; then
15846 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
15848 log "cache hits:: before: $BEFORE, after: $AFTER"
15851 log "Turn off the read cache and turn on the write cache"
15853 set_cache writethrough on
15855 log "Read again; it should be satisfied from the cache."
15857 cancel_lru_locks osc
15858 cat $file >/dev/null
15860 if ! let "AFTER - BEFORE == CPAGES"; then
15861 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
15863 log "cache hits:: before: $BEFORE, after: $AFTER"
15866 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15867 # > 2.12.56 uses pagecache if cached
15868 log "Read again; it should not be satisfied from the cache."
15870 cancel_lru_locks osc
15871 cat $file >/dev/null
15873 if ! let "AFTER - BEFORE == 0"; then
15874 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
15876 log "cache hits:: before: $BEFORE, after: $AFTER"
15880 log "Write data and read it back."
15881 log "Read should be satisfied from the cache."
15882 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15884 cancel_lru_locks osc
15885 cat $file >/dev/null
15887 if ! let "AFTER - BEFORE == CPAGES"; then
15888 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
15890 log "cache hits:: before: $BEFORE, after: $AFTER"
15893 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
15894 # > 2.12.56 uses pagecache if cached
15895 log "Read again; it should not be satisfied from the cache."
15897 cancel_lru_locks osc
15898 cat $file >/dev/null
15900 if ! let "AFTER - BEFORE == 0"; then
15901 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
15903 log "cache hits:: before: $BEFORE, after: $AFTER"
15907 log "Turn off read and write cache"
15909 set_cache writethrough off
15911 log "Write data and read it back"
15912 log "It should not be satisfied from the cache."
15914 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15915 cancel_lru_locks osc
15917 cat $file >/dev/null
15919 if ! let "AFTER - BEFORE == 0"; then
15920 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
15922 log "cache hits:: before: $BEFORE, after: $AFTER"
15925 log "Turn on the read cache and turn off the write cache"
15927 set_cache writethrough off
15929 log "Write data and read it back"
15930 log "It should not be satisfied from the cache."
15932 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
15934 cancel_lru_locks osc
15935 cat $file >/dev/null
15937 if ! let "AFTER - BEFORE == 0"; then
15938 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
15940 log "cache hits:: before: $BEFORE, after: $AFTER"
15943 log "Read again; it should be satisfied from the cache."
15945 cancel_lru_locks osc
15946 cat $file >/dev/null
15948 if ! let "AFTER - BEFORE == CPAGES"; then
15949 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
15951 log "cache hits:: before: $BEFORE, after: $AFTER"
15954 restore_lustre_params < $p
15957 run_test 156 "Verification of tunables"
15960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15961 remote_mds_nodsh && skip "remote MDS with nodsh"
15962 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
15963 skip "Need MDS version at least 2.2.0"
15965 changelog_register || error "changelog_register failed"
15966 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
15967 changelog_users $SINGLEMDS | grep -q $cl_user ||
15968 error "User $cl_user not found in changelog_users"
15970 mkdir_on_mdt0 $DIR/$tdir
15973 test_mkdir -p $DIR/$tdir/pics/2008/zachy
15974 changelog_clear 0 || error "changelog_clear failed"
15975 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
15976 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
15977 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15978 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15979 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15980 rm $DIR/$tdir/pics/desktop.jpg
15982 echo "verifying changelog mask"
15983 changelog_chmask "-MKDIR"
15984 changelog_chmask "-CLOSE"
15986 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
15987 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
15989 changelog_chmask "+MKDIR"
15990 changelog_chmask "+CLOSE"
15992 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
15993 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
15995 MKDIRS=$(changelog_dump | grep -c "MKDIR")
15996 CLOSES=$(changelog_dump | grep -c "CLOSE")
15997 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
15998 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
16001 echo "verifying target fid"
16002 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
16003 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
16004 [ "$fidc" == "$fidf" ] ||
16005 error "changelog '$tfile' fid $fidc != file fid $fidf"
16006 echo "verifying parent fid"
16007 # The FID returned from the Changelog may be the directory shard on
16008 # a different MDT, and not the FID returned by path2fid on the parent.
16009 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
16010 # since this is what will matter when recreating this file in the tree.
16011 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
16012 local pathp=$($LFS fid2path $MOUNT "$fidp")
16013 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
16014 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
16016 echo "getting records for $cl_user"
16017 changelog_users $SINGLEMDS
16018 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
16020 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
16021 error "changelog_clear failed"
16022 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
16023 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
16024 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
16025 error "user index expect $user_rec1 + $nclr != $user_rec2"
16027 local min0_rec=$(changelog_users $SINGLEMDS |
16028 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
16029 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
16030 awk '{ print $1; exit; }')
16032 changelog_dump | tail -n 5
16033 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
16034 [ $first_rec == $((min0_rec + 1)) ] ||
16035 error "first index should be $min0_rec + 1 not $first_rec"
16037 # LU-3446 changelog index reset on MDT restart
16038 local cur_rec1=$(changelog_users $SINGLEMDS |
16039 awk '/^current.index:/ { print $NF }')
16040 changelog_clear 0 ||
16041 error "clear all changelog records for $cl_user failed"
16042 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
16043 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
16044 error "Fail to start $SINGLEMDS"
16045 local cur_rec2=$(changelog_users $SINGLEMDS |
16046 awk '/^current.index:/ { print $NF }')
16047 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
16048 [ $cur_rec1 == $cur_rec2 ] ||
16049 error "current index should be $cur_rec1 not $cur_rec2"
16051 echo "verifying users from this test are deregistered"
16052 changelog_deregister || error "changelog_deregister failed"
16053 changelog_users $SINGLEMDS | grep -q $cl_user &&
16054 error "User '$cl_user' still in changelog_users"
16056 # lctl get_param -n mdd.*.changelog_users
16057 # current_index: 144
16058 # ID index (idle seconds)
16059 # cl3 144 (2) mask=<list>
16060 if [ -z "$(changelog_users $SINGLEMDS | grep -v current.index)" ]; then
16061 # this is the normal case where all users were deregistered
16062 # make sure no new records are added when no users are present
16063 local last_rec1=$(changelog_users $SINGLEMDS |
16064 awk '/^current.index:/ { print $NF }')
16065 touch $DIR/$tdir/chloe
16066 local last_rec2=$(changelog_users $SINGLEMDS |
16067 awk '/^current.index:/ { print $NF }')
16068 echo "verify changelogs are off: $last_rec1 == $last_rec2"
16069 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
16071 # any changelog users must be leftovers from a previous test
16072 changelog_users $SINGLEMDS
16073 echo "other changelog users; can't verify off"
16076 run_test 160a "changelog sanity"
16078 test_160b() { # LU-3587
16079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16080 remote_mds_nodsh && skip "remote MDS with nodsh"
16081 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
16082 skip "Need MDS version at least 2.2.0"
16084 changelog_register || error "changelog_register failed"
16085 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16086 changelog_users $SINGLEMDS | grep -q $cl_user ||
16087 error "User '$cl_user' not found in changelog_users"
16089 local longname1=$(str_repeat a 255)
16090 local longname2=$(str_repeat b 255)
16093 echo "creating very long named file"
16094 touch $longname1 || error "create of '$longname1' failed"
16095 echo "renaming very long named file"
16096 mv $longname1 $longname2
16098 changelog_dump | grep RENME | tail -n 5
16101 run_test 160b "Verify that very long rename doesn't crash in changelog"
16104 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16105 remote_mds_nodsh && skip "remote MDS with nodsh"
16107 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16108 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16109 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16110 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16114 # Registration step
16115 changelog_register || error "changelog_register failed"
16118 mkdir -p $DIR/$tdir
16119 $MCREATE $DIR/$tdir/foo_160c
16120 changelog_chmask "-TRUNC"
16121 $TRUNCATE $DIR/$tdir/foo_160c 200
16122 changelog_chmask "+TRUNC"
16123 $TRUNCATE $DIR/$tdir/foo_160c 199
16124 changelog_dump | tail -n 5
16125 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
16126 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
16128 run_test 160c "verify that changelog log catch the truncate event"
16131 remote_mds_nodsh && skip "remote MDS with nodsh"
16132 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16134 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
16135 skip "Need MDS version at least 2.7.60"
16137 # Registration step
16138 changelog_register || error "changelog_register failed"
16140 mkdir -p $DIR/$tdir/migrate_dir
16141 changelog_clear 0 || error "changelog_clear failed"
16143 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
16144 changelog_dump | tail -n 5
16145 local migrates=$(changelog_dump | grep -c "MIGRT")
16146 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
16148 run_test 160d "verify that changelog log catch the migrate event"
16151 remote_mds_nodsh && skip "remote MDS with nodsh"
16154 changelog_register || error "changelog_register failed"
16156 local MDT0=$(facet_svc $SINGLEMDS)
16159 # No user (expect fail)
16160 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister
16162 if [ $rc -eq 0 ]; then
16163 error "Should fail without user"
16164 elif [ $rc -ne 4 ]; then
16165 error "changelog_deregister failed with $rc, expect 4(CMD_HELP)"
16168 # Delete a future user (expect fail)
16169 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
16171 if [ $rc -eq 0 ]; then
16172 error "Deleted non-existant user cl77"
16173 elif [ $rc -ne 2 ]; then
16174 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
16177 # Clear to a bad index (1 billion should be safe)
16178 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
16181 if [ $rc -eq 0 ]; then
16182 error "Successfully cleared to invalid CL index"
16183 elif [ $rc -ne 22 ]; then
16184 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
16187 run_test 160e "changelog negative testing (should return errors)"
16190 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16191 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16192 skip "Need MDS version at least 2.10.56"
16194 local mdts=$(comma_list $(mdts_nodes))
16197 changelog_register || error "first changelog_register failed"
16198 changelog_register || error "second changelog_register failed"
16200 declare -A cl_user1
16201 declare -A cl_user2
16206 # generate some changelog records to accumulate on each MDT
16207 # use all_char because created files should be evenly distributed
16208 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16209 error "test_mkdir $tdir failed"
16210 log "$(date +%s): creating first files"
16211 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16212 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT)) ||
16213 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT)) failed"
16216 # check changelogs have been generated
16217 local start=$SECONDS
16218 local idle_time=$((MDSCOUNT * 5 + 5))
16219 local nbcl=$(changelog_dump | wc -l)
16220 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16222 for param in "changelog_max_idle_time=$idle_time" \
16224 "changelog_min_gc_interval=2" \
16225 "changelog_min_free_cat_entries=3"; do
16226 local MDT0=$(facet_svc $SINGLEMDS)
16227 local var="${param%=*}"
16228 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16230 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16231 do_nodes $mdts $LCTL set_param mdd.*.$param
16234 # force cl_user2 to be idle (1st part), but also cancel the
16235 # cl_user1 records so that it is not evicted later in the test.
16236 local sleep1=$((idle_time / 2))
16237 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
16240 # simulate changelog catalog almost full
16241 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
16242 do_nodes $mdts "$LCTL set_param fail_loc=0x1313 fail_val=3"
16244 for i in $(seq $MDSCOUNT); do
16245 cl_users=(${CL_USERS[mds$i]})
16246 cl_user1[mds$i]="${cl_users[0]}"
16247 cl_user2[mds$i]="${cl_users[1]}"
16249 [ -n "${cl_user1[mds$i]}" ] ||
16250 error "mds$i: no user registered"
16251 [ -n "${cl_user2[mds$i]}" ] ||
16252 error "mds$i: only ${cl_user2[mds$i]} is registered"
16254 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16255 [ -n "$user_rec1" ] ||
16256 error "mds$i: User ${cl_user1[mds$i]} not registered"
16257 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16258 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16259 [ -n "$user_rec2" ] ||
16260 error "mds$i: User ${cl_user1[mds$i]} not registered"
16261 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16262 "$user_rec1 + 2 == $user_rec2"
16263 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16264 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16265 "$user_rec1 + 2, but is $user_rec2"
16266 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16267 [ -n "$user_rec2" ] ||
16268 error "mds$i: User ${cl_user2[mds$i]} not registered"
16269 [ $user_rec1 == $user_rec2 ] ||
16270 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16271 "$user_rec1, but is $user_rec2"
16274 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
16275 local sleep2=$((idle_time - (SECONDS - start) + 1))
16276 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
16279 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16280 # cl_user1 should be OK because it recently processed records.
16281 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
16282 for ((i = 0; i < MDSCOUNT * 2; i++)); do
16283 $LFS mkdir -i $((i%MDSCOUNT)) $DIR/$tdir/d$i.$((i/MDSCOUNT+2))||
16284 error "create $DIR/$tdir/d$i.$((i/MDSCOUNT+2)) failed"
16287 # ensure gc thread is done
16288 for i in $(mdts_nodes); do
16289 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16290 error "$i: GC-thread not done"
16294 for (( i = 1; i <= MDSCOUNT; i++ )); do
16295 # check cl_user1 still registered
16296 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16297 error "mds$i: User ${cl_user1[mds$i]} not registered"
16298 # check cl_user2 unregistered
16299 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16300 error "mds$i: User ${cl_user2[mds$i]} still registered"
16302 # check changelogs are present and starting at $user_rec1 + 1
16303 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16304 [ -n "$user_rec1" ] ||
16305 error "mds$i: User ${cl_user1[mds$i]} not registered"
16306 first_rec=$($LFS changelog $(facet_svc mds$i) |
16307 awk '{ print $1; exit; }')
16309 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16310 [ $((user_rec1 + 1)) == $first_rec ] ||
16311 error "mds$i: rec $first_rec != $user_rec1 + 1"
16314 run_test 160f "changelog garbage collect (timestamped users)"
16317 remote_mds_nodsh && skip "remote MDS with nodsh"
16318 [[ $MDS1_VERSION -ge $(version_code 2.14.55) ]] ||
16319 skip "Need MDS version at least 2.14.55"
16321 local mdts=$(comma_list $(mdts_nodes))
16324 changelog_register || error "first changelog_register failed"
16325 changelog_register || error "second changelog_register failed"
16327 declare -A cl_user1
16328 declare -A cl_user2
16333 # generate some changelog records to accumulate on each MDT
16334 # use all_char because created files should be evenly distributed
16335 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16336 error "test_mkdir $tdir failed"
16337 for ((i = 0; i < MDSCOUNT; i++)); do
16338 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16339 error "create $DIR/$tdir/d$i.1 failed"
16342 # check changelogs have been generated
16343 local nbcl=$(changelog_dump | wc -l)
16344 (( $nbcl > 0 )) || error "no changelogs found"
16346 # reduce the max_idle_indexes value to make sure we exceed it
16347 for param in "changelog_max_idle_indexes=2" \
16349 "changelog_min_gc_interval=2"; do
16350 local MDT0=$(facet_svc $SINGLEMDS)
16351 local var="${param%=*}"
16352 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16354 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16355 do_nodes $mdts $LCTL set_param mdd.*.$param ||
16356 error "unable to set mdd.*.$param"
16359 local start=$SECONDS
16360 for i in $(seq $MDSCOUNT); do
16361 cl_users=(${CL_USERS[mds$i]})
16362 cl_user1[mds$i]="${cl_users[0]}"
16363 cl_user2[mds$i]="${cl_users[1]}"
16365 [ -n "${cl_user1[mds$i]}" ] ||
16366 error "mds$i: user1 is not registered"
16367 [ -n "${cl_user2[mds$i]}" ] ||
16368 error "mds$i: only ${cl_user1[mds$i]} is registered"
16370 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16371 [ -n "$user_rec1" ] ||
16372 error "mds$i: user1 ${cl_user1[mds$i]} not found"
16373 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16374 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16375 [ -n "$user_rec2" ] ||
16376 error "mds$i: user1 ${cl_user1[mds$i]} not found (2)"
16377 echo "mds$i: verifying user1 ${cl_user1[mds$i]} clear: " \
16378 "$user_rec1 + 2 == $user_rec2"
16379 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16380 error "mds$i: user1 ${cl_user1[mds$i]} index " \
16381 "expected $user_rec1 + 2, but is $user_rec2"
16382 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16383 [ -n "$user_rec2" ] ||
16384 error "mds$i: user2 ${cl_user2[mds$i]} not found"
16385 [ $user_rec1 == $user_rec2 ] ||
16386 error "mds$i: user2 ${cl_user2[mds$i]} index " \
16387 "expected $user_rec1, but is $user_rec2"
16390 # ensure we are past the previous changelog_min_gc_interval set above
16391 local sleep2=$((start + 2 - SECONDS))
16392 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
16393 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
16394 # cl_user1 should be OK because it recently processed records.
16395 for ((i = 0; i < MDSCOUNT; i++)); do
16396 $LFS mkdir -i $i $DIR/$tdir/d$i.3 ||
16397 error "create $DIR/$tdir/d$i.3 failed"
16400 # ensure gc thread is done
16401 for i in $(mdts_nodes); do
16402 wait_update $i "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
16403 error "$i: GC-thread not done"
16407 for (( i = 1; i <= MDSCOUNT; i++ )); do
16408 # check cl_user1 still registered
16409 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16410 error "mds$i: user1 ${cl_user1[mds$i]} not found (3)"
16411 # check cl_user2 unregistered
16412 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16413 error "mds$i: user2 ${cl_user2[mds$i]} is registered"
16415 # check changelogs are present and starting at $user_rec1 + 1
16416 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16417 [ -n "$user_rec1" ] ||
16418 error "mds$i: user1 ${cl_user1[mds$i]} not found (4)"
16419 first_rec=$($LFS changelog $(facet_svc mds$i) |
16420 awk '{ print $1; exit; }')
16422 echo "mds$i: $(date +%s) verify rec $user_rec1+1 == $first_rec"
16423 [ $((user_rec1 + 1)) == $first_rec ] ||
16424 error "mds$i: rec $first_rec != $user_rec1 + 1"
16427 run_test 160g "changelog garbage collect on idle records"
16430 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16431 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
16432 skip "Need MDS version at least 2.10.56"
16434 local mdts=$(comma_list $(mdts_nodes))
16437 changelog_register || error "first changelog_register failed"
16438 changelog_register || error "second changelog_register failed"
16440 declare -A cl_user1
16441 declare -A cl_user2
16446 # generate some changelog records to accumulate on each MDT
16447 # use all_char because created files should be evenly distributed
16448 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16449 error "test_mkdir $tdir failed"
16450 for ((i = 0; i < MDSCOUNT; i++)); do
16451 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16452 error "create $DIR/$tdir/d$i.1 failed"
16455 # check changelogs have been generated
16456 local nbcl=$(changelog_dump | wc -l)
16457 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16459 for param in "changelog_max_idle_time=10" \
16461 "changelog_min_gc_interval=2"; do
16462 local MDT0=$(facet_svc $SINGLEMDS)
16463 local var="${param%=*}"
16464 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
16466 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
16467 do_nodes $mdts $LCTL set_param mdd.*.$param
16470 # force cl_user2 to be idle (1st part)
16473 for i in $(seq $MDSCOUNT); do
16474 cl_users=(${CL_USERS[mds$i]})
16475 cl_user1[mds$i]="${cl_users[0]}"
16476 cl_user2[mds$i]="${cl_users[1]}"
16478 [ -n "${cl_user1[mds$i]}" ] ||
16479 error "mds$i: no user registered"
16480 [ -n "${cl_user2[mds$i]}" ] ||
16481 error "mds$i: only ${cl_user2[mds$i]} is registered"
16483 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16484 [ -n "$user_rec1" ] ||
16485 error "mds$i: User ${cl_user1[mds$i]} not registered"
16486 __changelog_clear mds$i ${cl_user1[mds$i]} +2
16487 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16488 [ -n "$user_rec2" ] ||
16489 error "mds$i: User ${cl_user1[mds$i]} not registered"
16490 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
16491 "$user_rec1 + 2 == $user_rec2"
16492 [ $((user_rec1 + 2)) == $user_rec2 ] ||
16493 error "mds$i: user ${cl_user1[mds$i]} index expected " \
16494 "$user_rec1 + 2, but is $user_rec2"
16495 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
16496 [ -n "$user_rec2" ] ||
16497 error "mds$i: User ${cl_user2[mds$i]} not registered"
16498 [ $user_rec1 == $user_rec2 ] ||
16499 error "mds$i: user ${cl_user2[mds$i]} index expected " \
16500 "$user_rec1, but is $user_rec2"
16503 # force cl_user2 to be idle (2nd part) and to reach
16504 # changelog_max_idle_time
16507 # force each GC-thread start and block then
16508 # one per MDT/MDD, set fail_val accordingly
16509 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
16510 do_nodes $mdts $LCTL set_param fail_loc=0x1316
16512 # generate more changelogs to trigger fail_loc
16513 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16514 error "create $DIR/$tdir/${tfile}bis failed"
16516 # stop MDT to stop GC-thread, should be done in back-ground as it will
16517 # block waiting for the thread to be released and exit
16518 declare -A stop_pids
16519 for i in $(seq $MDSCOUNT); do
16521 stop_pids[mds$i]=$!
16524 for i in $(mdts_nodes); do
16527 local facets=$(facets_up_on_host $i)
16529 for facet in ${facets//,/ }; do
16530 if [[ $facet == mds* ]]; then
16534 # ensure each MDS's gc threads are still present and all in "R"
16535 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
16536 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
16537 error "$i: expected $nb GC-thread"
16539 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
16541 error "$i: GC-thread not found in R-state"
16542 # check umounts of each MDT on MDS have reached kthread_stop()
16543 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
16544 error "$i: expected $nb umount"
16546 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
16547 error "$i: umount not found in D-state"
16550 # release all GC-threads
16551 do_nodes $mdts $LCTL set_param fail_loc=0
16553 # wait for MDT stop to complete
16554 for i in $(seq $MDSCOUNT); do
16555 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
16559 # may try to check if any orphan changelog records are present
16560 # via ldiskfs/zfs and llog_reader...
16562 # re-start/mount MDTs
16563 for i in $(seq $MDSCOUNT); do
16564 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
16565 error "Fail to start mds$i"
16569 for i in $(seq $MDSCOUNT); do
16570 # check cl_user1 still registered
16571 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
16572 error "mds$i: User ${cl_user1[mds$i]} not registered"
16573 # check cl_user2 unregistered
16574 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
16575 error "mds$i: User ${cl_user2[mds$i]} still registered"
16577 # check changelogs are present and starting at $user_rec1 + 1
16578 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
16579 [ -n "$user_rec1" ] ||
16580 error "mds$i: User ${cl_user1[mds$i]} not registered"
16581 first_rec=$($LFS changelog $(facet_svc mds$i) |
16582 awk '{ print $1; exit; }')
16584 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
16585 [ $((user_rec1 + 1)) == $first_rec ] ||
16586 error "mds$i: first index should be $user_rec1 + 1, " \
16587 "but is $first_rec"
16590 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
16595 local mdts=$(comma_list $(mdts_nodes))
16597 changelog_register || error "first changelog_register failed"
16599 # generate some changelog records to accumulate on each MDT
16600 # use all_char because created files should be evenly distributed
16601 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16602 error "test_mkdir $tdir failed"
16603 for ((i = 0; i < MDSCOUNT; i++)); do
16604 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16605 error "create $DIR/$tdir/d$i.1 failed"
16608 # check changelogs have been generated
16609 local nbcl=$(changelog_dump | wc -l)
16610 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16612 # simulate race between register and unregister
16613 # XXX as fail_loc is set per-MDS, with DNE configs the race
16614 # simulation will only occur for one MDT per MDS and for the
16615 # others the normal race scenario will take place
16616 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
16617 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
16618 do_nodes $mdts $LCTL set_param fail_val=1
16620 # unregister 1st user
16621 changelog_deregister &
16623 # wait some time for deregister work to reach race rdv
16625 # register 2nd user
16626 changelog_register || error "2nd user register failed"
16628 wait $pid1 || error "1st user deregister failed"
16632 declare -A LAST_REC
16633 for i in $(seq $MDSCOUNT); do
16634 if changelog_users mds$i | grep "^cl"; then
16635 # make sure new records are added with one user present
16636 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
16637 awk '/^current.index:/ { print $NF }')
16639 error "mds$i has no user registered"
16643 # generate more changelog records to accumulate on each MDT
16644 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
16645 error "create $DIR/$tdir/${tfile}bis failed"
16647 for i in $(seq $MDSCOUNT); do
16648 last_rec=$(changelog_users $SINGLEMDS |
16649 awk '/^current.index:/ { print $NF }')
16650 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
16651 [ $last_rec != ${LAST_REC[mds$i]} ] ||
16652 error "changelogs are off on mds$i"
16655 run_test 160i "changelog user register/unregister race"
16658 remote_mds_nodsh && skip "remote MDS with nodsh"
16659 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
16660 skip "Need MDS version at least 2.12.56"
16662 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
16663 stack_trap "umount $MOUNT2" EXIT
16665 changelog_register || error "first changelog_register failed"
16666 stack_trap "changelog_deregister" EXIT
16668 # generate some changelog
16669 # use all_char because created files should be evenly distributed
16670 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
16671 error "mkdir $tdir failed"
16672 for ((i = 0; i < MDSCOUNT; i++)); do
16673 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
16674 error "create $DIR/$tdir/d$i.1 failed"
16677 # open the changelog device
16678 exec 3>/dev/changelog-$FSNAME-MDT0000
16679 stack_trap "exec 3>&-" EXIT
16680 exec 4</dev/changelog-$FSNAME-MDT0000
16681 stack_trap "exec 4<&-" EXIT
16683 # umount the first lustre mount
16685 stack_trap "mount_client $MOUNT" EXIT
16687 # read changelog, which may or may not fail, but should not crash
16691 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16692 changelog_users $SINGLEMDS | grep -q $cl_user ||
16693 error "User $cl_user not found in changelog_users"
16695 printf 'clear:'$cl_user':0' >&3
16697 run_test 160j "client can be umounted while its chanangelog is being used"
16700 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16701 remote_mds_nodsh && skip "remote MDS with nodsh"
16703 mkdir -p $DIR/$tdir/1/1
16705 changelog_register || error "changelog_register failed"
16706 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16708 changelog_users $SINGLEMDS | grep -q $cl_user ||
16709 error "User '$cl_user' not found in changelog_users"
16710 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
16711 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
16712 rmdir $DIR/$tdir/1/1 & sleep 1
16714 touch $DIR/$tdir/2/2
16715 rm -rf $DIR/$tdir/2
16720 changelog_dump | grep rmdir || error "rmdir not recorded"
16722 run_test 160k "Verify that changelog records are not lost"
16724 # Verifies that a file passed as a parameter has recently had an operation
16725 # performed on it that has generated an MTIME changelog which contains the
16726 # correct parent FID. As files might reside on a different MDT from the
16727 # parent directory in DNE configurations, the FIDs are translated to paths
16728 # before being compared, which should be identical
16729 compare_mtime_changelog() {
16737 mdtidx=$($LFS getstripe --mdt-index $file)
16738 mdtidx=$(printf "%04x" $mdtidx)
16740 # Obtain the parent FID from the MTIME changelog
16741 mtime=$($LFS changelog $FSNAME-MDT$mdtidx | tail -n 1 | grep MTIME)
16742 [ -z "$mtime" ] && error "MTIME changelog not recorded"
16744 cl_fid=$(sed -e 's/.* p=//' -e 's/ .*//' <<<$mtime)
16745 [ -z "$cl_fid" ] && error "parent FID not present"
16747 # Verify that the path for the parent FID is the same as the path for
16748 # the test directory
16749 pdir=$($LFS fid2path $MOUNT "$cl_fid")
16753 [[ "${pdir%/}" == "$dir" ]] ||
16754 error "MTIME changelog parent FID is wrong, expected $dir, got $pdir"
16758 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16760 remote_mds_nodsh && skip "remote MDS with nodsh"
16761 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
16762 skip "Need MDS version at least 2.13.55"
16766 changelog_register || error "changelog_register failed"
16767 cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16769 changelog_users $SINGLEMDS | grep -q $cl_user ||
16770 error "User '$cl_user' not found in changelog_users"
16772 # Clear some types so that MTIME changelogs are generated
16773 changelog_chmask "-CREAT"
16774 changelog_chmask "-CLOSE"
16776 test_mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
16778 # Test CL_MTIME during setattr
16779 touch $DIR/$tdir/$tfile
16780 compare_mtime_changelog $DIR/$tdir/$tfile
16782 # Test CL_MTIME during close
16783 $MULTIOP $DIR/$tdir/${tfile}_2 O_2w4096c || error "multiop failed"
16784 compare_mtime_changelog $DIR/$tdir/${tfile}_2
16786 run_test 160l "Verify that MTIME changelog records contain the parent FID"
16789 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16790 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16791 skip "Need MDS version at least 2.14.51"
16798 changelog_register || error "first changelog_register failed"
16799 changelog_register || error "second changelog_register failed"
16801 cl_users=(${CL_USERS[mds1]})
16802 cl_user1="${cl_users[0]}"
16803 cl_user2="${cl_users[1]}"
16804 # generate some changelog records to accumulate on MDT0
16805 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16806 createmany -m $DIR/$tdir/$tfile 50 ||
16807 error "create $DIR/$tdir/$tfile failed"
16808 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16811 # check changelogs have been generated
16812 local nbcl=$(changelog_dump | wc -l)
16813 [[ $nbcl -eq 0 ]] && error "no changelogs found"
16815 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
16816 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
16818 __changelog_clear mds1 $cl_user1 +10
16819 __changelog_clear mds1 $cl_user2 0 &
16822 __changelog_clear mds1 $cl_user1 0 ||
16823 error "fail to cancel record for $cl_user1"
16825 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16827 run_test 160m "Changelog clear race"
16830 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16831 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16832 skip "Need MDS version at least 2.14.51"
16841 changelog_register || error "first changelog_register failed"
16843 cl_users=(${CL_USERS[mds1]})
16844 cl_user1="${cl_users[0]}"
16846 # generate some changelog records to accumulate on MDT0
16847 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16848 first_rec=$(changelog_users $SINGLEMDS |
16849 awk '/^current.index:/ { print $NF }')
16850 while (( last_rec < (( first_rec + 65000)) )); do
16851 createmany -m $DIR/$tdir/$tfile 10000 ||
16852 error "create $DIR/$tdir/$tfile failed"
16854 for i in $(seq 0 10000); do
16855 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
16859 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
16860 error "unlinkmany failed unlink"
16861 last_rec=$(changelog_users $SINGLEMDS |
16862 awk '/^current.index:/ { print $NF }')
16863 echo last record $last_rec
16864 (( last_rec == 0 )) && error "no changelog found"
16867 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
16868 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
16870 __changelog_clear mds1 $cl_user1 0 &
16873 __changelog_clear mds1 $cl_user1 0 ||
16874 error "fail to cancel record for $cl_user1"
16876 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
16878 run_test 160n "Changelog destroy race"
16881 local mdt="$(facet_svc $SINGLEMDS)"
16883 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16884 remote_mds_nodsh && skip "remote MDS with nodsh"
16885 [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
16886 skip "Need MDS version at least 2.14.52"
16888 changelog_register --user test_160o -m unlnk+close+open ||
16889 error "changelog_register failed"
16891 do_facet $SINGLEMDS $LCTL --device $mdt \
16892 changelog_register -u "Tt3_-#" &&
16893 error "bad symbols in name should fail"
16895 do_facet $SINGLEMDS $LCTL --device $mdt \
16896 changelog_register -u test_160o &&
16897 error "the same name registration should fail"
16899 do_facet $SINGLEMDS $LCTL --device $mdt \
16900 changelog_register -u test_160toolongname &&
16901 error "too long name registration should fail"
16903 changelog_chmask "MARK+HSM"
16904 lctl get_param mdd.*.changelog*mask
16905 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
16906 changelog_users $SINGLEMDS | grep -q $cl_user ||
16907 error "User $cl_user not found in changelog_users"
16909 echo $cl_user | grep -q test_160o ||
16910 error "User $cl_user has no specific name 'test160o'"
16913 changelog_clear 0 || error "changelog_clear failed"
16914 # generate some changelog records to accumulate on MDT0
16915 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16916 touch $DIR/$tdir/$tfile # open 1
16918 OPENS=$(changelog_dump | grep -c "OPEN")
16919 [[ $OPENS -eq 1 ]] || error "OPEN changelog mask count $OPENS != 1"
16921 # must be no MKDIR it wasn't set as user mask
16922 MKDIR=$(changelog_dump | grep -c "MKDIR")
16923 [[ $MKDIR -eq 0 ]] || error "MKDIR changelog mask found $MKDIR > 0"
16925 oldmask=$(do_facet $SINGLEMDS $LCTL get_param \
16926 mdd.$mdt.changelog_current_mask -n)
16927 # register maskless user
16928 changelog_register || error "changelog_register failed"
16929 # effective mask should be not changed because it is not minimal
16930 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16931 mdd.$mdt.changelog_current_mask -n)
16932 [[ $mask == $oldmask ]] || error "mask was changed: $mask vs $oldmask"
16933 # set server mask to minimal value
16934 changelog_chmask "MARK"
16935 # check effective mask again, should be treated as DEFMASK now
16936 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16937 mdd.$mdt.changelog_current_mask -n)
16938 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
16940 do_facet $SINGLEMDS $LCTL --device $mdt \
16941 changelog_deregister -u test_160o ||
16942 error "cannot deregister by name"
16944 run_test 160o "changelog user name and mask"
16947 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16948 [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
16949 skip "Need MDS version at least 2.14.51"
16950 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
16956 changelog_register || error "first changelog_register failed"
16958 cl_users=(${CL_USERS[mds1]})
16959 cl_user1="${cl_users[0]}"
16961 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
16962 createmany -m $DIR/$tdir/$tfile 50 ||
16963 error "create $DIR/$tdir/$tfile failed"
16964 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
16967 # check changelogs have been generated
16968 entry_count=$(changelog_dump | wc -l)
16969 ((entry_count != 0)) || error "no changelog entries found"
16971 # remove changelog_users and check that orphan entries are removed
16973 local dev=$(mdsdevname 1)
16974 do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $dev"
16975 start mds1 $dev $MDS_MOUNT_OPTS || error "cannot start mds1"
16976 entry_count=$(changelog_dump | wc -l)
16977 ((entry_count == 0)) ||
16978 error "found $entry_count changelog entries, expected none"
16980 run_test 160p "Changelog orphan cleanup with no users"
16983 local mdt="$(facet_svc $SINGLEMDS)"
16986 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16987 remote_mds_nodsh && skip "remote MDS with nodsh"
16988 [ $MDS1_VERSION -ge $(version_code 2.14.54) ] ||
16989 skip "Need MDS version at least 2.14.54"
16991 # set server mask to minimal value like server init does
16992 changelog_chmask "MARK"
16993 clu=$(do_facet $SINGLEMDS $LCTL --device $mdt changelog_register -n) ||
16994 error "changelog_register failed"
16995 # check effective mask again, should be treated as DEFMASK now
16996 mask=$(do_facet $SINGLEMDS $LCTL get_param \
16997 mdd.$mdt.changelog_current_mask -n)
16998 do_facet $SINGLEMDS $LCTL --device $mdt changelog_deregister $clu ||
16999 error "changelog_deregister failed"
17000 [[ $mask == *"HLINK"* ]] || error "mask is not DEFMASK as expected"
17002 run_test 160q "changelog effective mask is DEFMASK if not set"
17005 remote_mds_nodsh && skip "remote MDS with nodsh"
17006 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
17007 skip "Need MDS version at least 2.14.55"
17009 local mdts=$(comma_list $(mdts_nodes))
17011 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
17012 do_nodes $mdts $LCTL set_param fail_loc=0x1314 \
17013 fail_val=$((24 * 3600 * 10))
17015 # Create a user which is 10 days old
17016 changelog_register || error "first changelog_register failed"
17018 declare -A cl_user1
17021 # generate some changelog records to accumulate on each MDT
17022 # use all_char because created files should be evenly distributed
17023 test_mkdir -c $MDSCOUNT -H all_char $DIR/$tdir ||
17024 error "test_mkdir $tdir failed"
17025 for ((i = 0; i < MDSCOUNT; i++)); do
17026 $LFS mkdir -i $i $DIR/$tdir/d$i.1 $DIR/$tdir/d$i.2 ||
17027 error "create $DIR/$tdir/d$i.1 failed"
17030 # check changelogs have been generated
17031 local nbcl=$(changelog_dump | wc -l)
17032 (( nbcl > 0 )) || error "no changelogs found"
17034 # reduce the max_idle_indexes value to make sure we exceed it
17035 for param in "changelog_max_idle_indexes=2097446912" \
17036 "changelog_max_idle_time=2592000" \
17038 "changelog_min_gc_interval=2"; do
17039 local MDT0=$(facet_svc $SINGLEMDS)
17040 local var="${param%=*}"
17041 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
17043 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
17044 do_nodes $mdts $LCTL set_param mdd.*.$param ||
17045 error "unable to set mdd.*.$param"
17048 local start=$SECONDS
17049 for i in $(seq $MDSCOUNT); do
17050 cl_users=(${CL_USERS[mds$i]})
17051 cl_user1[mds$i]="${cl_users[0]}"
17053 [[ -n "${cl_user1[mds$i]}" ]] ||
17054 error "mds$i: no user registered"
17057 #define OBD_FAIL_MDS_CHANGELOG_IDX_PUMP 0x16d
17058 do_nodes $mdts $LCTL set_param fail_loc=0x16d fail_val=500000000
17060 # ensure we are past the previous changelog_min_gc_interval set above
17061 local sleep2=$((start + 2 - SECONDS))
17062 (( sleep2 > 0 )) && echo "sleep $sleep2 for interval" && sleep $sleep2
17064 # Generate one more changelog to trigger GC
17065 for ((i = 0; i < MDSCOUNT; i++)); do
17066 $LFS mkdir -i $i $DIR/$tdir/d$i.3 $DIR/$tdir/d$i.4 ||
17067 error "create $DIR/$tdir/d$i.3 failed"
17070 # ensure gc thread is done
17071 for node in $(mdts_nodes); do
17072 wait_update $node "pgrep chlg_gc_thread" "" 20 ||
17073 error "$node: GC-thread not done"
17076 do_nodes $mdts $LCTL set_param fail_loc=0
17078 for (( i = 1; i <= MDSCOUNT; i++ )); do
17079 # check cl_user1 is purged
17080 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" &&
17081 error "mds$i: User ${cl_user1[mds$i]} is registered"
17085 run_test 160s "changelog garbage collect on idle records * time"
17088 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17090 test_mkdir -c1 $DIR/$tdir
17091 cp /etc/hosts $DIR/$tdir/$tfile
17092 test_mkdir -c1 $DIR/$tdir/foo1
17093 test_mkdir -c1 $DIR/$tdir/foo2
17094 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
17095 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
17096 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
17097 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
17098 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
17099 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17100 $LFS fid2path $DIR $FID
17101 error "bad link ea"
17104 rm $DIR/$tdir/foo2/zachary
17106 rm $DIR/$tdir/foo2/thor
17108 rm $DIR/$tdir/$tfile
17110 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
17111 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
17112 { $LFS fid2path $DIR $FID; error "bad link rename"; }
17113 rm $DIR/$tdir/foo2/maggie
17116 local longname=$tfile.avg_len_is_thirty_two_
17117 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
17118 error_noexit 'failed to unlink many hardlinks'" EXIT
17119 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
17120 error "failed to hardlink many files"
17121 links=$($LFS fid2path $DIR $FID | wc -l)
17122 echo -n "${links}/1000 links in link EA"
17123 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
17125 run_test 161a "link ea sanity"
17128 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17129 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
17132 local remote_dir=$DIR/$tdir/remote_dir
17134 mkdir -p $DIR/$tdir
17135 $LFS mkdir -i $MDTIDX $remote_dir ||
17136 error "create remote directory failed"
17138 cp /etc/hosts $remote_dir/$tfile
17139 mkdir -p $remote_dir/foo1
17140 mkdir -p $remote_dir/foo2
17141 ln $remote_dir/$tfile $remote_dir/foo1/sofia
17142 ln $remote_dir/$tfile $remote_dir/foo2/zachary
17143 ln $remote_dir/$tfile $remote_dir/foo1/luna
17144 ln $remote_dir/$tfile $remote_dir/foo2/thor
17146 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
17148 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
17149 $LFS fid2path $DIR $FID
17150 error "bad link ea"
17153 rm $remote_dir/foo2/zachary
17155 rm $remote_dir/foo2/thor
17157 rm $remote_dir/$tfile
17159 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
17160 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
17161 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
17162 $LFS fid2path $DIR $FID
17163 error "bad link rename"
17165 rm $remote_dir/foo2/maggie
17168 local longname=filename_avg_len_is_thirty_two_
17169 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
17170 error "failed to hardlink many files"
17171 links=$($LFS fid2path $DIR $FID | wc -l)
17172 echo -n "${links}/1000 links in link EA"
17173 [[ ${links} -gt 60 ]] ||
17174 error "expected at least 60 links in link EA"
17175 unlinkmany $remote_dir/foo2/$longname 1000 ||
17176 error "failed to unlink many hardlinks"
17178 run_test 161b "link ea sanity under remote directory"
17181 remote_mds_nodsh && skip "remote MDS with nodsh"
17182 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17183 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
17184 skip "Need MDS version at least 2.1.5"
17186 # define CLF_RENAME_LAST 0x0001
17187 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
17188 changelog_register || error "changelog_register failed"
17191 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
17192 touch $DIR/$tdir/foo_161c
17193 touch $DIR/$tdir/bar_161c
17194 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17195 changelog_dump | grep RENME | tail -n 5
17196 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17197 changelog_clear 0 || error "changelog_clear failed"
17198 if [ x$flags != "x0x1" ]; then
17199 error "flag $flags is not 0x1"
17202 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
17203 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
17204 touch $DIR/$tdir/foo_161c
17205 touch $DIR/$tdir/bar_161c
17206 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17207 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
17208 changelog_dump | grep RENME | tail -n 5
17209 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
17210 changelog_clear 0 || error "changelog_clear failed"
17211 if [ x$flags != "x0x0" ]; then
17212 error "flag $flags is not 0x0"
17214 echo "rename overwrite a target having nlink > 1," \
17215 "changelog record has flags of $flags"
17217 # rename doesn't overwrite a target (changelog flag 0x0)
17218 touch $DIR/$tdir/foo_161c
17219 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
17220 changelog_dump | grep RENME | tail -n 5
17221 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
17222 changelog_clear 0 || error "changelog_clear failed"
17223 if [ x$flags != "x0x0" ]; then
17224 error "flag $flags is not 0x0"
17226 echo "rename doesn't overwrite a target," \
17227 "changelog record has flags of $flags"
17229 # define CLF_UNLINK_LAST 0x0001
17230 # unlink a file having nlink = 1 (changelog flag 0x1)
17231 rm -f $DIR/$tdir/foo2_161c
17232 changelog_dump | grep UNLNK | tail -n 5
17233 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17234 changelog_clear 0 || error "changelog_clear failed"
17235 if [ x$flags != "x0x1" ]; then
17236 error "flag $flags is not 0x1"
17238 echo "unlink a file having nlink = 1," \
17239 "changelog record has flags of $flags"
17241 # unlink a file having nlink > 1 (changelog flag 0x0)
17242 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
17243 rm -f $DIR/$tdir/foobar_161c
17244 changelog_dump | grep UNLNK | tail -n 5
17245 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
17246 changelog_clear 0 || error "changelog_clear failed"
17247 if [ x$flags != "x0x0" ]; then
17248 error "flag $flags is not 0x0"
17250 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
17252 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
17255 remote_mds_nodsh && skip "remote MDS with nodsh"
17256 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
17261 changelog_register || error "changelog_register failed"
17263 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
17264 # interfer with $MOUNT/.lustre/fid/ access
17266 [[ $? -eq 0 ]] || error "mkdir failed"
17268 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
17269 $LCTL set_param fail_loc=0x8000140c
17271 $LCTL set_param fail_val=5
17274 echo foofoo > $DIR/$tdir/$tfile &
17277 # wait for create to be delayed
17281 [[ $? -eq 0 ]] || error "create should be blocked"
17283 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
17284 stack_trap "rm -f $tempfile"
17285 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
17286 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
17287 # some delay may occur during ChangeLog publishing and file read just
17288 # above, that could allow file write to happen finally
17289 [[ -s $tempfile ]] && echo "file should be empty"
17291 $LCTL set_param fail_loc=0
17294 [[ $? -eq 0 ]] || error "create failed"
17296 run_test 161d "create with concurrent .lustre/fid access"
17299 local expected="$1"
17304 path=$($LFS fid2path "$@")
17307 if [ $rc -ne 0 ]; then
17308 error "path looked up of '$expected' failed: rc=$rc"
17309 elif [ "$path" != "$expected" ]; then
17310 error "path looked up '$path' instead of '$expected'"
17312 echo "FID '$fid' resolves to path '$path' as expected"
17316 test_162a() { # was test_162
17317 test_mkdir -p -c1 $DIR/$tdir/d2
17318 touch $DIR/$tdir/d2/$tfile
17319 touch $DIR/$tdir/d2/x1
17320 touch $DIR/$tdir/d2/x2
17321 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
17322 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
17324 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
17325 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
17328 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
17329 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
17330 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
17332 # softlink to wrong file
17333 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
17334 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
17335 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
17338 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
17339 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
17340 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
17341 # fid2path dir/fsname should both work
17342 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
17343 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
17345 # hardlink count: check that there are 2 links
17346 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
17347 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
17349 # hardlink indexing: remove the first link
17350 rm $DIR/$tdir/d2/p/q/r/hlink
17351 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
17353 run_test 162a "path lookup sanity"
17356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17357 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17360 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17361 error "create striped dir failed"
17363 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
17364 tail -n 1 | awk '{print $2}')
17365 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
17367 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
17368 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
17371 for ((i=0;i<5;i++)); do
17372 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
17373 error "get fid for f$i failed"
17374 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
17376 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
17377 error "get fid for d$i failed"
17378 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
17383 run_test 162b "striped directory path lookup sanity"
17385 # LU-4239: Verify fid2path works with paths 100 or more directories deep
17387 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
17388 skip "Need MDS version at least 2.7.51"
17390 local lpath=$tdir.local
17391 local rpath=$tdir.remote
17393 test_mkdir $DIR/$lpath
17394 test_mkdir $DIR/$rpath
17396 for ((i = 0; i <= 101; i++)); do
17399 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
17400 error "get fid for local directory $DIR/$lpath failed"
17401 check_path "$DIR/$lpath" $MOUNT $FID --link 0
17404 test_mkdir $DIR/$rpath
17405 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
17406 error "get fid for remote directory $DIR/$rpath failed"
17407 check_path "$DIR/$rpath" $MOUNT $FID --link 0
17412 run_test 162c "fid2path works with paths 100 or more directories deep"
17414 oalr_event_count() {
17418 awk -v name="${FSNAME}-OST0000" \
17419 -v event="${event}" \
17420 '$1 == "TRACE" && $2 == event && $3 == name' \
17425 oalr_expect_event_count() {
17428 local expect="${3}"
17431 count=$(oalr_event_count "${event}" "${trace}")
17432 if ((count == expect)); then
17436 error_noexit "${event} event count was '${count}', expected ${expect}"
17442 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
17444 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
17448 sync # Flush previous IOs so we can count log entries.
17449 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
17450 stack_trap cleanup_165 EXIT
17454 local trace="/tmp/${tfile}.trace"
17458 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17459 skip "OFD access log unsupported"
17462 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17465 do_facet ost1 ofd_access_log_reader --list
17468 do_facet ost1 killall -TERM ofd_access_log_reader
17472 if ((rc != 0)); then
17473 error "ofd_access_log_reader exited with rc = '${rc}'"
17476 # Parse trace file for discovery events:
17477 oalr_expect_event_count alr_log_add "${trace}" 1
17478 oalr_expect_event_count alr_log_eof "${trace}" 1
17479 oalr_expect_event_count alr_log_free "${trace}" 1
17481 run_test 165a "ofd access log discovery"
17484 local trace="/tmp/${tfile}.trace"
17485 local file="${DIR}/${tfile}"
17494 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17495 skip "OFD access log unsupported"
17498 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17501 do_facet ost1 ofd_access_log_reader --list
17503 lfs setstripe -c 1 -i 0 "${file}"
17504 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17505 error "cannot create '${file}'"
17508 do_facet ost1 killall -TERM ofd_access_log_reader
17512 if ((rc != 0)); then
17513 error "ofd_access_log_reader exited with rc = '${rc}'"
17516 oalr_expect_event_count alr_log_entry "${trace}" 1
17518 pfid1=$($LFS path2fid "${file}")
17520 # 1 2 3 4 5 6 7 8 9 10
17521 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
17522 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17524 echo "entry = '${entry[*]}'" >&2
17527 if [[ "${pfid1}" != "${pfid2}" ]]; then
17528 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17532 if ((size != 1048576)); then
17533 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
17537 if [[ "${flags}" != "w" ]]; then
17538 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
17541 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17544 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c ||
17545 error "cannot read '${file}'"
17548 do_facet ost1 killall -TERM ofd_access_log_reader
17552 if ((rc != 0)); then
17553 error "ofd_access_log_reader exited with rc = '${rc}'"
17556 oalr_expect_event_count alr_log_entry "${trace}" 1
17558 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
17559 echo "entry = '${entry[*]}'" >&2
17562 if [[ "${pfid1}" != "${pfid2}" ]]; then
17563 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
17567 if ((size != 524288)); then
17568 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
17572 if [[ "${flags}" != "r" ]]; then
17573 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
17576 run_test 165b "ofd access log entries are produced and consumed"
17579 local trace="/tmp/${tfile}.trace"
17580 local file="${DIR}/${tdir}/${tfile}"
17582 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17583 skip "OFD access log unsupported"
17585 test_mkdir "${DIR}/${tdir}"
17588 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
17591 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
17593 # 4096 / 64 = 64. Create twice as many entries.
17594 for ((i = 0; i < 128; i++)); do
17595 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c ||
17596 error "cannot create file"
17601 do_facet ost1 killall -TERM ofd_access_log_reader
17604 if ((rc != 0)); then
17605 error "ofd_access_log_reader exited with rc = '${rc}'"
17608 unlinkmany "${file}-%d" 128
17610 run_test 165c "full ofd access logs do not block IOs"
17612 oal_get_read_count() {
17615 # STATS lustre-OST0001 alr_read_count 1
17617 do_facet ost1 cat "${stats}" |
17618 awk '$1 == "STATS" && $3 == "alr_read_count" { count = $4; }
17619 END { print count; }'
17622 oal_expect_read_count() {
17627 # Ask ofd_access_log_reader to write stats.
17628 do_facet ost1 killall -USR1 ofd_access_log_reader
17630 # Allow some time for things to happen.
17633 count=$(oal_get_read_count "${stats}")
17634 if ((count == expect)); then
17638 error_noexit "bad read count, got ${count}, expected ${expect}"
17639 do_facet ost1 cat "${stats}" >&2
17644 local stats="/tmp/${tfile}.stats"
17645 local file="${DIR}/${tdir}/${tfile}"
17646 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
17648 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17649 skip "OFD access log unsupported"
17651 test_mkdir "${DIR}/${tdir}"
17654 do_facet ost1 ofd_access_log_reader --stats="${stats}" &
17657 lfs setstripe -c 1 -i 0 "${file}"
17659 do_facet ost1 lctl set_param "${param}=rw"
17660 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17661 error "cannot create '${file}'"
17662 oal_expect_read_count "${stats}" 1
17664 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17665 error "cannot read '${file}'"
17666 oal_expect_read_count "${stats}" 2
17668 do_facet ost1 lctl set_param "${param}=r"
17669 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17670 error "cannot create '${file}'"
17671 oal_expect_read_count "${stats}" 2
17673 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17674 error "cannot read '${file}'"
17675 oal_expect_read_count "${stats}" 3
17677 do_facet ost1 lctl set_param "${param}=w"
17678 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17679 error "cannot create '${file}'"
17680 oal_expect_read_count "${stats}" 4
17682 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17683 error "cannot read '${file}'"
17684 oal_expect_read_count "${stats}" 4
17686 do_facet ost1 lctl set_param "${param}=0"
17687 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c ||
17688 error "cannot create '${file}'"
17689 oal_expect_read_count "${stats}" 4
17691 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c ||
17692 error "cannot read '${file}'"
17693 oal_expect_read_count "${stats}" 4
17695 do_facet ost1 killall -TERM ofd_access_log_reader
17698 if ((rc != 0)); then
17699 error "ofd_access_log_reader exited with rc = '${rc}'"
17702 run_test 165d "ofd_access_log mask works"
17705 local stats="/tmp/${tfile}.stats"
17706 local file0="${DIR}/${tdir}-0/${tfile}"
17707 local file1="${DIR}/${tdir}-1/${tfile}"
17709 (( $OST1_VERSION >= $(version_code 2.13.54) )) ||
17710 skip "OFD access log unsupported"
17712 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
17714 test_mkdir -c 1 -i 0 "${DIR}/${tdir}-0"
17715 test_mkdir -c 1 -i 1 "${DIR}/${tdir}-1"
17717 lfs setstripe -c 1 -i 0 "${file0}"
17718 lfs setstripe -c 1 -i 0 "${file1}"
17721 do_facet ost1 ofd_access_log_reader -I 1 --stats="${stats}" &
17724 $MULTIOP "${file0}" oO_CREAT:O_WRONLY:w512c ||
17725 error "cannot create '${file0}'"
17727 oal_expect_read_count "${stats}" 0
17729 $MULTIOP "${file1}" oO_CREAT:O_WRONLY:w512c ||
17730 error "cannot create '${file1}'"
17732 oal_expect_read_count "${stats}" 1
17734 do_facet ost1 killall -TERM ofd_access_log_reader
17737 if ((rc != 0)); then
17738 error "ofd_access_log_reader exited with rc = '${rc}'"
17741 run_test 165e "ofd_access_log MDT index filter works"
17744 local trace="/tmp/${tfile}.trace"
17749 do_facet ost1 timeout 60 ofd_access_log_reader \
17750 --exit-on-close --debug=- --trace=- > "${trace}" &
17757 if ((rc != 0)); then
17758 error_noexit "ofd_access_log_reader exited with rc = '${rc}'"
17763 run_test 165f "ofd_access_log_reader --exit-on-close works"
17766 # do directio so as not to populate the page cache
17767 log "creating a 10 Mb file"
17768 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c ||
17769 error "multiop failed while creating a file"
17770 log "starting reads"
17771 dd if=$DIR/$tfile of=/dev/null bs=4096 &
17772 log "truncating the file"
17773 $MULTIOP $DIR/$tfile oO_TRUNC:c ||
17774 error "multiop failed while truncating the file"
17776 kill %+ || true # reads might have finished
17777 echo "wait until dd is finished"
17779 log "removing the temporary file"
17780 rm -rf $DIR/$tfile || error "tmp file removal failed"
17782 run_test 169 "parallel read and truncate should not deadlock"
17785 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17787 $LCTL clear # bug 18514
17788 $LCTL debug_daemon start $TMP/${tfile}_log_good
17790 $LCTL debug_daemon stop
17791 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
17792 error "sed failed to read log_good"
17794 $LCTL debug_daemon start $TMP/${tfile}_log_good
17796 $LCTL debug_daemon stop
17798 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
17799 error "lctl df log_bad failed"
17801 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17802 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17804 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
17805 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
17807 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
17808 error "bad_line good_line1 good_line2 are empty"
17810 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17811 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
17812 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
17814 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
17815 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
17816 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
17818 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
17819 error "bad_line_new good_line_new are empty"
17821 local expected_good=$((good_line1 + good_line2*2))
17823 rm -f $TMP/${tfile}*
17824 # LU-231, short malformed line may not be counted into bad lines
17825 if [ $bad_line -ne $bad_line_new ] &&
17826 [ $bad_line -ne $((bad_line_new - 1)) ]; then
17827 error "expected $bad_line bad lines, but got $bad_line_new"
17831 if [ $expected_good -ne $good_line_new ]; then
17832 error "expected $expected_good good lines, but got $good_line_new"
17837 run_test 170 "test lctl df to handle corrupted log ====================="
17839 test_171() { # bug20592
17840 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17842 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
17843 $LCTL set_param fail_loc=0x50e
17844 $LCTL set_param fail_val=3000
17845 multiop_bg_pause $DIR/$tfile O_s || true
17847 kill -USR1 $MULTIPID
17851 if dmesg | grep "recursive fault"; then
17852 error "caught a recursive fault"
17854 $LCTL set_param fail_loc=0
17857 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
17861 #define OBD_FAIL_OBD_CLEANUP 0x60e
17862 $LCTL set_param fail_loc=0x60e
17863 umount $MOUNT || error "umount $MOUNT failed"
17864 stack_trap "mount_client $MOUNT"
17866 (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )) ||
17867 error "no client OBDs are remained"
17869 $LCTL dl | while read devno state type name foo; do
17872 $LCTL --device $name cleanup
17873 $LCTL --device $name detach
17876 # skip server devices
17881 if (( $($LCTL dl | egrep -c " osc | lov | lmv | mdc ") > 0 )); then
17882 $LCTL dl | egrep " osc | lov | lmv | mdc "
17883 error "some client OBDs are still remained"
17887 run_test 172 "manual device removal with lctl cleanup/detach ======"
17889 # it would be good to share it with obdfilter-survey/iokit-libecho code
17890 setup_obdecho_osc () {
17893 local obdfilter_name=$2
17894 echo "Creating new osc for $obdfilter_name on $ost_nid"
17895 # make sure we can find loopback nid
17896 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
17898 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
17899 ${obdfilter_name}_osc_UUID || rc=2; }
17900 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
17901 ${obdfilter_name}_UUID $ost_nid || rc=3; }
17905 cleanup_obdecho_osc () {
17906 local obdfilter_name=$1
17907 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
17908 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
17915 local pages=${3:-64}
17920 local obd_size=$(get_obd_size $node $OBD)
17921 local page_size=$(get_page_size $node)
17922 if [[ -n "$obd_size" ]]; then
17923 local new_count=$((obd_size / (pages * page_size / 1024)))
17924 [[ $new_count -ge $count ]] || count=$new_count
17927 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
17928 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
17930 if [ $rc -eq 0 ]; then
17931 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
17932 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
17934 echo "New object id is $id"
17935 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
17937 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
17938 "test_brw $count w v $pages $id" || rc=4; }
17939 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
17941 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
17942 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
17943 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
17944 { do_facet $node "$LCTL --device ec detach" || rc=6; }
17945 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
17950 skip "obdecho on osc is no longer supported"
17952 run_test 180a "test obdecho on osc"
17955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17956 remote_ost_nodsh && skip "remote OST with nodsh"
17958 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17959 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17960 error "failed to load module obdecho"
17962 local target=$(do_facet ost1 $LCTL dl |
17963 awk '/obdfilter/ { print $4; exit; }')
17965 if [ -n "$target" ]; then
17966 obdecho_test $target ost1 || error "obdecho_test failed with $?"
17968 do_facet ost1 $LCTL dl
17969 error "there is no obdfilter target on ost1"
17972 run_test 180b "test obdecho directly on obdfilter"
17974 test_180c() { # LU-2598
17975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17976 remote_ost_nodsh && skip "remote OST with nodsh"
17977 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
17978 skip "Need MDS version at least 2.4.0"
17980 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
17981 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
17982 error "failed to load module obdecho"
17984 local target=$(do_facet ost1 $LCTL dl |
17985 awk '/obdfilter/ { print $4; exit; }')
17987 if [ -n "$target" ]; then
17988 local pages=16384 # 64MB bulk I/O RPC size
17990 obdecho_test "$target" ost1 "$pages" ||
17991 error "obdecho_test with pages=$pages failed with $?"
17993 do_facet ost1 $LCTL dl
17994 error "there is no obdfilter target on ost1"
17997 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
17999 test_181() { # bug 22177
18000 test_mkdir $DIR/$tdir
18001 # create enough files to index the directory
18002 createmany -o $DIR/$tdir/foobar 4000
18003 # print attributes for debug purpose
18006 multiop_bg_pause $DIR/$tdir D_Sc || return 1
18008 # remove the files & current working dir
18009 unlinkmany $DIR/$tdir/foobar 4000
18011 kill -USR1 $MULTIPID
18013 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
18016 run_test 181 "Test open-unlinked dir ========================"
18022 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18024 $LCTL set_param mdc.*.rpc_stats=clear
18026 for (( i = 0; i < $tcount; i++ )) ; do
18027 mkdir $DIR/$tdir/$i
18030 for (( i = 0; i < $tcount; i++ )) ; do
18031 createmany -o $DIR/$tdir/$i/f- $fcount &
18035 for (( i = 0; i < $tcount; i++ )) ; do
18036 unlinkmany $DIR/$tdir/$i/f- $fcount &
18040 $LCTL get_param mdc.*.rpc_stats
18044 run_test 182a "Test parallel modify metadata operations from mdc"
18047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18048 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18055 do_facet mds1 $LCTL list_param \
18056 osp.$FSNAME-MDT*-osp-MDT*.rpc_stats ||
18057 skip "MDS lacks parallel RPC handling"
18059 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18061 rpc_count=$(do_facet mds1 $LCTL get_param -n \
18062 osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight)
18065 createmany -i 0 -d $DIR/$tdir/t- $tcount
18067 for (( i = 0; i < $tcount; i++ )) ; do
18068 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18072 delta=$((etime - stime))
18073 echo "Time for file creation $delta sec for $rpc_count parallel RPCs"
18076 for (( i = 0; i < $tcount; i++ )) ; do
18077 unlinkmany -d $DIR/$tdir/$i/d- $dcount &
18081 delta=$((etime - stime))
18082 echo "Time for file removal $delta sec for $rpc_count parallel RPCs"
18086 $LFS mkdir -i 0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18088 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=1
18091 createmany -i 0 -d $DIR/$tdir/t- $tcount
18093 for (( i = 0; i < $tcount; i++ )) ; do
18094 createmany -i 0 -d $DIR/$tdir/t-$i/d- 0 $dcount &
18098 delta=$((etime - stime))
18099 echo "Time for file creation $delta sec for 1 RPC sent at a time"
18102 for (( i = 0; i < $tcount; i++ )) ; do
18103 unlinkmany -d $DIR/$tdir/t-$i/d- $dcount &
18107 delta=$((etime - stime))
18108 echo "Time for file removal $delta sec for 1 RPC sent at a time"
18110 do_facet mds1 $LCTL set_param osp.$FSNAME-MDT0001-osp-MDT0000.max_mod_rpcs_in_flight=$rpc_count
18112 run_test 182b "Test parallel modify metadata operations from osp"
18114 test_183() { # LU-2275
18115 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18116 remote_mds_nodsh && skip "remote MDS with nodsh"
18117 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
18118 skip "Need MDS version at least 2.3.56"
18120 mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
18121 echo aaa > $DIR/$tdir/$tfile
18123 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
18124 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
18126 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
18127 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
18129 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18131 # Flush negative dentry cache
18132 touch $DIR/$tdir/$tfile
18134 # We are not checking for any leaked references here, they'll
18135 # become evident next time we do cleanup with module unload.
18138 run_test 183 "No crash or request leak in case of strange dispositions ========"
18140 # test suite 184 is for LU-2016, LU-2017
18142 check_swap_layouts_support
18144 dir0=$DIR/$tdir/$testnum
18145 test_mkdir -p -c1 $dir0
18150 $LFS setstripe -c1 $file1
18152 $LFS setstripe -c2 $file2
18154 gen1=$($LFS getstripe -g $file1)
18155 gen2=$($LFS getstripe -g $file2)
18157 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
18158 gen=$($LFS getstripe -g $file1)
18159 [[ $gen1 != $gen ]] ||
18160 error "Layout generation on $file1 does not change"
18161 gen=$($LFS getstripe -g $file2)
18162 [[ $gen2 != $gen ]] ||
18163 error "Layout generation on $file2 does not change"
18165 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
18166 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
18168 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
18170 run_test 184a "Basic layout swap"
18173 check_swap_layouts_support
18175 dir0=$DIR/$tdir/$testnum
18176 mkdir -p $dir0 || error "creating dir $dir0"
18183 $LFS setstripe -c1 $file1
18184 $LFS setstripe -c2 $file2
18185 $LFS setstripe -c1 $file3
18186 chown $RUNAS_ID $file3
18187 gen1=$($LFS getstripe -g $file1)
18188 gen2=$($LFS getstripe -g $file2)
18190 $LFS swap_layouts $dir1 $dir2 &&
18191 error "swap of directories layouts should fail"
18192 $LFS swap_layouts $dir1 $file1 &&
18193 error "swap of directory and file layouts should fail"
18194 $RUNAS $LFS swap_layouts $file1 $file2 &&
18195 error "swap of file we cannot write should fail"
18196 $LFS swap_layouts $file1 $file3 &&
18197 error "swap of file with different owner should fail"
18198 /bin/true # to clear error code
18200 run_test 184b "Forbidden layout swap (will generate errors)"
18203 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
18204 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
18205 check_swap_layouts_support
18206 check_swap_layout_no_dom $DIR
18208 local dir0=$DIR/$tdir/$testnum
18209 mkdir -p $dir0 || error "creating dir $dir0"
18211 local ref1=$dir0/ref1
18212 local ref2=$dir0/ref2
18213 local file1=$dir0/file1
18214 local file2=$dir0/file2
18215 # create a file large enough for the concurrent test
18216 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
18217 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
18218 echo "ref file size: ref1($(stat -c %s $ref1))," \
18219 "ref2($(stat -c %s $ref2))"
18222 dd if=$ref1 of=$file1 bs=16k &
18225 # Make sure dd starts to copy file, but wait at most 5 seconds
18227 while [ ! -s $file1 -a $((loops++)) -lt 50 ]; do sleep 0.1; done
18229 $LFS swap_layouts $file1 $file2
18232 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
18233 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
18235 # how many bytes copied before swapping layout
18236 local copied=$(stat -c %s $file2)
18237 local remaining=$(stat -c %s $ref1)
18238 remaining=$((remaining - copied))
18239 echo "Copied $copied bytes before swapping layout..."
18241 cmp -n $copied $file1 $ref2 | grep differ &&
18242 error "Content mismatch [0, $copied) of ref2 and file1"
18243 cmp -n $copied $file2 $ref1 ||
18244 error "Content mismatch [0, $copied) of ref1 and file2"
18245 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
18246 error "Content mismatch [$copied, EOF) of ref1 and file1"
18249 rm -f $ref1 $ref2 $file1 $file2
18251 run_test 184c "Concurrent write and layout swap"
18254 check_swap_layouts_support
18255 check_swap_layout_no_dom $DIR
18256 [ -z "$(which getfattr 2>/dev/null)" ] &&
18257 skip_env "no getfattr command"
18259 local file1=$DIR/$tdir/$tfile-1
18260 local file2=$DIR/$tdir/$tfile-2
18261 local file3=$DIR/$tdir/$tfile-3
18265 mkdir -p $DIR/$tdir
18266 touch $file1 || error "create $file1 failed"
18267 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18268 error "create $file2 failed"
18269 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18270 error "create $file3 failed"
18271 lovea1=$(get_layout_param $file1)
18273 $LFS swap_layouts $file2 $file3 ||
18274 error "swap $file2 $file3 layouts failed"
18275 $LFS swap_layouts $file1 $file2 ||
18276 error "swap $file1 $file2 layouts failed"
18278 lovea2=$(get_layout_param $file2)
18281 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
18283 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18284 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
18286 run_test 184d "allow stripeless layouts swap"
18289 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
18290 skip "Need MDS version at least 2.6.94"
18291 check_swap_layouts_support
18292 check_swap_layout_no_dom $DIR
18293 [ -z "$(which getfattr 2>/dev/null)" ] &&
18294 skip_env "no getfattr command"
18296 local file1=$DIR/$tdir/$tfile-1
18297 local file2=$DIR/$tdir/$tfile-2
18298 local file3=$DIR/$tdir/$tfile-3
18301 mkdir -p $DIR/$tdir
18302 touch $file1 || error "create $file1 failed"
18303 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
18304 error "create $file2 failed"
18305 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
18306 error "create $file3 failed"
18308 $LFS swap_layouts $file1 $file2 ||
18309 error "swap $file1 $file2 layouts failed"
18311 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
18312 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
18314 echo 123 > $file1 || error "Should be able to write into $file1"
18316 $LFS swap_layouts $file1 $file3 ||
18317 error "swap $file1 $file3 layouts failed"
18319 echo 123 > $file1 || error "Should be able to write into $file1"
18321 rm -rf $file1 $file2 $file3
18323 run_test 184e "Recreate layout after stripeless layout swaps"
18326 # Create a file with name longer than sizeof(struct stat) ==
18327 # 144 to see if we can get chars from the file name to appear
18328 # in the returned striping. Note that 'f' == 0x66.
18329 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
18331 mkdir -p $DIR/$tdir
18332 mcreate $DIR/$tdir/$file
18333 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
18334 error "IOC_MDC_GETFILEINFO returned garbage striping"
18337 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
18339 test_185() { # LU-2441
18340 # LU-3553 - no volatile file support in old servers
18341 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
18342 skip "Need MDS version at least 2.3.60"
18344 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
18345 touch $DIR/$tdir/spoo
18346 local mtime1=$(stat -c "%Y" $DIR/$tdir)
18347 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
18348 error "cannot create/write a volatile file"
18349 [ "$FILESET" == "" ] &&
18350 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
18351 error "FID is still valid after close"
18353 multiop_bg_pause $DIR/$tdir vVw4096_c
18360 # assume that the next FID for this client is sequential, since stdout
18361 # is unfortunately eaten by multiop_bg_pause
18362 local n=$((${fidv[1]} + 1))
18363 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
18364 if [ "$FILESET" == "" ]; then
18365 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
18366 error "FID is missing before close"
18368 kill -USR1 $multi_pid
18369 # 1 second delay, so if mtime change we will see it
18371 local mtime2=$(stat -c "%Y" $DIR/$tdir)
18372 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
18374 run_test 185 "Volatile file support"
18376 function create_check_volatile() {
18380 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
18383 local FID=$(cat /tmp/${tfile}.fid)
18384 [ "$FID" == "" ] && error "can't get FID for volatile"
18385 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
18386 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
18387 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
18391 cancel_lru_locks mdc # flush opencache
18392 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
18397 # LU-12516 - volatile creation via .lustre
18398 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
18399 skip "Need MDS version at least 2.3.55"
18401 create_check_volatile 0
18402 [ $MDSCOUNT -lt 2 ] && return 0
18405 create_check_volatile 1
18409 run_test 185a "Volatile file creation in .lustre/fid/"
18412 remote_mds_nodsh && skip "remote MDS with nodsh"
18413 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18414 skip "Need MDS version at least 2.3.0"
18416 local dir0=$DIR/$tdir/$testnum
18417 mkdir -p $dir0 || error "creating dir $dir0"
18419 local file=$dir0/file1
18420 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
18421 local dv1=$($LFS data_version $file)
18422 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
18423 local dv2=$($LFS data_version $file)
18424 [[ $dv1 != $dv2 ]] ||
18425 error "data version did not change on write $dv1 == $dv2"
18430 run_test 187a "Test data version change"
18433 remote_mds_nodsh && skip "remote MDS with nodsh"
18434 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
18435 skip "Need MDS version at least 2.3.0"
18437 local dir0=$DIR/$tdir/$testnum
18438 mkdir -p $dir0 || error "creating dir $dir0"
18440 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
18441 [[ ${DV[0]} != ${DV[1]} ]] ||
18442 error "data version did not change on write"\
18443 " ${DV[0]} == ${DV[1]}"
18448 run_test 187b "Test data version change on volatile file"
18451 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18452 remote_mgs_nodsh && skip "remote MGS with nodsh"
18453 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
18455 local POOL=${POOL:-cea1}
18456 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
18457 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
18460 local last_ost=$(($OSTCOUNT - 1))
18462 local ost_list=$(seq $first_ost $ost_step $last_ost)
18463 local ost_range="$first_ost $last_ost $ost_step"
18464 local test_path=$POOL_ROOT/$POOL_DIR_NAME
18465 local file_dir=$POOL_ROOT/file_tst
18466 local subdir=$test_path/subdir
18470 # former test_200a test_200b
18471 pool_add $POOL || { rc=$? ; break; }
18472 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
18473 # former test_200c test_200d
18474 mkdir -p $test_path
18475 pool_set_dir $POOL $test_path || { rc=$? ; break; }
18476 pool_check_dir $POOL $test_path || { rc=$? ; break; }
18478 pool_check_dir $POOL $subdir || { rc=$? ; break; }
18479 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
18480 || { rc=$? ; break; }
18481 # former test_200e test_200f
18482 local files=$((OSTCOUNT*3))
18483 pool_alloc_files $POOL $test_path $files "$ost_list" \
18484 || { rc=$? ; break; }
18485 pool_create_files $POOL $file_dir $files "$ost_list" \
18486 || { rc=$? ; break; }
18487 # former test_200g test_200h
18488 pool_lfs_df $POOL || { rc=$? ; break; }
18489 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
18491 # former test_201a test_201b test_201c
18492 pool_remove_first_target $POOL || { rc=$? ; break; }
18494 local f=$test_path/$tfile
18495 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
18496 pool_remove $POOL $f || { rc=$? ; break; }
18504 run_test 200 "OST pools"
18506 # usage: default_attr <count | size | offset>
18508 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
18511 # usage: check_default_stripe_attr
18512 check_default_stripe_attr() {
18513 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
18516 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
18518 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
18522 error "unknown getstripe attr '$1'"
18525 [ $ACTUAL == $EXPECTED ] ||
18526 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
18530 test_mkdir $DIR/$tdir
18531 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
18533 check_default_stripe_attr --stripe-count
18534 check_default_stripe_attr --stripe-size
18535 check_default_stripe_attr --stripe-index
18537 run_test 204a "Print default stripe attributes"
18540 test_mkdir $DIR/$tdir
18541 $LFS setstripe --stripe-count 1 $DIR/$tdir
18543 check_default_stripe_attr --stripe-size
18544 check_default_stripe_attr --stripe-index
18546 run_test 204b "Print default stripe size and offset"
18549 test_mkdir $DIR/$tdir
18550 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18552 check_default_stripe_attr --stripe-count
18553 check_default_stripe_attr --stripe-index
18555 run_test 204c "Print default stripe count and offset"
18558 test_mkdir $DIR/$tdir
18559 $LFS setstripe --stripe-index 0 $DIR/$tdir
18561 check_default_stripe_attr --stripe-count
18562 check_default_stripe_attr --stripe-size
18564 run_test 204d "Print default stripe count and size"
18567 test_mkdir $DIR/$tdir
18568 $LFS setstripe -d $DIR/$tdir
18570 check_default_stripe_attr --stripe-count --raw
18571 check_default_stripe_attr --stripe-size --raw
18572 check_default_stripe_attr --stripe-index --raw
18574 run_test 204e "Print raw stripe attributes"
18577 test_mkdir $DIR/$tdir
18578 $LFS setstripe --stripe-count 1 $DIR/$tdir
18580 check_default_stripe_attr --stripe-size --raw
18581 check_default_stripe_attr --stripe-index --raw
18583 run_test 204f "Print raw stripe size and offset"
18586 test_mkdir $DIR/$tdir
18587 $LFS setstripe --stripe-size 65536 $DIR/$tdir
18589 check_default_stripe_attr --stripe-count --raw
18590 check_default_stripe_attr --stripe-index --raw
18592 run_test 204g "Print raw stripe count and offset"
18595 test_mkdir $DIR/$tdir
18596 $LFS setstripe --stripe-index 0 $DIR/$tdir
18598 check_default_stripe_attr --stripe-count --raw
18599 check_default_stripe_attr --stripe-size --raw
18601 run_test 204h "Print raw stripe count and size"
18603 # Figure out which job scheduler is being used, if any,
18604 # or use a fake one
18605 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
18606 JOBENV=SLURM_JOB_ID
18607 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
18609 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
18611 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
18612 JOBENV=LOADL_STEP_ID
18613 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
18616 $LCTL list_param jobid_name > /dev/null 2>&1
18617 if [ $? -eq 0 ]; then
18623 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
18625 verify_jobstats() {
18630 # we don't really need to clear the stats for this test to work, since each
18631 # command has a unique jobid, but it makes debugging easier if needed.
18632 # for facet in $facets; do
18633 # local dev=$(convert_facet2label $facet)
18634 # # clear old jobstats
18635 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
18638 # use a new JobID for each test, or we might see an old one
18639 [ "$JOBENV" = "FAKE_JOBID" ] &&
18640 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
18642 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
18644 [ "$JOBENV" = "nodelocal" ] && {
18645 FAKE_JOBID=id.$testnum.%e.$RANDOM
18646 $LCTL set_param jobid_name=$FAKE_JOBID
18647 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
18650 log "Test: ${cmd[*]}"
18651 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
18653 if [ $JOBENV = "FAKE_JOBID" ]; then
18654 FAKE_JOBID=$JOBVAL ${cmd[*]}
18659 # all files are created on OST0000
18660 for facet in $facets; do
18661 local stats="*.$(convert_facet2label $facet).job_stats"
18663 # strip out libtool wrappers for in-tree executables
18664 if (( $(do_facet $facet lctl get_param $stats |
18665 sed -e 's/\.lt-/./' | grep -cw $JOBVAL) != 1 )); then
18666 do_facet $facet lctl get_param $stats
18667 error "No jobstats for $JOBVAL found on $facet::$stats"
18673 local new_jobenv=$1
18675 set_persistent_param_and_check client "jobid_var" \
18676 "$FSNAME.sys.jobid_var" $new_jobenv
18679 test_205a() { # Job stats
18680 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18681 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
18682 skip "Need MDS version with at least 2.7.1"
18683 remote_mgs_nodsh && skip "remote MGS with nodsh"
18684 remote_mds_nodsh && skip "remote MDS with nodsh"
18685 remote_ost_nodsh && skip "remote OST with nodsh"
18686 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
18687 skip "Server doesn't support jobstats"
18688 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
18690 local old_jobenv=$($LCTL get_param -n jobid_var)
18691 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
18693 if [[ $PERM_CMD == *"set_param -P"* ]]; then
18694 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
18696 stack_trap "do_facet mgs $PERM_CMD \
18697 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
18701 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
18702 mdt.*.job_cleanup_interval | head -n 1)
18703 local new_interval=5
18704 do_facet $SINGLEMDS \
18705 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
18706 stack_trap "do_facet $SINGLEMDS \
18707 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
18708 local start=$SECONDS
18712 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
18713 verify_jobstats "$cmd" "$SINGLEMDS"
18715 cmd="rmdir $DIR/$tdir"
18716 verify_jobstats "$cmd" "$SINGLEMDS"
18717 # mkdir on secondary MDT
18718 if [ $MDSCOUNT -gt 1 ]; then
18719 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
18720 verify_jobstats "$cmd" "mds2"
18723 cmd="mknod $DIR/$tfile c 1 3"
18724 verify_jobstats "$cmd" "$SINGLEMDS"
18726 cmd="rm -f $DIR/$tfile"
18727 verify_jobstats "$cmd" "$SINGLEMDS"
18728 # create all files on OST0000 so verify_jobstats can find OST stats
18730 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
18731 verify_jobstats "$cmd" "$SINGLEMDS"
18733 cmd="touch $DIR/$tfile"
18734 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18736 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
18737 verify_jobstats "$cmd" "ost1"
18739 cancel_lru_locks osc
18740 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
18741 verify_jobstats "$cmd" "ost1"
18743 cmd="$TRUNCATE $DIR/$tfile 0"
18744 verify_jobstats "$cmd" "$SINGLEMDS ost1"
18746 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
18747 verify_jobstats "$cmd" "$SINGLEMDS"
18748 # jobstats expiry - sleep until old stats should be expired
18749 local left=$((new_interval + 5 - (SECONDS - start)))
18750 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
18751 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
18753 cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
18754 verify_jobstats "$cmd" "$SINGLEMDS"
18755 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
18756 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
18758 # Ensure that jobid are present in changelog (if supported by MDS)
18759 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
18760 changelog_dump | tail -10
18761 jobids=$(changelog_dump | tail -9 | grep -c "j=")
18762 [ $jobids -eq 9 ] ||
18763 error "Wrong changelog jobid count $jobids != 9"
18767 jobstats_set $JOBENV
18769 changelog_dump | grep $tfile
18770 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
18771 [ $jobids -eq 0 ] ||
18772 error "Unexpected jobids when jobid_var=$JOBENV"
18775 # test '%j' access to environment variable - if supported
18776 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"; then
18777 JOBENV="JOBCOMPLEX"
18778 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
18780 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18783 if lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%H.E"; then
18784 JOBENV="JOBCOMPLEX"
18785 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname -s).E"
18787 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18790 # test '%j' access to per-session jobid - if supported
18791 if lctl list_param jobid_this_session > /dev/null 2>&1
18793 lctl set_param jobid_var=session jobid_name="S.%j.%e.%u.%h.E"
18794 lctl set_param jobid_this_session=$USER
18796 JOBENV="JOBCOMPLEX"
18797 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
18799 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
18802 run_test 205a "Verify job stats"
18804 # LU-13117, LU-13597
18806 (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
18807 skip "Need MDS version at least 2.13.54.91"
18809 local job_stats="mdt.*.job_stats"
18810 local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
18812 do_facet mds1 $LCTL set_param $job_stats=clear
18814 # Setting jobid_var to USER might not be supported
18815 [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
18816 $LCTL set_param jobid_var=USER || true
18817 stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
18818 $LCTL set_param jobid_name="%j.%e.%u"
18820 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
18821 do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
18822 { do_facet mds1 $LCTL get_param $job_stats;
18823 error "Unexpected jobid found"; }
18824 do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
18825 { do_facet mds1 $LCTL get_param $job_stats;
18826 error "wrong job_stats format found"; }
18828 (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
18829 echo "MDS does not yet escape jobid" && return 0
18830 $LCTL set_param jobid_var=TEST205b
18831 env -i TEST205b="has sp" touch $DIR/$tfile.2
18832 do_facet mds1 $LCTL get_param $job_stats | grep "has.*x20sp" ||
18833 { do_facet mds1 $LCTL get_param $job_stats;
18834 error "jobid not escaped"; }
18836 run_test 205b "Verify job stats jobid and output format"
18840 $LCTL set_param llite.*.stats=0
18841 dd if=/dev/zero of=$DIR/$tfile.1 bs=4k count=1
18842 $LCTL get_param llite.*.stats
18843 $LCTL get_param llite.*.stats | grep \
18844 "write_bytes *1 samples \[bytes\] 4096 4096 4096 16777216" ||
18845 error "wrong client stats format found"
18847 run_test 205c "Verify client stats format"
18849 # LU-1480, LU-1773 and LU-1657
18851 mkdir -p $DIR/$tdir
18852 $LFS setstripe -c -1 $DIR/$tdir
18853 #define OBD_FAIL_LOV_INIT 0x1403
18854 $LCTL set_param fail_loc=0xa0001403
18855 $LCTL set_param fail_val=1
18856 touch $DIR/$tdir/$tfile || true
18858 run_test 206 "fail lov_init_raid0() doesn't lbug"
18861 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18862 local fsz=`stat -c %s $DIR/$tfile`
18863 cancel_lru_locks mdc
18865 # do not return layout in getattr intent
18866 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
18867 $LCTL set_param fail_loc=0x170
18868 local sz=`stat -c %s $DIR/$tfile`
18870 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
18874 run_test 207a "can refresh layout at glimpse"
18877 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
18878 local cksum=`md5sum $DIR/$tfile`
18879 local fsz=`stat -c %s $DIR/$tfile`
18880 cancel_lru_locks mdc
18881 cancel_lru_locks osc
18883 # do not return layout in getattr intent
18884 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
18885 $LCTL set_param fail_loc=0x171
18887 # it will refresh layout after the file is opened but before read issues
18888 echo checksum is "$cksum"
18889 echo "$cksum" |md5sum -c --quiet || error "file differs"
18893 run_test 207b "can refresh layout at open"
18896 # FIXME: in this test suite, only RD lease is used. This is okay
18897 # for now as only exclusive open is supported. After generic lease
18898 # is done, this test suite should be revised. - Jinshan
18900 remote_mds_nodsh && skip "remote MDS with nodsh"
18901 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
18902 skip "Need MDS version at least 2.4.52"
18904 echo "==== test 1: verify get lease work"
18905 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
18907 echo "==== test 2: verify lease can be broken by upcoming open"
18908 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
18912 $MULTIOP $DIR/$tfile oO_RDWR:c
18913 kill -USR1 $PID && wait $PID || error "break lease error"
18915 echo "==== test 3: verify lease can't be granted if an open already exists"
18916 $MULTIOP $DIR/$tfile oO_RDWR:_c &
18920 $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
18921 kill -USR1 $PID && wait $PID || error "open file error"
18923 echo "==== test 4: lease can sustain over recovery"
18924 $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
18930 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
18932 echo "==== test 5: lease broken can't be regained by replay"
18933 $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
18937 # open file to break lease and then recovery
18938 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
18941 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
18945 run_test 208 "Exclusive open"
18948 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
18949 skip_env "must have disp_stripe"
18952 sync; sleep 5; sync;
18954 echo 3 > /proc/sys/vm/drop_caches
18955 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18956 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18957 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18959 # open/close 500 times
18960 for i in $(seq 500); do
18964 echo 3 > /proc/sys/vm/drop_caches
18965 [ -f /sys/kernel/slab/ptlrpc_cache/shrink ] &&
18966 echo 1 > /sys/kernel/slab/ptlrpc_cache/shrink
18967 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
18969 echo "before: $req_before, after: $req_after"
18970 [ $((req_after - req_before)) -ge 300 ] &&
18971 error "open/close requests are not freed"
18974 run_test 209 "read-only open/close requests should be freed promptly"
18979 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
18983 $LFS getstripe $DIR/$tfile
18985 wait $pid || error "multiop failed"
18987 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
18991 $LFS getstripe $DIR/$tfile
18993 wait $pid || error "multiop failed"
18995 run_test 210 "lfs getstripe does not break leases"
18999 size=$((size % 8192 + 1))
19000 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
19001 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
19002 rm -f $DIR/f212 $DIR/f212.xyz
19004 run_test 212 "Sendfile test ============================================"
19007 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
19008 cancel_lru_locks osc
19009 lctl set_param fail_loc=0x8000040f
19010 # generate a read lock
19011 cat $DIR/$tfile > /dev/null
19012 # write to the file, it will try to cancel the above read lock.
19013 cat /etc/hosts >> $DIR/$tfile
19015 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
19017 test_214() { # for bug 20133
19018 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
19019 for (( i=0; i < 340; i++ )) ; do
19020 touch $DIR/$tdir/d214c/a$i
19023 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
19024 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
19025 ls $DIR/d214c || error "ls $DIR/d214c failed"
19026 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
19027 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
19029 run_test 214 "hash-indexed directory test - bug 20133"
19031 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
19032 create_lnet_proc_files() {
19033 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
19036 # counterpart of create_lnet_proc_files
19037 remove_lnet_proc_files() {
19038 rm -f $TMP/lnet_$1.sys
19041 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19042 # 3rd arg as regexp for body
19043 check_lnet_proc_stats() {
19044 local l=$(cat "$TMP/lnet_$1" |wc -l)
19045 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
19047 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
19050 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
19051 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
19052 # optional and can be regexp for 2nd line (lnet.routes case)
19053 check_lnet_proc_entry() {
19054 local blp=2 # blp stands for 'position of 1st line of body'
19055 [ -z "$5" ] || blp=3 # lnet.routes case
19057 local l=$(cat "$TMP/lnet_$1" |wc -l)
19058 # subtracting one from $blp because the body can be empty
19059 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
19061 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
19062 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
19064 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
19065 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
19067 # bail out if any unexpected line happened
19068 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
19069 [ "$?" != 0 ] || error "$2 misformatted"
19072 test_215() { # for bugs 18102, 21079, 21517
19073 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19075 local N='(0|[1-9][0-9]*)' # non-negative numeric
19076 local P='[1-9][0-9]*' # positive numeric
19077 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
19078 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
19079 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
19080 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
19082 local L1 # regexp for 1st line
19083 local L2 # regexp for 2nd line (optional)
19084 local BR # regexp for the rest (body)
19086 # lnet.stats should look as 11 space-separated non-negative numerics
19087 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
19088 create_lnet_proc_files "stats"
19089 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
19090 remove_lnet_proc_files "stats"
19092 # lnet.routes should look like this:
19093 # Routing disabled/enabled
19094 # net hops priority state router
19095 # where net is a string like tcp0, hops > 0, priority >= 0,
19096 # state is up/down,
19097 # router is a string like 192.168.1.1@tcp2
19098 L1="^Routing (disabled|enabled)$"
19099 L2="^net +hops +priority +state +router$"
19100 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
19101 create_lnet_proc_files "routes"
19102 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
19103 remove_lnet_proc_files "routes"
19105 # lnet.routers should look like this:
19106 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
19107 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
19108 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
19109 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
19110 L1="^ref +rtr_ref +alive +router$"
19111 BR="^$P +$P +(up|down) +$NID$"
19112 create_lnet_proc_files "routers"
19113 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
19114 remove_lnet_proc_files "routers"
19116 # lnet.peers should look like this:
19117 # nid refs state last max rtr min tx min queue
19118 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
19119 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
19120 # numeric (0 or >0 or <0), queue >= 0.
19121 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
19122 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
19123 create_lnet_proc_files "peers"
19124 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
19125 remove_lnet_proc_files "peers"
19127 # lnet.buffers should look like this:
19128 # pages count credits min
19129 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
19130 L1="^pages +count +credits +min$"
19131 BR="^ +$N +$N +$I +$I$"
19132 create_lnet_proc_files "buffers"
19133 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
19134 remove_lnet_proc_files "buffers"
19136 # lnet.nis should look like this:
19137 # nid status alive refs peer rtr max tx min
19138 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
19139 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
19140 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
19141 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
19142 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
19143 create_lnet_proc_files "nis"
19144 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
19145 remove_lnet_proc_files "nis"
19147 # can we successfully write to lnet.stats?
19148 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
19150 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
19152 test_216() { # bug 20317
19153 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19154 remote_ost_nodsh && skip "remote OST with nodsh"
19157 local facets=$(get_facets OST)
19158 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19160 save_lustre_params client "osc.*.contention_seconds" > $p
19161 save_lustre_params $facets \
19162 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
19163 save_lustre_params $facets \
19164 "ldlm.namespaces.filter-*.contended_locks" >> $p
19165 save_lustre_params $facets \
19166 "ldlm.namespaces.filter-*.contention_seconds" >> $p
19167 clear_stats osc.*.osc_stats
19169 # agressive lockless i/o settings
19170 do_nodes $(comma_list $(osts_nodes)) \
19171 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
19172 ldlm.namespaces.filter-*.contended_locks=0 \
19173 ldlm.namespaces.filter-*.contention_seconds=60"
19174 lctl set_param -n osc.*.contention_seconds=60
19176 $DIRECTIO write $DIR/$tfile 0 10 4096
19177 $CHECKSTAT -s 40960 $DIR/$tfile
19179 # disable lockless i/o
19180 do_nodes $(comma_list $(osts_nodes)) \
19181 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
19182 ldlm.namespaces.filter-*.contended_locks=32 \
19183 ldlm.namespaces.filter-*.contention_seconds=0"
19184 lctl set_param -n osc.*.contention_seconds=0
19185 clear_stats osc.*.osc_stats
19187 dd if=/dev/zero of=$DIR/$tfile count=0
19188 $CHECKSTAT -s 0 $DIR/$tfile
19190 restore_lustre_params <$p
19194 run_test 216 "check lockless direct write updates file size and kms correctly"
19196 test_217() { # bug 22430
19197 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19202 for node in $(nodes_list); do
19203 nid=$(host_nids_address $node $NETTYPE)
19204 if [[ $nid = *-* ]] ; then
19205 echo "lctl ping $(h2nettype $nid)"
19206 lctl ping $(h2nettype $nid)
19208 echo "skipping $node (no hyphen detected)"
19212 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
19215 # do directio so as not to populate the page cache
19216 log "creating a 10 Mb file"
19217 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
19218 log "starting reads"
19219 dd if=$DIR/$tfile of=/dev/null bs=4096 &
19220 log "truncating the file"
19221 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
19223 kill %+ || true # reads might have finished
19224 echo "wait until dd is finished"
19226 log "removing the temporary file"
19227 rm -rf $DIR/$tfile || error "tmp file removal failed"
19229 run_test 218 "parallel read and truncate should not deadlock"
19232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19234 # write one partial page
19235 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
19236 # set no grant so vvp_io_commit_write will do sync write
19237 $LCTL set_param fail_loc=0x411
19238 # write a full page at the end of file
19239 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
19241 $LCTL set_param fail_loc=0
19242 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
19243 $LCTL set_param fail_loc=0x411
19244 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
19247 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
19248 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
19250 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
19252 test_220() { #LU-325
19253 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19254 remote_ost_nodsh && skip "remote OST with nodsh"
19255 remote_mds_nodsh && skip "remote MDS with nodsh"
19256 remote_mgs_nodsh && skip "remote MGS with nodsh"
19260 # create on MDT0000 so the last_id and next_id are correct
19261 mkdir_on_mdt0 $DIR/$tdir
19262 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
19266 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
19267 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
19268 osp.$mdtosc_proc1.prealloc_last_id)
19269 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
19270 osp.$mdtosc_proc1.prealloc_next_id)
19274 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
19275 #define OBD_FAIL_OST_ENOINO 0x229
19276 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
19277 create_pool $FSNAME.$TESTNAME || return 1
19278 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
19280 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
19282 MDSOBJS=$((last_id - next_id))
19283 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
19285 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
19286 echo "OST still has $count kbytes free"
19288 echo "create $MDSOBJS files @next_id..."
19289 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
19291 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19292 osp.$mdtosc_proc1.prealloc_last_id)
19293 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
19294 osp.$mdtosc_proc1.prealloc_next_id)
19296 echo "after creation, last_id=$last_id2, next_id=$next_id2"
19301 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
19302 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
19304 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
19305 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
19306 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
19307 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
19308 echo "unlink $MDSOBJS files @$next_id..."
19309 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
19311 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
19314 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19316 dd if=`which date` of=$MOUNT/date oflag=sync
19317 chmod +x $MOUNT/date
19319 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
19320 $LCTL set_param fail_loc=0x80001401
19322 $MOUNT/date > /dev/null
19325 run_test 221 "make sure fault and truncate race to not cause OOM"
19328 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19331 test_mkdir $DIR/$tdir
19332 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19333 createmany -o $DIR/$tdir/$tfile 10
19334 cancel_lru_locks mdc
19335 cancel_lru_locks osc
19336 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19337 $LCTL set_param fail_loc=0x31a
19338 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
19339 $LCTL set_param fail_loc=0
19342 run_test 222a "AGL for ls should not trigger CLIO lock failure"
19345 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19348 test_mkdir $DIR/$tdir
19349 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19350 createmany -o $DIR/$tdir/$tfile 10
19351 cancel_lru_locks mdc
19352 cancel_lru_locks osc
19353 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
19354 $LCTL set_param fail_loc=0x31a
19355 rm -r $DIR/$tdir || error "AGL for rmdir failed"
19356 $LCTL set_param fail_loc=0
19358 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
19361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19364 test_mkdir $DIR/$tdir
19365 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19366 createmany -o $DIR/$tdir/$tfile 10
19367 cancel_lru_locks mdc
19368 cancel_lru_locks osc
19369 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
19370 $LCTL set_param fail_loc=0x31b
19371 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
19372 $LCTL set_param fail_loc=0
19375 run_test 223 "osc reenqueue if without AGL lock granted ======================="
19377 test_224a() { # LU-1039, MRP-303
19378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19379 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
19380 $LCTL set_param fail_loc=0x508
19381 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fsync
19382 $LCTL set_param fail_loc=0
19385 run_test 224a "Don't panic on bulk IO failure"
19387 test_224bd_sub() { # LU-1039, MRP-303
19388 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19392 dd if=/dev/urandom of=$TMP/$tfile bs=1M count=1
19394 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19396 dd if=$TMP/$tfile of=$DIR/$tfile bs=1M count=1
19397 cancel_lru_locks osc
19399 stack_trap "set_checksums $ORIG_CSUM" EXIT
19400 local at_max_saved=0
19402 # adaptive timeouts may prevent seeing the issue
19403 if at_is_enabled; then
19404 at_max_saved=$(at_max_get mds)
19405 at_max_set 0 mds client
19406 stack_trap "at_max_set $at_max_saved mds client" EXIT
19409 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
19410 do_facet ost1 $LCTL set_param fail_val=$timeout fail_loc=0x80000515
19411 dd of=$TMP/$tfile.new if=$DIR/$tfile bs=1M count=1 || "$@"
19413 do_facet ost1 $LCTL set_param fail_loc=0
19414 cmp $TMP/$tfile $TMP/$tfile.new || error "file contents wrong"
19419 test_224bd_sub 3 error "dd failed"
19421 run_test 224b "Don't panic on bulk IO failure"
19423 test_224c() { # LU-6441
19424 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19425 remote_mds_nodsh && skip "remote MDS with nodsh"
19427 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
19428 save_writethrough $p
19429 set_cache writethrough on
19431 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
19432 local at_max=$($LCTL get_param -n at_max)
19433 local timeout=$($LCTL get_param -n timeout)
19434 local test_at="at_max"
19435 local param_at="$FSNAME.sys.at_max"
19436 local test_timeout="timeout"
19437 local param_timeout="$FSNAME.sys.timeout"
19439 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
19441 set_persistent_param_and_check client "$test_at" "$param_at" 0
19442 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
19444 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
19445 do_facet ost1 "$LCTL set_param fail_loc=0x520"
19446 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19447 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
19449 do_facet ost1 "$LCTL set_param fail_loc=0"
19451 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
19452 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
19455 $LCTL set_param -n $pages_per_rpc
19456 restore_lustre_params < $p
19459 run_test 224c "Don't hang if one of md lost during large bulk RPC"
19461 test_224d() { # LU-11169
19462 test_224bd_sub $((TIMEOUT + 2)) error "dd failed"
19464 run_test 224d "Don't corrupt data on bulk IO timeout"
19466 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
19468 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19469 if [ -z ${MDSSURVEY} ]; then
19470 skip_env "mds-survey not found"
19472 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19473 skip "Need MDS version at least 2.2.51"
19475 local mds=$(facet_host $SINGLEMDS)
19476 local target=$(do_nodes $mds 'lctl dl' |
19477 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19479 local cmd1="file_count=1000 thrhi=4"
19480 local cmd2="dir_count=2 layer=mdd stripe_count=0"
19481 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19482 local cmd="$cmd1 $cmd2 $cmd3"
19484 rm -f ${TMP}/mds_survey*
19486 eval $cmd || error "mds-survey with zero-stripe failed"
19487 cat ${TMP}/mds_survey*
19488 rm -f ${TMP}/mds_survey*
19490 run_test 225a "Metadata survey sanity with zero-stripe"
19493 if [ -z ${MDSSURVEY} ]; then
19494 skip_env "mds-survey not found"
19496 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
19497 skip "Need MDS version at least 2.2.51"
19498 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19499 remote_mds_nodsh && skip "remote MDS with nodsh"
19500 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
19501 skip_env "Need to mount OST to test"
19504 local mds=$(facet_host $SINGLEMDS)
19505 local target=$(do_nodes $mds 'lctl dl' |
19506 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
19508 local cmd1="file_count=1000 thrhi=4"
19509 local cmd2="dir_count=2 layer=mdd stripe_count=1"
19510 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
19511 local cmd="$cmd1 $cmd2 $cmd3"
19513 rm -f ${TMP}/mds_survey*
19515 eval $cmd || error "mds-survey with stripe_count failed"
19516 cat ${TMP}/mds_survey*
19517 rm -f ${TMP}/mds_survey*
19519 run_test 225b "Metadata survey sanity with stripe_count = 1"
19521 mcreate_path2fid () {
19527 local path=$DIR/$tdir/$name
19532 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
19533 error "cannot create $desc"
19535 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
19537 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
19539 fid_path=$($LFS fid2path $MOUNT $fid)
19541 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
19543 [ "$path" == "$fid_path" ] ||
19544 error "fid2path returned $fid_path, expected $path"
19546 echo "pass with $path and $fid"
19551 mkdir -p $DIR/$tdir
19553 mcreate_path2fid 0010666 0 0 fifo "FIFO"
19554 mcreate_path2fid 0020666 1 3 null "character special file (null)"
19555 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
19556 mcreate_path2fid 0040666 0 0 dir "directory"
19557 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
19558 mcreate_path2fid 0100666 0 0 file "regular file"
19559 mcreate_path2fid 0120666 0 0 link "symbolic link"
19560 mcreate_path2fid 0140666 0 0 sock "socket"
19562 run_test 226a "call path2fid and fid2path on files of all type"
19565 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19570 mkdir -p $DIR/$tdir
19571 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
19572 error "create remote directory failed"
19573 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
19574 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
19575 "character special file (null)"
19576 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
19577 "character special file (no device)"
19578 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
19579 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
19580 "block special file (loop)"
19581 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
19582 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
19583 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
19585 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
19588 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19589 [[ $MDS1_VERSION -ge $(version_code 2.13.55) ]] ||
19590 skip "Need MDS version at least 2.13.55"
19592 local submnt=/mnt/submnt
19593 local srcfile=/etc/passwd
19594 local dstfile=$submnt/passwd
19600 $LFS setdirstripe -c -1 -i 1 $DIR/$tdir ||
19601 error "create remote directory failed"
19602 mkdir -p $submnt || error "create $submnt failed"
19603 $MOUNT_CMD $MGSNID:/$FSNAME/$tdir $submnt ||
19604 error "mount $submnt failed"
19605 stack_trap "umount $submnt" EXIT
19607 cp $srcfile $dstfile
19608 fid=$($LFS path2fid $dstfile)
19609 path=$($LFS fid2path $submnt "$fid")
19610 [ "$path" = "$dstfile" ] ||
19611 error "fid2path $submnt $fid failed ($path != $dstfile)"
19613 run_test 226c "call path2fid and fid2path under remote dir with subdir mount"
19615 # LU-1299 Executing or running ldd on a truncated executable does not
19616 # cause an out-of-memory condition.
19618 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19619 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
19621 dd if=$(which date) of=$MOUNT/date bs=1k count=1
19622 chmod +x $MOUNT/date
19624 $MOUNT/date > /dev/null
19625 ldd $MOUNT/date > /dev/null
19628 run_test 227 "running truncated executable does not cause OOM"
19630 # LU-1512 try to reuse idle OI blocks
19632 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19633 remote_mds_nodsh && skip "remote MDS with nodsh"
19634 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19636 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19637 local myDIR=$DIR/$tdir
19640 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19641 $LCTL set_param fail_loc=0x80001002
19642 createmany -o $myDIR/t- 10000
19643 $LCTL set_param fail_loc=0
19644 # The guard is current the largest FID holder
19646 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19648 local IDX=$(($SEQ % 64))
19650 do_facet $SINGLEMDS sync
19651 # Make sure journal flushed.
19653 local blk1=$(do_facet $SINGLEMDS \
19654 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19655 grep Blockcount | awk '{print $4}')
19657 # Remove old files, some OI blocks will become idle.
19658 unlinkmany $myDIR/t- 10000
19659 # Create new files, idle OI blocks should be reused.
19660 createmany -o $myDIR/t- 2000
19661 do_facet $SINGLEMDS sync
19662 # Make sure journal flushed.
19664 local blk2=$(do_facet $SINGLEMDS \
19665 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19666 grep Blockcount | awk '{print $4}')
19668 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19670 run_test 228a "try to reuse idle OI blocks"
19673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19674 remote_mds_nodsh && skip "remote MDS with nodsh"
19675 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19677 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19678 local myDIR=$DIR/$tdir
19681 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19682 $LCTL set_param fail_loc=0x80001002
19683 createmany -o $myDIR/t- 10000
19684 $LCTL set_param fail_loc=0
19685 # The guard is current the largest FID holder
19687 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19689 local IDX=$(($SEQ % 64))
19691 do_facet $SINGLEMDS sync
19692 # Make sure journal flushed.
19694 local blk1=$(do_facet $SINGLEMDS \
19695 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19696 grep Blockcount | awk '{print $4}')
19698 # Remove old files, some OI blocks will become idle.
19699 unlinkmany $myDIR/t- 10000
19702 stop $SINGLEMDS || error "Fail to stop MDT."
19704 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
19705 error "Fail to start MDT."
19707 df $MOUNT || error "Fail to df."
19708 # Create new files, idle OI blocks should be reused.
19709 createmany -o $myDIR/t- 2000
19710 do_facet $SINGLEMDS sync
19711 # Make sure journal flushed.
19713 local blk2=$(do_facet $SINGLEMDS \
19714 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19715 grep Blockcount | awk '{print $4}')
19717 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19719 run_test 228b "idle OI blocks can be reused after MDT restart"
19723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19724 remote_mds_nodsh && skip "remote MDS with nodsh"
19725 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19727 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
19728 local myDIR=$DIR/$tdir
19731 #define OBD_FAIL_SEQ_EXHAUST 0x1002
19732 $LCTL set_param fail_loc=0x80001002
19733 # 20000 files can guarantee there are index nodes in the OI file
19734 createmany -o $myDIR/t- 20000
19735 $LCTL set_param fail_loc=0
19736 # The guard is current the largest FID holder
19738 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
19740 local IDX=$(($SEQ % 64))
19742 do_facet $SINGLEMDS sync
19743 # Make sure journal flushed.
19745 local blk1=$(do_facet $SINGLEMDS \
19746 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19747 grep Blockcount | awk '{print $4}')
19749 # Remove old files, some OI blocks will become idle.
19750 unlinkmany $myDIR/t- 20000
19752 # The OI file should become empty now
19754 # Create new files, idle OI blocks should be reused.
19755 createmany -o $myDIR/t- 2000
19756 do_facet $SINGLEMDS sync
19757 # Make sure journal flushed.
19759 local blk2=$(do_facet $SINGLEMDS \
19760 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
19761 grep Blockcount | awk '{print $4}')
19763 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
19765 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
19767 test_229() { # LU-2482, LU-3448
19768 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19769 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19770 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
19771 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
19775 # Create a file with a released layout and stripe count 2.
19776 $MULTIOP $DIR/$tfile H2c ||
19777 error "failed to create file with released layout"
19779 $LFS getstripe -v $DIR/$tfile
19781 local pattern=$($LFS getstripe -L $DIR/$tfile)
19782 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
19784 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
19786 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
19787 stat $DIR/$tfile || error "failed to stat released file"
19789 chown $RUNAS_ID $DIR/$tfile ||
19790 error "chown $RUNAS_ID $DIR/$tfile failed"
19792 chgrp $RUNAS_ID $DIR/$tfile ||
19793 error "chgrp $RUNAS_ID $DIR/$tfile failed"
19795 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
19796 rm $DIR/$tfile || error "failed to remove released file"
19798 run_test 229 "getstripe/stat/rm/attr changes work on released files"
19801 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19802 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19803 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19804 skip "Need MDS version at least 2.11.52"
19808 test_mkdir $DIR/$tdir
19809 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
19810 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
19811 [ $mdt_idx -ne 0 ] &&
19812 error "create local directory on wrong MDT $mdt_idx"
19814 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
19815 error "create remote directory failed"
19816 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
19817 [ $mdt_idx -ne $MDTIDX ] &&
19818 error "create remote directory on wrong MDT $mdt_idx"
19820 createmany -o $DIR/$tdir/test_230/t- 10 ||
19821 error "create files on remote directory failed"
19822 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
19823 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
19824 rm -r $DIR/$tdir || error "unlink remote directory failed"
19826 run_test 230a "Create remote directory and files under the remote directory"
19829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19830 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19831 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
19832 skip "Need MDS version at least 2.11.52"
19840 local migrate_dir=$DIR/$tdir/migrate_dir
19841 local other_dir=$DIR/$tdir/other_dir
19843 test_mkdir $DIR/$tdir
19844 test_mkdir -i0 -c1 $migrate_dir
19845 test_mkdir -i0 -c1 $other_dir
19846 for ((i=0; i<10; i++)); do
19847 mkdir -p $migrate_dir/dir_${i}
19848 createmany -o $migrate_dir/dir_${i}/f 10 ||
19849 error "create files under remote dir failed $i"
19852 cp /etc/passwd $migrate_dir/$tfile
19853 cp /etc/passwd $other_dir/$tfile
19854 chattr +SAD $migrate_dir
19855 chattr +SAD $migrate_dir/$tfile
19857 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19858 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19859 local old_dir_mode=$(stat -c%f $migrate_dir)
19860 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
19862 mkdir -p $migrate_dir/dir_default_stripe2
19863 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
19864 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
19866 mkdir -p $other_dir
19867 ln $migrate_dir/$tfile $other_dir/luna
19868 ln $migrate_dir/$tfile $migrate_dir/sofia
19869 ln $other_dir/$tfile $migrate_dir/david
19870 ln -s $migrate_dir/$tfile $other_dir/zachary
19871 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
19872 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
19878 for len in 58 59 60; do
19879 lnktgt=$(str_repeat 'l' $len)
19880 touch $migrate_dir/$lnktgt
19881 ln -s $lnktgt $migrate_dir/${len}char_ln
19885 for len in 4094 4095; do
19886 lnktgt=$(str_repeat 'l' $len)
19887 ln -s $lnktgt $migrate_dir/${len}char_ln
19891 for len in 254 255; do
19892 touch $migrate_dir/$(str_repeat 'l' $len)
19895 $LFS migrate -m $MDTIDX $migrate_dir ||
19896 error "fails on migrating remote dir to MDT1"
19898 echo "migratate to MDT1, then checking.."
19899 for ((i = 0; i < 10; i++)); do
19900 for file in $(find $migrate_dir/dir_${i}); do
19901 mdt_index=$($LFS getstripe -m $file)
19902 # broken symlink getstripe will fail
19903 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19904 error "$file is not on MDT${MDTIDX}"
19908 # the multiple link file should still in MDT0
19909 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
19910 [ $mdt_index == 0 ] ||
19911 error "$file is not on MDT${MDTIDX}"
19913 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19914 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19915 error " expect $old_dir_flag get $new_dir_flag"
19917 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19918 [ "$old_file_flag" = "$new_file_flag" ] ||
19919 error " expect $old_file_flag get $new_file_flag"
19921 local new_dir_mode=$(stat -c%f $migrate_dir)
19922 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19923 error "expect mode $old_dir_mode get $new_dir_mode"
19925 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19926 [ "$old_file_mode" = "$new_file_mode" ] ||
19927 error "expect mode $old_file_mode get $new_file_mode"
19929 diff /etc/passwd $migrate_dir/$tfile ||
19930 error "$tfile different after migration"
19932 diff /etc/passwd $other_dir/luna ||
19933 error "luna different after migration"
19935 diff /etc/passwd $migrate_dir/sofia ||
19936 error "sofia different after migration"
19938 diff /etc/passwd $migrate_dir/david ||
19939 error "david different after migration"
19941 diff /etc/passwd $other_dir/zachary ||
19942 error "zachary different after migration"
19944 diff /etc/passwd $migrate_dir/${tfile}_ln ||
19945 error "${tfile}_ln different after migration"
19947 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
19948 error "${tfile}_ln_other different after migration"
19950 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
19951 [ $stripe_count = 2 ] ||
19952 error "dir strpe_count $d != 2 after migration."
19954 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
19955 [ $stripe_count = 2 ] ||
19956 error "file strpe_count $d != 2 after migration."
19958 #migrate back to MDT0
19961 $LFS migrate -m $MDTIDX $migrate_dir ||
19962 error "fails on migrating remote dir to MDT0"
19964 echo "migrate back to MDT0, checking.."
19965 for file in $(find $migrate_dir); do
19966 mdt_index=$($LFS getstripe -m $file)
19967 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
19968 error "$file is not on MDT${MDTIDX}"
19971 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
19972 [ "$old_dir_flag" = "$new_dir_flag" ] ||
19973 error " expect $old_dir_flag get $new_dir_flag"
19975 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
19976 [ "$old_file_flag" = "$new_file_flag" ] ||
19977 error " expect $old_file_flag get $new_file_flag"
19979 local new_dir_mode=$(stat -c%f $migrate_dir)
19980 [ "$old_dir_mode" = "$new_dir_mode" ] ||
19981 error "expect mode $old_dir_mode get $new_dir_mode"
19983 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
19984 [ "$old_file_mode" = "$new_file_mode" ] ||
19985 error "expect mode $old_file_mode get $new_file_mode"
19987 diff /etc/passwd ${migrate_dir}/$tfile ||
19988 error "$tfile different after migration"
19990 diff /etc/passwd ${other_dir}/luna ||
19991 error "luna different after migration"
19993 diff /etc/passwd ${migrate_dir}/sofia ||
19994 error "sofia different after migration"
19996 diff /etc/passwd ${other_dir}/zachary ||
19997 error "zachary different after migration"
19999 diff /etc/passwd $migrate_dir/${tfile}_ln ||
20000 error "${tfile}_ln different after migration"
20002 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
20003 error "${tfile}_ln_other different after migration"
20005 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
20006 [ $stripe_count = 2 ] ||
20007 error "dir strpe_count $d != 2 after migration."
20009 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
20010 [ $stripe_count = 2 ] ||
20011 error "file strpe_count $d != 2 after migration."
20013 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20015 run_test 230b "migrate directory"
20018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20019 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20020 remote_mds_nodsh && skip "remote MDS with nodsh"
20021 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20022 skip "Need MDS version at least 2.11.52"
20028 local migrate_dir=$DIR/$tdir/migrate_dir
20030 #If migrating directory fails in the middle, all entries of
20031 #the directory is still accessiable.
20032 test_mkdir $DIR/$tdir
20033 test_mkdir -i0 -c1 $migrate_dir
20034 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
20036 createmany -o $migrate_dir/f $total ||
20037 error "create files under ${migrate_dir} failed"
20039 # fail after migrating top dir, and this will fail only once, so the
20040 # first sub file migration will fail (currently f3), others succeed.
20041 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
20042 do_facet mds1 lctl set_param fail_loc=0x1801
20043 local t=$(ls $migrate_dir | wc -l)
20044 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
20045 error "migrate should fail"
20046 local u=$(ls $migrate_dir | wc -l)
20047 [ "$u" == "$t" ] || error "$u != $t during migration"
20049 # add new dir/file should succeed
20050 mkdir $migrate_dir/dir ||
20051 error "mkdir failed under migrating directory"
20052 touch $migrate_dir/file ||
20053 error "create file failed under migrating directory"
20055 # add file with existing name should fail
20056 for file in $migrate_dir/f*; do
20057 stat $file > /dev/null || error "stat $file failed"
20058 $OPENFILE -f O_CREAT:O_EXCL $file &&
20059 error "open(O_CREAT|O_EXCL) $file should fail"
20060 $MULTIOP $file m && error "create $file should fail"
20061 touch $DIR/$tdir/remote_dir/$tfile ||
20062 error "touch $tfile failed"
20063 ln $DIR/$tdir/remote_dir/$tfile $file &&
20064 error "link $file should fail"
20065 mdt_index=$($LFS getstripe -m $file)
20066 if [ $mdt_index == 0 ]; then
20067 # file failed to migrate is not allowed to rename to
20068 mv $DIR/$tdir/remote_dir/$tfile $file &&
20069 error "rename to $file should fail"
20071 mv $DIR/$tdir/remote_dir/$tfile $file ||
20072 error "rename to $file failed"
20074 echo hello >> $file || error "write $file failed"
20077 # resume migration with different options should fail
20078 $LFS migrate -m 0 $migrate_dir &&
20079 error "migrate -m 0 $migrate_dir should fail"
20081 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
20082 error "migrate -c 2 $migrate_dir should fail"
20084 # resume migration should succeed
20085 $LFS migrate -m $MDTIDX $migrate_dir ||
20086 error "migrate $migrate_dir failed"
20088 echo "Finish migration, then checking.."
20089 for file in $(find $migrate_dir); do
20090 mdt_index=$($LFS getstripe -m $file)
20091 [ $mdt_index == $MDTIDX ] ||
20092 error "$file is not on MDT${MDTIDX}"
20095 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20097 run_test 230c "check directory accessiblity if migration failed"
20100 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20101 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20102 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20103 skip "Need MDS version at least 2.11.52"
20105 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
20107 local migrate_dir=$DIR/$tdir/migrate_dir
20117 old_index=$((RANDOM % MDSCOUNT))
20118 old_count=$((MDSCOUNT - old_index))
20119 new_index=$((RANDOM % MDSCOUNT))
20120 new_count=$((MDSCOUNT - new_index))
20121 new_hash=1 # for all_char
20123 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
20124 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
20126 test_mkdir $DIR/$tdir
20127 test_mkdir -i $old_index -c $old_count $migrate_dir
20129 for ((i=0; i<100; i++)); do
20130 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
20131 createmany -o $migrate_dir/dir_${i}/f 100 ||
20132 error "create files under remote dir failed $i"
20135 echo -n "Migrate from MDT$old_index "
20136 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
20137 echo -n "to MDT$new_index"
20138 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
20141 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
20142 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
20143 error "migrate remote dir error"
20145 echo "Finish migration, then checking.."
20146 for file in $(find $migrate_dir -maxdepth 1); do
20147 mdt_index=$($LFS getstripe -m $file)
20148 if [ $mdt_index -lt $new_index ] ||
20149 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
20150 error "$file is on MDT$mdt_index"
20154 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20156 run_test 230d "check migrate big directory"
20159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20160 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20161 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20162 skip "Need MDS version at least 2.11.52"
20169 mkdir_on_mdt0 $DIR/$tdir
20170 mkdir $DIR/$tdir/migrate_dir
20171 mkdir $DIR/$tdir/other_dir
20172 touch $DIR/$tdir/migrate_dir/a
20173 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
20174 ls $DIR/$tdir/other_dir
20176 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20177 error "migrate dir fails"
20179 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20180 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20182 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20183 [ $mdt_index == 0 ] || error "a is not on MDT0"
20185 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
20186 error "migrate dir fails"
20188 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
20189 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
20191 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20192 [ $mdt_index == 1 ] || error "a is not on MDT1"
20194 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
20195 [ $mdt_index == 1 ] || error "b is not on MDT1"
20197 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20198 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
20200 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
20202 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20204 run_test 230e "migrate mulitple local link files"
20207 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20208 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20209 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20210 skip "Need MDS version at least 2.11.52"
20215 mkdir -p $DIR/$tdir
20216 mkdir $DIR/$tdir/migrate_dir
20217 $LFS mkdir -i1 $DIR/$tdir/other_dir
20218 touch $DIR/$tdir/migrate_dir/a
20219 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
20220 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
20221 ls $DIR/$tdir/other_dir
20223 # a should be migrated to MDT1, since no other links on MDT0
20224 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20225 error "#1 migrate dir fails"
20226 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
20227 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
20228 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20229 [ $mdt_index == 1 ] || error "a is not on MDT1"
20231 # a should stay on MDT1, because it is a mulitple link file
20232 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20233 error "#2 migrate dir fails"
20234 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20235 [ $mdt_index == 1 ] || error "a is not on MDT1"
20237 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
20238 error "#3 migrate dir fails"
20240 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
20241 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
20242 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
20244 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
20245 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
20247 # a should be migrated to MDT0, since no other links on MDT1
20248 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
20249 error "#4 migrate dir fails"
20250 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
20251 [ $mdt_index == 0 ] || error "a is not on MDT0"
20253 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20255 run_test 230f "migrate mulitple remote link files"
20258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20259 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20260 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20261 skip "Need MDS version at least 2.11.52"
20263 mkdir -p $DIR/$tdir/migrate_dir
20265 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
20266 error "migrating dir to non-exist MDT succeeds"
20269 run_test 230g "migrate dir to non-exist MDT"
20272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20273 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20274 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20275 skip "Need MDS version at least 2.11.52"
20279 mkdir -p $DIR/$tdir/migrate_dir
20281 $LFS migrate -m1 $DIR &&
20282 error "migrating mountpoint1 should fail"
20284 $LFS migrate -m1 $DIR/$tdir/.. &&
20285 error "migrating mountpoint2 should fail"
20288 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
20289 error "migrating $tdir/migrate_dir/.. should fail"
20293 run_test 230h "migrate .. and root"
20296 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20297 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20298 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20299 skip "Need MDS version at least 2.11.52"
20301 mkdir -p $DIR/$tdir/migrate_dir
20303 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
20304 error "migration fails with a tailing slash"
20306 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
20307 error "migration fails with two tailing slashes"
20309 run_test 230i "lfs migrate -m tolerates trailing slashes"
20312 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20313 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
20314 skip "Need MDS version at least 2.11.52"
20316 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20317 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
20318 error "create $tfile failed"
20319 cat /etc/passwd > $DIR/$tdir/$tfile
20321 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20323 cmp /etc/passwd $DIR/$tdir/$tfile ||
20324 error "DoM file mismatch after migration"
20326 run_test 230j "DoM file data not changed after dir migration"
20329 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
20330 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20331 skip "Need MDS version at least 2.11.56"
20334 local files_on_starting_mdt=0
20336 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
20337 $LFS getdirstripe $DIR/$tdir
20338 for i in $(seq $total); do
20339 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
20340 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20341 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20344 echo "$files_on_starting_mdt files on MDT0"
20346 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
20347 $LFS getdirstripe $DIR/$tdir
20349 files_on_starting_mdt=0
20350 for i in $(seq $total); do
20351 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20352 error "file $tfile.$i mismatch after migration"
20353 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
20354 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20357 echo "$files_on_starting_mdt files on MDT1 after migration"
20358 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
20360 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
20361 $LFS getdirstripe $DIR/$tdir
20363 files_on_starting_mdt=0
20364 for i in $(seq $total); do
20365 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
20366 error "file $tfile.$i mismatch after 2nd migration"
20367 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
20368 files_on_starting_mdt=$((files_on_starting_mdt + 1))
20371 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
20372 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
20376 run_test 230k "file data not changed after dir migration"
20379 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20380 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20381 skip "Need MDS version at least 2.11.56"
20383 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
20384 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
20385 error "create files under remote dir failed $i"
20386 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
20388 run_test 230l "readdir between MDTs won't crash"
20391 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20392 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20393 skip "Need MDS version at least 2.11.56"
20396 local mig_dir=$DIR/$tdir/migrate_dir
20397 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
20401 echo "Creating files and dirs with xattrs"
20402 test_mkdir $DIR/$tdir
20403 test_mkdir -i0 -c1 $mig_dir
20405 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
20406 error "cannot set xattr attr1 on dir"
20407 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
20408 error "cannot set xattr attr2 on dir"
20409 touch $mig_dir/dir/f0
20410 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
20411 error "cannot set xattr attr1 on file"
20412 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
20413 error "cannot set xattr attr2 on file"
20414 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20415 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20416 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
20417 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20418 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
20419 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20420 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
20421 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20422 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
20424 echo "Migrating to MDT1"
20425 $LFS migrate -m $MDTIDX $mig_dir ||
20426 error "fails on migrating dir to MDT1"
20428 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
20429 echo "Checking xattrs"
20430 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
20431 [ "$val" = $longstr ] ||
20432 error "expecting xattr1 $longstr on dir, found $val"
20433 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
20434 [ "$val" = $shortstr ] ||
20435 error "expecting xattr2 $shortstr on dir, found $val"
20436 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
20437 [ "$val" = $longstr ] ||
20438 error "expecting xattr1 $longstr on file, found $val"
20439 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
20440 [ "$val" = $shortstr ] ||
20441 error "expecting xattr2 $shortstr on file, found $val"
20443 run_test 230m "xattrs not changed after dir migration"
20446 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20447 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
20448 skip "Need MDS version at least 2.13.53"
20450 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
20451 cat /etc/hosts > $DIR/$tdir/$tfile
20452 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
20453 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
20455 cmp /etc/hosts $DIR/$tdir/$tfile ||
20456 error "File data mismatch after migration"
20458 run_test 230n "Dir migration with mirrored file"
20461 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
20462 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
20463 skip "Need MDS version at least 2.13.52"
20465 local mdts=$(comma_list $(mdts_nodes))
20467 local restripe_status
20471 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20473 # in case "crush" hash type is not set
20474 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20476 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20477 mdt.*MDT0000.enable_dir_restripe)
20478 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20479 stack_trap "do_nodes $mdts $LCTL set_param \
20480 mdt.*.enable_dir_restripe=$restripe_status"
20483 createmany -m $DIR/$tdir/f 100 ||
20484 error "create files under remote dir failed $i"
20485 createmany -d $DIR/$tdir/d 100 ||
20486 error "create dirs under remote dir failed $i"
20488 for i in $(seq 2 $MDSCOUNT); do
20489 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20490 $LFS setdirstripe -c $i $DIR/$tdir ||
20491 error "split -c $i $tdir failed"
20492 wait_update $HOSTNAME \
20493 "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout ||
20494 error "dir split not finished"
20495 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20496 awk '/migrate/ {sum += $2} END { print sum }')
20497 echo "$delta migrated when dir split $((i - 1)) to $i stripes"
20498 # delta is around total_files/stripe_count
20499 (( $delta < 200 / (i - 1) + 4 )) ||
20500 error "$delta files migrated >= $((200 / (i - 1) + 4))"
20503 run_test 230o "dir split"
20506 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
20507 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20508 skip "Need MDS version at least 2.13.52"
20510 local mdts=$(comma_list $(mdts_nodes))
20512 local restripe_status
20516 [[ $mds1_FSTYPE == zfs ]] && timeout=300
20518 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20520 restripe_status=$(do_facet mds1 $LCTL get_param -n \
20521 mdt.*MDT0000.enable_dir_restripe)
20522 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
20523 stack_trap "do_nodes $mdts $LCTL set_param \
20524 mdt.*.enable_dir_restripe=$restripe_status"
20526 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
20527 createmany -m $DIR/$tdir/f 100 ||
20528 error "create files under remote dir failed"
20529 createmany -d $DIR/$tdir/d 100 ||
20530 error "create dirs under remote dir failed"
20532 for c in $(seq $((MDSCOUNT - 1)) -1 1); do
20533 local mdt_hash="crush"
20535 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null"
20536 $LFS setdirstripe -c $c $DIR/$tdir ||
20537 error "split -c $c $tdir failed"
20538 if (( MDS1_VERSION >= $(version_code 2.14.51) )); then
20539 mdt_hash="$mdt_hash,fixed"
20540 elif [ $c -eq 1 ]; then
20543 wait_update $HOSTNAME \
20544 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash $timeout ||
20545 error "dir merge not finished"
20546 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
20547 awk '/migrate/ {sum += $2} END { print sum }')
20548 echo "$delta migrated when dir merge $((c + 1)) to $c stripes"
20549 # delta is around total_files/stripe_count
20550 (( delta < 200 / c + 4 )) ||
20551 error "$delta files migrated >= $((200 / c + 4))"
20554 run_test 230p "dir merge"
20557 (( MDSCOUNT > 1)) || skip "needs >= 2 MDTs"
20558 (( MDS1_VERSION >= $(version_code 2.13.52) )) ||
20559 skip "Need MDS version at least 2.13.52"
20561 local mdts=$(comma_list $(mdts_nodes))
20562 local saved_threshold=$(do_facet mds1 \
20563 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
20564 local saved_delta=$(do_facet mds1 \
20565 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
20566 local threshold=100
20569 local stripe_count=0
20574 # test with fewer files on ZFS
20575 [ "$mds1_FSTYPE" == "zfs" ] && threshold=40
20577 stack_trap "do_nodes $mdts $LCTL set_param \
20578 mdt.*.dir_split_count=$saved_threshold"
20579 stack_trap "do_nodes $mdts $LCTL set_param \
20580 mdt.*.dir_split_delta=$saved_delta"
20581 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
20582 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
20583 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
20584 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
20585 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
20586 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
20588 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
20589 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20591 create=$((threshold * 3 / 2))
20592 while [ $stripe_count -lt $MDSCOUNT ]; do
20593 createmany -m $DIR/$tdir/f $total $create ||
20594 error "create sub files failed"
20595 stat $DIR/$tdir > /dev/null
20596 total=$((total + create))
20597 stripe_count=$((stripe_count + delta))
20598 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
20600 wait_update $HOSTNAME \
20601 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
20602 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
20604 wait_update $HOSTNAME \
20605 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
20606 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
20608 nr_files=$($LFS find -m 1 $DIR/$tdir | grep -c -w $stripe_index)
20609 echo "$nr_files/$total files on MDT$stripe_index after split"
20610 # allow 10% margin of imbalance with crush hash
20611 (( $nr_files <= $total / $stripe_count + $create / 10)) ||
20612 error "$nr_files files on MDT$stripe_index after split"
20614 nr_files=$($LFS find -type f $DIR/$tdir | wc -l)
20615 [ $nr_files -eq $total ] ||
20616 error "total sub files $nr_files != $total"
20619 (( MDS1_VERSION >= $(version_code 2.14.51) )) || return 0
20621 echo "fixed layout directory won't auto split"
20622 $LFS migrate -m 0 $DIR/$tdir || error "migrate $tdir failed"
20623 wait_update $HOSTNAME "$LFS getdirstripe -H $DIR/$tdir" "crush,fixed" \
20624 10 || error "stripe hash $($LFS getdirstripe -H $DIR/$tdir)"
20625 wait_update $HOSTNAME "$LFS getdirstripe -c $DIR/$tdir" 1 10 ||
20626 error "stripe count $($LFS getdirstripe -c $DIR/$tdir)"
20628 run_test 230q "dir auto split"
20631 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
20632 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20633 [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] ||
20634 skip "Need MDS version at least 2.13.54"
20636 # maximum amount of local locks:
20637 # parent striped dir - 2 locks
20638 # new stripe in parent to migrate to - 1 lock
20639 # source and target - 2 locks
20640 # Total 5 locks for regular file
20641 mkdir -p $DIR/$tdir
20642 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
20643 touch $DIR/$tdir/dir1/eee
20645 # create 4 hardlink for 4 more locks
20646 # Total: 9 locks > RS_MAX_LOCKS (8)
20647 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
20648 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
20649 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
20650 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
20651 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
20652 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
20653 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
20654 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
20656 cancel_lru_locks mdc
20658 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
20659 error "migrate dir fails"
20661 rm -rf $DIR/$tdir || error "rm dir failed after migration"
20663 run_test 230r "migrate with too many local locks"
20666 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
20667 skip "Need MDS version at least 2.14.52"
20669 local mdts=$(comma_list $(mdts_nodes))
20670 local restripe_status=$(do_facet mds1 $LCTL get_param -n \
20671 mdt.*MDT0000.enable_dir_restripe)
20673 stack_trap "do_nodes $mdts $LCTL set_param \
20674 mdt.*.enable_dir_restripe=$restripe_status"
20678 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=$st"
20679 test_mkdir $DIR/$tdir
20680 $LFS mkdir $DIR/$tdir |& grep "File exists" ||
20681 error "$LFS mkdir should return EEXIST if target exists"
20685 run_test 230s "lfs mkdir should return -EEXIST if target exists"
20689 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
20690 [[ $MDS1_VERSION -ge $(version_code 2.14.50) ]] ||
20691 skip "Need MDS version at least 2.14.50"
20693 test_mkdir $DIR/$tdir || error "mkdir $tdir failed"
20694 test_mkdir $DIR/$tdir/subdir || error "mkdir subdir failed"
20695 $LFS project -p 1 -s $DIR/$tdir ||
20696 error "set $tdir project id failed"
20697 $LFS project -p 2 -s $DIR/$tdir/subdir ||
20698 error "set subdir project id failed"
20699 $LFS migrate -m 1 -c $MDSCOUNT $DIR/$tdir || error "migrate failed"
20701 run_test 230t "migrate directory with project ID set"
20705 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20706 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20707 skip "Need MDS version at least 2.14.53"
20711 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
20712 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20713 $LFS migrate -m -1 $DIR/$tdir/sub{0..99} || error "migrate sub failed"
20714 for i in $(seq 0 $((MDSCOUNT - 1))); do
20715 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20716 echo "$count dirs migrated to MDT$i"
20718 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
20719 (( count >= MDSCOUNT - 1 )) || error "dirs migrated to $count MDTs"
20721 run_test 230u "migrate directory by QOS"
20725 (( MDSCOUNT > 3 )) || skip_env "needs >= 4 MDTs"
20726 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20727 skip "Need MDS version at least 2.14.53"
20731 mkdir $DIR/$tdir || error "mkdir $tdir failed"
20732 mkdir $DIR/$tdir/sub{0..99} || error "mkdir sub failed"
20733 $LFS migrate -m 0,2,1 $DIR/$tdir || error "migrate $tdir failed"
20734 for i in $(seq 0 $((MDSCOUNT - 1))); do
20735 count=$($LFS getstripe -m $DIR/$tdir/sub* | grep -c ^$i)
20736 echo "$count subdirs migrated to MDT$i"
20737 (( i == 3 )) && (( count > 0 )) &&
20738 error "subdir shouldn't be migrated to MDT3"
20740 count=$($LFS getstripe -m $DIR/$tdir/sub* | sort -u | wc -l)
20741 (( count == 3 )) || error "dirs migrated to $count MDTs"
20743 run_test 230v "subdir migrated to the MDT where its parent is located"
20746 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
20747 (( MDS1_VERSION >= $(version_code 2.14.53) )) ||
20748 skip "Need MDS version at least 2.14.53"
20750 mkdir -p $DIR/$tdir/sub || error "mkdir failed"
20752 $LFS migrate -m 1 -c $MDSCOUNT -d $DIR/$tdir ||
20753 error "migrate failed"
20755 (( $($LFS getdirstripe -c $DIR/$tdir) == MDSCOUNT )) ||
20756 error "$tdir stripe count mismatch"
20758 (( $($LFS getdirstripe -c $DIR/$tdir/sub) == 0 )) ||
20759 error "$tdir/sub is striped"
20761 run_test 230w "non-recursive mode dir migration"
20765 # For simplicity this test assumes that max_pages_per_rpc
20766 # is the same across all OSCs
20767 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
20768 local bulk_size=$((max_pages * PAGE_SIZE))
20769 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
20772 mkdir -p $DIR/$tdir
20773 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
20774 error "failed to set stripe with -S ${brw_size}M option"
20776 # clear the OSC stats
20777 $LCTL set_param osc.*.stats=0 &>/dev/null
20780 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
20781 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
20782 oflag=direct &>/dev/null || error "dd failed"
20784 sync; sleep 1; sync # just to be safe
20785 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
20786 if [ x$nrpcs != "x1" ]; then
20787 $LCTL get_param osc.*.stats
20788 error "found $nrpcs ost_write RPCs, not 1 as expected"
20792 # Drop the OSC cache, otherwise we will read from it
20793 cancel_lru_locks osc
20795 # clear the OSC stats
20796 $LCTL set_param osc.*.stats=0 &>/dev/null
20798 # Client reads $bulk_size.
20799 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
20800 iflag=direct &>/dev/null || error "dd failed"
20802 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
20803 if [ x$nrpcs != "x1" ]; then
20804 $LCTL get_param osc.*.stats
20805 error "found $nrpcs ost_read RPCs, not 1 as expected"
20808 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
20811 mkdir -p $DIR/$tdir
20813 for i in {0..1023}; do
20814 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
20815 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
20816 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
20820 run_test 231b "must not assert on fully utilized OST request buffer"
20823 mkdir -p $DIR/$tdir
20824 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
20826 #define OBD_FAIL_LDLM_OST_LVB 0x31c
20827 do_facet ost1 $LCTL set_param fail_loc=0x31c
20829 # ignore dd failure
20830 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
20832 do_facet ost1 $LCTL set_param fail_loc=0
20833 umount_client $MOUNT || error "umount failed"
20834 mount_client $MOUNT || error "mount failed"
20835 stop ost1 || error "cannot stop ost1"
20836 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
20838 run_test 232a "failed lock should not block umount"
20841 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
20842 skip "Need MDS version at least 2.10.58"
20844 mkdir -p $DIR/$tdir
20845 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
20846 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
20848 cancel_lru_locks osc
20850 #define OBD_FAIL_LDLM_OST_LVB 0x31c
20851 do_facet ost1 $LCTL set_param fail_loc=0x31c
20854 $LFS data_version $DIR/$tdir/$tfile || true
20856 do_facet ost1 $LCTL set_param fail_loc=0
20857 umount_client $MOUNT || error "umount failed"
20858 mount_client $MOUNT || error "mount failed"
20859 stop ost1 || error "cannot stop ost1"
20860 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
20862 run_test 232b "failed data version lock should not block umount"
20865 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
20866 skip "Need MDS version at least 2.3.64"
20867 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
20869 local fid=$($LFS path2fid $MOUNT)
20871 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20872 error "cannot access $MOUNT using its FID '$fid'"
20874 run_test 233a "checking that OBF of the FS root succeeds"
20877 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
20878 skip "Need MDS version at least 2.5.90"
20879 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
20881 local fid=$($LFS path2fid $MOUNT/.lustre)
20883 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20884 error "cannot access $MOUNT/.lustre using its FID '$fid'"
20886 fid=$($LFS path2fid $MOUNT/.lustre/fid)
20887 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
20888 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
20890 run_test 233b "checking that OBF of the FS .lustre succeeds"
20893 local p="$TMP/sanityN-$TESTNAME.parameters"
20894 save_lustre_params client "llite.*.xattr_cache" > $p
20895 lctl set_param llite.*.xattr_cache 1 ||
20896 skip_env "xattr cache is not supported"
20898 mkdir -p $DIR/$tdir || error "mkdir failed"
20899 touch $DIR/$tdir/$tfile || error "touch failed"
20900 # OBD_FAIL_LLITE_XATTR_ENOMEM
20901 $LCTL set_param fail_loc=0x1405
20902 getfattr -n user.attr $DIR/$tdir/$tfile &&
20903 error "getfattr should have failed with ENOMEM"
20904 $LCTL set_param fail_loc=0x0
20907 restore_lustre_params < $p
20910 run_test 234 "xattr cache should not crash on ENOMEM"
20913 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
20914 skip "Need MDS version at least 2.4.52"
20916 flock_deadlock $DIR/$tfile
20921 124) error "process hangs on a deadlock"
20923 *) error "error executing flock_deadlock $DIR/$tfile"
20927 run_test 235 "LU-1715: flock deadlock detection does not work properly"
20931 check_swap_layouts_support
20933 local ref1=/etc/passwd
20934 local ref2=/etc/group
20935 local file1=$DIR/$tdir/f1
20936 local file2=$DIR/$tdir/f2
20938 test_mkdir -c1 $DIR/$tdir
20939 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
20940 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
20941 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
20942 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
20943 local fd=$(free_fd)
20944 local cmd="exec $fd<>$file2"
20947 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
20948 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
20951 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
20956 run_test 236 "Layout swap on open unlinked file"
20958 # LU-4659 linkea consistency
20960 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
20961 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
20962 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
20963 skip "Need MDS version at least 2.5.58 or 2.5.2+"
20966 ln $DIR/$tfile $DIR/$tfile.lnk
20967 touch $DIR/$tfile.new
20968 mv $DIR/$tfile.new $DIR/$tfile
20969 local fid1=$($LFS path2fid $DIR/$tfile)
20970 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
20971 local path1=$($LFS fid2path $FSNAME "$fid1")
20972 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
20973 local path2=$($LFS fid2path $FSNAME "$fid2")
20974 [ $tfile.lnk == $path2 ] ||
20975 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
20978 run_test 238 "Verify linkea consistency"
20980 test_239A() { # was test_239
20981 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
20982 skip "Need MDS version at least 2.5.60"
20984 local list=$(comma_list $(mdts_nodes))
20986 mkdir -p $DIR/$tdir
20987 createmany -o $DIR/$tdir/f- 5000
20988 unlinkmany $DIR/$tdir/f- 5000
20989 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
20990 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
20991 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
20992 osp.*MDT*.sync_in_flight" | calc_sum)
20993 [ "$changes" -eq 0 ] || error "$changes not synced"
20995 run_test 239A "osp_sync test"
20997 test_239a() { #LU-5297
20998 remote_mds_nodsh && skip "remote MDS with nodsh"
21001 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
21002 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
21003 chgrp $RUNAS_GID $DIR/$tfile
21004 wait_delete_completed
21006 run_test 239a "process invalid osp sync record correctly"
21008 test_239b() { #LU-5297
21009 remote_mds_nodsh && skip "remote MDS with nodsh"
21012 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
21013 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
21014 chgrp $RUNAS_GID $DIR/$tfile1
21015 wait_delete_completed
21016 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21018 chgrp $RUNAS_GID $DIR/$tfile2
21019 wait_delete_completed
21021 run_test 239b "process osp sync record with ENOMEM error correctly"
21024 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21025 remote_mds_nodsh && skip "remote MDS with nodsh"
21027 mkdir -p $DIR/$tdir
21029 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
21030 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
21031 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
21032 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
21034 umount_client $MOUNT || error "umount failed"
21035 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
21036 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
21037 mount_client $MOUNT || error "failed to mount client"
21039 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
21040 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
21042 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
21048 for LOOP in $(seq $count); do
21049 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
21050 cancel_lru_locks $OSC || true
21058 for LOOP in $(seq $1); do
21059 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
21064 test_241a() { # was test_241
21065 local bsize=$PAGE_SIZE
21067 (( bsize < 40960 )) && bsize=40960
21068 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21070 cancel_lru_locks $OSC
21071 test_241_bio 1000 $bsize &
21073 test_241_dio 1000 $bsize
21076 run_test 241a "bio vs dio"
21079 local bsize=$PAGE_SIZE
21081 (( bsize < 40960 )) && bsize=40960
21082 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
21084 test_241_dio 1000 $bsize &
21086 test_241_dio 1000 $bsize
21089 run_test 241b "dio vs dio"
21092 remote_mds_nodsh && skip "remote MDS with nodsh"
21094 mkdir_on_mdt0 $DIR/$tdir
21095 touch $DIR/$tdir/$tfile
21097 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
21098 do_facet mds1 lctl set_param fail_loc=0x105
21099 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
21101 do_facet mds1 lctl set_param fail_loc=0
21102 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
21104 run_test 242 "mdt_readpage failure should not cause directory unreadable"
21108 test_mkdir $DIR/$tdir
21109 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
21111 run_test 243 "various group lock tests"
21115 test_mkdir $DIR/$tdir
21116 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
21117 sendfile_grouplock $DIR/$tdir/$tfile || \
21118 error "sendfile+grouplock failed"
21121 run_test 244a "sendfile with group lock tests"
21125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
21128 local size=$((1024*1024))
21130 test_mkdir $DIR/$tdir
21131 for i in $(seq 1 $threads); do
21132 local file=$DIR/$tdir/file_$((i / 10))
21133 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
21136 for i in $(seq 1 $threads); do
21140 run_test 244b "multi-threaded write with group lock"
21143 local flagname="multi_mod_rpcs"
21144 local connect_data_name="max_mod_rpcs"
21147 # check if multiple modify RPCs flag is set
21148 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
21149 grep "connect_flags:")
21152 echo "$out" | grep -qw $flagname
21153 if [ $? -ne 0 ]; then
21154 echo "connect flag $flagname is not set"
21158 # check if multiple modify RPCs data is set
21159 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
21162 echo "$out" | grep -qw $connect_data_name ||
21163 error "import should have connect data $connect_data_name"
21165 run_test 245a "check mdc connection flag/data: multiple modify RPCs"
21168 local flagname="multi_mod_rpcs"
21169 local connect_data_name="max_mod_rpcs"
21172 remote_mds_nodsh && skip "remote MDS with nodsh"
21173 [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
21175 # check if multiple modify RPCs flag is set
21176 out=$(do_facet mds1 \
21177 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import |
21178 grep "connect_flags:")
21181 [[ "$out" =~ $flagname ]] || skip "connect flag $flagname is not set"
21183 # check if multiple modify RPCs data is set
21184 out=$(do_facet mds1 \
21185 $LCTL get_param osp.$FSNAME-MDT0001-osp-MDT0000.import)
21187 [[ "$out" =~ $connect_data_name ]] ||
21190 error "missing connect data $connect_data_name"
21193 run_test 245b "check osp connection flag/data: multiple modify RPCs"
21199 umount_client $submount
21204 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21206 skip_env "Fileset feature is not supported"
21208 local submount=${MOUNT}_$tdir
21211 mkdir -p $submount || error "mkdir $submount failed"
21212 FILESET="$FILESET/$tdir" mount_client $submount ||
21213 error "mount $submount failed"
21214 trap "cleanup_247 $submount" EXIT
21215 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
21216 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
21217 error "read $MOUNT/$tdir/$tfile failed"
21218 cleanup_247 $submount
21220 run_test 247a "mount subdir as fileset"
21223 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21224 skip_env "Fileset feature is not supported"
21226 local submount=${MOUNT}_$tdir
21228 rm -rf $MOUNT/$tdir
21229 mkdir -p $submount || error "mkdir $submount failed"
21231 FILESET="$FILESET/$tdir" mount_client $submount &&
21232 error "mount $submount should fail"
21235 run_test 247b "mount subdir that dose not exist"
21238 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21239 skip_env "Fileset feature is not supported"
21241 local submount=${MOUNT}_$tdir
21243 mkdir -p $MOUNT/$tdir/dir1
21244 mkdir -p $submount || error "mkdir $submount failed"
21245 trap "cleanup_247 $submount" EXIT
21246 FILESET="$FILESET/$tdir" mount_client $submount ||
21247 error "mount $submount failed"
21248 local fid=$($LFS path2fid $MOUNT/)
21249 $LFS fid2path $submount $fid && error "fid2path should fail"
21250 cleanup_247 $submount
21252 run_test 247c "running fid2path outside subdirectory root"
21255 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
21256 skip "Fileset feature is not supported"
21258 local submount=${MOUNT}_$tdir
21260 mkdir -p $MOUNT/$tdir/dir1
21261 mkdir -p $submount || error "mkdir $submount failed"
21262 FILESET="$FILESET/$tdir" mount_client $submount ||
21263 error "mount $submount failed"
21264 trap "cleanup_247 $submount" EXIT
21266 local td=$submount/dir1
21267 local fid=$($LFS path2fid $td)
21268 [ -z "$fid" ] && error "path2fid unable to get $td FID"
21270 # check that we get the same pathname back
21273 for rootpath in "$submount" "$submount///" "$submount/dir1"; do
21274 echo "$rootpath $fid"
21275 found=$($LFS fid2path $rootpath "$fid")
21276 [ -n "$found" ] || error "fid2path should succeed"
21277 [ "$found" == "$td" ] || error "fid2path $found != $td"
21279 # check wrong root path format
21280 rootpath=$submount"_wrong"
21281 found=$($LFS fid2path $rootpath "$fid")
21282 [ -z "$found" ] || error "fid2path should fail ($rootpath != $submount)"
21284 cleanup_247 $submount
21286 run_test 247d "running fid2path inside subdirectory root"
21290 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21292 skip "Fileset feature is not supported"
21294 local submount=${MOUNT}_$tdir
21297 mkdir -p $submount || error "mkdir $submount failed"
21298 FILESET="$FILESET/.." mount_client $submount &&
21299 error "mount $submount should fail"
21302 run_test 247e "mount .. as fileset"
21305 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21306 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
21307 skip "Need at least version 2.13.52"
21308 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21309 skip "Need at least version 2.14.50"
21310 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
21312 skip "Fileset feature is not supported"
21314 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
21315 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
21316 error "mkdir remote failed"
21317 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
21318 error "mkdir remote/subdir failed"
21319 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
21320 error "mkdir striped failed"
21321 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
21323 local submount=${MOUNT}_$tdir
21325 mkdir -p $submount || error "mkdir $submount failed"
21326 stack_trap "rmdir $submount"
21330 local fileset=$FILESET
21331 local mdts=$(comma_list $(mdts_nodes))
21333 stat=$(do_facet mds1 $LCTL get_param -n \
21334 mdt.*MDT0000.enable_remote_subdir_mount)
21335 stack_trap "do_nodes $mdts $LCTL set_param \
21336 mdt.*.enable_remote_subdir_mount=$stat"
21338 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
21339 stack_trap "umount_client $submount"
21340 FILESET="$fileset/$tdir/remote" mount_client $submount &&
21341 error "mount remote dir $dir should fail"
21343 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
21344 $tdir/striped/. ; do
21345 FILESET="$fileset/$dir" mount_client $submount ||
21346 error "mount $dir failed"
21347 umount_client $submount
21350 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
21351 FILESET="$fileset/$tdir/remote" mount_client $submount ||
21352 error "mount $tdir/remote failed"
21354 run_test 247f "mount striped or remote directory as fileset"
21357 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
21358 [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
21359 skip "Need at least version 2.14.50"
21361 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
21362 error "mkdir $tdir failed"
21363 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
21365 local submount=${MOUNT}_$tdir
21367 mkdir -p $submount || error "mkdir $submount failed"
21368 stack_trap "rmdir $submount"
21370 FILESET="$fileset/$tdir" mount_client $submount ||
21371 error "mount $dir failed"
21372 stack_trap "umount $submount"
21374 local mdts=$(comma_list $(mdts_nodes))
21378 stat $submount > /dev/null
21379 cancel_lru_locks $MDC
21380 stat $submount > /dev/null
21381 stat $submount/$tfile > /dev/null
21382 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
21383 stat $submount/$tfile > /dev/null
21384 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
21385 awk '/getattr/ {sum += $2} END {print sum}')
21387 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
21389 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
21392 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
21393 [ -z "$fast_read_sav" ] && skip "no fast read support"
21395 # create a large file for fast read verification
21396 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
21398 # make sure the file is created correctly
21399 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
21400 { rm -f $DIR/$tfile; skip "file creation error"; }
21402 echo "Test 1: verify that fast read is 4 times faster on cache read"
21404 # small read with fast read enabled
21405 $LCTL set_param -n llite.*.fast_read=1
21406 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21407 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21408 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21409 # small read with fast read disabled
21410 $LCTL set_param -n llite.*.fast_read=0
21411 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
21412 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21413 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21415 # verify that fast read is 4 times faster for cache read
21416 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
21417 error_not_in_vm "fast read was not 4 times faster: " \
21418 "$t_fast vs $t_slow"
21420 echo "Test 2: verify the performance between big and small read"
21421 $LCTL set_param -n llite.*.fast_read=1
21423 # 1k non-cache read
21424 cancel_lru_locks osc
21425 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21426 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21427 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21429 # 1M non-cache read
21430 cancel_lru_locks osc
21431 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
21432 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
21433 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
21435 # verify that big IO is not 4 times faster than small IO
21436 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
21437 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
21439 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
21442 run_test 248a "fast read verification"
21445 # Default short_io_bytes=16384, try both smaller and larger sizes.
21446 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
21447 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
21448 echo "bs=53248 count=113 normal buffered write"
21449 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
21450 error "dd of initial data file failed"
21451 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
21453 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
21454 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
21455 error "dd with sync normal writes failed"
21456 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
21458 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
21459 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
21460 error "dd with sync small writes failed"
21461 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
21463 cancel_lru_locks osc
21465 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
21466 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
21467 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
21468 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
21469 iflag=direct || error "dd with O_DIRECT small read failed"
21470 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
21471 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
21472 error "compare $TMP/$tfile.1 failed"
21474 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
21475 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
21477 # just to see what the maximum tunable value is, and test parsing
21478 echo "test invalid parameter 2MB"
21479 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
21480 error "too-large short_io_bytes allowed"
21481 echo "test maximum parameter 512KB"
21482 # if we can set a larger short_io_bytes, run test regardless of version
21483 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
21484 # older clients may not allow setting it this large, that's OK
21485 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
21486 skip "Need at least client version 2.13.50"
21487 error "medium short_io_bytes failed"
21489 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21490 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
21492 echo "test large parameter 64KB"
21493 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
21494 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
21496 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
21497 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
21498 error "dd with sync large writes failed"
21499 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
21501 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
21502 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
21503 num=$((113 * 4096 / PAGE_SIZE))
21504 echo "bs=$size count=$num oflag=direct large write $tfile.3"
21505 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
21506 error "dd with O_DIRECT large writes failed"
21507 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
21508 error "compare $DIR/$tfile.3 failed"
21510 cancel_lru_locks osc
21512 echo "bs=$size count=$num iflag=direct large read $tfile.2"
21513 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
21514 error "dd with O_DIRECT large read failed"
21515 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
21516 error "compare $TMP/$tfile.2 failed"
21518 echo "bs=$size count=$num iflag=direct large read $tfile.3"
21519 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
21520 error "dd with O_DIRECT large read failed"
21521 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
21522 error "compare $TMP/$tfile.3 failed"
21524 run_test 248b "test short_io read and write for both small and large sizes"
21526 test_249() { # LU-7890
21527 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
21528 skip "Need at least version 2.8.54"
21531 $LFS setstripe -c 1 $DIR/$tfile
21532 # Offset 2T == 4k * 512M
21533 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
21534 error "dd to 2T offset failed"
21536 run_test 249 "Write above 2T file size"
21539 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
21540 && skip "no 16TB file size limit on ZFS"
21542 $LFS setstripe -c 1 $DIR/$tfile
21543 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
21544 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
21545 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
21546 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
21547 conv=notrunc,fsync && error "append succeeded"
21550 run_test 250 "Write above 16T limit"
21553 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
21555 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
21556 #Skip once - writing the first stripe will succeed
21557 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21558 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
21559 error "short write happened"
21561 $LCTL set_param fail_loc=0xa0001407 fail_val=1
21562 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
21563 error "short read happened"
21567 run_test 251 "Handling short read and write correctly"
21570 remote_mds_nodsh && skip "remote MDS with nodsh"
21571 remote_ost_nodsh && skip "remote OST with nodsh"
21572 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
21573 skip_env "ldiskfs only test"
21583 # check lr_reader on OST0000
21585 dev=$(facet_device $tgt)
21586 out=$(do_facet $tgt $LR_READER $dev)
21587 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21589 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
21590 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
21591 error "Invalid uuid returned by $LR_READER on target $tgt"
21592 echo -e "uuid returned by $LR_READER is '$uuid'\n"
21594 # check lr_reader -c on MDT0000
21596 dev=$(facet_device $tgt)
21597 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
21598 skip "$LR_READER does not support additional options"
21600 out=$(do_facet $tgt $LR_READER -c $dev)
21601 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21603 num=$(echo "$out" | grep -c "mdtlov")
21604 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
21605 error "Invalid number of mdtlov clients returned by $LR_READER"
21606 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
21608 # check lr_reader -cr on MDT0000
21609 out=$(do_facet $tgt $LR_READER -cr $dev)
21610 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
21612 echo "$out" | grep -q "^reply_data:$" ||
21613 error "$LR_READER should have returned 'reply_data' section"
21614 num=$(echo "$out" | grep -c "client_generation")
21615 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
21617 run_test 252 "check lr_reader tool"
21620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21621 remote_mds_nodsh && skip "remote MDS with nodsh"
21622 remote_mgs_nodsh && skip "remote MGS with nodsh"
21626 local ost_name=$(ostname_from_index $ostidx)
21629 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
21630 do_facet $SINGLEMDS $LCTL get_param -n \
21631 osp.$mdtosc_proc1.reserved_mb_high ||
21632 skip "remote MDS does not support reserved_mb_high"
21636 wait_delete_completed
21639 pool_add $TESTNAME || error "Pool creation failed"
21640 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
21642 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
21643 error "Setstripe failed"
21645 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
21647 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
21649 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
21651 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21652 osp.$mdtosc_proc1.prealloc_status)
21653 echo "prealloc_status $oa_status"
21655 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
21656 error "File creation should fail"
21658 #object allocation was stopped, but we still able to append files
21659 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
21660 oflag=append || error "Append failed"
21662 rm -f $DIR/$tdir/$tfile.0
21664 # For this test, we want to delete the files we created to go out of
21665 # space but leave the watermark, so we remain nearly out of space
21666 ost_watermarks_enospc_delete_files $tfile $ostidx
21668 wait_delete_completed
21672 for i in $(seq 10 12); do
21673 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
21674 2>/dev/null || error "File creation failed after rm"
21677 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
21678 osp.$mdtosc_proc1.prealloc_status)
21679 echo "prealloc_status $oa_status"
21681 if (( oa_status != 0 )); then
21682 error "Object allocation still disable after rm"
21685 run_test 253 "Check object allocation limit"
21688 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21689 remote_mds_nodsh && skip "remote MDS with nodsh"
21691 local mdt=$(facet_svc $SINGLEMDS)
21693 do_facet $SINGLEMDS $LCTL get_param -n mdd.$mdt.changelog_size ||
21694 skip "MDS does not support changelog_size"
21698 changelog_register || error "changelog_register failed"
21700 changelog_clear 0 || error "changelog_clear failed"
21702 local size1=$(do_facet $SINGLEMDS \
21703 $LCTL get_param -n mdd.$mdt.changelog_size)
21704 echo "Changelog size $size1"
21707 $LFS mkdir -i 0 $DIR/$tdir
21709 mkdir -p $DIR/$tdir/pics/2008/zachy
21710 touch $DIR/$tdir/pics/2008/zachy/timestamp
21711 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
21712 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
21713 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
21714 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
21715 rm $DIR/$tdir/pics/desktop.jpg
21717 local size2=$(do_facet $SINGLEMDS \
21718 $LCTL get_param -n mdd.$mdt.changelog_size)
21719 echo "Changelog size after work $size2"
21721 (( $size2 > $size1 )) ||
21722 error "new Changelog size=$size2 less than old size=$size1"
21724 run_test 254 "Check changelog size"
21731 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
21732 awk -F: '{print $2}' | grep $type > /dev/null
21733 if [ $? -ne 0 ]; then
21743 lfs ladvise -a willread $file > /dev/null 2>&1
21744 if [ $? -eq 0 ]; then
21748 lfs ladvise -a willread $file 2>&1 |
21749 grep "Inappropriate ioctl for device" > /dev/null
21750 if [ $? -eq 0 ]; then
21757 bc <<<"scale=2; ($1 - $2) * 100 / $2"
21760 # run a random read IO workload
21761 # usage: random_read_iops <filename> <filesize> <iosize>
21762 random_read_iops() {
21765 local iosize=${3:-4096}
21767 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
21768 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
21771 drop_file_oss_cache() {
21775 $LFS ladvise -a dontneed $file 2>/dev/null ||
21776 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
21779 ladvise_willread_performance()
21782 local average_origin=0
21783 local average_cache=0
21784 local average_ladvise=0
21786 for ((i = 1; i <= $repeat; i++)); do
21787 echo "Iter $i/$repeat: reading without willread hint"
21788 cancel_lru_locks osc
21789 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
21790 local speed_origin=$(random_read_iops $DIR/$tfile $size)
21791 echo "Iter $i/$repeat: uncached speed: $speed_origin"
21792 average_origin=$(bc <<<"$average_origin + $speed_origin")
21794 cancel_lru_locks osc
21795 local speed_cache=$(random_read_iops $DIR/$tfile $size)
21796 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
21797 average_cache=$(bc <<<"$average_cache + $speed_cache")
21799 cancel_lru_locks osc
21800 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
21801 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
21802 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
21803 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
21804 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
21806 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
21807 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
21808 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
21810 speedup_cache=$(percent $average_cache $average_origin)
21811 speedup_ladvise=$(percent $average_ladvise $average_origin)
21813 echo "Average uncached read: $average_origin"
21814 echo "Average speedup with OSS cached read: " \
21815 "$average_cache = +$speedup_cache%"
21816 echo "Average speedup with ladvise willread: " \
21817 "$average_ladvise = +$speedup_ladvise%"
21819 local lowest_speedup=20
21820 if (( ${average_cache%.*} < $lowest_speedup )); then
21821 echo "Speedup with OSS cached read less than $lowest_speedup%,"\
21822 " got $average_cache%. Skipping ladvise willread check."
21826 # the test won't work on ZFS until it supports 'ladvise dontneed', but
21827 # it is still good to run until then to exercise 'ladvise willread'
21828 ! $LFS ladvise -a dontneed $DIR/$tfile &&
21829 [ "$ost1_FSTYPE" = "zfs" ] &&
21830 echo "osd-zfs does not support dontneed or drop_caches" &&
21833 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
21834 (( ${average_ladvise%.*} > ${lowest_speedup%.*} )) ||
21835 error_not_in_vm "Speedup with willread is less than " \
21836 "$lowest_speedup%, got $average_ladvise%"
21840 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
21841 skip "lustre < 2.8.54 does not support ladvise "
21842 remote_ost_nodsh && skip "remote OST with nodsh"
21844 stack_trap "rm -f $DIR/$tfile"
21845 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
21847 ladvise_no_type willread $DIR/$tfile &&
21848 skip "willread ladvise is not supported"
21850 ladvise_no_ioctl $DIR/$tfile &&
21851 skip "ladvise ioctl is not supported"
21854 local size=$((size_mb * 1048576))
21855 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
21856 error "dd to $DIR/$tfile failed"
21858 lfs ladvise -a willread $DIR/$tfile ||
21859 error "Ladvise failed with no range argument"
21861 lfs ladvise -a willread -s 0 $DIR/$tfile ||
21862 error "Ladvise failed with no -l or -e argument"
21864 lfs ladvise -a willread -e 1 $DIR/$tfile ||
21865 error "Ladvise failed with only -e argument"
21867 lfs ladvise -a willread -l 1 $DIR/$tfile ||
21868 error "Ladvise failed with only -l argument"
21870 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
21871 error "End offset should not be smaller than start offset"
21873 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
21874 error "End offset should not be equal to start offset"
21876 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
21877 error "Ladvise failed with overflowing -s argument"
21879 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
21880 error "Ladvise failed with overflowing -e argument"
21882 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
21883 error "Ladvise failed with overflowing -l argument"
21885 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
21886 error "Ladvise succeeded with conflicting -l and -e arguments"
21888 echo "Synchronous ladvise should wait"
21890 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
21891 do_nodes $(comma_list $(osts_nodes)) \
21892 $LCTL set_param fail_val=$delay fail_loc=0x237
21894 local start_ts=$SECONDS
21895 lfs ladvise -a willread $DIR/$tfile ||
21896 error "Ladvise failed with no range argument"
21897 local end_ts=$SECONDS
21898 local inteval_ts=$((end_ts - start_ts))
21900 if [ $inteval_ts -lt $(($delay - 1)) ]; then
21901 error "Synchronous advice didn't wait reply"
21904 echo "Asynchronous ladvise shouldn't wait"
21905 local start_ts=$SECONDS
21906 lfs ladvise -a willread -b $DIR/$tfile ||
21907 error "Ladvise failed with no range argument"
21908 local end_ts=$SECONDS
21909 local inteval_ts=$((end_ts - start_ts))
21911 if [ $inteval_ts -gt $(($delay / 2)) ]; then
21912 error "Asynchronous advice blocked"
21915 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
21916 ladvise_willread_performance
21918 run_test 255a "check 'lfs ladvise -a willread'"
21924 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
21928 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
21929 skip "lustre < 2.8.54 does not support ladvise "
21930 remote_ost_nodsh && skip "remote OST with nodsh"
21932 stack_trap "rm -f $DIR/$tfile"
21933 lfs setstripe -c 1 -i 0 $DIR/$tfile
21935 ladvise_no_type dontneed $DIR/$tfile &&
21936 skip "dontneed ladvise is not supported"
21938 ladvise_no_ioctl $DIR/$tfile &&
21939 skip "ladvise ioctl is not supported"
21941 ! $LFS ladvise -a dontneed $DIR/$tfile &&
21942 [ "$ost1_FSTYPE" = "zfs" ] &&
21943 skip "zfs-osd does not support 'ladvise dontneed'"
21946 local size=$((size_mb * 1048576))
21947 # In order to prevent disturbance of other processes, only check 3/4
21948 # of the memory usage
21949 local kibibytes=$((size_mb * 1024 * 3 / 4))
21951 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
21952 error "dd to $DIR/$tfile failed"
21954 #force write to complete before dropping OST cache & checking memory
21957 local total=$(facet_meminfo ost1 MemTotal)
21958 echo "Total memory: $total KiB"
21960 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
21961 local before_read=$(facet_meminfo ost1 Cached)
21962 echo "Cache used before read: $before_read KiB"
21964 lfs ladvise -a willread $DIR/$tfile ||
21965 error "Ladvise willread failed"
21966 local after_read=$(facet_meminfo ost1 Cached)
21967 echo "Cache used after read: $after_read KiB"
21969 lfs ladvise -a dontneed $DIR/$tfile ||
21970 error "Ladvise dontneed again failed"
21971 local no_read=$(facet_meminfo ost1 Cached)
21972 echo "Cache used after dontneed ladvise: $no_read KiB"
21974 if [ $total -lt $((before_read + kibibytes)) ]; then
21975 echo "Memory is too small, abort checking"
21979 if [ $((before_read + kibibytes)) -gt $after_read ]; then
21980 error "Ladvise willread should use more memory" \
21981 "than $kibibytes KiB"
21984 if [ $((no_read + kibibytes)) -gt $after_read ]; then
21985 error "Ladvise dontneed should release more memory" \
21986 "than $kibibytes KiB"
21989 run_test 255b "check 'lfs ladvise -a dontneed'"
21992 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
21993 skip "lustre < 2.10.50 does not support lockahead"
21995 local ost1_imp=$(get_osc_import_name client ost1)
21996 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
22004 test_mkdir -p $DIR/$tdir
22005 $LFS setstripe -i 0 -c 1 $DIR/$tdir
22007 #test 10 returns only success/failure
22009 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22011 if [ $rc -eq 255 ]; then
22012 error "Ladvise test${i} failed, ${rc}"
22015 #test 11 counts lock enqueue requests, all others count new locks
22017 count=$(do_facet ost1 \
22018 $LCTL get_param -n ost.OSS.ost.stats)
22019 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
22021 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22023 if [ $rc -eq 255 ]; then
22024 error "Ladvise test${i} failed, ${rc}"
22027 new_count=$(do_facet ost1 \
22028 $LCTL get_param -n ost.OSS.ost.stats)
22029 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
22030 awk '{ print $2 }')
22032 difference="$((new_count - count))"
22033 if [ $difference -ne $rc ]; then
22034 error "Ladvise test${i}, bad enqueue count, returned " \
22035 "${rc}, actual ${difference}"
22038 for i in $(seq 12 21); do
22039 # If we do not do this, we run the risk of having too many
22040 # locks and starting lock cancellation while we are checking
22042 cancel_lru_locks osc
22044 count=$($LCTL get_param -n \
22045 ldlm.namespaces.$imp_name.lock_unused_count)
22047 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22049 if [ $rc -eq 255 ]; then
22050 error "Ladvise test ${i} failed, ${rc}"
22053 new_count=$($LCTL get_param -n \
22054 ldlm.namespaces.$imp_name.lock_unused_count)
22055 difference="$((new_count - count))"
22057 # Test 15 output is divided by 100 to map down to valid return
22058 if [ $i -eq 15 ]; then
22062 if [ $difference -ne $rc ]; then
22063 error "Ladvise test ${i}, bad lock count, returned " \
22064 "${rc}, actual ${difference}"
22068 #test 22 returns only success/failure
22070 lockahead_test -d $DIR/$tdir -t $i -f $tfile
22072 if [ $rc -eq 255 ]; then
22073 error "Ladvise test${i} failed, ${rc}"
22076 run_test 255c "suite of ladvise lockahead tests"
22079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22080 remote_mds_nodsh && skip "remote MDS with nodsh"
22081 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22082 changelog_users $SINGLEMDS | grep "^cl" &&
22083 skip "active changelog user"
22089 mdt_dev=$(facet_device $SINGLEMDS)
22092 changelog_register || error "changelog_register failed"
22095 mkdir_on_mdt -i$(($(facet_number $SINGLEMDS) - 1)) $DIR/$tdir
22097 changelog_clear 0 || error "changelog_clear failed"
22100 touch $DIR/$tdir/{1..10}
22103 stop $SINGLEMDS || error "Fail to stop MDT"
22106 start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
22107 error "Fail to start MDT"
22109 #after mount new plainllog is used
22110 touch $DIR/$tdir/{11..19}
22111 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
22112 stack_trap "rm -f $tmpfile"
22113 cat_sl=$(do_facet $SINGLEMDS "sync; \
22114 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22115 llog_reader $tmpfile | grep -c type=1064553b")
22116 do_facet $SINGLEMDS llog_reader $tmpfile
22118 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
22120 changelog_clear 0 || error "changelog_clear failed"
22122 cat_sl=$(do_facet $SINGLEMDS "sync; \
22123 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
22124 llog_reader $tmpfile | grep -c type=1064553b")
22126 if (( cat_sl == 2 )); then
22127 error "Empty plain llog was not deleted from changelog catalog"
22128 elif (( cat_sl != 1 )); then
22129 error "Active plain llog shouldn't be deleted from catalog"
22132 run_test 256 "Check llog delete for empty and not full state"
22135 remote_mds_nodsh && skip "remote MDS with nodsh"
22136 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
22137 skip "Need MDS version at least 2.8.55"
22139 test_mkdir $DIR/$tdir
22141 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
22142 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
22145 #define OBD_FAIL_MDS_XATTR_REP 0x161
22146 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22147 local facet=mds$((mdtidx + 1))
22148 set_nodes_failloc $(facet_active_host $facet) 0x80000161
22149 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
22151 stop $facet || error "stop MDS failed"
22152 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
22153 error "start MDS fail"
22154 wait_recovery_complete $facet
22156 run_test 257 "xattr locks are not lost"
22158 # Verify we take the i_mutex when security requires it
22160 #define OBD_FAIL_IMUTEX_SEC 0x141c
22161 $LCTL set_param fail_loc=0x141c
22163 chmod u+s $DIR/$tfile
22164 chmod a+rwx $DIR/$tfile
22165 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22167 if [ $RC -ne 0 ]; then
22168 error "error, failed to take i_mutex, rc=$?"
22172 run_test 258a "verify i_mutex security behavior when suid attributes is set"
22174 # Verify we do NOT take the i_mutex in the normal case
22176 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
22177 $LCTL set_param fail_loc=0x141d
22180 chmod a+rw $DIR/$tfile
22181 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
22183 if [ $RC -ne 0 ]; then
22184 error "error, took i_mutex unnecessarily, rc=$?"
22189 run_test 258b "verify i_mutex security behavior"
22192 local file=$DIR/$tfile
22196 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
22198 stack_trap "rm -f $file" EXIT
22200 wait_delete_completed
22201 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22202 echo "before: $before"
22204 $LFS setstripe -i 0 -c 1 $file
22205 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
22207 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22208 echo "after write: $after"
22210 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
22211 do_facet ost1 $LCTL set_param fail_loc=0x2301
22213 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22214 echo "after truncate: $after"
22217 do_facet ost1 $LCTL set_param fail_loc=0
22218 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
22220 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
22221 echo "after restart: $after"
22222 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
22223 error "missing truncate?"
22227 run_test 259 "crash at delayed truncate"
22230 #define OBD_FAIL_MDC_CLOSE 0x806
22231 $LCTL set_param fail_loc=0x80000806
22235 run_test 260 "Check mdc_close fail"
22237 ### Data-on-MDT sanity tests ###
22239 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22240 skip "Need MDS version at least 2.10.55 for DoM"
22243 local dom=$DIR/$tdir/dom_file
22244 local tmp=$DIR/$tdir/tmp_file
22246 mkdir_on_mdt0 $DIR/$tdir
22248 # basic checks for DoM component creation
22249 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
22250 error "Can set MDT layout to non-first entry"
22252 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
22253 error "Can define multiple entries as MDT layout"
22255 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
22257 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
22258 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
22259 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
22261 local mdtidx=$($LFS getstripe -m $dom)
22262 local mdtname=MDT$(printf %04x $mdtidx)
22263 local facet=mds$((mdtidx + 1))
22264 local space_check=1
22266 # Skip free space checks with ZFS
22267 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
22271 local size_tmp=$((65536 * 3))
22272 local mdtfree1=$(do_facet $facet \
22273 lctl get_param -n osd*.*$mdtname.kbytesfree)
22275 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22276 # check also direct IO along write
22277 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
22278 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22280 cmp $tmp $dom || error "file data is different"
22281 [ $(stat -c%s $dom) == $size_tmp ] ||
22282 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22283 if [ $space_check == 1 ]; then
22284 local mdtfree2=$(do_facet $facet \
22285 lctl get_param -n osd*.*$mdtname.kbytesfree)
22287 # increase in usage from by $size_tmp
22288 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22289 error "MDT free space wrong after write: " \
22290 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22294 local size_dom=10000
22296 $TRUNCATE $dom $size_dom
22297 [ $(stat -c%s $dom) == $size_dom ] ||
22298 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
22299 if [ $space_check == 1 ]; then
22300 mdtfree1=$(do_facet $facet \
22301 lctl get_param -n osd*.*$mdtname.kbytesfree)
22302 # decrease in usage from $size_tmp to new $size_dom
22303 [ $(($mdtfree1 - $mdtfree2)) -ge \
22304 $(((size_tmp - size_dom) / 1024)) ] ||
22305 error "MDT free space is wrong after truncate: " \
22306 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
22312 size_dom=$((size_dom + size_tmp))
22313 [ $(stat -c%s $dom) == $size_dom ] ||
22314 error "bad size after append: $(stat -c%s $dom) != $size_dom"
22315 if [ $space_check == 1 ]; then
22316 mdtfree2=$(do_facet $facet \
22317 lctl get_param -n osd*.*$mdtname.kbytesfree)
22318 # increase in usage by $size_tmp from previous
22319 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
22320 error "MDT free space is wrong after append: " \
22321 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
22326 if [ $space_check == 1 ]; then
22327 mdtfree1=$(do_facet $facet \
22328 lctl get_param -n osd*.*$mdtname.kbytesfree)
22329 # decrease in usage by $size_dom from previous
22330 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
22331 error "MDT free space is wrong after removal: " \
22332 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
22335 # combined striping
22336 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
22337 error "Can't create DoM + OST striping"
22339 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
22340 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
22341 # check also direct IO along write
22342 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
22344 cmp $tmp $dom || error "file data is different"
22345 [ $(stat -c%s $dom) == $size_tmp ] ||
22346 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
22351 run_test 270a "DoM: basic functionality tests"
22354 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22355 skip "Need MDS version at least 2.10.55"
22357 local dom=$DIR/$tdir/dom_file
22358 local max_size=1048576
22360 mkdir -p $DIR/$tdir
22361 $LFS setstripe -E $max_size -L mdt $dom
22363 # truncate over the limit
22364 $TRUNCATE $dom $(($max_size + 1)) &&
22365 error "successful truncate over the maximum size"
22366 # write over the limit
22367 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
22368 error "successful write over the maximum size"
22369 # append over the limit
22370 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
22371 echo "12345" >> $dom && error "successful append over the maximum size"
22376 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
22379 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22380 skip "Need MDS version at least 2.10.55"
22382 mkdir -p $DIR/$tdir
22383 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22385 # check files inherit DoM EA
22386 touch $DIR/$tdir/first
22387 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
22388 error "bad pattern"
22389 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
22390 error "bad stripe count"
22391 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
22392 error "bad stripe size"
22394 # check directory inherits DoM EA and uses it as default
22395 mkdir $DIR/$tdir/subdir
22396 touch $DIR/$tdir/subdir/second
22397 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
22398 error "bad pattern in sub-directory"
22399 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
22400 error "bad stripe count in sub-directory"
22401 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
22402 error "bad stripe size in sub-directory"
22405 run_test 270c "DoM: DoM EA inheritance tests"
22408 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22409 skip "Need MDS version at least 2.10.55"
22411 mkdir -p $DIR/$tdir
22412 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22414 # inherit default DoM striping
22415 mkdir $DIR/$tdir/subdir
22416 touch $DIR/$tdir/subdir/f1
22418 # change default directory striping
22419 $LFS setstripe -c 1 $DIR/$tdir/subdir
22420 touch $DIR/$tdir/subdir/f2
22421 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
22422 error "wrong default striping in file 2"
22423 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
22424 error "bad pattern in file 2"
22427 run_test 270d "DoM: change striping from DoM to RAID0"
22430 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22431 skip "Need MDS version at least 2.10.55"
22433 mkdir -p $DIR/$tdir/dom
22434 mkdir -p $DIR/$tdir/norm
22437 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
22438 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
22440 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
22441 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
22443 # find DoM files by layout
22444 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
22445 [ $NUM -eq $DOMFILES ] ||
22446 error "lfs find -L: found $NUM, expected $DOMFILES"
22447 echo "Test 1: lfs find 20 DOM files by layout: OK"
22449 # there should be 1 dir with default DOM striping
22450 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
22452 error "lfs find -L: found $NUM, expected 1 dir"
22453 echo "Test 2: lfs find 1 DOM dir by layout: OK"
22455 # find DoM files by stripe size
22456 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
22457 [ $NUM -eq $DOMFILES ] ||
22458 error "lfs find -S: found $NUM, expected $DOMFILES"
22459 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
22461 # find files by stripe offset except DoM files
22462 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
22463 [ $NUM -eq $NORMFILES ] ||
22464 error "lfs find -i: found $NUM, expected $NORMFILES"
22465 echo "Test 5: lfs find no DOM files by stripe index: OK"
22468 run_test 270e "DoM: lfs find with DoM files test"
22471 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22472 skip "Need MDS version at least 2.10.55"
22474 local mdtname=${FSNAME}-MDT0000-mdtlov
22475 local dom=$DIR/$tdir/dom_file
22476 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
22477 lod.$mdtname.dom_stripesize)
22478 local dom_limit=131072
22480 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
22481 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22482 lod.$mdtname.dom_stripesize)
22483 [ ${dom_limit} -eq ${dom_current} ] ||
22484 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
22486 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22487 $LFS setstripe -d $DIR/$tdir
22488 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
22489 error "Can't set directory default striping"
22491 # exceed maximum stripe size
22492 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22493 error "Can't create file with $((dom_limit * 2)) DoM stripe"
22494 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
22495 error "Able to create DoM component size more than LOD limit"
22497 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22498 dom_current=$(do_facet mds1 $LCTL get_param -n \
22499 lod.$mdtname.dom_stripesize)
22500 [ 0 -eq ${dom_current} ] ||
22501 error "Can't set zero DoM stripe limit"
22504 # attempt to create DoM file on server with disabled DoM should
22505 # remove DoM entry from layout and be succeed
22506 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
22507 error "Can't create DoM file (DoM is disabled)"
22508 [ $($LFS getstripe -L $dom) == "mdt" ] &&
22509 error "File has DoM component while DoM is disabled"
22512 # attempt to create DoM file with only DoM stripe should return error
22513 $LFS setstripe -E $dom_limit -L mdt $dom &&
22514 error "Able to create DoM-only file while DoM is disabled"
22516 # too low values to be aligned with smallest stripe size 64K
22517 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
22518 dom_current=$(do_facet mds1 $LCTL get_param -n \
22519 lod.$mdtname.dom_stripesize)
22520 [ 30000 -eq ${dom_current} ] &&
22521 error "Can set too small DoM stripe limit"
22523 # 64K is a minimal stripe size in Lustre, expect limit of that size
22524 [ 65536 -eq ${dom_current} ] ||
22525 error "Limit is not set to 64K but ${dom_current}"
22527 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
22528 dom_current=$(do_facet mds1 $LCTL get_param -n \
22529 lod.$mdtname.dom_stripesize)
22531 [ 2147483648 -eq ${dom_current} ] &&
22532 error "Can set too large DoM stripe limit"
22534 do_facet mds1 $LCTL set_param -n \
22535 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
22536 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
22537 error "Can't create DoM component size after limit change"
22538 do_facet mds1 $LCTL set_param -n \
22539 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
22540 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
22541 error "Can't create DoM file after limit decrease"
22542 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
22543 error "Can create big DoM component after limit decrease"
22544 touch ${dom}_def ||
22545 error "Can't create file with old default layout"
22547 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
22550 run_test 270f "DoM: maximum DoM stripe size checks"
22553 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
22554 skip "Need MDS version at least 2.13.52"
22555 local dom=$DIR/$tdir/$tfile
22557 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22558 local lodname=${FSNAME}-MDT0000-mdtlov
22560 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22561 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
22562 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
22563 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22565 local dom_limit=1024
22566 local dom_threshold="50%"
22568 $LFS setstripe -d $DIR/$tdir
22569 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
22570 error "Can't set directory default striping"
22572 do_facet mds1 $LCTL set_param -n \
22573 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
22574 # set 0 threshold and create DOM file to change tunable stripesize
22575 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
22576 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22577 error "Failed to create $dom file"
22578 # now tunable dom_cur_stripesize should reach maximum
22579 local dom_current=$(do_facet mds1 $LCTL get_param -n \
22580 lod.${lodname}.dom_stripesize_cur_kb)
22581 [[ $dom_current == $dom_limit ]] ||
22582 error "Current DOM stripesize is not maximum"
22585 # set threshold for further tests
22586 do_facet mds1 $LCTL set_param -n \
22587 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
22588 echo "DOM threshold is $dom_threshold free space"
22591 # Spoof bfree to exceed threshold
22592 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
22593 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
22594 for spfree in 40 20 0 15 30 55; do
22595 do_facet mds1 $LCTL set_param -n fail_val=$spfree
22596 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
22597 error "Failed to create $dom file"
22598 dom_def=$(do_facet mds1 $LCTL get_param -n \
22599 lod.${lodname}.dom_stripesize_cur_kb)
22600 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
22601 [[ $dom_def != $dom_current ]] ||
22602 error "Default stripe size was not changed"
22603 if (( spfree > 0 )) ; then
22604 dom_set=$($LFS getstripe -S $dom)
22605 (( dom_set == dom_def * 1024 )) ||
22606 error "DOM component size is still old"
22608 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22609 error "DoM component is set with no free space"
22612 dom_current=$dom_def
22615 run_test 270g "DoM: default DoM stripe size depends on free space"
22618 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
22619 skip "Need MDS version at least 2.13.53"
22621 local mdtname=${FSNAME}-MDT0000-mdtlov
22622 local dom=$DIR/$tdir/$tfile
22623 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22625 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
22626 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22628 $LFS mkdir -i 0 -c 1 $DIR/$tdir
22629 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
22630 error "can't create OST file"
22631 # mirrored file with DOM entry in the second mirror
22632 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
22633 error "can't create mirror with DoM component"
22635 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
22637 # DOM component in the middle and has other enries in the same mirror,
22638 # should succeed but lost DoM component
22639 $LFS setstripe --copy=${dom}_1 $dom ||
22640 error "Can't create file from OST|DOM mirror layout"
22641 # check new file has no DoM layout after all
22642 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
22643 error "File has DoM component while DoM is disabled"
22645 run_test 270h "DoM: DoM stripe removal when disabled on server"
22648 (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
22649 skip "Need MDS version at least 2.14.54"
22652 $LFS setstripe -L mdt -S 128k -c -1 $DIR/$tdir &&
22653 error "setstripe should fail" || true
22655 run_test 270i "DoM: setting invalid DoM striping should fail"
22658 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22659 skip "Need MDS version at least 2.10.55"
22661 local dom=$DIR/$tdir/dom
22663 mkdir -p $DIR/$tdir
22665 $LFS setstripe -E 1024K -L mdt $dom
22667 lctl set_param -n mdc.*.stats=clear
22668 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
22669 cat $dom > /dev/null
22670 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
22671 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
22675 run_test 271a "DoM: data is cached for read after write"
22678 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22679 skip "Need MDS version at least 2.10.55"
22681 local dom=$DIR/$tdir/dom
22683 mkdir -p $DIR/$tdir
22685 $LFS setstripe -E 1024K -L mdt -E EOF $dom
22687 lctl set_param -n mdc.*.stats=clear
22688 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
22689 cancel_lru_locks mdc
22690 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
22691 # second stat to check size is cached on client
22692 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
22693 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
22694 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
22697 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
22700 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22701 skip "Need MDS version at least 2.10.55"
22703 local dom=$DIR/$tdir/dom
22705 mkdir -p $DIR/$tdir
22707 $LFS setstripe -E 1024K -L mdt -E EOF $dom
22709 lctl set_param -n mdc.*.stats=clear
22710 lctl set_param -n osc.*.stats=clear
22711 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
22712 cancel_lru_locks mdc
22713 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
22714 # second stat to check size is cached on client
22715 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
22716 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
22717 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
22718 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
22719 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
22722 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
22728 local mdt=MDT$(printf %04x $mdtidx)
22730 if [ -z $param ]; then
22731 lctl get_param -n mdc.*$mdt*.stats
22733 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
22738 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
22739 skip "Need MDS version at least 2.10.55"
22741 local dom=$DIR/$tdir/dom
22743 mkdir -p $DIR/$tdir
22745 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22747 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
22748 local facet=mds$((mdtidx + 1))
22750 cancel_lru_locks mdc
22751 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
22752 createmany -o $dom 1000
22753 lctl set_param -n mdc.*.stats=clear
22754 smalliomany -w $dom 1000 200
22755 get_mdc_stats $mdtidx
22756 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
22757 # Each file has 1 open, 1 IO enqueues, total 2000
22758 # but now we have also +1 getxattr for security.capability, total 3000
22759 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
22760 unlinkmany $dom 1000
22762 cancel_lru_locks mdc
22763 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
22764 createmany -o $dom 1000
22765 lctl set_param -n mdc.*.stats=clear
22766 smalliomany -w $dom 1000 200
22767 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
22768 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
22769 # for OPEN and IO lock.
22770 [ $((enq - enq_2)) -ge 1000 ] ||
22771 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
22772 unlinkmany $dom 1000
22775 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
22777 cleanup_271def_tests() {
22783 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
22784 skip "Need MDS version at least 2.10.57"
22786 local dom=$DIR/$tdir/dom
22787 local tmp=$TMP/$tfile
22788 trap "cleanup_271def_tests $tmp" EXIT
22790 mkdir -p $DIR/$tdir
22792 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22794 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
22796 cancel_lru_locks mdc
22797 dd if=/dev/urandom of=$tmp bs=1000 count=1
22798 dd if=$tmp of=$dom bs=1000 count=1
22799 cancel_lru_locks mdc
22801 cat /etc/hosts >> $tmp
22802 lctl set_param -n mdc.*.stats=clear
22804 # append data to the same file it should update local page
22805 echo "Append to the same page"
22806 cat /etc/hosts >> $dom
22807 local num=$(get_mdc_stats $mdtidx ost_read)
22808 local ra=$(get_mdc_stats $mdtidx req_active)
22809 local rw=$(get_mdc_stats $mdtidx req_waittime)
22811 [ -z $num ] || error "$num READ RPC occured"
22812 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22816 cmp $tmp $dom || error "file miscompare"
22818 cancel_lru_locks mdc
22819 lctl set_param -n mdc.*.stats=clear
22821 echo "Open and read file"
22822 cat $dom > /dev/null
22823 local num=$(get_mdc_stats $mdtidx ost_read)
22824 local ra=$(get_mdc_stats $mdtidx req_active)
22825 local rw=$(get_mdc_stats $mdtidx req_waittime)
22827 [ -z $num ] || error "$num READ RPC occured"
22828 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22832 cmp $tmp $dom || error "file miscompare"
22836 run_test 271d "DoM: read on open (1K file in reply buffer)"
22839 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
22840 skip "Need MDS version at least 2.10.57"
22842 local dom=$DIR/$tdir/dom
22843 local tmp=$TMP/$tfile
22844 trap "cleanup_271def_tests $tmp" EXIT
22846 mkdir -p $DIR/$tdir
22848 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
22850 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
22852 cancel_lru_locks mdc
22853 dd if=/dev/urandom of=$tmp bs=265000 count=1
22854 dd if=$tmp of=$dom bs=265000 count=1
22855 cancel_lru_locks mdc
22856 cat /etc/hosts >> $tmp
22857 lctl set_param -n mdc.*.stats=clear
22859 echo "Append to the same page"
22860 cat /etc/hosts >> $dom
22861 local num=$(get_mdc_stats $mdtidx ost_read)
22862 local ra=$(get_mdc_stats $mdtidx req_active)
22863 local rw=$(get_mdc_stats $mdtidx req_waittime)
22865 [ -z $num ] || error "$num READ RPC occured"
22866 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22870 cmp $tmp $dom || error "file miscompare"
22872 cancel_lru_locks mdc
22873 lctl set_param -n mdc.*.stats=clear
22875 echo "Open and read file"
22876 cat $dom > /dev/null
22877 local num=$(get_mdc_stats $mdtidx ost_read)
22878 local ra=$(get_mdc_stats $mdtidx req_active)
22879 local rw=$(get_mdc_stats $mdtidx req_waittime)
22881 [ -z $num ] && num=0
22882 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
22883 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
22887 cmp $tmp $dom || error "file miscompare"
22891 run_test 271f "DoM: read on open (200K file and read tail)"
22894 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
22895 skip "Skipping due to old client or server version"
22897 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
22899 $CHECKSTAT -t file $DIR1/$tfile
22901 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
22904 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
22905 $LCTL set_param fail_loc=0x80000314
22906 rm $DIR1/$tfile || error "Unlink fails"
22908 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
22909 [ $RC -eq 0 ] || error "Failed write to stale object"
22911 run_test 271g "Discard DoM data vs client flush race"
22914 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22915 skip "Need MDS version at least 2.11.50"
22917 local dom=$DIR/$tdir/dom
22918 mkdir -p $DIR/$tdir
22920 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
22921 dd if=/dev/urandom of=$dom bs=512K count=1 ||
22922 error "failed to write data into $dom"
22923 local old_md5=$(md5sum $dom)
22925 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
22926 error "failed to migrate to the same DoM component"
22928 local new_md5=$(md5sum $dom)
22930 [ "$old_md5" == "$new_md5" ] ||
22931 error "md5sum differ: $old_md5, $new_md5"
22933 [ $($LFS getstripe -c $dom) -eq 2 ] ||
22934 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
22936 run_test 272a "DoM migration: new layout with the same DOM component"
22939 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22940 skip "Need MDS version at least 2.11.50"
22942 local dom=$DIR/$tdir/dom
22943 mkdir -p $DIR/$tdir
22944 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22946 local mdtidx=$($LFS getstripe -m $dom)
22947 local mdtname=MDT$(printf %04x $mdtidx)
22948 local facet=mds$((mdtidx + 1))
22950 local mdtfree1=$(do_facet $facet \
22951 lctl get_param -n osd*.*$mdtname.kbytesfree)
22952 dd if=/dev/urandom of=$dom bs=2M count=1 ||
22953 error "failed to write data into $dom"
22954 local old_md5=$(md5sum $dom)
22955 cancel_lru_locks mdc
22956 local mdtfree1=$(do_facet $facet \
22957 lctl get_param -n osd*.*$mdtname.kbytesfree)
22959 $LFS migrate -c2 $dom ||
22960 error "failed to migrate to the new composite layout"
22961 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
22962 error "MDT stripe was not removed"
22964 cancel_lru_locks mdc
22965 local new_md5=$(md5sum $dom)
22966 [ "$old_md5" == "$new_md5" ] ||
22967 error "$old_md5 != $new_md5"
22969 # Skip free space checks with ZFS
22970 if [ "$(facet_fstype $facet)" != "zfs" ]; then
22971 local mdtfree2=$(do_facet $facet \
22972 lctl get_param -n osd*.*$mdtname.kbytesfree)
22973 [ $mdtfree2 -gt $mdtfree1 ] ||
22974 error "MDT space is not freed after migration"
22978 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
22981 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
22982 skip "Need MDS version at least 2.11.50"
22984 local dom=$DIR/$tdir/$tfile
22985 mkdir -p $DIR/$tdir
22986 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
22988 local mdtidx=$($LFS getstripe -m $dom)
22989 local mdtname=MDT$(printf %04x $mdtidx)
22990 local facet=mds$((mdtidx + 1))
22992 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
22993 error "failed to write data into $dom"
22994 local old_md5=$(md5sum $dom)
22995 cancel_lru_locks mdc
22996 local mdtfree1=$(do_facet $facet \
22997 lctl get_param -n osd*.*$mdtname.kbytesfree)
22999 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
23000 error "failed to migrate to the new composite layout"
23001 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
23002 error "MDT stripe was not removed"
23004 cancel_lru_locks mdc
23005 local new_md5=$(md5sum $dom)
23006 [ "$old_md5" == "$new_md5" ] ||
23007 error "$old_md5 != $new_md5"
23009 # Skip free space checks with ZFS
23010 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23011 local mdtfree2=$(do_facet $facet \
23012 lctl get_param -n osd*.*$mdtname.kbytesfree)
23013 [ $mdtfree2 -gt $mdtfree1 ] ||
23014 error "MDS space is not freed after migration"
23018 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
23021 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23022 skip "Need MDS version at least 2.12.55"
23024 local dom=$DIR/$tdir/$tfile
23025 mkdir -p $DIR/$tdir
23026 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
23028 local mdtidx=$($LFS getstripe -m $dom)
23029 local mdtname=MDT$(printf %04x $mdtidx)
23030 local facet=mds$((mdtidx + 1))
23032 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23033 error "failed to write data into $dom"
23034 local old_md5=$(md5sum $dom)
23035 cancel_lru_locks mdc
23036 local mdtfree1=$(do_facet $facet \
23037 lctl get_param -n osd*.*$mdtname.kbytesfree)
23039 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
23040 error "failed mirroring to the new composite layout"
23041 $LFS mirror resync $dom ||
23042 error "failed mirror resync"
23043 $LFS mirror split --mirror-id 1 -d $dom ||
23044 error "failed mirror split"
23046 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
23047 error "MDT stripe was not removed"
23049 cancel_lru_locks mdc
23050 local new_md5=$(md5sum $dom)
23051 [ "$old_md5" == "$new_md5" ] ||
23052 error "$old_md5 != $new_md5"
23054 # Skip free space checks with ZFS
23055 if [ "$(facet_fstype $facet)" != "zfs" ]; then
23056 local mdtfree2=$(do_facet $facet \
23057 lctl get_param -n osd*.*$mdtname.kbytesfree)
23058 [ $mdtfree2 -gt $mdtfree1 ] ||
23059 error "MDS space is not freed after DOM mirror deletion"
23063 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
23066 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23067 skip "Need MDS version at least 2.12.55"
23069 local dom=$DIR/$tdir/$tfile
23070 mkdir -p $DIR/$tdir
23071 $LFS setstripe -c 2 $dom
23073 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23074 error "failed to write data into $dom"
23075 local old_md5=$(md5sum $dom)
23078 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
23079 error "failed mirroring to the DOM layout"
23080 $LFS mirror resync $dom ||
23081 error "failed mirror resync"
23082 $LFS mirror split --mirror-id 1 -d $dom ||
23083 error "failed mirror split"
23085 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23086 error "MDT stripe wasn't set"
23089 local new_md5=$(md5sum $dom)
23090 [ "$old_md5" == "$new_md5" ] ||
23091 error "$old_md5 != $new_md5"
23095 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
23098 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
23099 skip "Need MDS version at least 2.12.55"
23101 local dom=$DIR/$tdir/$tfile
23102 mkdir -p $DIR/$tdir
23103 $LFS setstripe -c 2 $dom
23105 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
23106 error "failed to write data into $dom"
23107 local old_md5=$(md5sum $dom)
23110 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
23111 error "failed migrating to the DOM file"
23113 [[ $($LFS getstripe -L --component-start=0 $dom) == 'mdt' ]] ||
23114 error "MDT stripe wasn't set"
23117 local new_md5=$(md5sum $dom)
23118 [ "$old_md5" != "$new_md5" ] &&
23119 error "$old_md5 != $new_md5"
23123 run_test 272f "DoM migration: OST-striped file to DOM file"
23126 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
23127 skip "Need MDS version at least 2.11.50"
23129 # Layout swap cannot be done if either file has DOM component,
23130 # this will never be supported, migration should be used instead
23132 local dom=$DIR/$tdir/$tfile
23133 mkdir -p $DIR/$tdir
23135 $LFS setstripe -c2 ${dom}_plain
23136 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
23137 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
23138 error "can swap layout with DoM component"
23139 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
23140 error "can swap layout with DoM component"
23142 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
23143 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
23144 error "can swap layout with DoM component"
23145 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
23146 error "can swap layout with DoM component"
23149 run_test 273a "DoM: layout swapping should fail with DOM"
23152 mkdir -p $DIR/$tdir
23153 $LFS setstripe -E 1M -L mdt -E -1 -c -1 $DIR/$tdir
23155 #define OBD_FAIL_MDS_COMMITRW_DELAY 0x16b
23156 do_facet mds1 $LCTL set_param fail_loc=0x8000016b fail_val=2
23158 $MULTIOP $DIR/$tdir/$tfile Ouw2097152c
23160 run_test 273b "DoM: race writeback and object destroy"
23163 remote_ost_nodsh && skip "remote OST with nodsh"
23164 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
23165 skip "Need OST version >= 2.10.57"
23167 local file=$DIR/$tfile
23170 oss=$(comma_list $(osts_nodes))
23172 dd if=/dev/urandom of=$file bs=1M count=2 ||
23173 error "failed to create a file"
23174 cancel_lru_locks osc
23177 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23178 error "failed to read a file"
23180 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
23181 $LCTL set_param fail_loc=0x8000031f
23183 cancel_lru_locks osc &
23186 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
23187 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
23188 #IO takes another lock, but matches the PENDING one
23189 #and places it to the IO RPC
23190 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
23191 error "failed to read a file with PENDING lock"
23193 run_test 275 "Read on a canceled duplicate lock"
23196 remote_ost_nodsh && skip "remote OST with nodsh"
23199 do_facet ost1 "(while true; do \
23200 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
23201 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
23204 for LOOP in $(seq 20); do
23206 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
23209 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
23210 rm $TMP/sanity_276_pid"
23212 run_test 276 "Race between mount and obd_statfs"
23215 $LCTL set_param ldlm.namespaces.*.lru_size=0
23216 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23217 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23218 grep ^used_mb | awk '{print $2}')
23219 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
23220 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
23221 oflag=direct conv=notrunc
23222 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
23223 grep ^used_mb | awk '{print $2}')
23224 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
23226 run_test 277 "Direct IO shall drop page cache"
23229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
23230 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
23231 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
23232 skip "needs the same host for mdt1 mdt2" && return
23237 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
23238 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
23244 echo "Starting MDTs"
23245 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
23247 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
23249 do_facet mds2 $LCTL set_param fail_loc=0
23251 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
23252 wait_recovery_complete mds2
23254 run_test 278 "Race starting MDS between MDTs stop/start"
23257 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
23258 skip "Need MGS version at least 2.13.52"
23259 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23260 combined_mgs_mds || skip "needs combined MGS/MDT"
23262 umount_client $MOUNT
23263 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
23264 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
23266 mount_client $MOUNT &
23268 stop mgs || error "stop mgs failed"
23269 #for a race mgs would crash
23270 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
23271 # make sure we unmount client before remounting
23273 umount_client $MOUNT
23274 mount_client $MOUNT || error "mount client failed"
23276 run_test 280 "Race between MGS umount and client llog processing"
23278 cleanup_test_300() {
23282 test_striped_dir() {
23287 mkdir -p $DIR/$tdir
23289 SAVE_UMASK=$(umask)
23290 trap cleanup_test_300 RETURN EXIT
23292 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
23293 $DIR/$tdir/striped_dir ||
23294 error "set striped dir error"
23296 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
23297 [ "$mode" = "755" ] || error "expect 755 got $mode"
23299 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
23300 error "getdirstripe failed"
23301 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
23302 if [ "$stripe_count" != "2" ]; then
23303 error "1:stripe_count is $stripe_count, expect 2"
23305 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
23306 if [ "$stripe_count" != "2" ]; then
23307 error "2:stripe_count is $stripe_count, expect 2"
23310 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
23311 if [ "$stripe_index" != "$mdt_index" ]; then
23312 error "stripe_index is $stripe_index, expect $mdt_index"
23315 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23316 error "nlink error after create striped dir"
23318 mkdir $DIR/$tdir/striped_dir/a
23319 mkdir $DIR/$tdir/striped_dir/b
23321 stat $DIR/$tdir/striped_dir/a ||
23322 error "create dir under striped dir failed"
23323 stat $DIR/$tdir/striped_dir/b ||
23324 error "create dir under striped dir failed"
23326 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
23327 error "nlink error after mkdir"
23329 rmdir $DIR/$tdir/striped_dir/a
23330 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
23331 error "nlink error after rmdir"
23333 rmdir $DIR/$tdir/striped_dir/b
23334 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
23335 error "nlink error after rmdir"
23337 chattr +i $DIR/$tdir/striped_dir
23338 createmany -o $DIR/$tdir/striped_dir/f 10 &&
23339 error "immutable flags not working under striped dir!"
23340 chattr -i $DIR/$tdir/striped_dir
23342 rmdir $DIR/$tdir/striped_dir ||
23343 error "rmdir striped dir error"
23351 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23352 skip "skipped for lustre < 2.7.0"
23353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23354 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23356 test_striped_dir 0 || error "failed on striped dir on MDT0"
23357 test_striped_dir 1 || error "failed on striped dir on MDT0"
23359 run_test 300a "basic striped dir sanity test"
23362 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23363 skip "skipped for lustre < 2.7.0"
23364 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23365 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23372 test_mkdir $DIR/$tdir || error "mkdir fail"
23373 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23374 error "set striped dir error"
23375 for i in {0..9}; do
23376 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
23378 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
23379 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
23380 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
23382 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
23383 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
23384 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
23388 run_test 300b "check ctime/mtime for striped dir"
23391 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23392 skip "skipped for lustre < 2.7.0"
23393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23394 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23398 mkdir_on_mdt0 $DIR/$tdir
23399 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
23400 error "set striped dir error"
23402 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
23403 error "chown striped dir failed"
23405 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
23406 error "create 5k files failed"
23408 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
23410 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
23414 run_test 300c "chown && check ls under striped directory"
23417 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
23418 skip "skipped for lustre < 2.7.0"
23419 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23420 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23425 mkdir -p $DIR/$tdir
23426 $LFS setstripe -c 2 $DIR/$tdir
23428 #local striped directory
23429 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23430 error "set striped dir error"
23431 #look at the directories for debug purposes
23433 $LFS getdirstripe $DIR/$tdir
23434 ls -l $DIR/$tdir/striped_dir
23435 $LFS getdirstripe $DIR/$tdir/striped_dir
23436 createmany -o $DIR/$tdir/striped_dir/f 10 ||
23437 error "create 10 files failed"
23439 #remote striped directory
23440 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
23441 error "set striped dir error"
23442 #look at the directories for debug purposes
23444 $LFS getdirstripe $DIR/$tdir
23445 ls -l $DIR/$tdir/remote_striped_dir
23446 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
23447 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
23448 error "create 10 files failed"
23450 for file in $(find $DIR/$tdir); do
23451 stripe_count=$($LFS getstripe -c $file)
23452 [ $stripe_count -eq 2 ] ||
23453 error "wrong stripe $stripe_count for $file"
23458 run_test 300d "check default stripe under striped directory"
23461 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23462 skip "Need MDS version at least 2.7.55"
23463 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23464 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23469 mkdir -p $DIR/$tdir
23471 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23472 error "set striped dir error"
23474 touch $DIR/$tdir/striped_dir/a
23475 touch $DIR/$tdir/striped_dir/b
23476 touch $DIR/$tdir/striped_dir/c
23478 mkdir $DIR/$tdir/striped_dir/dir_a
23479 mkdir $DIR/$tdir/striped_dir/dir_b
23480 mkdir $DIR/$tdir/striped_dir/dir_c
23482 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
23483 error "set striped adir under striped dir error"
23485 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
23486 error "set striped bdir under striped dir error"
23488 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
23489 error "set striped cdir under striped dir error"
23491 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
23492 error "rename dir under striped dir fails"
23494 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
23495 error "rename dir under different stripes fails"
23497 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
23498 error "rename file under striped dir should succeed"
23500 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
23501 error "rename dir under striped dir should succeed"
23505 run_test 300e "check rename under striped directory"
23508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23509 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23510 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23511 skip "Need MDS version at least 2.7.55"
23517 mkdir -p $DIR/$tdir
23519 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
23520 error "set striped dir error"
23522 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
23523 error "set striped dir error"
23525 touch $DIR/$tdir/striped_dir/a
23526 mkdir $DIR/$tdir/striped_dir/dir_a
23527 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
23528 error "create striped dir under striped dir fails"
23530 touch $DIR/$tdir/striped_dir1/b
23531 mkdir $DIR/$tdir/striped_dir1/dir_b
23532 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
23533 error "create striped dir under striped dir fails"
23535 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
23536 error "rename dir under different striped dir should fail"
23538 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
23539 error "rename striped dir under diff striped dir should fail"
23541 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
23542 error "rename file under diff striped dirs fails"
23546 run_test 300f "check rename cross striped directory"
23548 test_300_check_default_striped_dir()
23551 local default_count=$2
23552 local default_index=$3
23555 local dir_stripe_index
23558 echo "checking $dirname $default_count $default_index"
23559 $LFS setdirstripe -D -c $default_count -i $default_index \
23560 -H all_char $DIR/$tdir/$dirname ||
23561 error "set default stripe on striped dir error"
23562 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
23563 [ $stripe_count -eq $default_count ] ||
23564 error "expect $default_count get $stripe_count for $dirname"
23566 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
23567 [ $stripe_index -eq $default_index ] ||
23568 error "expect $default_index get $stripe_index for $dirname"
23570 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
23571 error "create dirs failed"
23573 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
23574 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
23575 for dir in $(find $DIR/$tdir/$dirname/*); do
23576 stripe_count=$($LFS getdirstripe -c $dir)
23577 (( $stripe_count == $default_count )) ||
23578 (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
23579 (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
23580 error "stripe count $default_count != $stripe_count for $dir"
23582 stripe_index=$($LFS getdirstripe -i $dir)
23583 [ $default_index -eq -1 ] ||
23584 [ $stripe_index -eq $default_index ] ||
23585 error "$stripe_index != $default_index for $dir"
23587 #check default stripe
23588 stripe_count=$($LFS getdirstripe -D -c $dir)
23589 [ $stripe_count -eq $default_count ] ||
23590 error "default count $default_count != $stripe_count for $dir"
23592 stripe_index=$($LFS getdirstripe -D -i $dir)
23593 [ $stripe_index -eq $default_index ] ||
23594 error "default index $default_index != $stripe_index for $dir"
23596 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
23600 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23601 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23602 skip "Need MDS version at least 2.7.55"
23608 mkdir_on_mdt0 $DIR/$tdir
23609 mkdir $DIR/$tdir/normal_dir
23611 #Checking when client cache stripe index
23612 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
23613 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
23614 error "create striped_dir failed"
23616 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
23617 error "create dir0 fails"
23618 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
23619 [ $stripe_index -eq 0 ] ||
23620 error "dir0 expect index 0 got $stripe_index"
23622 mkdir $DIR/$tdir/striped_dir/dir1 ||
23623 error "create dir1 fails"
23624 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
23625 [ $stripe_index -eq 1 ] ||
23626 error "dir1 expect index 1 got $stripe_index"
23628 #check default stripe count/stripe index
23629 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
23630 test_300_check_default_striped_dir normal_dir 1 0
23631 test_300_check_default_striped_dir normal_dir -1 1
23632 test_300_check_default_striped_dir normal_dir 2 -1
23634 #delete default stripe information
23635 echo "delete default stripeEA"
23636 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
23637 error "set default stripe on striped dir error"
23639 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
23640 for dir in $(find $DIR/$tdir/normal_dir/*); do
23641 stripe_count=$($LFS getdirstripe -c $dir)
23642 [ $stripe_count -eq 0 ] ||
23643 error "expect 1 get $stripe_count for $dir"
23646 run_test 300g "check default striped directory for normal directory"
23649 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23650 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23651 skip "Need MDS version at least 2.7.55"
23657 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23658 error "set striped dir error"
23660 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
23661 test_300_check_default_striped_dir striped_dir 1 0
23662 test_300_check_default_striped_dir striped_dir -1 1
23663 test_300_check_default_striped_dir striped_dir 2 -1
23665 #delete default stripe information
23666 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
23667 error "set default stripe on striped dir error"
23669 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
23670 for dir in $(find $DIR/$tdir/striped_dir/*); do
23671 stripe_count=$($LFS getdirstripe -c $dir)
23672 [ $stripe_count -eq 0 ] ||
23673 error "expect 1 get $stripe_count for $dir"
23676 run_test 300h "check default striped directory for striped directory"
23679 [[ $PARALLEL == "yes" ]] && skip "skip parallel run"
23680 (( $MDSCOUNT >= 2 )) || skip_env "needs >= 2 MDTs"
23681 (( $MDS1_VERSION >= $(version_code 2.7.55) )) ||
23682 skip "Need MDS version at least 2.7.55"
23689 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23690 error "set striped dir error"
23692 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
23693 error "create files under striped dir failed"
23695 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
23696 error "set striped hashdir error"
23698 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
23699 error "create dir0 under hash dir failed"
23700 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
23701 error "create dir1 under hash dir failed"
23702 $LFS setdirstripe -i0 -c$MDSCOUNT -H crush $DIR/$tdir/hashdir/d2 ||
23703 error "create dir2 under hash dir failed"
23705 # unfortunately, we need to umount to clear dir layout cache for now
23706 # once we fully implement dir layout, we can drop this
23707 umount_client $MOUNT || error "umount failed"
23708 mount_client $MOUNT || error "mount failed"
23710 $LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir
23711 local dircnt=$($LFS find -H fnv_1a_64,crush $DIR/$tdir/hashdir | wc -l)
23712 (( $dircnt == 2 )) || error "lfs find striped dir got $dircnt != 2"
23714 if (( $MDS1_VERSION > $(version_code 2.15.0) )); then
23715 $LFS mkdir -i0 -c$MDSCOUNT -H crush2 $DIR/$tdir/hashdir/d3 ||
23716 error "create crush2 dir $tdir/hashdir/d3 failed"
23717 $LFS find -H crush2 $DIR/$tdir/hashdir
23718 dircnt=$($LFS find -H crush2 $DIR/$tdir/hashdir | wc -l)
23719 (( $dircnt == 1 )) || error "find crush2 dir got $dircnt != 1"
23721 # mkdir with an invalid hash type (hash=fail_val) from client
23722 # should be replaced on MDS with a valid (default) hash type
23723 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
23724 $LCTL set_param fail_loc=0x1901 fail_val=99
23725 $LFS mkdir -c2 $DIR/$tdir/hashdir/d99
23727 local hash=$($LFS getdirstripe -H $DIR/$tdir/hashdir/d99)
23728 local expect=$(do_facet mds1 \
23729 $LCTL get_param -n lod.$FSNAME-MDT0000-mdtlov.mdt_hash)
23730 [[ $hash == $expect ]] ||
23731 error "d99 hash '$hash' != expected hash '$expect'"
23734 #set the stripe to be unknown hash type on read
23735 #define OBD_FAIL_LMV_UNKNOWN_STRIPE 0x1901
23736 $LCTL set_param fail_loc=0x1901 fail_val=99
23737 for ((i = 0; i < 10; i++)); do
23738 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
23739 error "stat f-$i failed"
23740 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
23743 touch $DIR/$tdir/striped_dir/f0 &&
23744 error "create under striped dir with unknown hash should fail"
23746 $LCTL set_param fail_loc=0
23748 umount_client $MOUNT || error "umount failed"
23749 mount_client $MOUNT || error "mount failed"
23753 run_test 300i "client handle unknown hash type striped directory"
23756 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23758 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23759 skip "Need MDS version at least 2.7.55"
23766 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
23767 $LCTL set_param fail_loc=0x1702
23768 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
23769 error "set striped dir error"
23771 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
23772 error "create files under striped dir failed"
23774 $LCTL set_param fail_loc=0
23776 rm -rf $DIR/$tdir || error "unlink striped dir fails"
23780 run_test 300j "test large update record"
23783 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23784 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23785 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23786 skip "Need MDS version at least 2.7.55"
23788 # this test needs a huge transaction
23790 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
23791 osd*.$FSNAME-MDT0000.kbytestotal")
23792 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
23799 #define OBD_FAIL_LARGE_STRIPE 0x1703
23800 $LCTL set_param fail_loc=0x1703
23801 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
23802 error "set striped dir error"
23803 $LCTL set_param fail_loc=0
23805 $LFS getdirstripe $DIR/$tdir/striped_dir ||
23806 error "getstripeddir fails"
23807 rm -rf $DIR/$tdir/striped_dir ||
23808 error "unlink striped dir fails"
23812 run_test 300k "test large striped directory"
23815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23816 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23817 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23818 skip "Need MDS version at least 2.7.55"
23822 test_mkdir -p $DIR/$tdir/striped_dir
23823 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
23824 error "chown $RUNAS_ID failed"
23825 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
23826 error "set default striped dir failed"
23828 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
23829 $LCTL set_param fail_loc=0x80000158
23830 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
23832 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
23833 [ $stripe_index -eq 1 ] ||
23834 error "expect 1 get $stripe_index for $dir"
23836 run_test 300l "non-root user to create dir under striped dir with stale layout"
23839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23840 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
23841 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23842 skip "Need MDS version at least 2.7.55"
23844 mkdir -p $DIR/$tdir/striped_dir
23845 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
23846 error "set default stripes dir error"
23848 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
23850 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
23851 [ $stripe_count -eq 0 ] ||
23852 error "expect 0 get $stripe_count for a"
23854 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
23855 error "set default stripes dir error"
23857 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
23859 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
23860 [ $stripe_count -eq 0 ] ||
23861 error "expect 0 get $stripe_count for b"
23863 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
23864 error "set default stripes dir error"
23866 mkdir $DIR/$tdir/striped_dir/c &&
23867 error "default stripe_index is invalid, mkdir c should fails"
23869 rm -rf $DIR/$tdir || error "rmdir fails"
23871 run_test 300m "setstriped directory on single MDT FS"
23874 local list=$(comma_list $(mdts_nodes))
23877 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23882 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23883 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23884 skip "Need MDS version at least 2.7.55"
23885 remote_mds_nodsh && skip "remote MDS with nodsh"
23888 local list=$(comma_list $(mdts_nodes))
23890 trap cleanup_300n RETURN EXIT
23891 mkdir -p $DIR/$tdir
23892 chmod 777 $DIR/$tdir
23893 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
23894 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
23895 error "create striped dir succeeds with gid=0"
23897 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
23898 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
23899 error "create striped dir fails with gid=-1"
23901 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23902 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
23903 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
23904 error "set default striped dir succeeds with gid=0"
23907 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
23908 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
23909 error "set default striped dir fails with gid=-1"
23912 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
23913 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
23914 error "create test_dir fails"
23915 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
23916 error "create test_dir1 fails"
23917 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
23918 error "create test_dir2 fails"
23921 run_test 300n "non-root user to create dir under striped dir with default EA"
23924 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23925 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23926 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
23927 skip "Need MDS version at least 2.7.55"
23932 mkdir -p $DIR/$tdir
23934 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
23935 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
23936 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
23937 skip "not enough free inodes $numfree1 $numfree2"
23940 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
23941 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
23942 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
23943 skip "not enough free space $numfree1 $numfree2"
23946 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
23947 error "setdirstripe fails"
23949 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
23950 error "create dirs fails"
23952 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
23953 ls $DIR/$tdir/striped_dir > /dev/null ||
23954 error "ls striped dir fails"
23955 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
23956 error "unlink big striped dir fails"
23958 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
23961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23962 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23963 remote_mds_nodsh && skip "remote MDS with nodsh"
23965 mkdir_on_mdt0 $DIR/$tdir
23967 #define OBD_FAIL_OUT_ENOSPC 0x1704
23968 do_facet mds2 lctl set_param fail_loc=0x80001704
23969 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
23970 && error "create striped directory should fail"
23972 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
23974 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
23977 run_test 300p "create striped directory without space"
23980 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23981 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
23983 local fd=$(free_fd)
23984 local cmd="exec $fd<$tdir"
23986 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
23989 trap "eval $cmd" EXIT
23990 cd $tdir || error "cd $tdir fails"
23991 rmdir ../$tdir || error "rmdir $tdir fails"
23992 mkdir local_dir && error "create dir succeeds"
23993 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
23997 run_test 300q "create remote directory under orphan directory"
24000 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24001 skip "Need MDS version at least 2.7.55" && return
24002 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24006 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
24007 error "set striped dir error"
24009 $LFS getdirstripe $DIR/$tdir/striped_dir ||
24010 error "getstripeddir fails"
24013 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
24014 awk '/lmv_stripe_count:/ { print $2 }')
24016 [ $MDSCOUNT -ne $stripe_count ] &&
24017 error "wrong stripe count $stripe_count expected $MDSCOUNT"
24019 rm -rf $DIR/$tdir/striped_dir ||
24020 error "unlink striped dir fails"
24022 run_test 300r "test -1 striped directory"
24024 test_300s_helper() {
24027 local stripe_dir=$DIR/$tdir/striped_dir.$count
24029 $LFS mkdir -c $count $stripe_dir ||
24030 error "lfs mkdir -c error"
24032 $LFS getdirstripe $stripe_dir ||
24033 error "lfs getdirstripe fails"
24036 stripe_count=$($LFS getdirstripe $stripe_dir |
24037 awk '/lmv_stripe_count:/ { print $2 }')
24039 [ $count -ne $stripe_count ] &&
24040 error_noexit "bad stripe count $stripe_count expected $count"
24043 dupe_stripes=$($LFS getdirstripe $stripe_dir |
24044 awk '/0x/ {count[$1] += 1}; END {
24045 for (idx in count) {
24046 if (count[idx]>1) {
24047 print "index " idx " count " count[idx]
24052 if [[ -n "$dupe_stripes" ]] ; then
24053 lfs getdirstripe $stripe_dir
24054 error_noexit "Dupe MDT above: $dupe_stripes "
24057 rm -rf $stripe_dir ||
24058 error_noexit "unlink $stripe_dir fails"
24062 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
24063 skip "Need MDS version at least 2.7.55" && return
24064 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
24067 for count in $(seq 2 $MDSCOUNT); do
24068 test_300s_helper $count
24071 run_test 300s "test lfs mkdir -c without -i"
24074 (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
24075 skip "need MDS 2.14.55 or later"
24076 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
24078 local testdir="$DIR/$tdir/striped_dir"
24079 local dir1=$testdir/dir1
24080 local dir2=$testdir/dir2
24084 $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
24085 error "failed to set default stripe count for $testdir"
24088 local stripe_count=$($LFS getdirstripe -c $dir1)
24090 (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
24092 local max_count=$((MDSCOUNT - 1))
24093 local mdts=$(comma_list $(mdts_nodes))
24095 do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
24096 stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
24099 stripe_count=$($LFS getdirstripe -c $dir2)
24101 (( $stripe_count == $max_count )) || error "wrong stripe count"
24103 run_test 300t "test max_mdt_stripecount"
24105 prepare_remote_file() {
24106 mkdir $DIR/$tdir/src_dir ||
24107 error "create remote source failed"
24109 cp /etc/hosts $DIR/$tdir/src_dir/a ||
24110 error "cp to remote source failed"
24111 touch $DIR/$tdir/src_dir/a
24113 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
24114 error "create remote target dir failed"
24116 touch $DIR/$tdir/tgt_dir/b
24118 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
24119 error "rename dir cross MDT failed!"
24121 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
24122 error "src_child still exists after rename"
24124 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
24125 error "missing file(a) after rename"
24127 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
24128 error "diff after rename"
24132 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24135 local remote_file=$DIR/$tdir/tgt_dir/b
24137 mkdir -p $DIR/$tdir
24139 prepare_remote_file || error "prepare remote file failed"
24142 $OPENUNLINK $remote_file $remote_file ||
24143 error "openunlink $remote_file failed"
24144 $CHECKSTAT -a $remote_file || error "$remote_file exists"
24146 run_test 310a "open unlink remote file"
24149 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
24150 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24152 local remote_file=$DIR/$tdir/tgt_dir/b
24154 mkdir -p $DIR/$tdir
24156 prepare_remote_file || error "prepare remote file failed"
24158 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24159 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
24160 $CHECKSTAT -t file $remote_file || error "check file failed"
24162 run_test 310b "unlink remote file with multiple links while open"
24165 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24166 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
24168 local remote_file=$DIR/$tdir/tgt_dir/b
24170 mkdir -p $DIR/$tdir
24172 prepare_remote_file || error "prepare remote file failed"
24174 ln $remote_file $DIR/$tfile || error "link failed for remote file"
24175 multiop_bg_pause $remote_file O_uc ||
24176 error "mulitop failed for remote file"
24178 $MULTIOP $DIR/$tfile Ouc
24179 kill -USR1 $MULTIPID
24182 run_test 310c "open-unlink remote file with multiple links"
24186 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24187 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24188 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
24189 skip "lustre < 2.8.54 does not contain LU-4825 fix"
24190 remote_mds_nodsh && skip "remote MDS with nodsh"
24192 local old_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24193 local mdts=$(comma_list $(mdts_nodes))
24195 mkdir -p $DIR/$tdir
24196 $LFS setstripe -i 0 -c 1 $DIR/$tdir
24197 createmany -o $DIR/$tdir/$tfile. 1000
24199 # statfs data is not real time, let's just calculate it
24200 old_iused=$((old_iused + 1000))
24202 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24203 osp.*OST0000*MDT0000.create_count")
24204 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
24205 osp.*OST0000*MDT0000.max_create_count")
24206 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
24208 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
24209 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
24210 [ $index -ne 0 ] || error "$tfile stripe index is 0"
24212 unlinkmany $DIR/$tdir/$tfile. 1000
24214 do_nodes $mdts "$LCTL set_param -n \
24215 osp.*OST0000*.max_create_count=$max_count"
24216 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
24217 do_nodes $mdts "$LCTL set_param -n \
24218 osp.*OST0000*.create_count=$count"
24219 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
24220 grep "=0" && error "create_count is zero"
24223 for i in $(seq 120); do
24224 new_iused=$($LFS df -i | awk '/OST0000/ { print $3; exit; }')
24225 # system may be too busy to destroy all objs in time, use
24226 # a somewhat small value to not fail autotest
24227 [ $((old_iused - new_iused)) -gt 400 ] && break
24231 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
24232 [ $((old_iused - new_iused)) -gt 400 ] ||
24233 error "objs not destroyed after unlink"
24235 run_test 311 "disable OSP precreate, and unlink should destroy objs"
24242 local vdevdir=$(dirname $(facet_vdevice $ost))
24243 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
24244 local zfs_zapid=$(do_facet $ost $cmd |
24245 grep -w "/O/0/d$((objid%32))" -C 5 |
24246 awk '/Object/{getline; print $1}')
24247 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
24248 awk "/$objid = /"'{printf $3}')
24253 zfs_object_blksz() {
24257 local vdevdir=$(dirname $(facet_vdevice $ost))
24258 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
24259 local blksz=$(do_facet $ost $cmd $objid |
24260 awk '/dblk/{getline; printf $4}')
24262 case "${blksz: -1}" in
24263 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
24264 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
24271 test_312() { # LU-4856
24272 remote_ost_nodsh && skip "remote OST with nodsh"
24273 [ "$ost1_FSTYPE" = "zfs" ] ||
24274 skip_env "the test only applies to zfs"
24276 local max_blksz=$(do_facet ost1 \
24277 $ZFS get -p recordsize $(facet_device ost1) |
24278 awk '!/VALUE/{print $3}')
24280 # to make life a little bit easier
24281 $LFS mkdir -c 1 -i 0 $DIR/$tdir
24282 $LFS setstripe -c 1 -i 0 $DIR/$tdir
24284 local tf=$DIR/$tdir/$tfile
24286 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24288 # Get ZFS object id
24289 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24290 # block size change by sequential overwrite
24293 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
24294 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
24296 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
24297 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
24301 # block size change by sequential append write
24302 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
24303 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24304 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24307 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
24308 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
24309 oflag=sync conv=notrunc
24311 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24312 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
24313 error "blksz error, actual $blksz, " \
24314 "expected: 2 * $count * $PAGE_SIZE"
24320 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
24321 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
24323 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
24324 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24325 [ $blksz -eq $PAGE_SIZE ] ||
24326 error "blksz error: $blksz, expected: $PAGE_SIZE"
24328 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
24329 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24330 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
24332 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
24333 blksz=$(zfs_object_blksz ost1 $zfs_objid)
24334 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
24336 run_test 312 "make sure ZFS adjusts its block size by write pattern"
24339 remote_ost_nodsh && skip "remote OST with nodsh"
24341 local file=$DIR/$tfile
24344 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
24346 # define OBD_FAIL_TGT_RCVD_EIO 0x720
24347 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24348 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
24349 error "write should failed"
24350 do_facet ost1 "$LCTL set_param fail_loc=0"
24353 run_test 313 "io should fail after last_rcvd update fail"
24356 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
24358 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
24359 do_facet ost1 "$LCTL set_param fail_loc=0x720"
24361 wait_delete_completed
24362 do_facet ost1 "$LCTL set_param fail_loc=0"
24364 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
24366 test_315() { # LU-618
24367 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
24369 local file=$DIR/$tfile
24372 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
24373 error "multiop file write failed"
24374 $MULTIOP $file oO_RDONLY:r4063232_c &
24379 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
24382 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
24385 run_test 315 "read should be accounted"
24388 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24389 large_xattr_enabled || skip "ea_inode feature disabled"
24391 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
24392 mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
24393 chown nobody $DIR/$tdir/d || error "chown $tdir/d failed"
24394 touch $DIR/$tdir/d/$tfile || error "touch $tdir/d/$tfile failed"
24396 $LFS migrate -m1 $DIR/$tdir/d || error "lfs migrate -m1 failed"
24398 run_test 316 "lfs migrate of file with large_xattr enabled"
24401 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
24402 skip "Need MDS version at least 2.11.53"
24403 if [ "$ost1_FSTYPE" == "zfs" ]; then
24404 skip "LU-10370: no implementation for ZFS"
24408 local grant_blk_size
24410 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
24411 awk '/grant_block_size:/ { print $2; exit; }')
24413 # Create File of size 5M. Truncate it to below size's and verify
24416 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
24417 error "Create file $DIR/$tfile failed"
24418 stack_trap "rm -f $DIR/$tfile" EXIT
24420 for trunc_sz in 2097152 4097 4000 509 0; do
24421 $TRUNCATE $DIR/$tfile $trunc_sz ||
24422 error "truncate $tfile to $trunc_sz failed"
24423 local sz=$(stat --format=%s $DIR/$tfile)
24424 local blk=$(stat --format=%b $DIR/$tfile)
24425 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
24426 grant_blk_size) * 8))
24428 if [[ $blk -ne $trunc_blk ]]; then
24429 $(which stat) $DIR/$tfile
24430 error "Expected Block $trunc_blk got $blk for $tfile"
24433 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24434 error "Expected Size $trunc_sz got $sz for $tfile"
24439 # Create file with a hole and write actual 65536 bytes which aligned
24440 # with 4K and 64K PAGE_SIZE. Block count must be 128.
24443 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 seek=5 conv=fsync ||
24444 error "Create file : $DIR/$tfile"
24447 # Truncate to size $trunc_sz bytes. Strip tail blocks and leave only 8
24448 # blocks. The block count must drop to 8.
24450 trunc_sz=$(($(stat --format=%s $DIR/$tfile) -
24451 ((bs - grant_blk_size) + 1)))
24452 $TRUNCATE $DIR/$tfile $trunc_sz ||
24453 error "truncate $tfile to $trunc_sz failed"
24455 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
24456 sz=$(stat --format=%s $DIR/$tfile)
24457 blk=$(stat --format=%b $DIR/$tfile)
24459 if [[ $blk -ne $trunc_bsz ]]; then
24460 $(which stat) $DIR/$tfile
24461 error "Expected Block $trunc_bsz got $blk for $tfile"
24464 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
24465 error "Expected Size $trunc_sz got $sz for $tfile"
24467 run_test 317 "Verify blocks get correctly update after truncate"
24470 local llite_name="llite.$($LFS getname $MOUNT | awk '{print $1}')"
24471 local old_max_active=$($LCTL get_param -n \
24472 ${llite_name}.max_read_ahead_async_active \
24475 $LCTL set_param llite.*.max_read_ahead_async_active=256
24476 local max_active=$($LCTL get_param -n \
24477 ${llite_name}.max_read_ahead_async_active \
24479 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
24481 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
24482 error "set max_read_ahead_async_active should succeed"
24484 $LCTL set_param llite.*.max_read_ahead_async_active=512
24485 max_active=$($LCTL get_param -n \
24486 ${llite_name}.max_read_ahead_async_active 2>/dev/null)
24487 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
24489 # restore @max_active
24490 [ $old_max_active -ne 0 ] && $LCTL set_param \
24491 llite.*.max_read_ahead_async_active=$old_max_active
24493 local old_threshold=$($LCTL get_param -n \
24494 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24495 local max_per_file_mb=$($LCTL get_param -n \
24496 ${llite_name}.max_read_ahead_per_file_mb 2>/dev/null)
24498 local invalid=$(($max_per_file_mb + 1))
24500 llite.*.read_ahead_async_file_threshold_mb=$invalid\
24501 && error "set $invalid should fail"
24503 local valid=$(($invalid - 1))
24505 llite.*.read_ahead_async_file_threshold_mb=$valid ||
24506 error "set $valid should succeed"
24507 local threshold=$($LCTL get_param -n \
24508 ${llite_name}.read_ahead_async_file_threshold_mb 2>/dev/null)
24509 [ $threshold -eq $valid ] || error \
24510 "expect threshold $valid got $threshold"
24512 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
24514 run_test 318 "Verify async readahead tunables"
24517 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
24519 local before=$(date +%s)
24521 local mdir=$DIR/$tdir
24522 local file=$mdir/xxx
24524 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
24527 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
24528 $LCTL set_param fail_val=5 fail_loc=0x8000032c
24529 $LFS migrate -m1 $mdir &
24532 dd if=$file of=/dev/null
24534 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
24535 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
24537 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
24539 run_test 319 "lost lease lock on migrate error"
24541 test_398a() { # LU-4198
24542 local ost1_imp=$(get_osc_import_name client ost1)
24543 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24546 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24547 $LCTL set_param ldlm.namespaces.*.lru_size=clear
24549 # Disabled: DIO does not push out buffered I/O pages, see LU-12587
24550 # request a new lock on client
24551 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24553 #dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
24554 #local lock_count=$($LCTL get_param -n \
24555 # ldlm.namespaces.$imp_name.lru_size)
24556 #[[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
24558 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24560 # no lock cached, should use lockless DIO and not enqueue new lock
24561 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct \
24563 error "dio write failed"
24564 lock_count=$($LCTL get_param -n \
24565 ldlm.namespaces.$imp_name.lru_size)
24566 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
24568 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
24570 # no lock cached, should use locked DIO append
24571 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
24572 conv=notrunc || error "DIO append failed"
24573 lock_count=$($LCTL get_param -n \
24574 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
24575 [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
24577 run_test 398a "direct IO should cancel lock otherwise lockless"
24579 test_398b() { # LU-4198
24580 which fio || skip_env "no fio installed"
24581 $LFS setstripe -c -1 -S 1M $DIR/$tfile
24584 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
24587 # Single page, multiple pages, stripe size, 4*stripe size
24588 for bsize in $(( $PAGE_SIZE )) $(( 4*$PAGE_SIZE )) 1048576 4194304; do
24589 echo "mix direct rw ${bsize} by fio with $njobs jobs..."
24590 fio --name=rand-rw --rw=randrw --bs=$bsize --direct=1 \
24591 --numjobs=$njobs --fallocate=none \
24592 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24593 --filename=$DIR/$tfile &
24596 echo "mix buffer rw ${bsize} by fio with $njobs jobs..."
24597 fio --name=rand-rw --rw=randrw --bs=$bsize \
24598 --numjobs=$njobs --fallocate=none \
24599 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24600 --filename=$DIR/$tfile || true
24604 evict=$(do_facet client $LCTL get_param \
24605 osc.$FSNAME-OST*-osc-*/state |
24606 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
24608 [ -z "$evict" ] || [[ $evict -le $before ]] ||
24609 (do_facet client $LCTL get_param \
24610 osc.$FSNAME-OST*-osc-*/state;
24611 error "eviction happened: $evict before:$before")
24615 run_test 398b "DIO and buffer IO race"
24617 test_398c() { # LU-4198
24618 local ost1_imp=$(get_osc_import_name client ost1)
24619 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
24622 which fio || skip_env "no fio installed"
24624 saved_debug=$($LCTL get_param -n debug)
24625 $LCTL set_param debug=0
24627 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
24628 ((size /= 1024)) # by megabytes
24629 ((size /= 2)) # write half of the OST at most
24630 [ $size -gt 40 ] && size=40 #reduce test time anyway
24632 $LFS setstripe -c 1 $DIR/$tfile
24634 # it seems like ldiskfs reserves more space than necessary if the
24635 # writing blocks are not mapped, so it extends the file firstly
24636 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
24637 cancel_lru_locks osc
24639 # clear and verify rpc_stats later
24640 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
24643 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
24644 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
24645 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24646 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24647 --filename=$DIR/$tfile
24648 [ $? -eq 0 ] || error "fio write error"
24650 [ $($LCTL get_param -n ldlm.namespaces.$imp_name.lock_count) -eq 0 ] ||
24651 error "Locks were requested while doing AIO"
24653 # get the percentage of 1-page I/O
24654 pct=$($LCTL get_param osc.${imp_name}.rpc_stats |
24655 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
24657 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
24659 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
24660 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
24661 --numjobs=$njobs --fallocate=none --ioengine=libaio \
24662 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
24663 --filename=$DIR/$tfile
24664 [ $? -eq 0 ] || error "fio mixed read write error"
24666 echo "AIO with large block size ${size}M"
24667 fio --name=rand-rw --rw=randrw --bs=${size}M --direct=1 \
24668 --numjobs=1 --fallocate=none --ioengine=libaio \
24669 --iodepth=16 --allow_file_create=0 --size=${size}M \
24670 --filename=$DIR/$tfile
24671 [ $? -eq 0 ] || error "fio large block size failed"
24674 $LCTL set_param debug="$saved_debug"
24676 run_test 398c "run fio to test AIO"
24678 test_398d() { # LU-13846
24679 which aiocp || skip_env "no aiocp installed"
24680 local aio_file=$DIR/$tfile.aio
24682 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
24684 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=64
24685 aiocp -a $PAGE_SIZE -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file
24686 stack_trap "rm -f $DIR/$tfile $aio_file"
24688 diff $DIR/$tfile $aio_file || error "file diff after aiocp"
24690 # make sure we don't crash and fail properly
24691 aiocp -a 512 -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
24692 error "aio not aligned with PAGE SIZE should fail"
24694 rm -f $DIR/$tfile $aio_file
24696 run_test 398d "run aiocp to verify block size > stripe size"
24699 dd if=/dev/zero of=$DIR/$tfile bs=1234 count=1
24700 touch $DIR/$tfile.new
24701 dd if=$DIR/$tfile of=$DIR/$tfile.new bs=1M count=1 oflag=direct
24703 run_test 398e "O_Direct open cleared by fcntl doesn't cause hang"
24705 test_398f() { # LU-14687
24706 which aiocp || skip_env "no aiocp installed"
24707 local aio_file=$DIR/$tfile.aio
24709 $LFS setstripe -c -1 -S 1M $DIR/$tfile $aio_file
24711 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
24712 stack_trap "rm -f $DIR/$tfile $aio_file"
24714 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
24715 $LCTL set_param fail_loc=0x1418
24716 # make sure we don't crash and fail properly
24717 aiocp -b 64M -s 64M -f O_DIRECT $DIR/$tfile $aio_file &&
24718 error "aio with page allocation failure succeeded"
24719 $LCTL set_param fail_loc=0
24720 diff $DIR/$tfile $aio_file
24721 [[ $? != 0 ]] || error "no diff after failed aiocp"
24723 run_test 398f "verify aio handles ll_direct_rw_pages errors correctly"
24725 # NB: To get the parallel DIO behavior in LU-13798, there must be > 1
24726 # stripe and i/o size must be > stripe size
24727 # Old style synchronous DIO waits after submitting each chunk, resulting in a
24728 # single RPC in flight. This test shows async DIO submission is working by
24729 # showing multiple RPCs in flight.
24730 test_398g() { # LU-13798
24731 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
24733 # We need to do some i/o first to acquire enough grant to put our RPCs
24734 # in flight; otherwise a new connection may not have enough grant
24736 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24737 error "parallel dio failed"
24738 stack_trap "rm -f $DIR/$tfile"
24740 # Reduce RPC size to 1M to avoid combination in to larger RPCs
24741 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
24742 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
24743 stack_trap "$LCTL set_param -n $pages_per_rpc"
24745 # Recreate file so it's empty
24747 $LFS setstripe -o 0,0 -S 1M $DIR/$tfile
24748 #Pause rpc completion to guarantee we see multiple rpcs in flight
24749 #define OBD_FAIL_OST_BRW_PAUSE_BULK
24750 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
24751 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24754 $LCTL set_param osc.*.rpc_stats=c
24756 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24757 error "parallel dio failed"
24758 stack_trap "rm -f $DIR/$tfile"
24760 $LCTL get_param osc.*-OST0000-*.rpc_stats
24761 pct=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
24762 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
24763 grep "8:" | awk '{print $8}')
24764 # We look at the "8 rpcs in flight" field, and verify A) it is present
24765 # and B) it includes all RPCs. This proves we had 8 RPCs in flight,
24766 # as expected for an 8M DIO to a file with 1M stripes.
24767 [ $pct -eq 100 ] || error "we should see 8 RPCs in flight"
24769 # Verify turning off parallel dio works as expected
24771 $LCTL set_param osc.*.rpc_stats=c
24772 $LCTL set_param llite.*.parallel_dio=0
24773 stack_trap '$LCTL set_param llite.*.parallel_dio=1'
24775 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=1 oflag=direct ||
24776 error "dio with parallel dio disabled failed"
24778 # Ideally, we would see only one RPC in flight here, but there is an
24779 # unavoidable race between i/o completion and RPC in flight counting,
24780 # so while only 1 i/o is in flight at a time, the RPC in flight counter
24781 # will sometimes exceed 1 (3 or 4 is not rare on VM testing).
24782 # So instead we just verify it's always < 8.
24783 $LCTL get_param osc.*-OST0000-*.rpc_stats
24784 ret=$($LCTL get_param osc.*-OST0000-*.rpc_stats |
24785 grep -A 8 'rpcs in flight' | grep -v 'rpcs in flight' |
24786 grep '^$' -B1 | grep . | awk '{print $1}')
24787 [ $ret != "8:" ] ||
24788 error "we should see fewer than 8 RPCs in flight (saw $ret)"
24790 run_test 398g "verify parallel dio async RPC submission"
24792 test_398h() { # LU-13798
24793 local dio_file=$DIR/$tfile.dio
24795 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
24797 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
24798 stack_trap "rm -f $DIR/$tfile $dio_file"
24800 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct ||
24801 error "parallel dio failed"
24802 diff $DIR/$tfile $dio_file
24803 [[ $? == 0 ]] || error "file diff after aiocp"
24805 run_test 398h "verify correctness of read & write with i/o size >> stripe size"
24807 test_398i() { # LU-13798
24808 local dio_file=$DIR/$tfile.dio
24810 $LFS setstripe -C 2 -S 1M $DIR/$tfile $dio_file
24812 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
24813 stack_trap "rm -f $DIR/$tfile $dio_file"
24815 #define OBD_FAIL_LLITE_PAGE_ALLOC 0x1418
24816 $LCTL set_param fail_loc=0x1418
24817 # make sure we don't crash and fail properly
24818 dd if=$DIR/$tfile of=$dio_file bs=8M count=8 iflag=direct oflag=direct &&
24819 error "parallel dio page allocation failure succeeded"
24820 diff $DIR/$tfile $dio_file
24821 [[ $? != 0 ]] || error "no diff after failed aiocp"
24823 run_test 398i "verify parallel dio handles ll_direct_rw_pages errors correctly"
24825 test_398j() { # LU-13798
24826 # Stripe size > RPC size but less than i/o size tests split across
24827 # stripes and RPCs for individual i/o op
24828 $LFS setstripe -o 0,0 -S 4M $DIR/$tfile $DIR/$tfile.2
24830 # Reduce RPC size to 1M to guarantee split to multiple RPCs per stripe
24831 local pages_per_rpc=$($LCTL get_param osc.*-OST0000-*.max_pages_per_rpc)
24832 $LCTL set_param osc.*-OST0000-*.max_pages_per_rpc=1M
24833 stack_trap "$LCTL set_param -n $pages_per_rpc"
24835 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24836 error "parallel dio write failed"
24837 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.2"
24839 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct ||
24840 error "parallel dio read failed"
24841 diff $DIR/$tfile $DIR/$tfile.2
24842 [[ $? == 0 ]] || error "file diff after parallel dio read"
24844 run_test 398j "test parallel dio where stripe size > rpc_size"
24846 test_398k() { # LU-13798
24847 wait_delete_completed
24850 # 4 stripe file; we will cause out of space on OST0
24851 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
24853 # Fill OST0 (if it's not too large)
24854 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
24856 if [[ $ORIGFREE -gt $MAXFREE ]]; then
24857 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
24859 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
24860 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
24861 error "dd should fill OST0"
24862 stack_trap "rm -f $DIR/$tfile.1"
24864 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct
24868 $CHECKSTAT -t file -s 0 $DIR/$tfile ||
24869 error "file is not 0 bytes in size"
24871 # dd above should not succeed, but don't error until here so we can
24872 # get debug info above
24874 error "parallel dio write with enospc succeeded"
24875 stack_trap "rm -f $DIR/$tfile"
24877 run_test 398k "test enospc on first stripe"
24879 test_398l() { # LU-13798
24880 wait_delete_completed
24883 # 4 stripe file; we will cause out of space on OST0
24884 # Note the 1M stripe size and the > 1M i/o size mean this ENOSPC
24885 # happens on the second i/o chunk we issue
24886 $LFS setstripe -o 1,0,1,0 -S 1M $DIR/$tfile $DIR/$tfile.2
24888 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=2 oflag=direct
24889 stack_trap "rm -f $DIR/$tfile"
24891 # Fill OST0 (if it's not too large)
24892 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
24894 if [[ $ORIGFREE -gt $MAXFREE ]]; then
24895 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
24897 $LFS setstripe -i 0 -c 1 $DIR/$tfile.1
24898 dd if=/dev/zero of=$DIR/$tfile.1 bs=1024 count=$MAXFREE &&
24899 error "dd should fill OST0"
24900 stack_trap "rm -f $DIR/$tfile.1"
24902 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 oflag=direct
24904 stack_trap "rm -f $DIR/$tfile.2"
24906 # Check that short write completed as expected
24907 ls -la $DIR/$tfile.2
24908 $CHECKSTAT -t file -s 1048576 $DIR/$tfile.2 ||
24909 error "file is not 1M in size"
24911 # dd above should not succeed, but don't error until here so we can
24912 # get debug info above
24914 error "parallel dio write with enospc succeeded"
24916 # Truncate source file to same length as output file and diff them
24917 $TRUNCATE $DIR/$tfile 1048576
24918 diff $DIR/$tfile $DIR/$tfile.2
24919 [[ $? == 0 ]] || error "data incorrect after short write"
24921 run_test 398l "test enospc on intermediate stripe/RPC"
24923 test_398m() { # LU-13798
24924 $LFS setstripe -o 0,1,0,1 -S 1M $DIR/$tfile
24926 # Set up failure on OST0, the first stripe:
24927 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
24928 #NB: Fail val is ost # + 1, because we cannot use cfs_fail_val = 0
24929 # So this fail_val specifies OST0
24930 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=1
24931 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24933 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
24934 error "parallel dio write with failure on first stripe succeeded"
24935 stack_trap "rm -f $DIR/$tfile"
24936 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24938 # Place data in file for read
24939 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24940 error "parallel dio write failed"
24942 # Fail read on OST0, first stripe
24943 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
24944 do_facet ost1 $LCTL set_param fail_loc=0x20f fail_val=1
24945 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
24946 error "parallel dio read with error on first stripe succeeded"
24947 rm -f $DIR/$tfile.2
24948 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24950 # Switch to testing on OST1, second stripe
24951 # Clear file contents, maintain striping
24953 # Set up failure on OST1, second stripe:
24954 do_facet ost1 $LCTL set_param fail_loc=0x20e fail_val=2
24955 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0"
24957 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct &&
24958 error "parallel dio write with failure on first stripe succeeded"
24959 stack_trap "rm -f $DIR/$tfile"
24960 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
24962 # Place data in file for read
24963 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 oflag=direct ||
24964 error "parallel dio write failed"
24966 # Fail read on OST1, second stripe
24967 #define OBD_FAIL_OST_BRW_READ_BULK 0x20f
24968 do_facet ost2 $LCTL set_param fail_loc=0x20f fail_val=2
24969 dd if=$DIR/$tfile of=$DIR/$tfile.2 bs=8M count=8 iflag=direct &&
24970 error "parallel dio read with error on first stripe succeeded"
24971 rm -f $DIR/$tfile.2
24972 do_facet ost2 $LCTL set_param fail_loc=0 fail_val=0
24974 run_test 398m "test RPC failures with parallel dio"
24976 # Parallel submission of DIO should not cause problems for append, but it's
24977 # important to verify.
24978 test_398n() { # LU-13798
24979 $LFS setstripe -C 2 -S 1M $DIR/$tfile
24981 dd if=/dev/urandom of=$DIR/$tfile bs=8M count=8 ||
24982 error "dd to create source file failed"
24983 stack_trap "rm -f $DIR/$tfile"
24985 dd if=$DIR/$tfile of=$DIR/$tfile.1 bs=8M count=8 oflag=direct oflag=append ||
24986 error "parallel dio write with failure on second stripe succeeded"
24987 stack_trap "rm -f $DIR/$tfile $DIR/$tfile.1"
24988 diff $DIR/$tfile $DIR/$tfile.1
24989 [[ $? == 0 ]] || error "data incorrect after append"
24992 run_test 398n "test append with parallel DIO"
24995 local read_write=$1
24996 if [ "$read_write" = "write" ]; then
24997 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
24998 elif [ "$read_write" = "read" ]; then
24999 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
25001 error "argument error"
25004 # turn off debug for performance testing
25005 local saved_debug=$($LCTL get_param -n debug)
25006 $LCTL set_param debug=0
25008 $LFS setstripe -c 1 -i 0 $DIR/$tfile
25010 # get ost1 size - $FSNAME-OST0000
25011 local ost1_avail_size=$($LFS df $DIR | awk /${ost1_svc}/'{ print $4 }')
25012 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
25013 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
25015 if [ "$read_write" = "read" ]; then
25016 $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks)
25019 local start_time=$(date +%s.%N)
25020 $dd_cmd bs=1M count=$blocks oflag=sync ||
25021 error "real dd $read_write error"
25022 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
25024 if [ "$read_write" = "write" ]; then
25028 # define OBD_FAIL_OST_FAKE_RW 0x238
25029 do_facet ost1 $LCTL set_param fail_loc=0x238
25031 local start_time=$(date +%s.%N)
25032 $dd_cmd bs=1M count=$blocks oflag=sync ||
25033 error "fake dd $read_write error"
25034 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
25036 if [ "$read_write" = "write" ]; then
25038 cancel_lru_locks osc
25039 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
25040 error "$tfile size not $blocks MB"
25042 do_facet ost1 $LCTL set_param fail_loc=0
25044 echo "fake $read_write $duration_fake vs. normal $read_write" \
25045 "$duration in seconds"
25046 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
25047 error_not_in_vm "fake write is slower"
25049 $LCTL set_param -n debug="$saved_debug"
25052 test_399a() { # LU-7655 for OST fake write
25053 remote_ost_nodsh && skip "remote OST with nodsh"
25057 run_test 399a "fake write should not be slower than normal write"
25059 test_399b() { # LU-8726 for OST fake read
25060 remote_ost_nodsh && skip "remote OST with nodsh"
25061 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
25062 skip_env "ldiskfs only test"
25067 run_test 399b "fake read should not be slower than normal read"
25069 test_400a() { # LU-1606, was conf-sanity test_74
25070 if ! which $CC > /dev/null 2>&1; then
25071 skip_env "$CC is not installed"
25074 local extra_flags=''
25075 local out=$TMP/$tfile
25076 local prefix=/usr/include/lustre
25079 # Oleg removes c files in his test rig so test if any c files exist
25080 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
25081 skip_env "Needed c test files are missing"
25083 if ! [[ -d $prefix ]]; then
25084 # Assume we're running in tree and fixup the include path.
25085 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
25086 extra_flags+=" -L$LUSTRE/utils/.lib"
25089 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
25090 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
25091 error "client api broken"
25095 run_test 400a "Lustre client api program can compile and link"
25097 test_400b() { # LU-1606, LU-5011
25099 local out=$TMP/$tfile
25100 local prefix=/usr/include/linux/lustre
25102 # We use a hard coded prefix so that this test will not fail
25103 # when run in tree. There are headers in lustre/include/lustre/
25104 # that are not packaged (like lustre_idl.h) and have more
25105 # complicated include dependencies (like config.h and lnet/types.h).
25106 # Since this test about correct packaging we just skip them when
25107 # they don't exist (see below) rather than try to fixup cppflags.
25109 if ! which $CC > /dev/null 2>&1; then
25110 skip_env "$CC is not installed"
25113 for header in $prefix/*.h; do
25114 if ! [[ -f "$header" ]]; then
25118 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
25119 continue # lustre_ioctl.h is internal header
25122 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
25123 error "cannot compile '$header'"
25127 run_test 400b "packaged headers can be compiled"
25129 test_401a() { #LU-7437
25130 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
25131 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
25133 #count the number of parameters by "list_param -R"
25134 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
25135 #count the number of parameters by listing proc files
25136 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
25137 echo "proc_dirs='$proc_dirs'"
25138 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
25139 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
25142 [ $params -eq $procs ] ||
25143 error "found $params parameters vs. $procs proc files"
25145 # test the list_param -D option only returns directories
25146 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
25147 #count the number of parameters by listing proc directories
25148 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
25151 [ $params -eq $procs ] ||
25152 error "found $params parameters vs. $procs proc files"
25154 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
25157 # jobid_var may not allow arbitrary values, so use jobid_name
25159 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25160 local testname=jobid_name tmp='testing%p'
25162 local testname=jobid_var tmp=testing
25165 local save=$($LCTL get_param -n $testname)
25167 $LCTL set_param foo=bar $testname=$tmp bar=baz &&
25168 error "no error returned when setting bad parameters"
25170 local jobid_new=$($LCTL get_param -n foe $testname baz)
25171 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
25173 $LCTL set_param -n fog=bam $testname=$save bat=fog
25174 local jobid_old=$($LCTL get_param -n foe $testname bag)
25175 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
25177 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
25180 # jobid_var may not allow arbitrary values, so use jobid_name
25182 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25183 local testname=jobid_name
25185 local testname=jobid_var
25188 local jobid_var_old=$($LCTL get_param -n $testname)
25189 local jobid_var_new
25191 $LCTL set_param $testname= &&
25192 error "no error returned for 'set_param a='"
25194 jobid_var_new=$($LCTL get_param -n $testname)
25195 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25196 error "$testname was changed by setting without value"
25198 $LCTL set_param $testname &&
25199 error "no error returned for 'set_param a'"
25201 jobid_var_new=$($LCTL get_param -n $testname)
25202 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
25203 error "$testname was changed by setting without value"
25205 run_test 401c "Verify 'lctl set_param' without value fails in either format."
25208 # jobid_var may not allow arbitrary values, so use jobid_name
25210 if $LCTL list_param jobid_name > /dev/null 2>&1; then
25211 local testname=jobid_name new_value='foo=bar%p'
25213 local testname=jobid_var new_valuie=foo=bar
25216 local jobid_var_old=$($LCTL get_param -n $testname)
25217 local jobid_var_new
25219 $LCTL set_param $testname=$new_value ||
25220 error "'set_param a=b' did not accept a value containing '='"
25222 jobid_var_new=$($LCTL get_param -n $testname)
25223 [[ "$jobid_var_new" == "$new_value" ]] ||
25224 error "'set_param a=b' failed on a value containing '='"
25226 # Reset the $testname to test the other format
25227 $LCTL set_param $testname=$jobid_var_old
25228 jobid_var_new=$($LCTL get_param -n $testname)
25229 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25230 error "failed to reset $testname"
25232 $LCTL set_param $testname $new_value ||
25233 error "'set_param a b' did not accept a value containing '='"
25235 jobid_var_new=$($LCTL get_param -n $testname)
25236 [[ "$jobid_var_new" == "$new_value" ]] ||
25237 error "'set_param a b' failed on a value containing '='"
25239 $LCTL set_param $testname $jobid_var_old
25240 jobid_var_new=$($LCTL get_param -n $testname)
25241 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
25242 error "failed to reset $testname"
25244 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
25246 test_401e() { # LU-14779
25247 $LCTL list_param -R "ldlm.namespaces.MGC*" ||
25248 error "lctl list_param MGC* failed"
25249 $LCTL get_param "ldlm.namespaces.MGC*" || error "lctl get_param failed"
25250 $LCTL get_param "ldlm.namespaces.MGC*.lru_size" ||
25251 error "lctl get_param lru_size failed"
25253 run_test 401e "verify 'lctl get_param' works with NID in parameter"
25256 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
25257 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
25258 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
25259 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
25260 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
25261 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
25262 remote_mds_nodsh && skip "remote MDS with nodsh"
25264 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
25265 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
25266 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
25267 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
25268 echo "Touch failed - OK"
25270 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
25273 local file1=$DIR/$tfile.1
25274 local file2=$DIR/$tfile.2
25275 local tfile=$TMP/$tfile
25277 rm -f $file1 $file2 $tfile
25282 # 30 sec OBD_TIMEOUT in ll_getattr()
25283 # right before populating st_nlink
25284 $LCTL set_param fail_loc=0x80001409
25285 stat -c %h $file1 > $tfile &
25287 # create an alias, drop all locks and reclaim the dentry
25289 cancel_lru_locks mdc
25290 cancel_lru_locks osc
25291 sysctl -w vm.drop_caches=2
25295 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
25297 rm -f $tfile $file1 $file2
25299 run_test 403 "i_nlink should not drop to zero due to aliasing"
25301 test_404() { # LU-6601
25302 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
25303 skip "Need server version newer than 2.8.52"
25304 remote_mds_nodsh && skip "remote MDS with nodsh"
25306 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
25307 awk '/osp .*-osc-MDT/ { print $4}')
25310 for osp in $mosps; do
25311 echo "Deactivate: " $osp
25312 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
25313 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25314 awk -vp=$osp '$4 == p { print $2 }')
25315 [ $stat = IN ] || {
25316 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25317 error "deactivate error"
25319 echo "Activate: " $osp
25320 do_facet $SINGLEMDS $LCTL --device %$osp activate
25321 local stat=$(do_facet $SINGLEMDS $LCTL dl |
25322 awk -vp=$osp '$4 == p { print $2 }')
25323 [ $stat = UP ] || {
25324 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
25325 error "activate error"
25329 run_test 404 "validate manual {de}activated works properly for OSPs"
25332 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
25333 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
25334 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
25335 skip "Layout swap lock is not supported"
25337 check_swap_layouts_support
25338 check_swap_layout_no_dom $DIR
25340 test_mkdir $DIR/$tdir
25341 swap_lock_test -d $DIR/$tdir ||
25342 error "One layout swap locked test failed"
25344 run_test 405 "Various layout swap lock tests"
25347 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25348 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
25349 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
25350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
25351 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
25352 skip "Need MDS version at least 2.8.50"
25354 local def_stripe_size=$($LFS getstripe -S $MOUNT)
25355 local test_pool=$TESTNAME
25357 pool_add $test_pool || error "pool_add failed"
25358 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
25359 error "pool_add_targets failed"
25361 save_layout_restore_at_exit $MOUNT
25363 # parent set default stripe count only, child will stripe from both
25364 # parent and fs default
25365 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
25366 error "setstripe $MOUNT failed"
25367 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
25368 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
25369 for i in $(seq 10); do
25370 local f=$DIR/$tdir/$tfile.$i
25371 touch $f || error "touch failed"
25372 local count=$($LFS getstripe -c $f)
25373 [ $count -eq $OSTCOUNT ] ||
25374 error "$f stripe count $count != $OSTCOUNT"
25375 local offset=$($LFS getstripe -i $f)
25376 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
25377 local size=$($LFS getstripe -S $f)
25378 [ $size -eq $((def_stripe_size * 2)) ] ||
25379 error "$f stripe size $size != $((def_stripe_size * 2))"
25380 local pool=$($LFS getstripe -p $f)
25381 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
25384 # change fs default striping, delete parent default striping, now child
25385 # will stripe from new fs default striping only
25386 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
25387 error "change $MOUNT default stripe failed"
25388 $LFS setstripe -c 0 $DIR/$tdir ||
25389 error "delete $tdir default stripe failed"
25390 for i in $(seq 11 20); do
25391 local f=$DIR/$tdir/$tfile.$i
25392 touch $f || error "touch $f failed"
25393 local count=$($LFS getstripe -c $f)
25394 [ $count -eq 1 ] || error "$f stripe count $count != 1"
25395 local offset=$($LFS getstripe -i $f)
25396 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
25397 local size=$($LFS getstripe -S $f)
25398 [ $size -eq $def_stripe_size ] ||
25399 error "$f stripe size $size != $def_stripe_size"
25400 local pool=$($LFS getstripe -p $f)
25401 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
25404 unlinkmany $DIR/$tdir/$tfile. 1 20
25406 local f=$DIR/$tdir/$tfile
25407 pool_remove_all_targets $test_pool $f
25408 pool_remove $test_pool $f
25410 run_test 406 "DNE support fs default striping"
25413 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
25414 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
25415 skip "Need MDS version at least 2.8.55"
25416 remote_mds_nodsh && skip "remote MDS with nodsh"
25418 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
25419 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
25420 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
25421 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
25422 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
25424 #define OBD_FAIL_DT_TXN_STOP 0x2019
25425 for idx in $(seq $MDSCOUNT); do
25426 do_facet mds$idx "lctl set_param fail_loc=0x2019"
25428 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
25429 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
25430 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
25433 run_test 407 "transaction fail should cause operation fail"
25436 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
25438 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
25439 lctl set_param fail_loc=0x8000040a
25440 # let ll_prepare_partial_page() fail
25441 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
25445 # create at least 100 unused inodes so that
25446 # shrink_icache_memory(0) should not return 0
25447 touch $DIR/$tfile-{0..100}
25448 rm -f $DIR/$tfile-{0..100}
25451 echo 2 > /proc/sys/vm/drop_caches
25453 run_test 408 "drop_caches should not hang due to page leaks"
25457 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
25459 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
25460 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
25461 touch $DIR/$tdir/guard || error "(2) Fail to create"
25463 local PREFIX=$(str_repeat 'A' 128)
25464 echo "Create 1K hard links start at $(date)"
25465 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25466 error "(3) Fail to hard link"
25468 echo "Links count should be right although linkEA overflow"
25469 stat $DIR/$tdir/guard || error "(4) Fail to stat"
25470 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
25471 [ $linkcount -eq 1001 ] ||
25472 error "(5) Unexpected hard links count: $linkcount"
25474 echo "List all links start at $(date)"
25475 ls -l $DIR/$tdir/foo > /dev/null ||
25476 error "(6) Fail to list $DIR/$tdir/foo"
25478 echo "Unlink hard links start at $(date)"
25479 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
25480 error "(7) Fail to unlink"
25481 echo "Unlink hard links finished at $(date)"
25483 run_test 409 "Large amount of cross-MDTs hard links on the same file"
25487 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
25488 skip "Need client version at least 2.9.59"
25489 [ -f $LUSTRE/tests/kernel/kinode.ko ] ||
25490 skip "Need MODULES build"
25492 # Create a file, and stat it from the kernel
25493 local testfile=$DIR/$tfile
25496 local run_id=$RANDOM
25497 local my_ino=$(stat --format "%i" $testfile)
25499 # Try to insert the module. This will always fail as the
25500 # module is designed to not be inserted.
25501 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
25504 # Anything but success is a test failure
25506 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
25507 error "no inode match"
25509 run_test 410 "Test inode number returned from kernel thread"
25511 cleanup_test411_cgroup() {
25517 local cg_basedir=/sys/fs/cgroup/memory
25519 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
25520 skip "no setup for cgroup"
25522 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
25523 error "test file creation failed"
25524 cancel_lru_locks osc
25526 # Create a very small memory cgroup to force a slab allocation error
25527 local cgdir=$cg_basedir/osc_slab_alloc
25528 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
25529 trap "cleanup_test411_cgroup $cgdir" EXIT
25530 echo 2M > $cgdir/memory.kmem.limit_in_bytes
25531 echo 1M > $cgdir/memory.limit_in_bytes
25533 # Should not LBUG, just be killed by oom-killer
25534 # dd will return 0 even allocation failure in some environment.
25535 # So don't check return value
25536 bash -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
25537 cleanup_test411_cgroup $cgdir
25541 run_test 411 "Slab allocation error with cgroup does not LBUG"
25544 (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
25545 (( $MDS1_VERSION >= $(version_code 2.10.55) )) ||
25546 skip "Need server version at least 2.10.55"
25548 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
25549 error "mkdir failed"
25550 $LFS getdirstripe $DIR/$tdir
25551 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
25552 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
25553 error "expect $((MDSCOUT - 1)) get $stripe_index"
25554 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
25555 [ $stripe_count -eq 2 ] ||
25556 error "expect 2 get $stripe_count"
25558 (( $MDS1_VERSION >= $(version_code 2.14.55) )) || return 0
25563 # subdirs should be on the same MDT as parent
25564 for i in $(seq 0 $((MDSCOUNT - 1))); do
25565 $LFS mkdir -i $i $DIR/$tdir/mdt$i || error "mkdir mdt$i failed"
25566 mkdir $DIR/$tdir/mdt$i/sub || error "mkdir sub failed"
25567 index=$($LFS getstripe -m $DIR/$tdir/mdt$i/sub)
25568 (( index == i )) || error "mdt$i/sub on MDT$index"
25571 # stripe offset -1, ditto
25572 for i in {1..10}; do
25573 $LFS mkdir -i -1 $DIR/$tdir/qos$i || error "mkdir qos$i failed"
25574 index=$($LFS getstripe -m $DIR/$tdir/qos$i)
25575 mkdir $DIR/$tdir/qos$i/sub || error "mkdir sub failed"
25576 index2=$($LFS getstripe -m $DIR/$tdir/qos$i/sub)
25577 (( index == index2 )) ||
25578 error "qos$i on MDT$index, sub on MDT$index2"
25581 local testdir=$DIR/$tdir/inherit
25583 $LFS mkdir -i 1 --max-inherit=3 $testdir || error "mkdir inherit failed"
25586 testdir=$testdir/s$i
25587 mkdir $testdir || error "mkdir $testdir failed"
25588 index=$($LFS getstripe -m $testdir)
25589 (( index == 1 )) ||
25590 error "$testdir on MDT$index"
25593 # not inherit any more
25594 testdir=$testdir/s3
25595 mkdir $testdir || error "mkdir $testdir failed"
25596 getfattr -d -m dmv $testdir | grep dmv &&
25597 error "default LMV set on $testdir" || true
25599 run_test 412 "mkdir on specific MDTs"
25601 generate_uneven_mdts() {
25603 local lmv_qos_maxage
25604 local lod_qos_maxage
25614 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25615 $LCTL set_param lmv.*.qos_maxage=1
25616 stack_trap "$LCTL set_param \
25617 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
25618 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25619 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25620 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25621 lod.*.mdt_qos_maxage=1
25622 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
25623 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
25626 echo "Check for uneven MDTs: "
25628 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25629 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25630 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25632 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25633 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25636 for ((i = 1; i < ${#ffree[@]}; i++)); do
25637 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25638 if [ $tmp -gt $max ]; then
25642 if [ $tmp -lt $min ]; then
25648 (( ${ffree[min_index]} > 0 )) ||
25649 skip "no free files in MDT$min_index"
25650 (( ${ffree[min_index]} < 10000000 )) ||
25651 skip "too many free files in MDT$min_index"
25653 # Check if we need to generate uneven MDTs
25654 local diff=$(((max - min) * 100 / min))
25655 local testdir=$DIR/$tdir-fillmdt
25661 while (( diff < threshold )); do
25662 # generate uneven MDTs, create till $threshold% diff
25663 echo -n "weight diff=$diff% must be > $threshold% ..."
25664 echo "Fill MDT$min_index with 1000 files: loop $i"
25665 testdir=$DIR/$tdir-fillmdt/$i
25666 [ -d $testdir ] || $LFS mkdir -i $min_index $testdir ||
25667 error "mkdir $testdir failed"
25668 $LFS setstripe -E 1M -L mdt $testdir ||
25669 error "setstripe $testdir failed"
25671 for F in f.{0..999}; do
25672 dd if=/dev/zero of=$testdir/$F bs=64K count=1 > \
25673 /dev/null 2>&1 || error "dd $F failed"
25676 # wait for QOS to update
25677 (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
25679 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
25680 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
25681 max=$(((${ffree[max_index]} >> 8) *
25682 (${bavail[max_index]} * bsize >> 16)))
25683 min=$(((${ffree[min_index]} >> 8) *
25684 (${bavail[min_index]} * bsize >> 16)))
25685 diff=$(((max - min) * 100 / min))
25689 echo "MDT filesfree available: ${ffree[*]}"
25690 echo "MDT blocks available: ${bavail[*]}"
25691 echo "weight diff=$diff%"
25696 local stripe_count=$2
25697 local mdts=$(comma_list $(mdts_nodes))
25700 local lmv_qos_prio_free
25701 local lmv_qos_threshold_rr
25702 local lmv_qos_maxage
25703 local lod_qos_prio_free
25704 local lod_qos_threshold_rr
25705 local lod_qos_maxage
25709 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
25710 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
25711 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
25713 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
25714 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
25715 stack_trap "$LCTL set_param \
25716 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null"
25717 stack_trap "$LCTL set_param \
25718 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null"
25719 stack_trap "$LCTL set_param \
25720 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
25722 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
25723 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
25724 lod_qos_prio_free=${lod_qos_prio_free%%%}
25725 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
25726 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
25727 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
25728 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
25729 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
25730 stack_trap "do_nodes $mdts $LCTL set_param \
25731 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null"
25732 stack_trap "do_nodes $mdts $LCTL set_param \
25733 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null"
25734 stack_trap "do_nodes $mdts $LCTL set_param \
25735 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null"
25737 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
25738 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
25740 testdir=$DIR/$tdir-s$stripe_count/rr
25742 local stripe_index=$($LFS getstripe -m $testdir)
25743 local test_mkdir_rr=true
25745 getfattr -d -m dmv -e hex $testdir | grep dmv
25746 if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.51) )); then
25747 echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
25748 (( $($LFS getdirstripe -D --max-inherit-rr $testdir) == 0 )) &&
25749 test_mkdir_rr=false
25754 echo "Mkdir (stripe_count $stripe_count) roundrobin:" ||
25755 echo "Mkdir (stripe_count $stripe_count) on stripe $stripe_index"
25757 stack_trap "unlinkmany -d $testdir/subdir $((100 * MDSCOUNT))"
25758 for (( i = 0; i < 100 * MDSCOUNT; i++ )); do
25759 eval $mkdir_cmd $testdir/subdir$i ||
25760 error "$mkdir_cmd subdir$i failed"
25763 for (( i = 0; i < $MDSCOUNT; i++ )); do
25764 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
25765 echo "$count directories created on MDT$i"
25766 if $test_mkdir_rr; then
25767 (( $count == 100 )) ||
25768 error "subdirs are not evenly distributed"
25769 elif (( $i == $stripe_index )); then
25770 (( $count == 100 * MDSCOUNT )) ||
25771 error "$count subdirs created on MDT$i"
25773 (( $count == 0 )) ||
25774 error "$count subdirs created on MDT$i"
25777 if $test_mkdir_rr && [ $stripe_count -gt 1 ]; then
25778 count=$($LFS getdirstripe $testdir/* |
25779 grep -c -P "^\s+$i\t")
25780 echo "$count stripes created on MDT$i"
25781 # deviation should < 5% of average
25782 (( $count >= 95 * stripe_count &&
25783 $count <= 105 * stripe_count)) ||
25784 error "stripes are not evenly distributed"
25789 echo "Check for uneven MDTs: "
25799 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25800 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25801 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25803 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25804 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25807 for ((i = 1; i < ${#ffree[@]}; i++)); do
25808 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25809 if [ $tmp -gt $max ]; then
25813 if [ $tmp -lt $min ]; then
25819 (( ${ffree[min_index]} > 0 )) ||
25820 skip "no free files in MDT$min_index"
25821 (( ${ffree[min_index]} < 10000000 )) ||
25822 skip "too many free files in MDT$min_index"
25824 echo "MDT filesfree available: ${ffree[*]}"
25825 echo "MDT blocks available: ${bavail[*]}"
25826 echo "weight diff=$(((max - min) * 100 / min))%"
25828 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
25830 $LCTL set_param lmv.*.qos_threshold_rr=0 > /dev/null
25831 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
25832 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=0 > /dev/null
25833 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
25834 # decrease statfs age, so that it can be updated in time
25835 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
25836 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
25840 testdir=$DIR/$tdir-s$stripe_count/qos
25843 stack_trap "unlinkmany -d $testdir/subdir $((num * MDSCOUNT))"
25844 for (( i = 0; i < num * MDSCOUNT; i++ )); do
25845 eval $mkdir_cmd $testdir/subdir$i ||
25846 error "$mkdir_cmd subdir$i failed"
25850 for (( i = 0; i < $MDSCOUNT; i++ )); do
25851 count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
25852 (( count > max )) && max=$count
25853 echo "$count directories created on MDT$i"
25856 min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
25858 # D-value should > 10% of averge
25859 (( max - min > num / 10 )) ||
25860 error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
25862 # ditto for stripes
25863 if (( stripe_count > 1 )); then
25865 for (( i = 0; i < $MDSCOUNT; i++ )); do
25866 count=$($LFS getdirstripe $testdir/* |
25867 grep -c -P "^\s+$i\t")
25868 (( count > max )) && max=$count
25869 echo "$count stripes created on MDT$i"
25872 min=$($LFS getdirstripe $testdir/* |
25873 grep -c -P "^\s+$min_index\t")
25874 (( max - min > num * stripe_count / 10 )) ||
25875 error "stripes shouldn't be evenly distributed: $max - $min < $((num / 10)) * $stripe_count"
25887 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
25888 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
25889 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
25891 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
25893 for ((i = 1; i < ${#ffree[@]}; i++)); do
25894 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
25895 (( tmp < min )) && min=$tmp && min_index=$i
25902 [ $MDSCOUNT -lt 2 ] &&
25903 skip "We need at least 2 MDTs for this test"
25905 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
25906 skip "Need server version at least 2.12.52"
25910 generate_uneven_mdts 100
25911 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
25912 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
25913 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
25914 $LFS mkdir -i $(most_full_mdt) $DIR/$tdir-s$stripe_count/qos ||
25915 error "mkdir failed"
25916 test_qos_mkdir "$LFS mkdir -i -1 -c $stripe_count" $stripe_count
25919 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
25922 [ $MDSCOUNT -lt 2 ] &&
25923 skip "We need at least 2 MDTs for this test"
25925 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
25926 skip "Need server version at least 2.12.52"
25931 generate_uneven_mdts 100
25932 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
25933 testdir=$DIR/$tdir-s$stripe_count
25934 mkdir $testdir || error "mkdir $testdir failed"
25935 mkdir $testdir/rr || error "mkdir rr failed"
25936 $LFS mkdir -i $(most_full_mdt) $testdir/qos ||
25937 error "mkdir qos failed"
25938 $LFS setdirstripe -D -c $stripe_count --max-inherit-rr 2 \
25939 $testdir/rr || error "setdirstripe rr failed"
25940 $LFS setdirstripe -D -c $stripe_count $testdir/qos ||
25941 error "setdirstripe failed"
25942 test_qos_mkdir "mkdir" $stripe_count
25945 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
25948 (( $MDSCOUNT >= 2 )) ||
25949 skip "We need at least 2 MDTs for this test"
25951 (( $MDS1_VERSION >= $(version_code 2.14.51) )) ||
25952 skip "Need server version at least 2.14.51"
25958 testdir=$DIR/${tdir}-s1
25959 mkdir $testdir || error "mkdir $testdir failed"
25960 mkdir $testdir/rr || error "mkdir rr failed"
25961 $LFS mkdir -i $(most_full_mdt) $testdir/qos || error "mkdir qos failed"
25962 # default max_inherit is -1, default max_inherit_rr is 0
25963 $LFS setdirstripe -D -c 1 $testdir/rr ||
25964 error "setdirstripe rr failed"
25965 $LFS setdirstripe -D -c 1 -i -1 -X 2 --max-inherit-rr 1 $testdir/qos ||
25966 error "setdirstripe qos failed"
25967 test_qos_mkdir "mkdir" 1
25969 mkdir $testdir/rr/level1 || error "mkdir rr/level1 failed"
25970 inherit=$($LFS getdirstripe -D -X $testdir/rr/level1)
25971 (( $inherit == -1 )) || error "rr/level1 inherit $inherit != -1"
25972 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/rr/level1)
25973 (( $inherit_rr == 0 )) || error "rr/level1 inherit-rr $inherit_rr != 0"
25975 mkdir $testdir/qos/level1 || error "mkdir qos/level1 failed"
25976 inherit=$($LFS getdirstripe -D -X $testdir/qos/level1)
25977 (( $inherit == 1 )) || error "qos/level1 inherit $inherit != 1"
25978 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir/qos/level1)
25979 (( $inherit_rr == 0 )) || error "qos/level1 inherit-rr $inherit_rr != 0"
25980 mkdir $testdir/qos/level1/level2 || error "mkdir level2 failed"
25981 getfattr -d -m dmv -e hex $testdir/qos/level1/level2 | grep dmv &&
25982 error "level2 shouldn't have default LMV" || true
25984 run_test 413c "mkdir with default LMV max inherit rr"
25987 (( MDSCOUNT >= 2 )) ||
25988 skip "We need at least 2 MDTs for this test"
25990 (( MDS1_VERSION >= $(version_code 2.14.51) )) ||
25991 skip "Need server version at least 2.14.51"
25993 local lmv_qos_threshold_rr
25995 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
25997 stack_trap "$LCTL set_param \
25998 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
26000 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
26001 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
26002 getfattr -d -m dmv -e hex $DIR/$tdir | grep dmv &&
26003 error "$tdir shouldn't have default LMV"
26004 createmany -d $DIR/$tdir/sub $((100 * MDSCOUNT)) ||
26005 error "mkdir sub failed"
26007 local count=$($LFS getstripe -m $DIR/$tdir/* | grep -c ^0)
26009 (( count == 100 )) || error "$count subdirs on MDT0"
26011 run_test 413d "inherit ROOT default LMV"
26014 (( MDSCOUNT >= 2 )) ||
26015 skip "We need at least 2 MDTs for this test"
26016 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26017 skip "Need server version at least 2.14.55"
26019 local testdir=$DIR/$tdir
26020 local tmpfile=$TMP/temp.setdirstripe.stderr.$$
26022 local sub_max_inherit
26024 mkdir -p $testdir || error "failed to create $testdir"
26026 # set default max-inherit to -1 if stripe count is 0 or 1
26027 $LFS setdirstripe -D -c 1 $testdir ||
26028 error "failed to set default LMV"
26029 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26030 (( max_inherit == -1 )) ||
26031 error "wrong max_inherit value $max_inherit"
26033 # set default max_inherit to a fixed value if stripe count is not 0 or 1
26034 $LFS setdirstripe -D -c -1 $testdir ||
26035 error "failed to set default LMV"
26036 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26037 (( max_inherit > 0 )) ||
26038 error "wrong max_inherit value $max_inherit"
26040 # and the subdir will decrease the max_inherit by 1
26041 mkdir -p $testdir/subdir-1 || error "failed to make subdir"
26042 sub_max_inherit=$($LFS getdirstripe -D --max-inherit $testdir/subdir-1)
26043 (( sub_max_inherit == max_inherit - 1)) ||
26044 error "wrong max-inherit of subdir $sub_max_inherit"
26046 # check specified --max-inherit and warning message
26047 stack_trap "rm -f $tmpfile"
26048 $LFS setdirstripe -D -c 2 --max-inherit=-1 $testdir 2> $tmpfile ||
26049 error "failed to set default LMV"
26050 max_inherit=$($LFS getdirstripe -D --max-inherit $testdir)
26051 (( max_inherit == -1 )) ||
26052 error "wrong max_inherit value $max_inherit"
26054 # check the warning messages
26055 if ! [[ $(cat $tmpfile) =~ "max-inherit=" ]]; then
26056 error "failed to detect warning string"
26059 run_test 413e "check default max-inherit value"
26061 test_fs_dmv_inherit()
26063 local testdir=$DIR/$tdir
26070 mkdir $testdir || error "mkdir $testdir failed"
26071 count=$($LFS getdirstripe -D -c $testdir)
26072 (( count == 1 )) ||
26073 error "$testdir default LMV count mismatch $count != 1"
26074 inherit=$($LFS getdirstripe -D -X $testdir)
26075 (( inherit == 3 - i )) ||
26076 error "$testdir default LMV max-inherit $inherit != $((3 - i))"
26077 inherit_rr=$($LFS getdirstripe -D --max-inherit-rr $testdir)
26078 (( inherit_rr == 3 - i )) ||
26079 error "$testdir default LMV max-inherit-rr $inherit_rr != $((3 - i))"
26080 testdir=$testdir/sub
26083 mkdir $testdir || error "mkdir $testdir failed"
26084 count=$($LFS getdirstripe -D -c $testdir)
26085 (( count == 0 )) ||
26086 error "$testdir default LMV count not zero: $count"
26090 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26092 (( MDS1_VERSION >= $(version_code 2.14.55) )) ||
26093 skip "Need server version at least 2.14.55"
26095 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26096 error "dump $DIR default LMV failed"
26097 stack_trap "setfattr --restore=$TMP/dmv.ea"
26099 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26100 error "set $DIR default LMV failed"
26102 test_fs_dmv_inherit
26104 run_test 413f "lfs getdirstripe -D list ROOT default LMV if it's not set on dir"
26107 (( MDSCOUNT >= 2 )) || skip "We need at least 2 MDTs for this test"
26109 mkdir -p $DIR/$tdir/l2/l3/l4 || error "mkdir $tdir/l1/l2/l3 failed"
26110 getfattr -d -m trusted.dmv --absolute-names $DIR > $TMP/dmv.ea ||
26111 error "dump $DIR default LMV failed"
26112 stack_trap "setfattr --restore=$TMP/dmv.ea"
26114 $LFS setdirstripe -D -i -1 -c 1 -X 3 --max-inherit-rr 3 $DIR ||
26115 error "set $DIR default LMV failed"
26117 FILESET="$FILESET/$tdir/l2/l3/l4" mount_client $MOUNT2 ||
26118 error "mount $MOUNT2 failed"
26119 stack_trap "umount_client $MOUNT2"
26121 local saved_DIR=$DIR
26125 stack_trap "export DIR=$saved_DIR"
26127 # first check filesystem-wide default LMV inheritance
26128 test_fs_dmv_inherit || error "incorrect fs default LMV inheritance"
26130 # then check subdirs are spread to all MDTs
26131 createmany -d $DIR/s $((MDSCOUNT * 100)) || error "createmany failed"
26133 local count=$($LFS getstripe -m $DIR/s* | sort -u | wc -l)
26135 (( $count == $MDSCOUNT )) || error "dirs are spread to $count MDTs"
26137 run_test 413g "enforce ROOT default LMV on subdir mount"
26144 for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
26145 unlinkmany $subdir/f. 1000 &
26149 for pid in $pids; do
26153 run_test 413z "413 test cleanup"
26156 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
26157 $LCTL set_param fail_loc=0x80000521
26158 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
26161 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
26164 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26165 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
26166 skip "Need server version at least 2.11.52"
26176 # this test may be slow on ZFS
26177 [ "$mds1_FSTYPE" == "zfs" ] && total=50
26179 # though this test is designed for striped directory, let's test normal
26180 # directory too since lock is always saved as CoS lock.
26181 test_mkdir $DIR/$tdir || error "mkdir $tdir"
26182 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
26191 start_time=$(date +%s)
26192 for i in $(seq $total); do
26193 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
26196 end_time=$(date +%s)
26197 duration=$((end_time - start_time))
26199 kill -9 $setattr_pid
26201 echo "rename $total files took $duration sec"
26202 [ $duration -lt 100 ] || error "rename took $duration sec"
26204 run_test 415 "lock revoke is not missing"
26207 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
26208 skip "Need server version at least 2.11.55"
26210 # define OBD_FAIL_OSD_TXN_START 0x19a
26211 do_facet mds1 lctl set_param fail_loc=0x19a
26213 lfs mkdir -c $MDSCOUNT $DIR/$tdir
26217 run_test 416 "transaction start failure won't cause system hung"
26221 do_nodes $(comma_list $(mdts_nodes)) \
26222 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
26223 do_nodes $(comma_list $(mdts_nodes)) \
26224 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
26225 do_nodes $(comma_list $(mdts_nodes)) \
26226 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
26230 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26231 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
26232 skip "Need MDS version at least 2.11.56"
26234 trap cleanup_417 RETURN EXIT
26236 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
26237 do_nodes $(comma_list $(mdts_nodes)) \
26238 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
26239 $LFS migrate -m 0 $DIR/$tdir.1 &&
26240 error "migrate dir $tdir.1 should fail"
26242 do_nodes $(comma_list $(mdts_nodes)) \
26243 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
26244 $LFS mkdir -i 1 $DIR/$tdir.2 &&
26245 error "create remote dir $tdir.2 should fail"
26247 do_nodes $(comma_list $(mdts_nodes)) \
26248 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
26249 $LFS mkdir -c 2 $DIR/$tdir.3 &&
26250 error "create striped dir $tdir.3 should fail"
26253 run_test 417 "disable remote dir, striped dir and dir migration"
26255 # Checks that the outputs of df [-i] and lfs df [-i] match
26257 # usage: check_lfs_df <blocks | inodes> <mountpoint>
26267 [ "$1" == "blocks" ] && inodes= || inodes="-i"
26269 for count in {1..100}; do
26270 do_nodes "$CLIENTS" \
26271 $LCTL set_param ldlm.namespaces.*.lru_size=clear
26274 # read the lines of interest
26275 df_out=($(df -P $inodes $dir | tail -n +2)) ||
26276 error "df $inodes $dir | tail -n +2 failed"
26277 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
26278 error "lfs df $inodes $dir | grep summary: failed"
26280 # skip first substrings of each output as they are different
26281 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
26282 # compare the two outputs
26284 # skip "available" on MDT until LU-13997 is fixed.
26285 #for i in {1..5}; do
26286 for i in 1 2 4 5; do
26287 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
26295 lfs df $inodes $dir
26296 error "df and lfs df $1 output mismatch: " \
26297 "df ${inodes}: ${df_out[*]}, " \
26298 "lfs df ${inodes}: ${lfs_df_out[*]}"
26303 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26305 local dir=$DIR/$tdir
26306 local numfiles=$((RANDOM % 4096 + 2))
26307 local numblocks=$((RANDOM % 256 + 1))
26309 wait_delete_completed
26312 # check block output
26313 check_lfs_df blocks $dir
26314 # check inode output
26315 check_lfs_df inodes $dir
26317 # create a single file and retest
26318 echo "Creating a single file and testing"
26319 createmany -o $dir/$tfile- 1 &>/dev/null ||
26320 error "creating 1 file in $dir failed"
26321 check_lfs_df blocks $dir
26322 check_lfs_df inodes $dir
26324 # create a random number of files
26325 echo "Creating $((numfiles - 1)) files and testing"
26326 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
26327 error "creating $((numfiles - 1)) files in $dir failed"
26329 # write a random number of blocks to the first test file
26330 echo "Writing $numblocks 4K blocks and testing"
26331 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
26332 count=$numblocks &>/dev/null ||
26333 error "dd to $dir/${tfile}-0 failed"
26336 check_lfs_df blocks $dir
26337 check_lfs_df inodes $dir
26339 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
26340 error "unlinking $numfiles files in $dir failed"
26342 run_test 418 "df and lfs df outputs match"
26346 local dir=$DIR/$tdir
26351 cancel_lru_locks mdc
26353 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
26354 $LCTL set_param fail_loc=0x1410
26356 $LCTL set_param fail_loc=0
26359 run_test 419 "Verify open file by name doesn't crash kernel"
26363 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
26364 skip "Need MDS version at least 2.12.53"
26366 local SAVE_UMASK=$(umask)
26367 local dir=$DIR/$tdir
26368 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
26372 mkdir -m03777 $dir/testdir
26373 ls -dn $dir/testdir
26374 # Need to remove trailing '.' when SELinux is enabled
26375 local dirperms=$(ls -dn $dir/testdir |
26376 awk '{ sub(/\.$/, "", $1); print $1}')
26377 [ $dirperms == "drwxrwsrwt" ] ||
26378 error "incorrect perms on $dir/testdir"
26380 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
26381 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
26382 ls -n $dir/testdir/testfile
26383 local fileperms=$(ls -n $dir/testdir/testfile |
26384 awk '{ sub(/\.$/, "", $1); print $1}')
26385 [ $fileperms == "-rwxr-xr-x" ] ||
26386 error "incorrect perms on $dir/testdir/testfile"
26390 run_test 420 "clear SGID bit on non-directories for non-members"
26397 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26398 skip "Need MDS version at least 2.12.54"
26400 test_mkdir $DIR/$tdir
26401 createmany -o $DIR/$tdir/f 3
26402 cnt=$(ls -1 $DIR/$tdir | wc -l)
26403 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26405 fid1=$(lfs path2fid $DIR/$tdir/f1)
26406 fid2=$(lfs path2fid $DIR/$tdir/f2)
26407 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
26409 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
26410 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
26412 cnt=$(ls -1 $DIR/$tdir | wc -l)
26413 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26415 rm -f $DIR/$tdir/f3 || error "can't remove f3"
26416 createmany -o $DIR/$tdir/f 3
26417 cnt=$(ls -1 $DIR/$tdir | wc -l)
26418 [ $cnt != 3 ] && error "unexpected #files: $cnt"
26420 fid1=$(lfs path2fid $DIR/$tdir/f1)
26421 fid2=$(lfs path2fid $DIR/$tdir/f2)
26422 echo "remove using fsname $FSNAME"
26423 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
26425 cnt=$(ls -1 $DIR/$tdir | wc -l)
26426 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
26428 run_test 421a "simple rm by fid"
26435 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26436 skip "Need MDS version at least 2.12.54"
26438 test_mkdir $DIR/$tdir
26439 createmany -o $DIR/$tdir/f 3
26440 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
26443 FID1=$(lfs path2fid $DIR/$tdir/f1)
26444 FID2=$(lfs path2fid $DIR/$tdir/f2)
26445 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
26447 kill -USR1 $MULTIPID
26450 cnt=$(ls $DIR/$tdir | wc -l)
26451 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
26453 run_test 421b "rm by fid on open file"
26459 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26460 skip "Need MDS version at least 2.12.54"
26462 test_mkdir $DIR/$tdir
26463 createmany -o $DIR/$tdir/f 3
26464 touch $DIR/$tdir/$tfile
26465 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
26466 cnt=$(ls -1 $DIR/$tdir | wc -l)
26467 [ $cnt != 184 ] && error "unexpected #files: $cnt"
26469 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
26470 $LFS rmfid $DIR $FID1 || error "rmfid failed"
26472 cnt=$(ls $DIR/$tdir | wc -l)
26473 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
26475 run_test 421c "rm by fid against hardlinked files"
26481 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26482 skip "Need MDS version at least 2.12.54"
26484 test_mkdir $DIR/$tdir
26485 createmany -o $DIR/$tdir/f 4097
26486 cnt=$(ls -1 $DIR/$tdir | wc -l)
26487 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
26489 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
26490 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26492 cnt=$(ls $DIR/$tdir | wc -l)
26494 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26496 run_test 421d "rmfid en masse"
26502 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26503 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26504 skip "Need MDS version at least 2.12.54"
26506 mkdir -p $DIR/$tdir
26507 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26508 createmany -o $DIR/$tdir/striped_dir/f 512
26509 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26510 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26512 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26513 sed "s/[/][^:]*://g")
26514 $LFS rmfid $DIR $FIDS || error "rmfid failed"
26516 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
26518 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26520 run_test 421e "rmfid in DNE"
26526 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26527 skip "Need MDS version at least 2.12.54"
26529 test_mkdir $DIR/$tdir
26531 cnt=$(ls -1 $DIR/$tdir | wc -l)
26532 [ $cnt != 1 ] && error "unexpected #files: $cnt"
26534 FID=$(lfs path2fid $DIR/$tdir/f)
26535 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
26536 # rmfid should fail
26537 cnt=$(ls -1 $DIR/$tdir | wc -l)
26538 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
26540 chmod a+rw $DIR/$tdir
26542 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
26543 # rmfid should fail
26544 cnt=$(ls -1 $DIR/$tdir | wc -l)
26545 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
26548 $RUNAS touch $DIR/$tdir/f
26549 FID=$(lfs path2fid $DIR/$tdir/f)
26550 echo "rmfid as root"
26551 $LFS rmfid $DIR $FID || error "rmfid as root failed"
26552 cnt=$(ls -1 $DIR/$tdir | wc -l)
26553 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
26556 $RUNAS touch $DIR/$tdir/f
26557 cnt=$(ls -1 $DIR/$tdir | wc -l)
26558 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
26559 FID=$(lfs path2fid $DIR/$tdir/f)
26560 # rmfid w/o user_fid2path mount option should fail
26561 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
26562 cnt=$(ls -1 $DIR/$tdir | wc -l)
26563 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
26565 tmpdir=$(mktemp -d /tmp/lustre-XXXXXX)
26566 stack_trap "rmdir $tmpdir"
26567 mount_client $tmpdir "$MOUNT_OPTS,user_fid2path" ||
26568 error "failed to mount client'"
26569 stack_trap "umount_client $tmpdir"
26571 $RUNAS $LFS rmfid $tmpdir $FID || error "rmfid failed"
26572 # rmfid should succeed
26573 cnt=$(ls -1 $tmpdir/$tdir | wc -l)
26574 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
26576 # rmfid shouldn't allow to remove files due to dir's permission
26577 chmod a+rwx $tmpdir/$tdir
26578 touch $tmpdir/$tdir/f
26579 ls -la $tmpdir/$tdir
26580 FID=$(lfs path2fid $tmpdir/$tdir/f)
26581 $RUNAS $LFS rmfid $tmpdir $FID && error "rmfid didn't fail"
26584 run_test 421f "rmfid checks permissions"
26590 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
26591 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
26592 skip "Need MDS version at least 2.12.54"
26594 mkdir -p $DIR/$tdir
26595 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
26596 createmany -o $DIR/$tdir/striped_dir/f 512
26597 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26598 [ $cnt != 512 ] && error "unexpected #files: $cnt"
26600 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
26601 sed "s/[/][^:]*://g")
26603 rm -f $DIR/$tdir/striped_dir/f1*
26604 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
26605 removed=$((512 - cnt))
26607 # few files have been just removed, so we expect
26608 # rmfid to fail on their fids
26609 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
26610 [ $removed != $errors ] && error "$errors != $removed"
26612 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
26614 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
26616 run_test 421g "rmfid to return errors properly"
26619 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
26620 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
26621 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
26622 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
26623 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
26625 local amc=$(at_max_get client)
26626 local amo=$(at_max_get mds1)
26627 local timeout=`lctl get_param -n timeout`
26629 at_max_set 0 client
26632 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
26633 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
26634 fail_val=$(((2*timeout + 10)*1000))
26635 touch $DIR/$tdir/d3/file &
26637 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
26638 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
26639 fail_val=$((2*timeout + 5))
26640 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
26644 sleep $((2 * timeout))
26648 touch $DIR/$tdir/d2/file3
26649 touch $DIR/$tdir/d2/file4
26650 touch $DIR/$tdir/d2/file5
26653 at_max_set $amc client
26654 at_max_set $amo mds1
26656 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
26657 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
26658 error "Watchdog is always throttled"
26660 run_test 422 "kill a process with RPC in progress"
26673 # ensure statfs cache is expired
26676 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
26677 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
26681 run_test 423 "statfs should return a right data"
26684 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
26685 $LCTL set_param fail_loc=0x80000522
26686 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
26689 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
26692 test_mkdir -c -1 $DIR/$tdir
26693 $LFS setstripe -c -1 $DIR/$tdir
26695 lru_resize_disable "" 100
26696 stack_trap "lru_resize_enable" EXIT
26700 for i in $(seq $((MDSCOUNT * 125))); do
26701 local t=$DIR/$tdir/$tfile_$i
26703 dd if=/dev/zero of=$t bs=4K count=1 > /dev/null 2>&1 ||
26704 error_noexit "Create file $t"
26706 stack_trap "rm -rf $DIR/$tdir" EXIT
26708 for oscparam in $($LCTL list_param ldlm.namespaces.*osc-[-0-9a-f]*); do
26709 local lru_size=$($LCTL get_param -n $oscparam.lru_size)
26710 local lock_count=$($LCTL get_param -n $oscparam.lock_count)
26712 [ $lock_count -le $lru_size ] ||
26713 error "osc lock count $lock_count > lru size $lru_size"
26716 for mdcparam in $($LCTL list_param ldlm.namespaces.*mdc-*); do
26717 local lru_size=$($LCTL get_param -n $mdcparam.lru_size)
26718 local lock_count=$($LCTL get_param -n $mdcparam.lock_count)
26720 [ $lock_count -le $lru_size ] ||
26721 error "mdc lock count $lock_count > lru size $lru_size"
26724 run_test 425 "lock count should not exceed lru size"
26727 splice-test -r $DIR/$tfile
26728 splice-test -rd $DIR/$tfile
26729 splice-test $DIR/$tfile
26730 splice-test -d $DIR/$tfile
26732 run_test 426 "splice test on Lustre"
26735 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
26736 (( $MDS1_VERSION >= $(version_code 2.12.4) )) ||
26737 skip "Need MDS version at least 2.12.4"
26743 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/1/dir
26744 test_mkdir -c $MDSCOUNT -i 1 $DIR/$tdir/2/dir2
26746 $LFS getdirstripe $DIR/$tdir/1/dir
26748 #first setfattr for creating updatelog
26749 setfattr -n user.attr0 -v "some text" $DIR/$tdir/1/dir
26751 #define OBD_FAIL_OUT_OBJECT_MISS 0x1708
26752 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80001708
26753 setfattr -n user.attr1 -v "some text" $DIR/$tdir/1/dir &
26754 setfattr -n user.attr2 -v "another attr" $DIR/$tdir/2/dir2 &
26758 wait_recovery_complete mds2 $((2*TIMEOUT))
26760 log=$(do_facet mds1 dmesg | tac | sed "/${TESTNAME//_/ }/,$ d")
26761 echo $log | grep "get update log failed" &&
26762 error "update log corruption is detected" || true
26764 run_test 427 "Failed DNE2 update request shouldn't corrupt updatelog"
26767 [ $PARALLEL == "yes" ] && skip "skip parallel run"
26768 local cache_limit=$CACHE_MAX
26770 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$cache_limit"
26771 $LCTL set_param -n llite.*.max_cached_mb=64
26774 $LFS setstripe -c 1 $DIR/$tdir
26775 eval touch $DIR/$tdir/$tfile.{1..$OSTCOUNT}
26776 stack_trap "rm -f $DIR/$tdir/$tfile.*"
26778 for f in $(seq 4); do
26779 dd if=/dev/zero of=$DIR/$tdir/$tfile.$f bs=128M count=1 &
26783 cancel_lru_locks osc
26785 for f in $(seq 4); do
26786 dd if=$DIR/$tdir/$tfile.$f of=/dev/null bs=128M count=1 &
26790 run_test 428 "large block size IO should not hang"
26792 test_429() { # LU-7915 / LU-10948
26793 local ll_opencache_threshold_count="llite.*.opencache_threshold_count"
26794 local testfile=$DIR/$tfile
26795 local mdc_rpcstats="mdc.$FSNAME-MDT0000-*.stats"
26801 $LCTL get_param $ll_opencache_threshold_count ||
26802 skip "client does not have opencache parameter"
26804 set_opencache $new_flag
26805 stack_trap "restore_opencache"
26806 [ $($LCTL get_param -n $ll_opencache_threshold_count) == $new_flag ] ||
26807 error "enable opencache failed"
26809 # drop MDC DLM locks
26810 cancel_lru_locks mdc
26811 # clear MDC RPC stats counters
26812 $LCTL set_param $mdc_rpcstats=clear
26814 # According to the current implementation, we need to run 3 times
26815 # open & close file to verify if opencache is enabled correctly.
26816 # 1st, RPCs are sent for lookup/open and open handle is released on
26818 # 2nd, RPC is sent for open, MDS_OPEN_LOCK is fetched automatically,
26819 # so open handle won't be released thereafter.
26820 # 3rd, No RPC is sent out.
26821 $MULTIOP $testfile oc || error "multiop failed"
26822 first_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
26823 echo "1st: $first_rpc RPCs in flight"
26825 $MULTIOP $testfile oc || error "multiop failed"
26826 second_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
26827 echo "2nd: $second_rpc RPCs in flight"
26829 $MULTIOP $testfile oc || error "multiop failed"
26830 third_rpc=$(calc_stats $mdc_rpcstats ldlm_ibits_enqueue)
26831 echo "3rd: $third_rpc RPCs in flight"
26833 #verify no MDC RPC is sent
26834 [[ $second_rpc == $third_rpc ]] || error "MDC RPC is still sent"
26836 run_test 429 "verify if opencache flag on client side does work"
26842 # data at [200K, 400K)
26843 dd if=/dev/urandom of=$file bs=256K count=1 seek=1 ||
26844 error "256K->512K dd fails"
26846 dd if=/dev/urandom of=$file bs=1M count=1 seek=2 ||
26847 error "2M->3M dd fails"
26849 dd if=/dev/urandom of=$file bs=1M count=1 seek=4 ||
26850 error "4M->5M dd fails"
26851 echo "Data at 256K...512K, 2M...3M and 4M...5M"
26852 # start at first component hole #1
26853 printf "Seeking hole from 1000 ... "
26854 offset=$(lseek_test -l 1000 $file)
26856 [[ $offset == 1000 ]] || error "offset $offset != 1000"
26857 printf "Seeking data from 1000 ... "
26858 offset=$(lseek_test -d 1000 $file)
26860 [[ $offset == 262144 ]] || error "offset $offset != 262144"
26862 # start at first component data block
26863 printf "Seeking hole from 300000 ... "
26864 offset=$(lseek_test -l 300000 $file)
26866 [[ $offset == 524288 ]] || error "offset $offset != 524288"
26867 printf "Seeking data from 300000 ... "
26868 offset=$(lseek_test -d 300000 $file)
26870 [[ $offset == 300000 ]] || error "offset $offset != 300000"
26872 # start at the first component but beyond end of object size
26873 printf "Seeking hole from 1000000 ... "
26874 offset=$(lseek_test -l 1000000 $file)
26876 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
26877 printf "Seeking data from 1000000 ... "
26878 offset=$(lseek_test -d 1000000 $file)
26880 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
26882 # start at second component stripe 2 (empty file)
26883 printf "Seeking hole from 1500000 ... "
26884 offset=$(lseek_test -l 1500000 $file)
26886 [[ $offset == 1500000 ]] || error "offset $offset != 1500000"
26887 printf "Seeking data from 1500000 ... "
26888 offset=$(lseek_test -d 1500000 $file)
26890 [[ $offset == 2097152 ]] || error "offset $offset != 2097152"
26892 # start at second component stripe 1 (all data)
26893 printf "Seeking hole from 3000000 ... "
26894 offset=$(lseek_test -l 3000000 $file)
26896 [[ $offset == 3145728 ]] || error "offset $offset != 3145728"
26897 printf "Seeking data from 3000000 ... "
26898 offset=$(lseek_test -d 3000000 $file)
26900 [[ $offset == 3000000 ]] || error "offset $offset != 3000000"
26902 dd if=/dev/urandom of=$file bs=640K count=1 seek=1 ||
26903 error "2nd dd fails"
26904 echo "Add data block at 640K...1280K"
26906 # start at before new data block, in hole
26907 printf "Seeking hole from 600000 ... "
26908 offset=$(lseek_test -l 600000 $file)
26910 [[ $offset == 600000 ]] || error "offset $offset != 600000"
26911 printf "Seeking data from 600000 ... "
26912 offset=$(lseek_test -d 600000 $file)
26914 [[ $offset == 655360 ]] || error "offset $offset != 655360"
26916 # start at the first component new data block
26917 printf "Seeking hole from 1000000 ... "
26918 offset=$(lseek_test -l 1000000 $file)
26920 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
26921 printf "Seeking data from 1000000 ... "
26922 offset=$(lseek_test -d 1000000 $file)
26924 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
26926 # start at second component stripe 2, new data
26927 printf "Seeking hole from 1200000 ... "
26928 offset=$(lseek_test -l 1200000 $file)
26930 [[ $offset == 1310720 ]] || error "offset $offset != 1310720"
26931 printf "Seeking data from 1200000 ... "
26932 offset=$(lseek_test -d 1200000 $file)
26934 [[ $offset == 1200000 ]] || error "offset $offset != 1200000"
26936 # start beyond file end
26937 printf "Using offset > filesize ... "
26938 lseek_test -l 4000000 $file && error "lseek should fail"
26939 printf "Using offset > filesize ... "
26940 lseek_test -d 4000000 $file && error "lseek should fail"
26946 $LCTL get_param mdc.*.import | grep -q 'connect_flags:.*seek' ||
26947 skip "MDT does not support SEEK_HOLE"
26949 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
26950 skip "OST does not support SEEK_HOLE"
26952 local file=$DIR/$tdir/$tfile
26954 mkdir -p $DIR/$tdir
26956 $LFS setstripe -E 1M -L mdt -E eof -c2 $file
26957 # OST stripe #1 will have continuous data at [1M, 3M)
26958 # OST stripe #2 is empty
26959 echo "Component #1: 1M DoM, component #2: EOF, 2 stripes 1M"
26960 lseek_test_430 $file
26962 $LFS setstripe -E 1M -c2 -S 64K -E 10M -c2 -S 1M $file
26963 echo "Component #1: 1M, 2 stripes 64K, component #2: EOF, 2 stripes 1M"
26964 lseek_test_430 $file
26966 $LFS setstripe -c2 -S 512K $file
26967 echo "Two stripes, stripe size 512K"
26968 lseek_test_430 $file
26970 # FLR with stale mirror
26971 $LFS setstripe -N -E 512K -c1 -S 64K -E eof -c2 -S 512K \
26973 echo "Mirrored file:"
26974 echo "Component #1: 512K, stripe 64K, component #2: EOF, 2 stripes 512K"
26975 echo "Plain 2 stripes 1M"
26976 lseek_test_430 $file
26979 run_test 430a "lseek: SEEK_DATA/SEEK_HOLE basic functionality"
26982 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
26983 skip "OST does not support SEEK_HOLE"
26986 local file=$DIR/$tdir/$tfile
26988 mkdir -p $DIR/$tdir
26989 # Empty layout lseek should fail
26992 printf "Seeking hole from 0 ... "
26993 lseek_test -l 0 $file && error "lseek should fail"
26994 printf "Seeking data from 0 ... "
26995 lseek_test -d 0 $file && error "lseek should fail"
26999 $LFS setstripe -E 1M -c2 -E eof $file
27000 $TRUNCATE $file 1048576
27001 printf "Seeking hole from 1000000 ... "
27002 offset=$(lseek_test -l 1000000 $file)
27004 [[ $offset == 1000000 ]] || error "offset $offset != 1000000"
27005 printf "Seeking data from 1000000 ... "
27006 lseek_test -d 1000000 $file && error "lseek should fail"
27009 # full component followed by non-inited one
27010 $LFS setstripe -E 1M -c2 -E eof $file
27011 dd if=/dev/urandom of=$file bs=1M count=1
27012 printf "Seeking hole from 1000000 ... "
27013 offset=$(lseek_test -l 1000000 $file)
27015 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27016 printf "Seeking hole from 1048576 ... "
27017 lseek_test -l 1048576 $file && error "lseek should fail"
27018 # init second component and truncate back
27019 echo "123" >> $file
27020 $TRUNCATE $file 1048576
27021 printf "Seeking hole from 1000000 ... "
27022 offset=$(lseek_test -l 1000000 $file)
27024 [[ $offset == 1048576 ]] || error "offset $offset != 1048576"
27025 printf "Seeking hole from 1048576 ... "
27026 lseek_test -l 1048576 $file && error "lseek should fail"
27027 # boundary checks for big values
27028 dd if=/dev/urandom of=$file.10g bs=1 count=1 seek=10G
27029 offset=$(lseek_test -d 0 $file.10g)
27030 [[ $offset == 10737418240 ]] || error "offset $offset != 10737418240"
27031 dd if=/dev/urandom of=$file.100g bs=1 count=1 seek=100G
27032 offset=$(lseek_test -d 0 $file.100g)
27033 [[ $offset == 107374182400 ]] || error "offset $offset != 107374182400"
27036 run_test 430b "lseek: SEEK_DATA/SEEK_HOLE special cases"
27039 $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
27040 skip "OST does not support SEEK_HOLE"
27042 local file=$DIR/$tdir/$tfile
27045 mkdir -p $DIR/$tdir
27046 dd if=/dev/urandom of=$file bs=1k count=1 seek=5M
27048 # cp version 8.33+ prefers lseek over fiemap
27049 if [[ $(cp --version | head -n1 | sed "s/[^0-9]//g") -ge 833 ]]; then
27051 time cp $file /dev/null
27052 (( SECONDS - start < 5 )) ||
27053 error "cp: too long runtime $((SECONDS - start))"
27056 # tar version 1.29+ supports SEEK_HOLE/DATA
27057 if [[ $(tar --version | head -n1 | sed "s/[^0-9]//g") -ge 129 ]]; then
27059 time tar cS $file - | cat > /dev/null
27060 (( SECONDS - start < 5 )) ||
27061 error "tar: too long runtime $((SECONDS - start))"
27064 run_test 430c "lseek: external tools check"
27066 test_431() { # LU-14187
27067 local file=$DIR/$tdir/$tfile
27069 mkdir -p $DIR/$tdir
27070 $LFS setstripe -c 1 -i 0 $file || error "lfs setstripe failed"
27071 dd if=/dev/urandom of=$file bs=4k count=1
27072 dd if=/dev/urandom of=$file bs=4k count=1 seek=10 conv=notrunc
27073 dd if=/dev/urandom of=$file bs=4k count=1 seek=12 conv=notrunc
27074 #define OBD_FAIL_OST_RESTART_IO 0x251
27075 do_facet ost1 "$LCTL set_param fail_loc=0x251"
27076 $LFS setstripe -c 1 -i 0 $file.0 || error "lfs setstripe failed"
27080 echo 3 > /proc/sys/vm/drop_caches
27081 diff $file $file.0 || error "data diff"
27083 run_test 431 "Restart transaction for IO"
27085 cleanup_test_432() {
27086 do_facet mgs $LCTL nodemap_activate 0
27087 wait_nm_sync active
27091 local tmpdir=$TMP/dir432
27093 (( $MDS1_VERSION >= $(version_code 2.14.52) )) ||
27094 skip "Need MDS version at least 2.14.52"
27096 stack_trap cleanup_test_432 EXIT
27100 do_facet mgs $LCTL nodemap_activate 1
27101 wait_nm_sync active
27102 do_facet mgs $LCTL nodemap_modify --name default \
27103 --property admin --value 1
27104 do_facet mgs $LCTL nodemap_modify --name default \
27105 --property trusted --value 1
27106 cancel_lru_locks mdc
27107 wait_nm_sync default admin_nodemap
27108 wait_nm_sync default trusted_nodemap
27110 if [ $(mv $tmpdir $DIR/$tdir/ 2>&1 |
27111 grep -ci "Operation not permitted") -ne 0 ]; then
27112 error "mv $tmpdir $DIR/$tdir/ hits 'Operation not permitted'"
27115 run_test 432 "mv dir from outside Lustre"
27118 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27120 [[ -n "$($LCTL list_param llite.*.inode_cache 2>/dev/null)" ]] ||
27121 skip "inode cache not supported"
27123 $LCTL set_param llite.*.inode_cache=0
27124 stack_trap "$LCTL set_param llite.*.inode_cache=1"
27130 cancel_lru_locks mdc
27131 test_mkdir $DIR/$tdir || error "mkdir $tdir"
27132 createmany -m $DIR/$tdir/f $count
27133 createmany -d $DIR/$tdir/d $count
27134 ls -l $DIR/$tdir > /dev/null
27135 stack_trap "rm -rf $DIR/$tdir"
27137 before=$(num_objects)
27138 cancel_lru_locks mdc
27139 after=$(num_objects)
27141 # sometimes even @before is less than 2 * count
27142 while (( before - after < count )); do
27144 after=$(num_objects)
27146 (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after"
27147 if (( wait > 60 )); then
27148 error "inode slab grew from $before to $after"
27152 echo "lustre_inode_cache $before objs before lock cancel, $after after"
27154 run_test 433 "ldlm lock cancel releases dentries and inodes"
27157 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27158 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27159 skip "Need server version at least 2.9.55"
27161 start_full_debug_logging
27165 stop_full_debug_logging
27169 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27170 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27171 awk '/The barrier for/ { print $7 }')
27174 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
27179 barrier_expired() {
27182 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
27183 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
27184 awk '/will be expired/ { print $7 }')
27186 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
27195 echo "Start barrier_freeze at: $(date)"
27196 #define OBD_FAIL_BARRIER_DELAY 0x2202
27197 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
27198 # Do not reduce barrier time - See LU-11873
27199 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
27202 local b_status=$(barrier_stat)
27203 echo "Got barrier status at: $(date)"
27204 [ "$b_status" = "'freezing_p1'" ] ||
27205 error "(1) unexpected barrier status $b_status"
27207 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
27209 b_status=$(barrier_stat)
27210 [ "$b_status" = "'frozen'" ] ||
27211 error "(2) unexpected barrier status $b_status"
27213 local expired=$(barrier_expired)
27214 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
27215 sleep $((expired + 3))
27217 b_status=$(barrier_stat)
27218 [ "$b_status" = "'expired'" ] ||
27219 error "(3) unexpected barrier status $b_status"
27221 # Do not reduce barrier time - See LU-11873
27222 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
27223 error "(4) fail to freeze barrier"
27225 b_status=$(barrier_stat)
27226 [ "$b_status" = "'frozen'" ] ||
27227 error "(5) unexpected barrier status $b_status"
27229 echo "Start barrier_thaw at: $(date)"
27230 #define OBD_FAIL_BARRIER_DELAY 0x2202
27231 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
27232 do_facet mgs $LCTL barrier_thaw $FSNAME &
27235 b_status=$(barrier_stat)
27236 echo "Got barrier status at: $(date)"
27237 [ "$b_status" = "'thawing'" ] ||
27238 error "(6) unexpected barrier status $b_status"
27240 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
27242 b_status=$(barrier_stat)
27243 [ "$b_status" = "'thawed'" ] ||
27244 error "(7) unexpected barrier status $b_status"
27246 #define OBD_FAIL_BARRIER_FAILURE 0x2203
27247 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
27248 do_facet mgs $LCTL barrier_freeze $FSNAME
27250 b_status=$(barrier_stat)
27251 [ "$b_status" = "'failed'" ] ||
27252 error "(8) unexpected barrier status $b_status"
27254 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
27255 do_facet mgs $LCTL barrier_thaw $FSNAME
27259 run_test 801a "write barrier user interfaces and stat machine"
27264 mkdir $DIR/$tdir || error "(1) fail to mkdir"
27265 createmany -d $DIR/$tdir/d 6 || error "(2) fail to mkdir"
27266 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
27267 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
27268 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
27270 cancel_lru_locks mdc
27272 # 180 seconds should be long enough
27273 do_facet mgs $LCTL barrier_freeze $FSNAME 180
27275 local b_status=$(barrier_stat)
27276 [ "$b_status" = "'frozen'" ] ||
27277 error "(6) unexpected barrier status $b_status"
27279 mkdir $DIR/$tdir/d0/d10 &
27282 touch $DIR/$tdir/d1/f13 &
27285 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
27288 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
27291 rm -f $DIR/$tdir/d4/f12 &
27294 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
27296 # To guarantee taht the 'stat' is not blocked
27297 b_status=$(barrier_stat)
27298 [ "$b_status" = "'frozen'" ] ||
27299 error "(8) unexpected barrier status $b_status"
27301 # let above commands to run at background
27304 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
27305 ps -p $touch_pid || error "(10) touch should be blocked"
27306 ps -p $ln_pid || error "(11) link should be blocked"
27307 ps -p $mv_pid || error "(12) rename should be blocked"
27308 ps -p $rm_pid || error "(13) unlink should be blocked"
27310 b_status=$(barrier_stat)
27311 [ "$b_status" = "'frozen'" ] ||
27312 error "(14) unexpected barrier status $b_status"
27314 do_facet mgs $LCTL barrier_thaw $FSNAME
27315 b_status=$(barrier_stat)
27316 [ "$b_status" = "'thawed'" ] ||
27317 error "(15) unexpected barrier status $b_status"
27319 wait $mkdir_pid || error "(16) mkdir should succeed"
27320 wait $touch_pid || error "(17) touch should succeed"
27321 wait $ln_pid || error "(18) link should succeed"
27322 wait $mv_pid || error "(19) rename should succeed"
27323 wait $rm_pid || error "(20) unlink should succeed"
27327 run_test 801b "modification will be blocked by write barrier"
27330 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27334 stop mds2 || error "(1) Fail to stop mds2"
27336 do_facet mgs $LCTL barrier_freeze $FSNAME 30
27338 local b_status=$(barrier_stat)
27339 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
27340 do_facet mgs $LCTL barrier_thaw $FSNAME
27341 error "(2) unexpected barrier status $b_status"
27344 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27345 error "(3) Fail to rescan barrier bitmap"
27347 # Do not reduce barrier time - See LU-11873
27348 do_facet mgs $LCTL barrier_freeze $FSNAME 20
27350 b_status=$(barrier_stat)
27351 [ "$b_status" = "'frozen'" ] ||
27352 error "(4) unexpected barrier status $b_status"
27354 do_facet mgs $LCTL barrier_thaw $FSNAME
27355 b_status=$(barrier_stat)
27356 [ "$b_status" = "'thawed'" ] ||
27357 error "(5) unexpected barrier status $b_status"
27359 local devname=$(mdsdevname 2)
27361 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
27363 do_facet mgs $LCTL barrier_rescan $FSNAME ||
27364 error "(7) Fail to rescan barrier bitmap"
27368 run_test 801c "rescan barrier bitmap"
27370 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
27371 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
27372 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
27373 saved_MOUNT_OPTS=$MOUNT_OPTS
27379 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
27380 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
27381 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
27382 MOUNT_OPTS=$saved_MOUNT_OPTS
27387 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
27388 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
27389 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
27390 skip "Need server version at least 2.9.55"
27392 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
27394 mkdir $DIR/$tdir || error "(1) fail to mkdir"
27396 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27397 error "(2) Fail to copy"
27399 trap cleanup_802a EXIT
27401 # sync by force before remount as readonly
27402 sync; sync_all_data; sleep 3; sync_all_data
27406 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
27407 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
27408 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
27410 echo "Mount the server as read only"
27411 setupall server_only || error "(3) Fail to start servers"
27413 echo "Mount client without ro should fail"
27414 mount_client $MOUNT &&
27415 error "(4) Mount client without 'ro' should fail"
27417 echo "Mount client with ro should succeed"
27418 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
27419 mount_client $MOUNT ||
27420 error "(5) Mount client with 'ro' should succeed"
27422 echo "Modify should be refused"
27423 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27425 echo "Read should be allowed"
27426 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27427 error "(7) Read should succeed under ro mode"
27431 run_test 802a "simulate readonly device"
27434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27435 remote_mds_nodsh && skip "remote MDS with nodsh"
27437 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
27438 skip "readonly option not available"
27440 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
27442 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
27443 error "(2) Fail to copy"
27445 # write back all cached data before setting MDT to readonly
27449 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
27450 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
27452 echo "Modify should be refused"
27453 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
27455 echo "Read should be allowed"
27456 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
27457 error "(7) Read should succeed under ro mode"
27460 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
27462 run_test 802b "be able to set MDTs to readonly"
27465 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27466 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27467 skip "MDS needs to be newer than 2.10.54"
27469 mkdir_on_mdt0 $DIR/$tdir
27470 # Create some objects on all MDTs to trigger related logs objects
27471 for idx in $(seq $MDSCOUNT); do
27472 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
27473 $DIR/$tdir/dir${idx} ||
27474 error "Fail to create $DIR/$tdir/dir${idx}"
27478 wait_delete_completed # ensure old test cleanups are finished
27479 echo "before create:"
27481 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27483 for i in {1..10}; do
27484 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
27485 error "Fail to create $DIR/$tdir/foo$i"
27489 echo "after create:"
27491 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27493 # allow for an llog to be cleaned up during the test
27494 [ $after_used -ge $((before_used + 10 - 1)) ] ||
27495 error "before ($before_used) + 10 > after ($after_used)"
27497 for i in {1..10}; do
27498 rm -rf $DIR/$tdir/foo$i ||
27499 error "Fail to remove $DIR/$tdir/foo$i"
27502 sleep 3 # avoid MDT return cached statfs
27503 wait_delete_completed
27504 echo "after unlink:"
27506 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
27508 # allow for an llog to be created during the test
27509 [ $after_used -le $((before_used + 1)) ] ||
27510 error "after ($after_used) > before ($before_used) + 1"
27512 run_test 803a "verify agent object for remote object"
27515 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27516 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
27517 skip "MDS needs to be newer than 2.13.56"
27518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27520 for i in $(seq 0 $((MDSCOUNT - 1))); do
27521 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
27529 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27530 for i in $(seq 0 $((MDSCOUNT - 1))); do
27531 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27532 awk '/getattr/ { print $2 }')
27533 before=$((before + tmp))
27535 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
27536 for i in $(seq 0 $((MDSCOUNT - 1))); do
27537 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
27538 awk '/getattr/ { print $2 }')
27539 after=$((after + tmp))
27542 [ $before -eq $after ] || error "getattr count $before != $after"
27544 run_test 803b "remote object can getattr from cache"
27547 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
27548 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
27549 skip "MDS needs to be newer than 2.10.54"
27550 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
27552 mkdir -p $DIR/$tdir
27553 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
27554 error "Fail to create $DIR/$tdir/dir0"
27556 local fid=$($LFS path2fid $DIR/$tdir/dir0)
27557 local dev=$(mdsdevname 2)
27559 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27560 grep ${fid} || error "NOT found agent entry for dir0"
27562 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
27563 error "Fail to create $DIR/$tdir/dir1"
27565 touch $DIR/$tdir/dir1/foo0 ||
27566 error "Fail to create $DIR/$tdir/dir1/foo0"
27567 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
27570 for idx in $(seq $MDSCOUNT); do
27571 dev=$(mdsdevname $idx)
27572 do_facet mds${idx} \
27573 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27574 grep ${fid} && rc=$idx
27577 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
27578 error "Fail to rename foo0 to foo1"
27579 if [ $rc -eq 0 ]; then
27580 for idx in $(seq $MDSCOUNT); do
27581 dev=$(mdsdevname $idx)
27582 do_facet mds${idx} \
27583 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27584 grep ${fid} && rc=$idx
27588 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
27589 error "Fail to rename foo1 to foo2"
27590 if [ $rc -eq 0 ]; then
27591 for idx in $(seq $MDSCOUNT); do
27592 dev=$(mdsdevname $idx)
27593 do_facet mds${idx} \
27594 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
27595 grep ${fid} && rc=$idx
27599 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
27601 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
27602 error "Fail to link to $DIR/$tdir/dir1/foo2"
27603 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
27604 error "Fail to rename foo2 to foo0"
27605 unlink $DIR/$tdir/dir1/foo0 ||
27606 error "Fail to unlink $DIR/$tdir/dir1/foo0"
27607 rm -rf $DIR/$tdir/dir0 ||
27608 error "Fail to rm $DIR/$tdir/dir0"
27610 for idx in $(seq $MDSCOUNT); do
27614 dev=$(mdsdevname $idx)
27615 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
27617 start mds${idx} $dev $MDS_MOUNT_OPTS ||
27618 error "mount mds$idx failed"
27619 df $MOUNT > /dev/null 2>&1
27621 # e2fsck should not return error
27623 error "e2fsck detected error on MDT${idx}: rc=$rc"
27626 run_test 804 "verify agent entry for remote entry"
27629 do_facet $SINGLEMDS zfs set quota=$old $fsset
27630 unlinkmany $DIR/$tdir/f- 1000000
27635 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
27636 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
27637 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
27638 skip "netfree not implemented before 0.7"
27639 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
27640 skip "Need MDS version at least 2.10.57"
27647 local pref="osd-zfs.$FSNAME-MDT0000."
27649 # limit available space on MDS dataset to meet nospace issue
27650 # quickly. then ZFS 0.7.2 can use reserved space if asked
27651 # properly (using netfree flag in osd_declare_destroy()
27652 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
27653 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
27655 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
27656 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
27657 let "usedkb=usedkb-freekb"
27658 let "freekb=freekb/2"
27659 if let "freekb > 5000"; then
27662 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
27663 trap cleanup_805 EXIT
27664 mkdir_on_mdt0 $DIR/$tdir
27665 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
27666 error "Can't set PFL layout"
27667 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
27668 rm -rf $DIR/$tdir || error "not able to remove"
27669 do_facet $SINGLEMDS zfs set quota=$old $fsset
27672 run_test 805 "ZFS can remove from full fs"
27678 local expect=$(stat -c %s $file)
27680 check_lsom_size $1 $expect
27682 local blocks=$($LFS getsom -b $file)
27683 expect=$(stat -c %b $file)
27684 [[ $blocks == $expect ]] ||
27685 error "$file expected blocks: $expect, got: $blocks"
27693 cancel_lru_locks mdc
27695 size=$($LFS getsom -s $1)
27696 [[ $size == $expect ]] ||
27697 error "$file expected size: $expect, got: $size"
27701 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
27702 skip "Need MDS version at least 2.11.52"
27706 touch $DIR/$tfile || error "touch $tfile failed"
27708 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
27709 save_lustre_params client "llite.*.xattr_cache" > $save
27710 lctl set_param llite.*.xattr_cache=0
27711 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
27713 # single-threaded write
27714 echo "Test SOM for single-threaded write"
27715 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
27716 error "write $tfile failed"
27717 check_lsom_size $DIR/$tfile $bs
27720 local size=$(($num * $bs))
27724 echo "Test SOM for single client multi-threaded($num) write"
27725 $TRUNCATE $DIR/$tfile 0
27726 for ((i = 0; i < $num; i++)); do
27727 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27729 offset=$((offset + $bs))
27731 for (( i=0; i < $num; i++ )); do
27734 check_lsom_size $DIR/$tfile $size
27736 $TRUNCATE $DIR/$tfile 0
27737 for ((i = 0; i < $num; i++)); do
27738 offset=$((offset - $bs))
27739 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27742 for (( i=0; i < $num; i++ )); do
27745 check_lsom_size $DIR/$tfile $size
27747 # multi-client writes
27748 num=$(get_node_count ${CLIENTS//,/ })
27749 size=$(($num * $bs))
27753 echo "Test SOM for multi-client ($num) writes"
27754 $TRUNCATE $DIR/$tfile 0
27755 for client in ${CLIENTS//,/ }; do
27756 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27759 offset=$((offset + $bs))
27761 for (( i=0; i < $num; i++ )); do
27764 check_lsom_size $DIR/$tfile $offset
27767 $TRUNCATE $DIR/$tfile 0
27768 for client in ${CLIENTS//,/ }; do
27769 offset=$((offset - $bs))
27770 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27774 for (( i=0; i < $num; i++ )); do
27777 check_lsom_size $DIR/$tfile $size
27780 echo "Test SOM for truncate"
27781 $TRUNCATE $DIR/$tfile 1048576
27782 check_lsom_size $DIR/$tfile 1048576
27783 $TRUNCATE $DIR/$tfile 1234
27784 check_lsom_size $DIR/$tfile 1234
27786 # verify SOM blocks count
27787 echo "Verify SOM block count"
27788 $TRUNCATE $DIR/$tfile 0
27789 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
27790 error "failed to write file $tfile"
27791 check_lsom_data $DIR/$tfile
27793 run_test 806 "Verify Lazy Size on MDS"
27796 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
27797 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
27798 skip "Need MDS version at least 2.11.52"
27800 # Registration step
27801 changelog_register || error "changelog_register failed"
27802 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
27803 changelog_users $SINGLEMDS | grep -q $cl_user ||
27804 error "User $cl_user not found in changelog_users"
27806 rm -rf $DIR/$tdir || error "rm $tdir failed"
27807 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
27808 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
27809 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
27810 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
27811 error "truncate $tdir/trunc failed"
27814 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
27815 error "write $tfile failed"
27817 # multi-client wirtes
27818 local num=$(get_node_count ${CLIENTS//,/ })
27822 echo "Test SOM for multi-client ($num) writes"
27823 touch $DIR/$tfile || error "touch $tfile failed"
27824 $TRUNCATE $DIR/$tfile 0
27825 for client in ${CLIENTS//,/ }; do
27826 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
27829 offset=$((offset + $bs))
27831 for (( i=0; i < $num; i++ )); do
27835 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
27836 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
27837 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
27838 check_lsom_data $DIR/$tdir/trunc
27839 check_lsom_data $DIR/$tdir/single_dd
27840 check_lsom_data $DIR/$tfile
27843 # Deregistration step
27844 changelog_deregister || error "changelog_deregister failed"
27846 run_test 807 "verify LSOM syncing tool"
27848 check_som_nologged()
27850 local lines=$($LFS changelog $FSNAME-MDT0000 |
27851 grep 'x=trusted.som' | wc -l)
27852 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
27856 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
27857 skip "Need MDS version at least 2.11.55"
27859 # Registration step
27860 changelog_register || error "changelog_register failed"
27862 touch $DIR/$tfile || error "touch $tfile failed"
27865 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
27866 error "write $tfile failed"
27869 $TRUNCATE $DIR/$tfile 1234
27872 $TRUNCATE $DIR/$tfile 1048576
27875 # Deregistration step
27876 changelog_deregister || error "changelog_deregister failed"
27878 run_test 808 "Check trusted.som xattr not logged in Changelogs"
27883 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
27887 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
27888 skip "Need MDS version at least 2.11.56"
27890 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
27891 error "failed to create DoM-only file $DIR/$tfile"
27892 touch $DIR/$tfile || error "touch $tfile failed"
27893 check_som_nodata $DIR/$tfile
27895 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
27896 error "write $tfile failed"
27897 check_som_nodata $DIR/$tfile
27899 $TRUNCATE $DIR/$tfile 1234
27900 check_som_nodata $DIR/$tfile
27902 $TRUNCATE $DIR/$tfile 4097
27903 check_som_nodata $DIR/$file
27905 run_test 809 "Verify no SOM xattr store for DoM-only files"
27908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
27909 $GSS && skip_env "could not run with gss"
27910 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
27911 skip "OST < 2.12.58 doesn't align checksum"
27914 stack_trap "set_checksums $ORIG_CSUM" EXIT
27915 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
27920 for csum in $CKSUM_TYPES; do
27921 #define OBD_FAIL_OSC_NO_GRANT 0x411
27922 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
27923 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
27925 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
27926 before=$(md5sum $DIR/$tfile)
27927 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
27928 after=$(md5sum $DIR/$tfile)
27929 [ "$before" == "$after" ] ||
27930 error "$csum: $before != $after bs=$1 seek=$2"
27934 run_test 810 "partial page writes on ZFS (LU-11663)"
27937 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
27938 skip "OST < 2.12.51 doesn't support this fail_loc"
27940 $LFS setstripe -c 1 -i 0 $DIR/$tfile
27941 # ensure ost1 is connected
27942 stat $DIR/$tfile >/dev/null || error "can't stat"
27943 wait_osc_import_state client ost1 FULL
27944 # no locks, no reqs to let the connection idle
27945 cancel_lru_locks osc
27947 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
27948 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
27949 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
27950 wait_osc_import_state client ost1 CONNECTING
27951 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
27953 stat $DIR/$tfile >/dev/null || error "can't stat file"
27955 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
27957 test_812b() { # LU-12378
27958 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
27959 skip "OST < 2.12.51 doesn't support this fail_loc"
27961 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
27962 # ensure ost1 is connected
27963 stat $DIR/$tfile >/dev/null || error "can't stat"
27964 wait_osc_import_state client ost1 FULL
27965 # no locks, no reqs to let the connection idle
27966 cancel_lru_locks osc
27968 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
27969 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
27970 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
27971 wait_osc_import_state client ost1 CONNECTING
27972 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
27974 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
27975 wait_osc_import_state client ost1 IDLE
27977 run_test 812b "do not drop no resend request for idle connect"
27982 old=$($LCTL get_param -n osc.*.idle_timeout | head -n 1)
27984 $LFS setstripe -c 1 -o 0 $DIR/$tfile
27985 $LFS getstripe $DIR/$tfile
27986 $LCTL set_param osc.*.idle_timeout=10
27987 stack_trap "$LCTL set_param osc.*.idle_timeout=$old" EXIT
27988 # ensure ost1 is connected
27989 stat $DIR/$tfile >/dev/null || error "can't stat"
27990 wait_osc_import_state client ost1 FULL
27991 # no locks, no reqs to let the connection idle
27992 cancel_lru_locks osc
27994 #define OBD_FAIL_PTLRPC_IDLE_RACE 0x533
27995 $LCTL set_param fail_loc=0x80000533
27997 dd if=/dev/zero of=$DIR/$tfile count=1 conv=sync || error "dd failed"
27999 run_test 812c "idle import vs lock enqueue race"
28002 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
28003 [ -z "$file_heat_sav" ] && skip "no file heat support"
28014 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
28015 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
28017 $LCTL set_param -n llite.*.file_heat=1
28018 echo "Turn on file heat"
28019 echo "Period second: $period_second, Decay percentage: $decay_pct"
28021 echo "QQQQ" > $DIR/$tfile
28022 echo "QQQQ" > $DIR/$tfile
28023 echo "QQQQ" > $DIR/$tfile
28024 cat $DIR/$tfile > /dev/null
28025 cat $DIR/$tfile > /dev/null
28026 cat $DIR/$tfile > /dev/null
28027 cat $DIR/$tfile > /dev/null
28029 local out=$($LFS heat_get $DIR/$tfile)
28031 $LFS heat_get $DIR/$tfile
28032 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28033 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28034 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28035 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28037 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
28038 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
28039 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
28040 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
28042 sleep $((period_second + 3))
28043 echo "Sleep $((period_second + 3)) seconds..."
28044 # The recursion formula to calculate the heat of the file f is as
28046 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
28047 # Where Hi is the heat value in the period between time points i*I and
28048 # (i+1)*I; Ci is the access count in the period; the symbol P refers
28049 # to the weight of Ci.
28050 out=$($LFS heat_get $DIR/$tfile)
28051 $LFS heat_get $DIR/$tfile
28052 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28053 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28054 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28055 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28057 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
28058 error "read sample ($readsample) is wrong"
28059 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
28060 error "write sample ($writesample) is wrong"
28061 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
28062 error "read bytes ($readbyte) is wrong"
28063 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
28064 error "write bytes ($writebyte) is wrong"
28066 echo "QQQQ" > $DIR/$tfile
28067 echo "QQQQ" > $DIR/$tfile
28068 echo "QQQQ" > $DIR/$tfile
28069 cat $DIR/$tfile > /dev/null
28070 cat $DIR/$tfile > /dev/null
28071 cat $DIR/$tfile > /dev/null
28072 cat $DIR/$tfile > /dev/null
28074 sleep $((period_second + 3))
28075 echo "Sleep $((period_second + 3)) seconds..."
28077 out=$($LFS heat_get $DIR/$tfile)
28078 $LFS heat_get $DIR/$tfile
28079 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28080 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28081 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28082 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28084 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
28085 4 * $decay_pct) / 100") -eq 1 ] ||
28086 error "read sample ($readsample1) is wrong"
28087 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
28088 3 * $decay_pct) / 100") -eq 1 ] ||
28089 error "write sample ($writesample1) is wrong"
28090 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
28091 20 * $decay_pct) / 100") -eq 1 ] ||
28092 error "read bytes ($readbyte1) is wrong"
28093 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
28094 15 * $decay_pct) / 100") -eq 1 ] ||
28095 error "write bytes ($writebyte1) is wrong"
28097 echo "Turn off file heat for the file $DIR/$tfile"
28098 $LFS heat_set -o $DIR/$tfile
28100 echo "QQQQ" > $DIR/$tfile
28101 echo "QQQQ" > $DIR/$tfile
28102 echo "QQQQ" > $DIR/$tfile
28103 cat $DIR/$tfile > /dev/null
28104 cat $DIR/$tfile > /dev/null
28105 cat $DIR/$tfile > /dev/null
28106 cat $DIR/$tfile > /dev/null
28108 out=$($LFS heat_get $DIR/$tfile)
28109 $LFS heat_get $DIR/$tfile
28110 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28111 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28112 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28113 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28115 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28116 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28117 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28118 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28120 echo "Trun on file heat for the file $DIR/$tfile"
28121 $LFS heat_set -O $DIR/$tfile
28123 echo "QQQQ" > $DIR/$tfile
28124 echo "QQQQ" > $DIR/$tfile
28125 echo "QQQQ" > $DIR/$tfile
28126 cat $DIR/$tfile > /dev/null
28127 cat $DIR/$tfile > /dev/null
28128 cat $DIR/$tfile > /dev/null
28129 cat $DIR/$tfile > /dev/null
28131 out=$($LFS heat_get $DIR/$tfile)
28132 $LFS heat_get $DIR/$tfile
28133 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28134 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28135 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28136 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28138 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
28139 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
28140 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
28141 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
28143 $LFS heat_set -c $DIR/$tfile
28144 $LCTL set_param -n llite.*.file_heat=0
28145 echo "Turn off file heat support for the Lustre filesystem"
28147 echo "QQQQ" > $DIR/$tfile
28148 echo "QQQQ" > $DIR/$tfile
28149 echo "QQQQ" > $DIR/$tfile
28150 cat $DIR/$tfile > /dev/null
28151 cat $DIR/$tfile > /dev/null
28152 cat $DIR/$tfile > /dev/null
28153 cat $DIR/$tfile > /dev/null
28155 out=$($LFS heat_get $DIR/$tfile)
28156 $LFS heat_get $DIR/$tfile
28157 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
28158 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
28159 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
28160 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
28162 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
28163 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
28164 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
28165 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
28167 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
28170 run_test 813 "File heat verfication"
28174 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
28175 echo -n y >> $DIR/$tfile
28176 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
28177 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
28179 run_test 814 "sparse cp works as expected (LU-12361)"
28183 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
28184 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
28186 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
28189 local ost1_imp=$(get_osc_import_name client ost1)
28190 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
28193 $LFS setstripe -c 1 -i 0 $DIR/$tfile
28194 # ensure ost1 is connected
28196 stat $DIR/$tfile >/dev/null || error "can't stat"
28197 wait_osc_import_state client ost1 FULL
28198 # no locks, no reqs to let the connection idle
28199 cancel_lru_locks osc
28200 lru_resize_disable osc
28203 before=$($LCTL get_param -n \
28204 ldlm.namespaces.$imp_name.lru_size)
28206 wait_osc_import_state client ost1 IDLE
28207 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
28208 now=$($LCTL get_param -n \
28209 ldlm.namespaces.$imp_name.lru_size)
28210 [ $before == $now ] || error "lru_size changed $before != $now"
28212 run_test 816 "do not reset lru_resize on idle reconnect"
28216 exportfs -u localhost:$DIR/nfsexp
28221 systemctl restart nfs-server.service || skip "failed to restart nfsd"
28223 mkdir -p $DIR/nfsexp
28224 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
28225 error "failed to export nfs"
28227 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
28228 stack_trap cleanup_817 EXIT
28230 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
28231 error "failed to mount nfs to $tmpdir"
28233 cp /bin/true $tmpdir
28234 $DIR/nfsexp/true || error "failed to execute 'true' command"
28236 run_test 817 "nfsd won't cache write lock for exec file"
28239 test_mkdir -i0 -c1 $DIR/$tdir
28240 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
28241 $LFS setstripe -c1 -i1 $DIR/$tdir/$tfile
28244 # restore osp-syn threads
28245 stack_trap "fail $SINGLEMDS"
28247 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
28248 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
28249 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
28250 error "start $SINGLEMDS failed"
28253 local testid=$(echo $TESTNAME | tr '_' ' ')
28255 do_facet mds1 dmesg | tac | sed "/$testid/,$ d" |
28256 grep "run LFSCK" || error "run LFSCK is not suggested"
28258 run_test 818 "unlink with failed llog"
28261 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28262 cancel_lru_locks osc
28263 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28264 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28265 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
28268 run_test 819a "too big niobuf in read"
28271 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
28272 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
28273 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28274 cancel_lru_locks osc
28278 run_test 819b "too big niobuf in write"
28281 function test_820_start_ost() {
28284 for num in $(seq $OSTCOUNT); do
28285 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
28290 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
28293 umount_client $MOUNT || error "umount failed"
28294 for num in $(seq $OSTCOUNT); do
28298 # mount client with no active OSTs
28299 # so that the client can't initialize max LOV EA size
28300 # from OSC notifications
28301 mount_client $MOUNT || error "mount failed"
28302 # delay OST starting to keep this 0 max EA size for a while
28303 test_820_start_ost &
28305 # create a directory on MDS2
28306 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
28307 error "Failed to create directory"
28308 # open intent should update default EA size
28309 # see mdc_update_max_ea_from_body()
28310 # notice this is the very first RPC to MDS2
28311 out=$(cp /etc/services $DIR/$tdir/mds2 2>&1)
28314 # With SSK, this situation can lead to -EPERM being returned.
28315 # In that case, simply retry.
28316 if [ $ret -ne 0 ] && $SHARED_KEY; then
28317 if echo "$out" | grep -q "not permitted"; then
28318 cp /etc/services $DIR/$tdir/mds2
28322 [ $ret -eq 0 ] || error "Failed to copy files to mds$n"
28324 run_test 820 "update max EA from open intent"
28327 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28329 save_lustre_params mds1 \
28330 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
28331 do_facet $SINGLEMDS "$LCTL set_param -n \
28332 osp.$FSNAME-OST*MDT0000.max_create_count=0"
28333 do_facet $SINGLEMDS "$LCTL set_param -n \
28334 osp.$FSNAME-OST0000*MDT0000.max_create_count=20000"
28336 # wait for statfs update to clear OS_STATFS_NOPRECREATE
28337 local maxage=$(do_facet mds1 $LCTL get_param -n \
28338 osp.$FSNAME-OST0000*MDT0000.maxage)
28339 sleep $((maxage + 1))
28341 #define OBD_FAIL_NET_ERROR_RPC 0x532
28342 do_facet mds1 "$LCTL set_param fail_loc=0x80000532 fail_val=5"
28344 stack_trap "restore_lustre_params < $p; rm $p"
28346 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
28347 osp.$FSNAME-OST0000*MDT0000.create_count")
28348 for i in $(seq 1 $count); do
28349 touch $DIR/$tfile.${i} || error "touch failed"
28352 run_test 822 "test precreate failure"
28355 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28356 local OST_MAX_PRECREATE=20000
28358 (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
28359 skip "Need MDS version at least 2.14.56"
28361 save_lustre_params mds1 \
28362 "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
28363 do_facet $SINGLEMDS "$LCTL set_param -n \
28364 osp.$FSNAME-OST*MDT0000.max_create_count=0"
28365 do_facet $SINGLEMDS "$LCTL set_param -n \
28366 osp.$FSNAME-OST0000*MDT0000.max_create_count=$OST_MAX_PRECREATE"
28368 stack_trap "restore_lustre_params < $p; rm $p"
28370 do_facet $SINGLEMDS "$LCTL set_param -n \
28371 osp.$FSNAME-OST*-osc-MDT*.create_count=100200"
28373 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28374 osp.$FSNAME-OST0000*MDT0000.create_count")
28375 local max=$(do_facet $SINGLEMDS "$LCTL get_param -n \
28376 osp.$FSNAME-OST0000*MDT0000.max_create_count")
28377 local expect_count=$(((($max/2)/256) * 256))
28379 log "setting create_count to 100200:"
28380 log " -result- count: $count with max: $max, expecting: $expect_count"
28382 [[ $count -eq expect_count ]] ||
28383 error "Create count not set to max precreate."
28385 run_test 823 "Setting create_count > OST_MAX_PRECREATE is lowered to maximum"
28388 [[ $MDS1_VERSION -lt $(version_code 2.14.56) ]] &&
28389 skip "Need MDS version 2.14.56"
28391 local sync_changes=$(do_facet $SINGLEMDS \
28392 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28394 [ "$sync_changes" -gt 100 ] &&
28395 skip "Sync changes $sync_changes > 100 already"
28397 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
28399 $LFS mkdir -i 0 $DIR/$tdir
28400 $LFS setstripe -c 1 -i 0 $DIR/$tdir
28402 save_lustre_params mds1 \
28403 "osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes" > $p
28404 save_lustre_params mds1 \
28405 "osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress" >> $p
28407 do_facet mds1 "$LCTL set_param -n \
28408 osp.$FSNAME-OST*-osc-MDT0000.max_sync_changes=100 \
28409 osp.$FSNAME-OST*-osc-MDT0000.max_rpcs_in_progress=128"
28410 stack_trap "restore_lustre_params < $p" EXIT
28412 createmany -o $DIR/$tdir/f- 1000
28413 unlinkmany $DIR/$tdir/f- 1000 &
28414 local UNLINK_PID=$!
28417 sync_changes=$(do_facet mds1 \
28418 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.sync_changes)
28419 # the check in the code is racy, fail the test
28420 # if the value above the limit by 10.
28421 [ $sync_changes -gt 110 ] && {
28422 kill -2 $UNLINK_PID
28424 error "osp changes throttling failed, $sync_changes>110"
28426 kill -0 $UNLINK_PID 2> /dev/null || break
28430 run_test 831 "throttling unlink/setattr queuing on OSP"
28433 # tests that do cleanup/setup should be run at the end
28437 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28440 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
28441 $LCTL set_param fail_loc=0x903
28443 cancel_lru_locks MGC
28445 FAIL_ON_ERROR=true cleanup
28446 FAIL_ON_ERROR=true setup
28448 run_test 900 "umount should not race with any mgc requeue thread"
28450 # LUS-6253/LU-11185
28458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
28460 # some get_param have a bug to handle dot in param name
28461 cancel_lru_locks MGC
28462 old=$(mount -t lustre | wc -l)
28470 while [ $old -ne $oldc ]; do
28471 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28474 if [ $count -ge $TIMEOUT ]; then
28475 error "too large timeout"
28478 umount_client $MOUNT || error "umount failed"
28479 mount_client $MOUNT || error "mount failed"
28480 cancel_lru_locks MGC
28481 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
28483 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
28487 run_test 901 "don't leak a mgc lock on client umount"
28491 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
28492 skip "client does not have LU-13377 fix"
28493 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
28494 $LCTL set_param fail_loc=0x1415
28495 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
28496 cancel_lru_locks osc
28499 run_test 902 "test short write doesn't hang lustre"
28503 $LFS setstripe -i 0 -c 1 $DIR/$tfile $DIR/${tfile}-2
28504 echo "blah" > $DIR/${tfile}-2
28505 dd if=/dev/zero of=$DIR/$tfile bs=1M count=6 conv=fsync
28506 #define OBD_FAIL_OSC_SLOW_PAGE_EVICT 0x417
28507 $LCTL set_param fail_loc=0x417 fail_val=20
28509 mv $DIR/${tfile}-2 $DIR/$tfile # Destroys the big object
28510 sleep 1 # To start the destroy
28511 wait_destroy_complete 150 || error "Destroy taking too long"
28512 cat $DIR/$tfile > /dev/null || error "Evicted"
28514 run_test 903 "Test long page discard does not cause evictions"
28517 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
28518 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
28519 grep -q project || skip "skip project quota not supported"
28521 local testfile="$DIR/$tdir/$tfile"
28522 local xattr="trusted.projid"
28524 local mdts=$(comma_list $(mdts_nodes))
28525 local saved=$(do_facet mds1 $LCTL get_param -n \
28526 osd-ldiskfs.*MDT0000.enable_projid_xattr)
28528 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=0
28529 stack_trap "do_nodes $mdts $LCTL set_param \
28530 osd-ldiskfs.*MDT*.enable_projid_xattr=$saved"
28532 mkdir -p $DIR/$tdir
28534 #hide projid xattr on server
28535 $LFS project -p 1 $testfile ||
28536 error "set $testfile project id failed"
28537 getfattr -m - $testfile | grep $xattr &&
28538 error "do not show trusted.projid when disabled on server"
28539 do_nodes $mdts $LCTL set_param osd-ldiskfs.*MDT*.enable_projid_xattr=1
28540 #should be hidden when projid is 0
28541 $LFS project -p 0 $testfile ||
28542 error "set $testfile project id failed"
28543 getfattr -m - $testfile | grep $xattr &&
28544 error "do not show trusted.projid with project ID 0"
28546 #still can getxattr explicitly
28547 projid=$(getfattr -n $xattr $testfile |
28548 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28549 [ $projid == "0" ] ||
28550 error "projid expected 0 not $projid"
28552 #set the projid via setxattr
28553 setfattr -n $xattr -v "1000" $testfile ||
28554 error "setattr failed with $?"
28555 projid=($($LFS project $testfile))
28556 [ ${projid[0]} == "1000" ] ||
28557 error "projid expected 1000 not $projid"
28559 #check the new projid via getxattr
28560 $LFS project -p 1001 $testfile ||
28561 error "set $testfile project id failed"
28562 getfattr -m - $testfile | grep $xattr ||
28563 error "should show trusted.projid when project ID != 0"
28564 projid=$(getfattr -n $xattr $testfile |
28565 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28566 [ $projid == "1001" ] ||
28567 error "projid expected 1001 not $projid"
28569 #try to set invalid projid
28570 setfattr -n $xattr -v "4294967295" $testfile &&
28571 error "set invalid projid should fail"
28573 #remove the xattr means setting projid to 0
28574 setfattr -x $xattr $testfile ||
28575 error "setfattr failed with $?"
28576 projid=($($LFS project $testfile))
28577 [ ${projid[0]} == "0" ] ||
28578 error "projid expected 0 not $projid"
28580 #should be hidden when parent has inherit flag and same projid
28581 $LFS project -srp 1002 $DIR/$tdir ||
28582 error "set $tdir project id failed"
28583 getfattr -m - $testfile | grep $xattr &&
28584 error "do not show trusted.projid with inherit flag"
28586 #still can getxattr explicitly
28587 projid=$(getfattr -n $xattr $testfile |
28588 sed -n 's/^trusted\.projid="\(.*\)"/\1/p')
28589 [ $projid == "1002" ] ||
28590 error "projid expected 1002 not $projid"
28592 run_test 904 "virtual project ID xattr"
28596 (( $OST1_VERSION >= $(version_code 2.8.54) )) ||
28597 skip "lustre < 2.8.54 does not support ladvise"
28599 remote_ost_nodsh && skip "remote OST with nodsh"
28600 $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
28602 $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
28604 #define OBD_FAIL_OST_OPCODE 0x253
28606 do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
28607 $LFS ladvise -a willread $DIR/$tfile &&
28608 error "unexpected success of ladvise with fault injection"
28609 $LFS ladvise -a willread $DIR/$tfile |&
28610 grep -q "Operation not supported"
28611 (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
28613 run_test 905 "bad or new opcode should not stuck client"
28616 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
28617 check_and_cleanup_lustre
28618 if [ "$I_MOUNTED" != "yes" ]; then
28619 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true