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"
16 CREATETEST=${CREATETEST:-createtest}
17 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
18 OPENFILE=${OPENFILE:-openfile}
19 OPENUNLINK=${OPENUNLINK:-openunlink}
20 READS=${READS:-"reads"}
21 MUNLINK=${MUNLINK:-munlink}
22 SOCKETSERVER=${SOCKETSERVER:-socketserver}
23 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
24 MEMHOG=${MEMHOG:-memhog}
25 DIRECTIO=${DIRECTIO:-directio}
26 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
28 CHECK_GRANT=${CHECK_GRANT:-"yes"}
29 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
30 export PARALLEL=${PARALLEL:-"no"}
33 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
34 LUSTRE=${LUSTRE:-$(dirname $0)/..}
35 . $LUSTRE/tests/test-framework.sh
40 ALWAYS_EXCEPT="$SANITY_EXCEPT "
41 # bug number for skipped test: LU-9693 LU-6493 LU-9693 LU-11058
42 ALWAYS_EXCEPT+=" 42a 42b 42c 77k"
43 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
45 # skipped tests: LU-8411 LU-9096 LU-9054 ..
46 ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
49 # bug number for skipped tests: LU-9795 (all below)
50 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 17n 60a 133g 300f"
53 if [[ $(uname -m) = aarch64 ]]; then
54 # bug number: LU-11596 (all below)
55 ALWAYS_EXCEPT+=" 42d 42e 63a 63b 64a 64b 64c"
56 # bug number: LU-11671 LU-11665 LU-11594 LU-11667 LU-11729
57 ALWAYS_EXCEPT+=" 45 101c 103a 317 810"
60 # skip nfs tests on kernels >= 4.12.0 until they are fixed
61 if [ $LINUX_VERSION_CODE -ge $(version_code 4.12.0) ]; then
62 # bug number: LU-12661
66 # skip cgroup tests on RHEL8.1 kernels until they are fixed
67 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
68 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
69 # bug number: LU-13063
74 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
76 if [ "$mds1_FSTYPE" = "zfs" ]; then
77 # bug number for skipped test:
78 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
80 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
83 # Get the SLES distro version
85 # Returns a version string that should only be used in comparing
86 # strings returned by version_code()
89 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
91 # All SuSE Linux versions have one decimal. version_code expects two
92 local sles_version=$version.0
93 version_code $sles_version
96 # Check if we are running on Ubuntu or SLES so we can make decisions on
98 if [ -r /etc/SuSE-release ]; then
99 sles_version=$(sles_version_code)
100 [ $sles_version -lt $(version_code 11.4.0) ] &&
101 # bug number for skipped test: LU-4341
102 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
103 [ $sles_version -lt $(version_code 12.0.0) ] &&
104 # bug number for skipped test: LU-3703
105 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
106 elif [ -r /etc/os-release ]; then
107 if grep -qi ubuntu /etc/os-release; then
108 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
109 -e 's/^VERSION=//p' \
113 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
114 # bug number for skipped test:
116 ALWAYS_EXCEPT+=" 103a 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_and_setup_lustre
146 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
148 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
149 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
150 rm -rf $DIR/[Rdfs][0-9]*
152 # $RUNAS_ID may get set incorrectly somewhere else
153 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
154 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
156 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
158 if [ "${ONLY}" = "MOUNT" ] ; then
159 echo "Lustre is up, please go on"
163 echo "preparing for tests involving mounts"
164 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
166 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
167 echo # add a newline after mke2fs.
171 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
172 lctl set_param debug=-1 2> /dev/null || true
175 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
177 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
179 run_test 0a "touch; rm ====================="
182 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
183 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
185 run_test 0b "chmod 0755 $DIR ============================="
188 $LCTL get_param mdc.*.import | grep "state: FULL" ||
189 error "import not FULL"
190 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
193 run_test 0c "check import proc"
195 test_0d() { # LU-3397
196 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
197 skip "proc exports not supported before 2.10.57"
199 local mgs_exp="mgs.MGS.exports"
200 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
202 local exp_client_version
205 local temp_imp=$DIR/$tfile.import
206 local temp_exp=$DIR/$tfile.export
208 # save mgc import file to $temp_imp
209 $LCTL get_param mgc.*.import | tee $temp_imp
210 # Check if client uuid is found in MGS export
211 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
212 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
216 # save mgs export file to $temp_exp
217 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
219 # Compare the value of field "connect_flags"
220 imp_val=$(grep "connect_flags" $temp_imp)
221 exp_val=$(grep "connect_flags" $temp_exp)
222 [ "$exp_val" == "$imp_val" ] ||
223 error "export flags '$exp_val' != import flags '$imp_val'"
225 # Compare the value of client version
226 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
227 exp_val=$(version_code $exp_client_version)
228 imp_val=$CLIENT_VERSION
229 [ "$exp_val" == "$imp_val" ] ||
230 error "export client version '$exp_val' != '$imp_val'"
232 run_test 0d "check export proc ============================="
235 test_mkdir $DIR/$tdir
236 test_mkdir $DIR/$tdir/d2
237 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
238 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
241 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
243 run_test 1 "mkdir; remkdir; rmdir"
246 test_mkdir $DIR/$tdir
247 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
248 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
250 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
252 run_test 2 "mkdir; touch; rmdir; check file"
255 test_mkdir $DIR/$tdir
256 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
257 touch $DIR/$tdir/$tfile
258 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
260 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
262 run_test 3 "mkdir; touch; rmdir; check dir"
264 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
266 test_mkdir -i 1 $DIR/$tdir
268 touch $DIR/$tdir/$tfile ||
269 error "Create file under remote directory failed"
272 error "Expect error removing in-use dir $DIR/$tdir"
274 test -d $DIR/$tdir || error "Remote directory disappeared"
276 rm -rf $DIR/$tdir || error "remove remote dir error"
278 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
281 test_mkdir $DIR/$tdir
282 test_mkdir $DIR/$tdir/d2
283 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
284 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
285 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
287 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
290 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
291 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
292 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
293 error "$tfile does not have perm 0666 or UID $UID"
294 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
295 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
296 error "$tfile should be 0666 and owned by UID $UID"
298 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
301 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
304 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
305 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
306 error "$tfile should be owned by UID $RUNAS_ID"
307 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
308 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
309 error "$tfile should be owned by UID $RUNAS_ID"
311 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
314 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
317 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
318 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
319 error "$tfile should be owned by GID $UID"
320 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
321 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
322 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
324 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
327 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
329 test_mkdir $DIR/$tdir
330 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
331 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
332 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
333 test_mkdir $DIR/$tdir/d/subdir
334 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
335 error "$tdir/d/subdir should be GID $RUNAS_GID"
336 if [[ $MDSCOUNT -gt 1 ]]; then
337 # check remote dir sgid inherite
338 $LFS mkdir -i 0 $DIR/$tdir.local ||
339 error "mkdir $tdir.local failed"
340 chmod g+s $DIR/$tdir.local ||
341 error "chmod $tdir.local failed"
342 chgrp $RUNAS_GID $DIR/$tdir.local ||
343 error "chgrp $tdir.local failed"
344 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
345 error "mkdir $tdir.remote failed"
346 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
347 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
348 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
349 error "$tdir.remote should be mode 02755"
352 run_test 6g "verify new dir in sgid dir inherits group"
354 test_6h() { # bug 7331
355 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
357 touch $DIR/$tfile || error "touch failed"
358 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
359 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
360 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
361 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
362 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
364 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
367 test_mkdir $DIR/$tdir
368 $MCREATE $DIR/$tdir/$tfile
369 chmod 0666 $DIR/$tdir/$tfile
370 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
371 error "$tdir/$tfile should be mode 0666"
373 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
376 if [ ! -d $DIR/$tdir ]; then
377 test_mkdir $DIR/$tdir
379 $MCREATE $DIR/$tdir/$tfile
380 echo -n foo > $DIR/$tdir/$tfile
381 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
382 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
384 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
387 test_mkdir $DIR/$tdir
388 touch $DIR/$tdir/$tfile
389 chmod 0666 $DIR/$tdir/$tfile
390 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
391 error "$tfile mode not 0666"
393 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
396 test_mkdir $DIR/$tdir
397 test_mkdir $DIR/$tdir/d2
398 test_mkdir $DIR/$tdir/d2/d3
399 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
401 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
404 test_mkdir $DIR/$tdir
405 test_mkdir $DIR/$tdir/d2
406 touch $DIR/$tdir/d2/$tfile
407 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
408 error "$tdir/d2/$tfile not a file"
410 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
413 test_mkdir $DIR/$tdir
414 test_mkdir $DIR/$tdir/d2
415 chmod 0666 $DIR/$tdir/d2
416 chmod 0705 $DIR/$tdir/d2
417 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
418 error "$tdir/d2 mode not 0705"
420 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
423 test_mkdir $DIR/$tdir
424 touch $DIR/$tdir/$tfile
425 chmod 0666 $DIR/$tdir/$tfile
426 chmod 0654 $DIR/$tdir/$tfile
427 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
428 error "$tdir/d2 mode not 0654"
430 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
433 test_mkdir $DIR/$tdir
434 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
436 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
437 error "$tdir/$tfile size not 0 after truncate"
439 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
442 test_mkdir $DIR/$tdir
443 touch $DIR/$tdir/$tfile
445 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
447 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
450 test_mkdir $DIR/$tdir
451 touch $DIR/$tdir/$tfile
452 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
453 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
454 error "$tdir/${tfile_2} not a file after rename"
455 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
457 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
460 test_mkdir $DIR/$tdir
461 touch $DIR/$tdir/$tfile
462 rm -rf $DIR/$tdir/$tfile
463 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
465 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
468 test_mkdir $DIR/$tdir
469 touch $DIR/$tdir/$tfile
470 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
472 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
473 error "$tdir/l-exist not a symlink"
474 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
475 error "$tdir/l-exist not referencing a file"
476 rm -f $DIR/$tdir/l-exist
477 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
479 run_test 17a "symlinks: create, remove (real)"
482 test_mkdir $DIR/$tdir
483 ln -s no-such-file $DIR/$tdir/l-dangle
485 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
486 error "$tdir/l-dangle not referencing no-such-file"
487 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
488 error "$tdir/l-dangle not referencing non-existent file"
489 rm -f $DIR/$tdir/l-dangle
490 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
492 run_test 17b "symlinks: create, remove (dangling)"
494 test_17c() { # bug 3440 - don't save failed open RPC for replay
495 test_mkdir $DIR/$tdir
496 ln -s foo $DIR/$tdir/$tfile
497 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
499 run_test 17c "symlinks: open dangling (should return error)"
502 test_mkdir $DIR/$tdir
503 ln -s foo $DIR/$tdir/$tfile
504 touch $DIR/$tdir/$tfile || error "creating to new symlink"
506 run_test 17d "symlinks: create dangling"
509 test_mkdir $DIR/$tdir
510 local foo=$DIR/$tdir/$tfile
511 ln -s $foo $foo || error "create symlink failed"
512 ls -l $foo || error "ls -l failed"
513 ls $foo && error "ls not failed" || true
515 run_test 17e "symlinks: create recursive symlink (should return error)"
518 test_mkdir $DIR/$tdir
519 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
520 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
521 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
522 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
523 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
524 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
527 run_test 17f "symlinks: long and very long symlink name"
529 # str_repeat(S, N) generate a string that is string S repeated N times
534 while [ $((n -= 1)) -ge 0 ]; do
540 # Long symlinks and LU-2241
542 test_mkdir $DIR/$tdir
543 local TESTS="59 60 61 4094 4095"
545 # Fix for inode size boundary in 2.1.4
546 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
549 # Patch not applied to 2.2 or 2.3 branches
550 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
551 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
554 # skip long symlink name for rhel6.5.
555 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
556 grep -q '6.5' /etc/redhat-release &>/dev/null &&
557 TESTS="59 60 61 4062 4063"
560 local SYMNAME=$(str_repeat 'x' $i)
561 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
562 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
565 run_test 17g "symlinks: really long symlink name and inode boundaries"
567 test_17h() { #bug 17378
568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
569 remote_mds_nodsh && skip "remote MDS with nodsh"
573 test_mkdir $DIR/$tdir
574 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
575 $LFS setstripe -c -1 $DIR/$tdir
576 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
577 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
578 touch $DIR/$tdir/$tfile || true
580 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
582 test_17i() { #bug 20018
583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
584 remote_mds_nodsh && skip "remote MDS with nodsh"
586 local foo=$DIR/$tdir/$tfile
589 test_mkdir -c1 $DIR/$tdir
590 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
591 ln -s $foo $foo || error "create symlink failed"
592 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
593 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
594 ls -l $foo && error "error not detected"
597 run_test 17i "don't panic on short symlink (should return error)"
599 test_17k() { #bug 22301
600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
601 [[ -z "$(which rsync 2>/dev/null)" ]] &&
602 skip "no rsync command"
603 rsync --help | grep -q xattr ||
604 skip_env "$(rsync --version | head -n1) does not support xattrs"
605 test_mkdir $DIR/$tdir
606 test_mkdir $DIR/$tdir.new
607 touch $DIR/$tdir/$tfile
608 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
609 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
610 error "rsync failed with xattrs enabled"
612 run_test 17k "symlinks: rsync with xattrs enabled"
614 test_17l() { # LU-279
615 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
616 skip "no getfattr command"
618 test_mkdir $DIR/$tdir
619 touch $DIR/$tdir/$tfile
620 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
621 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
622 # -h to not follow symlinks. -m '' to list all the xattrs.
623 # grep to remove first line: '# file: $path'.
624 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
626 lgetxattr_size_check $path $xattr ||
627 error "lgetxattr_size_check $path $xattr failed"
631 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
636 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
637 remote_mds_nodsh && skip "remote MDS with nodsh"
638 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
639 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
640 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
642 local short_sym="0123456789"
643 local wdir=$DIR/$tdir
648 # create a long symlink file
649 for ((i = 0; i < 4; ++i)); do
650 long_sym=${long_sym}${long_sym}
653 echo "create 512 short and long symlink files under $wdir"
654 for ((i = 0; i < 256; ++i)); do
655 ln -sf ${long_sym}"a5a5" $wdir/long-$i
656 ln -sf ${short_sym}"a5a5" $wdir/short-$i
662 wait_delete_completed
664 echo "recreate the 512 symlink files with a shorter string"
665 for ((i = 0; i < 512; ++i)); do
666 # rewrite the symlink file with a shorter string
667 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
668 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
671 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
672 local devname=$(mdsdevname $mds_index)
674 echo "stop and checking mds${mds_index}:"
675 # e2fsck should not return error
677 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
680 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
681 error "start mds${mds_index} failed"
682 df $MOUNT > /dev/null 2>&1
684 error "e2fsck detected error for short/long symlink: rc=$rc"
687 run_test 17m "run e2fsck against MDT which contains short/long symlink"
689 check_fs_consistency_17n() {
693 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
694 # so it only check MDT1/MDT2 instead of all of MDTs.
695 for mdt_index in 1 2; do
696 local devname=$(mdsdevname $mdt_index)
697 # e2fsck should not return error
699 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
702 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
703 error "mount mds$mdt_index failed"
704 df $MOUNT > /dev/null 2>&1
710 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
712 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
713 remote_mds_nodsh && skip "remote MDS with nodsh"
714 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
715 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
716 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
720 test_mkdir $DIR/$tdir
721 for ((i=0; i<10; i++)); do
722 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
723 error "create remote dir error $i"
724 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
725 error "create files under remote dir failed $i"
728 check_fs_consistency_17n ||
729 error "e2fsck report error after create files under remote dir"
731 for ((i = 0; i < 10; i++)); do
732 rm -rf $DIR/$tdir/remote_dir_${i} ||
733 error "destroy remote dir error $i"
736 check_fs_consistency_17n ||
737 error "e2fsck report error after unlink files under remote dir"
739 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
740 skip "lustre < 2.4.50 does not support migrate mv"
742 for ((i = 0; i < 10; i++)); do
743 mkdir -p $DIR/$tdir/remote_dir_${i}
744 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
745 error "create files under remote dir failed $i"
746 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
747 error "migrate remote dir error $i"
749 check_fs_consistency_17n || error "e2fsck report error after migration"
751 for ((i = 0; i < 10; i++)); do
752 rm -rf $DIR/$tdir/remote_dir_${i} ||
753 error "destroy remote dir error $i"
756 check_fs_consistency_17n || error "e2fsck report error after unlink"
758 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
761 remote_mds_nodsh && skip "remote MDS with nodsh"
762 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
763 skip "Need MDS version at least 2.3.64"
765 local wdir=$DIR/${tdir}o
771 mdt_index=$($LFS getstripe -m $wdir/$tfile)
772 mdt_index=$((mdt_index + 1))
775 #fail mds will wait the failover finish then set
776 #following fail_loc to avoid interfer the recovery process.
779 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
780 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
781 ls -l $wdir/$tfile && rc=1
782 do_facet mds${mdt_index} lctl set_param fail_loc=0
783 [[ $rc -eq 0 ]] || error "stat file should fail"
785 run_test 17o "stat file with incompat LMA feature"
788 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
789 ls $DIR || error "Failed to ls $DIR: $?"
791 run_test 18 "touch .../f ; ls ... =============================="
797 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
799 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
802 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
804 run_test 19b "ls -l .../f19 (should return error) =============="
807 [ $RUNAS_ID -eq $UID ] &&
808 skip_env "RUNAS_ID = UID = $UID -- skipping"
810 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
812 run_test 19c "$RUNAS touch .../f19 (should return error) =="
815 cat $DIR/f19 && error || true
817 run_test 19d "cat .../f19 (should return error) =============="
826 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
828 run_test 20 "touch .../f ; ls -l ..."
831 test_mkdir $DIR/$tdir
832 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
833 ln -s dangle $DIR/$tdir/link
834 echo foo >> $DIR/$tdir/link
835 cat $DIR/$tdir/dangle
836 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
837 $CHECKSTAT -f -t file $DIR/$tdir/link ||
838 error "$tdir/link not linked to a file"
840 run_test 21 "write to dangling link"
843 local wdir=$DIR/$tdir
845 chown $RUNAS_ID:$RUNAS_GID $wdir
846 (cd $wdir || error "cd $wdir failed";
847 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
849 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
850 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
851 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
852 error "checkstat -u failed"
854 run_test 22 "unpack tar archive as non-root user"
858 test_mkdir $DIR/$tdir
859 local file=$DIR/$tdir/$tfile
861 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
862 openfile -f O_CREAT:O_EXCL $file &&
863 error "$file recreate succeeded" || true
865 run_test 23a "O_CREAT|O_EXCL in subdir"
867 test_23b() { # bug 18988
868 test_mkdir $DIR/$tdir
869 local file=$DIR/$tdir/$tfile
872 echo foo > $file || error "write filed"
873 echo bar >> $file || error "append filed"
874 $CHECKSTAT -s 8 $file || error "wrong size"
877 run_test 23b "O_APPEND check"
879 # LU-9409, size with O_APPEND and tiny writes
881 local file=$DIR/$tfile
884 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
885 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
889 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
890 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
895 #racing tiny & normal writes
896 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
899 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
902 #racing tiny & normal writes 2, ugly numbers
903 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
904 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
906 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
909 run_test 23c "O_APPEND size checks for tiny writes"
911 # LU-11069 file offset is correct after appending writes
913 local file=$DIR/$tfile
916 echo CentaurHauls > $file
917 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
918 if ((offset != 26)); then
919 error "wrong offset, expected 26, got '$offset'"
922 run_test 23d "file offset is correct after appending writes"
926 echo '-- same directory rename'
927 test_mkdir $DIR/$tdir
928 touch $DIR/$tdir/$tfile.1
929 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
930 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
932 run_test 24a "rename file to non-existent target"
935 test_mkdir $DIR/$tdir
936 touch $DIR/$tdir/$tfile.{1,2}
937 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
938 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
939 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
941 run_test 24b "rename file to existing target"
944 test_mkdir $DIR/$tdir
945 test_mkdir $DIR/$tdir/d$testnum.1
946 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
947 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
948 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
950 run_test 24c "rename directory to non-existent target"
953 test_mkdir -c1 $DIR/$tdir
954 test_mkdir -c1 $DIR/$tdir/d$testnum.1
955 test_mkdir -c1 $DIR/$tdir/d$testnum.2
956 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
957 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
958 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
960 run_test 24d "rename directory to existing target"
963 echo '-- cross directory renames --'
967 mv $DIR/R5a/f $DIR/R5b/g
968 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
969 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
971 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
976 touch $DIR/R6a/f $DIR/R6b/g
977 mv $DIR/R6a/f $DIR/R6b/g
978 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
979 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
981 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
986 test_mkdir $DIR/R7a/d
987 mv $DIR/R7a/d $DIR/R7b/e
988 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
989 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
991 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
994 test_mkdir -c1 $DIR/R8a
995 test_mkdir -c1 $DIR/R8b
996 test_mkdir -c1 $DIR/R8a/d
997 test_mkdir -c1 $DIR/R8b/e
998 mrename $DIR/R8a/d $DIR/R8b/e
999 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1000 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1002 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1005 echo "-- rename error cases"
1007 test_mkdir $DIR/R9/a
1009 mrename $DIR/R9/f $DIR/R9/a
1010 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1011 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1012 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1014 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1018 mrename $DIR/R10/f $DIR/R10/g
1019 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1020 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1021 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1023 run_test 24j "source does not exist ============================"
1026 test_mkdir $DIR/R11a
1027 test_mkdir $DIR/R11a/d
1029 mv $DIR/R11a/f $DIR/R11a/d
1030 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1031 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1033 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1035 # bug 2429 - rename foo foo foo creates invalid file
1038 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1040 run_test 24l "Renaming a file to itself ========================"
1044 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1045 # on ext3 this does not remove either the source or target files
1046 # though the "expected" operation would be to remove the source
1047 $CHECKSTAT -t file ${f} || error "${f} missing"
1048 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1050 run_test 24m "Renaming a file to a hard link to itself ========="
1054 # this stats the old file after it was renamed, so it should fail
1056 $CHECKSTAT ${f} || error "${f} missing"
1058 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1059 $CHECKSTAT -a ${f} || error "${f} exists"
1061 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1064 test_mkdir $DIR/$tdir
1065 rename_many -s random -v -n 10 $DIR/$tdir
1067 run_test 24o "rename of files during htree split"
1070 test_mkdir $DIR/R12a
1071 test_mkdir $DIR/R12b
1072 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1073 mrename $DIR/R12a $DIR/R12b
1074 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1075 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1076 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1077 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1079 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1081 cleanup_multiop_pause() {
1083 kill -USR1 $MULTIPID
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1089 test_mkdir $DIR/R13a
1090 test_mkdir $DIR/R13b
1091 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1092 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1095 trap cleanup_multiop_pause EXIT
1096 mrename $DIR/R13a $DIR/R13b
1097 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1098 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1099 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1100 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1101 cleanup_multiop_pause
1102 wait $MULTIPID || error "multiop close failed"
1104 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1106 test_24r() { #bug 3789
1107 test_mkdir $DIR/R14a
1108 test_mkdir $DIR/R14a/b
1109 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1110 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1111 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1113 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1116 test_mkdir $DIR/R15a
1117 test_mkdir $DIR/R15a/b
1118 test_mkdir $DIR/R15a/b/c
1119 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1120 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1121 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1123 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1125 test_mkdir $DIR/R16a
1126 test_mkdir $DIR/R16a/b
1127 test_mkdir $DIR/R16a/b/c
1128 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1129 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1130 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1132 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1134 test_24u() { # bug12192
1135 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1136 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1138 run_test 24u "create stripe file"
1140 simple_cleanup_common() {
1143 [ -z "$DIR" -o -z "$tdir" ] && return 0
1145 local start=$SECONDS
1148 wait_delete_completed
1149 echo "cleanup time $((SECONDS - start))"
1153 max_pages_per_rpc() {
1154 local mdtname="$(printf "MDT%04x" ${1:-0})"
1155 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1161 local nrfiles=${COUNT:-100000}
1162 local fname="$DIR/$tdir/$tfile"
1164 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1165 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1167 test_mkdir "$(dirname $fname)"
1168 # assume MDT0000 has the fewest inodes
1169 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1170 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1171 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1173 trap simple_cleanup_common EXIT
1175 createmany -m "$fname" $nrfiles
1177 cancel_lru_locks mdc
1178 lctl set_param mdc.*.stats clear
1180 # was previously test_24D: LU-6101
1181 # readdir() returns correct number of entries after cursor reload
1182 local num_ls=$(ls $DIR/$tdir | wc -l)
1183 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1184 local num_all=$(ls -a $DIR/$tdir | wc -l)
1185 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1186 $num_all -ne $((nrfiles + 2)) ]; then
1187 error "Expected $nrfiles files, got $num_ls " \
1188 "($num_uniq unique $num_all .&..)"
1190 # LU-5 large readdir
1191 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1192 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1193 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1194 # take into account of overhead in lu_dirpage header and end mark in
1195 # each page, plus one in rpc_num calculation.
1196 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1197 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1198 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1199 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1200 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1201 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1202 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1203 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1204 error "large readdir doesn't take effect: " \
1205 "$mds_readpage should be about $rpc_max"
1207 simple_cleanup_common
1209 run_test 24v "list large directory (test hash collision, b=17560)"
1211 test_24w() { # bug21506
1213 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1214 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1215 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1216 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1217 [[ "$SZ1" -eq "$SZ2" ]] ||
1218 error "Error reading at the end of the file $tfile"
1220 run_test 24w "Reading a file larger than 4Gb"
1223 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1225 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1226 skip "Need MDS version at least 2.7.56"
1229 local remote_dir=$DIR/$tdir/remote_dir
1231 test_mkdir $DIR/$tdir
1232 $LFS mkdir -i $MDTIDX $remote_dir ||
1233 error "create remote directory failed"
1235 test_mkdir $DIR/$tdir/src_dir
1236 touch $DIR/$tdir/src_file
1237 test_mkdir $remote_dir/tgt_dir
1238 touch $remote_dir/tgt_file
1240 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1241 error "rename dir cross MDT failed!"
1243 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1244 error "rename file cross MDT failed!"
1246 touch $DIR/$tdir/ln_file
1247 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1248 error "ln file cross MDT failed"
1250 rm -rf $DIR/$tdir || error "Can not delete directories"
1252 run_test 24x "cross MDT rename/link"
1255 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1258 local remote_dir=$DIR/$tdir/remote_dir
1261 test_mkdir $DIR/$tdir
1262 $LFS mkdir -i $mdtidx $remote_dir ||
1263 error "create remote directory failed"
1265 test_mkdir $remote_dir/src_dir
1266 touch $remote_dir/src_file
1267 test_mkdir $remote_dir/tgt_dir
1268 touch $remote_dir/tgt_file
1270 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1271 error "rename subdir in the same remote dir failed!"
1273 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1274 error "rename files in the same remote dir failed!"
1276 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1277 error "link files in the same remote dir failed!"
1279 rm -rf $DIR/$tdir || error "Can not delete directories"
1281 run_test 24y "rename/link on the same dir should succeed"
1284 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1285 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1286 skip "Need MDS version at least 2.12.51"
1290 for index in 0 1; do
1291 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1292 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1295 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1297 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1298 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1300 local mdts=$(comma_list $(mdts_nodes))
1302 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1303 stack_trap "do_nodes $mdts $LCTL \
1304 set_param mdt.*.enable_remote_rename=1" EXIT
1306 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1308 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1309 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1311 run_test 24z "cross-MDT rename is done as cp"
1313 test_24A() { # LU-3182
1317 test_mkdir $DIR/$tdir
1318 trap simple_cleanup_common EXIT
1319 createmany -m $DIR/$tdir/$tfile $NFILES
1320 local t=$(ls $DIR/$tdir | wc -l)
1321 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1322 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1323 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1324 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1327 simple_cleanup_common || error "Can not delete directories"
1329 run_test 24A "readdir() returns correct number of entries."
1331 test_24B() { # LU-4805
1332 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1336 test_mkdir $DIR/$tdir
1337 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1338 error "create striped dir failed"
1340 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1341 [ $count -eq 2 ] || error "Expected 2, got $count"
1343 touch $DIR/$tdir/striped_dir/a
1345 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1346 [ $count -eq 3 ] || error "Expected 3, got $count"
1348 touch $DIR/$tdir/striped_dir/.f
1350 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1351 [ $count -eq 4 ] || error "Expected 4, got $count"
1353 rm -rf $DIR/$tdir || error "Can not delete directories"
1355 run_test 24B "readdir for striped dir return correct number of entries"
1358 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1364 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1365 error "create striped dir failed"
1367 cd $DIR/$tdir/d0/striped_dir
1369 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1370 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1371 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1373 [ "$d0_ino" = "$parent_ino" ] ||
1374 error ".. wrong, expect $d0_ino, get $parent_ino"
1376 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1377 error "mv striped dir failed"
1379 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1381 [ "$d1_ino" = "$parent_ino" ] ||
1382 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1384 run_test 24C "check .. in striped dir"
1387 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1388 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1391 mkdir $DIR/$tdir/src_dir
1392 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1393 error "create remote source failed"
1395 touch $DIR/$tdir/src_dir/src_child/a
1397 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1398 error "create remote target dir failed"
1400 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1401 error "create remote target child failed"
1403 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1404 error "rename dir cross MDT failed!"
1408 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1409 error "src_child still exists after rename"
1411 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1412 error "missing file(a) after rename"
1414 rm -rf $DIR/$tdir || error "Can not delete directories"
1416 run_test 24E "cross MDT rename/link"
1419 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1422 [ "$SLOW" = "no" ] && repeats=100
1426 echo "$repeats repeats"
1427 for ((i = 0; i < repeats; i++)); do
1428 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1429 touch $DIR/$tdir/test/a || error "touch fails"
1430 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1431 rm -rf $DIR/$tdir/test || error "rmdir fails"
1436 run_test 24F "hash order vs readdir (LU-11330)"
1439 echo '== symlink sanity ============================================='
1443 touch $DIR/s25/foo ||
1444 error "File creation in symlinked directory failed"
1446 run_test 25a "create file in symlinked directory ==============="
1449 [ ! -d $DIR/d25 ] && test_25a
1450 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1452 run_test 25b "lookup file in symlinked directory ==============="
1456 test_mkdir $DIR/d26/d26-2
1457 ln -s d26/d26-2 $DIR/s26
1458 touch $DIR/s26/foo || error "File creation failed"
1460 run_test 26a "multiple component symlink ======================="
1463 test_mkdir -p $DIR/$tdir/d26-2
1464 ln -s $tdir/d26-2/foo $DIR/s26-2
1465 touch $DIR/s26-2 || error "File creation failed"
1467 run_test 26b "multiple component symlink at end of lookup ======"
1470 test_mkdir $DIR/d26.2
1471 touch $DIR/d26.2/foo
1472 ln -s d26.2 $DIR/s26.2-1
1473 ln -s s26.2-1 $DIR/s26.2-2
1474 ln -s s26.2-2 $DIR/s26.2-3
1475 chmod 0666 $DIR/s26.2-3/foo
1477 run_test 26c "chain of symlinks"
1479 # recursive symlinks (bug 439)
1481 ln -s d26-3/foo $DIR/d26-3
1483 run_test 26d "create multiple component recursive symlink"
1486 [ ! -h $DIR/d26-3 ] && test_26d
1489 run_test 26e "unlink multiple component recursive symlink"
1491 # recursive symlinks (bug 7022)
1493 test_mkdir $DIR/$tdir
1494 test_mkdir $DIR/$tdir/$tfile
1495 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1496 test_mkdir -p lndir/bar1
1497 test_mkdir $DIR/$tdir/$tfile/$tfile
1498 cd $tfile || error "cd $tfile failed"
1499 ln -s .. dotdot || error "ln dotdot failed"
1500 ln -s dotdot/lndir lndir || error "ln lndir failed"
1501 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1502 output=`ls $tfile/$tfile/lndir/bar1`
1503 [ "$output" = bar1 ] && error "unexpected output"
1504 rm -r $tfile || error "rm $tfile failed"
1505 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1507 run_test 26f "rm -r of a directory which has recursive symlink"
1510 test_mkdir $DIR/$tdir
1511 $LFS getstripe $DIR/$tdir
1512 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1513 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1514 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1516 run_test 27a "one stripe file"
1519 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1521 test_mkdir $DIR/$tdir
1522 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1523 $LFS getstripe -c $DIR/$tdir/$tfile
1524 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1525 error "two-stripe file doesn't have two stripes"
1527 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1529 run_test 27b "create and write to two stripe file"
1532 test_mkdir $DIR/$tdir
1533 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1534 error "setstripe failed"
1535 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1536 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1538 run_test 27d "create file with default settings"
1541 # LU-5839 adds check for existed layout before setting it
1542 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1543 skip "Need MDS version at least 2.7.56"
1545 test_mkdir $DIR/$tdir
1546 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1547 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1548 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1550 run_test 27e "setstripe existing file (should return error)"
1553 test_mkdir $DIR/$tdir
1554 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1555 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1556 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1557 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1558 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1559 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1561 run_test 27f "setstripe with bad stripe size (should return error)"
1564 test_mkdir $DIR/$tdir
1565 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1566 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1567 error "$DIR/$tdir/$tfile has object"
1569 run_test 27g "$LFS getstripe with no objects"
1572 test_mkdir $DIR/$tdir
1573 touch $DIR/$tdir/$tfile || error "touch failed"
1574 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1575 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1577 (( rc == 2 )) || error "getstripe did not return ENOENT"
1579 run_test 27ga "$LFS getstripe with missing file (should return error)"
1582 test_mkdir $DIR/$tdir
1583 touch $DIR/$tdir/$tfile || error "touch failed"
1584 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1585 error "missing objects"
1587 run_test 27i "$LFS getstripe with some objects"
1590 test_mkdir $DIR/$tdir
1591 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1592 error "setstripe failed" || true
1594 run_test 27j "setstripe with bad stripe offset (should return error)"
1596 test_27k() { # bug 2844
1597 test_mkdir $DIR/$tdir
1598 local file=$DIR/$tdir/$tfile
1599 local ll_max_blksize=$((4 * 1024 * 1024))
1600 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1601 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1602 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1603 dd if=/dev/zero of=$file bs=4k count=1
1604 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1605 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1607 run_test 27k "limit i_blksize for broken user apps"
1610 mcreate $DIR/$tfile || error "creating file"
1611 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1612 error "setstripe should have failed" || true
1614 run_test 27l "check setstripe permissions (should return error)"
1617 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1619 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1621 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1622 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1624 trap simple_cleanup_common EXIT
1625 test_mkdir $DIR/$tdir
1626 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1627 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1628 error "dd should fill OST0"
1630 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1632 [ $i -gt 256 ] && break
1635 touch $DIR/$tdir/$tfile.$i
1636 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1637 awk '{print $1}'| grep -w "0") ] &&
1638 error "OST0 was full but new created file still use it"
1640 touch $DIR/$tdir/$tfile.$i
1641 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1642 awk '{print $1}'| grep -w "0") ] &&
1643 error "OST0 was full but new created file still use it"
1644 simple_cleanup_common
1646 run_test 27m "create file while OST0 was full"
1649 local delay=$(do_facet $SINGLEMDS lctl get_param -n lo[vd].*.qos_maxage |
1650 awk '{ print $1 * 2; exit; }')
1654 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1655 # if the OST isn't full anymore.
1657 local OSTIDX=${1:-""}
1659 local list=$(comma_list $(osts_nodes))
1660 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1662 do_nodes $list lctl set_param fail_loc=0
1663 sync # initiate all OST_DESTROYs from MDS to OST
1667 exhaust_precreations() {
1670 local FAILIDX=${3:-$OSTIDX}
1671 local ofacet=ost$((OSTIDX + 1))
1673 test_mkdir -p -c1 $DIR/$tdir
1674 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1675 local mfacet=mds$((mdtidx + 1))
1676 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1678 local OST=$(ostname_from_index $OSTIDX)
1681 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1682 local last_id=$(do_facet $mfacet lctl get_param -n \
1683 osp.$mdtosc_proc1.prealloc_last_id)
1684 local next_id=$(do_facet $mfacet lctl get_param -n \
1685 osp.$mdtosc_proc1.prealloc_next_id)
1687 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1688 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1690 test_mkdir -p $DIR/$tdir/${OST}
1691 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1692 #define OBD_FAIL_OST_ENOSPC 0x215
1693 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1694 echo "Creating to objid $last_id on ost $OST..."
1695 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1696 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1697 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1701 exhaust_all_precreations() {
1703 for (( i=0; i < OSTCOUNT; i++ )) ; do
1704 exhaust_precreations $i $1 -1
1709 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1710 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1711 remote_mds_nodsh && skip "remote MDS with nodsh"
1712 remote_ost_nodsh && skip "remote OST with nodsh"
1715 rm -f $DIR/$tdir/$tfile
1716 exhaust_precreations 0 0x80000215
1717 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1718 touch $DIR/$tdir/$tfile || error "touch failed"
1719 $LFS getstripe $DIR/$tdir/$tfile
1722 run_test 27n "create file with some full OSTs"
1725 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1727 remote_mds_nodsh && skip "remote MDS with nodsh"
1728 remote_ost_nodsh && skip "remote OST with nodsh"
1731 rm -f $DIR/$tdir/$tfile
1732 exhaust_all_precreations 0x215
1734 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1739 run_test 27o "create file with all full OSTs (should error)"
1741 function create_and_checktime() {
1746 for ((i=0; i < $loops; i++)); do
1747 local start=$SECONDS
1748 multiop $fname-$i Oc
1749 ((SECONDS-start < TIMEOUT)) ||
1750 error "creation took " $((SECONDS-$start)) && return 1
1755 local mdts=$(comma_list $(mdts_nodes))
1757 [ $MDS1_VERSION -lt $(version_code 2.12.6) ] &&
1758 skip "Need MDS version at least 2.12.6"
1760 local f0=$DIR/${tfile}-0
1761 local f1=$DIR/${tfile}-1
1763 wait_delete_completed
1765 # refill precreated objects
1766 $LFS setstripe -i0 -c1 $f0
1768 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1769 # force QoS allocation policy
1770 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1771 stack_trap "do_nodes $mdts $LCTL set_param \
1772 lov.*.qos_threshold_rr=$saved" EXIT
1775 # one OST is unavailable, but still have few objects preallocated
1777 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1778 rm -rf $f1 $DIR/$tdir*" EXIT
1780 for ((i=0; i < 7; i++)); do
1781 mkdir $DIR/$tdir$i || error "can't create dir"
1782 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1783 error "can't set striping"
1785 for ((i=0; i < 7; i++)); do
1786 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1790 run_test 27oo "don't let few threads to reserve too many objects"
1793 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1795 remote_mds_nodsh && skip "remote MDS with nodsh"
1796 remote_ost_nodsh && skip "remote OST with nodsh"
1799 rm -f $DIR/$tdir/$tfile
1800 test_mkdir $DIR/$tdir
1802 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1803 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1804 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1806 exhaust_precreations 0 0x80000215
1807 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1808 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1809 $LFS getstripe $DIR/$tdir/$tfile
1813 run_test 27p "append to a truncated file with some full OSTs"
1816 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1817 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1818 remote_mds_nodsh && skip "remote MDS with nodsh"
1819 remote_ost_nodsh && skip "remote OST with nodsh"
1822 rm -f $DIR/$tdir/$tfile
1824 test_mkdir $DIR/$tdir
1825 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1826 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1827 error "truncate $DIR/$tdir/$tfile failed"
1828 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1830 exhaust_all_precreations 0x215
1832 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1833 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1837 run_test 27q "append to truncated file with all OSTs full (should error)"
1840 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1842 remote_mds_nodsh && skip "remote MDS with nodsh"
1843 remote_ost_nodsh && skip "remote OST with nodsh"
1846 rm -f $DIR/$tdir/$tfile
1847 exhaust_precreations 0 0x80000215
1849 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1853 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1855 test_27s() { # bug 10725
1856 test_mkdir $DIR/$tdir
1857 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1858 local stripe_count=0
1859 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1860 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1861 error "stripe width >= 2^32 succeeded" || true
1864 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1866 test_27t() { # bug 10864
1871 $WLFS getstripe $tfile
1874 run_test 27t "check that utils parse path correctly"
1876 test_27u() { # bug 4900
1877 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1878 remote_mds_nodsh && skip "remote MDS with nodsh"
1881 local list=$(comma_list $(mdts_nodes))
1883 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1884 do_nodes $list $LCTL set_param fail_loc=0x139
1885 test_mkdir -p $DIR/$tdir
1886 trap simple_cleanup_common EXIT
1887 createmany -o $DIR/$tdir/t- 1000
1888 do_nodes $list $LCTL set_param fail_loc=0
1890 TLOG=$TMP/$tfile.getstripe
1891 $LFS getstripe $DIR/$tdir > $TLOG
1892 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1893 unlinkmany $DIR/$tdir/t- 1000
1895 [[ $OBJS -gt 0 ]] &&
1896 error "$OBJS objects created on OST-0. See $TLOG" ||
1899 run_test 27u "skip object creation on OSC w/o objects"
1901 test_27v() { # bug 4900
1902 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1904 remote_mds_nodsh && skip "remote MDS with nodsh"
1905 remote_ost_nodsh && skip "remote OST with nodsh"
1907 exhaust_all_precreations 0x215
1910 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1912 touch $DIR/$tdir/$tfile
1913 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1915 for (( i=1; i < OSTCOUNT; i++ )); do
1916 do_facet ost$i lctl set_param fail_loc=0x705
1918 local START=`date +%s`
1919 createmany -o $DIR/$tdir/$tfile 32
1921 local FINISH=`date +%s`
1922 local TIMEOUT=`lctl get_param -n timeout`
1923 local PROCESS=$((FINISH - START))
1924 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1925 error "$FINISH - $START >= $TIMEOUT / 2"
1926 sleep $((TIMEOUT / 2 - PROCESS))
1929 run_test 27v "skip object creation on slow OST"
1931 test_27w() { # bug 10997
1932 test_mkdir $DIR/$tdir
1933 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1934 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1935 error "stripe size $size != 65536" || true
1936 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1937 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1939 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1942 [[ $OSTCOUNT -lt 2 ]] &&
1943 skip_env "skipping multiple stripe count/offset test"
1945 test_mkdir $DIR/$tdir
1946 for i in $(seq 1 $OSTCOUNT); do
1948 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1949 error "setstripe -c $i -i $offset failed"
1950 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1951 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1952 [ $count -ne $i ] && error "stripe count $count != $i" || true
1953 [ $index -ne $offset ] &&
1954 error "stripe offset $index != $offset" || true
1957 run_test 27wa "check $LFS setstripe -c -i options"
1960 remote_ost_nodsh && skip "remote OST with nodsh"
1961 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1964 OFFSET=$(($OSTCOUNT - 1))
1966 local OST=$(ostname_from_index $OSTIDX)
1968 test_mkdir $DIR/$tdir
1969 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1970 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1972 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1973 for i in $(seq 0 $OFFSET); do
1974 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1975 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1976 error "OST0 was degraded but new created file still use it"
1978 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1980 run_test 27x "create files while OST0 is degraded"
1983 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1984 remote_mds_nodsh && skip "remote MDS with nodsh"
1985 remote_ost_nodsh && skip "remote OST with nodsh"
1986 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1988 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1989 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1990 osp.$mdtosc.prealloc_last_id)
1991 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1992 osp.$mdtosc.prealloc_next_id)
1993 local fcount=$((last_id - next_id))
1994 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1995 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1997 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1998 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1999 local OST_DEACTIVE_IDX=-1
2004 for OSC in $MDS_OSCS; do
2005 OST=$(osc_to_ost $OSC)
2006 OSTIDX=$(index_from_ostuuid $OST)
2007 if [ $OST_DEACTIVE_IDX == -1 ]; then
2008 OST_DEACTIVE_IDX=$OSTIDX
2010 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2011 echo $OSC "is Deactivated:"
2012 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2016 OSTIDX=$(index_from_ostuuid $OST)
2017 test_mkdir $DIR/$tdir
2018 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2020 for OSC in $MDS_OSCS; do
2021 OST=$(osc_to_ost $OSC)
2022 OSTIDX=$(index_from_ostuuid $OST)
2023 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2024 echo $OST "is degraded:"
2025 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2026 obdfilter.$OST.degraded=1
2031 createmany -o $DIR/$tdir/$tfile $fcount
2033 for OSC in $MDS_OSCS; do
2034 OST=$(osc_to_ost $OSC)
2035 OSTIDX=$(index_from_ostuuid $OST)
2036 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2037 echo $OST "is recovered from degraded:"
2038 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2039 obdfilter.$OST.degraded=0
2041 do_facet $SINGLEMDS lctl --device %$OSC activate
2045 # all osp devices get activated, hence -1 stripe count restored
2046 local stripe_count=0
2048 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2049 # devices get activated.
2051 $LFS setstripe -c -1 $DIR/$tfile
2052 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2054 [ $stripe_count -ne $OSTCOUNT ] &&
2055 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2058 run_test 27y "create files while OST0 is degraded and the rest inactive"
2064 lmm_count=$($GETSTRIPE -c $1)
2065 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
2066 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
2068 local old_ifs="$IFS"
2070 fid=($($LFS path2fid $1))
2073 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2074 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2076 # compare lmm_seq and lu_fid->f_seq
2077 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2078 # compare lmm_object_id and lu_fid->oid
2079 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2081 # check the trusted.fid attribute of the OST objects of the file
2082 local have_obdidx=false
2084 $GETSTRIPE $1 | while read obdidx oid hex seq; do
2085 # skip lines up to and including "obdidx"
2086 [ -z "$obdidx" ] && break
2087 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2088 $have_obdidx || continue
2090 local ost=$((obdidx + 1))
2091 local dev=$(ostdevname $ost)
2094 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2096 seq=$(echo $seq | sed -e "s/^0x//g")
2097 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2098 oid_hex=$(echo $oid)
2100 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2102 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2106 # Don't unmount/remount the OSTs if we don't need to do that.
2107 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2108 # update too, until that use mount/ll_decode_filter_fid/mount.
2109 # Re-enable when debugfs will understand new filter_fid.
2111 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2112 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2113 $dev 2>/dev/null" | grep "parent=")
2115 if [ -z "$ff" ]; then
2117 mount_fstype ost$ost
2118 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2119 $(facet_mntpt ost$ost)/$obj_file)
2120 unmount_fstype ost$ost
2121 start ost$ost $dev $OST_MOUNT_OPTS
2125 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2127 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2129 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2130 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2132 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2133 # stripe_size=1048576 component_id=1 component_start=0 \
2134 # component_end=33554432
2135 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2136 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2137 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2139 if grep -q 'stripe=' <<<$ff; then
2140 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2142 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2143 # into f_ver in this case. See comment on ff_parent.
2144 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2147 # compare lmm_seq and filter_fid->ff_parent.f_seq
2148 [ $ff_pseq = $lmm_seq ] ||
2149 error "FF parent SEQ $ff_pseq != $lmm_seq"
2150 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2151 [ $ff_poid = $lmm_oid ] ||
2152 error "FF parent OID $ff_poid != $lmm_oid"
2153 (($ff_pstripe == $stripe_nr)) ||
2154 error "FF stripe $ff_pstripe != $stripe_nr"
2156 stripe_nr=$((stripe_nr + 1))
2157 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2159 if grep -q 'stripe_count=' <<<$ff; then
2160 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2161 -e 's/ .*//' <<<$ff)
2162 [ $lmm_count = $ff_scnt ] ||
2163 error "FF stripe count $lmm_count != $ff_scnt"
2169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2170 remote_ost_nodsh && skip "remote OST with nodsh"
2172 test_mkdir $DIR/$tdir
2173 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2174 { error "setstripe -c -1 failed"; return 1; }
2175 # We need to send a write to every object to get parent FID info set.
2176 # This _should_ also work for setattr, but does not currently.
2177 # touch $DIR/$tdir/$tfile-1 ||
2178 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2179 { error "dd $tfile-1 failed"; return 2; }
2180 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2181 { error "setstripe -c -1 failed"; return 3; }
2182 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2183 { error "dd $tfile-2 failed"; return 4; }
2185 # make sure write RPCs have been sent to OSTs
2188 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2189 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2191 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2193 test_27A() { # b=19102
2194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2196 save_layout_restore_at_exit $MOUNT
2197 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2198 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2199 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2200 local default_size=$($GETSTRIPE -S $MOUNT)
2201 local default_offset=$($GETSTRIPE -i $MOUNT)
2202 local dsize=$(do_facet $SINGLEMDS \
2203 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2204 [ $default_size -eq $dsize ] ||
2205 error "stripe size $default_size != $dsize"
2206 [ $default_offset -eq -1 ] ||
2207 error "stripe offset $default_offset != -1"
2209 run_test 27A "check filesystem-wide default LOV EA values"
2211 test_27B() { # LU-2523
2212 test_mkdir $DIR/$tdir
2213 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2215 # open f1 with O_LOV_DELAY_CREATE
2217 # call setstripe ioctl on open file descriptor for f1
2219 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2223 # open f1 with O_LOV_DELAY_CREATE
2225 # call setstripe ioctl on open file descriptor for f1
2227 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2229 # Allow multiop to fail in imitation of NFS's busted semantics.
2232 run_test 27B "call setstripe on open unlinked file/rename victim"
2234 test_27C() { #LU-2871
2235 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2243 test_mkdir $DIR/$tdir
2245 for i in $(seq 0 $((OSTCOUNT - 1))); do
2246 # set stripe across all OSTs starting from OST$i
2247 $SETSTRIPE -i $i -c -1 $tfile$i
2248 # get striping information
2249 ost_idx=($($GETSTRIPE $tfile$i |
2250 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2254 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2255 error "${#ost_idx[@]} != $OSTCOUNT"
2257 for index in $(seq 0 $((OSTCOUNT - 1))); do
2259 for j in $(echo ${ost_idx[@]}); do
2260 if [ $index -eq $j ]; then
2266 error "Can not find $index in ${ost_idx[@]}"
2270 run_test 27C "check full striping across all OSTs"
2273 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2274 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2275 remote_mds_nodsh && skip "remote MDS with nodsh"
2277 local POOL=${POOL:-testpool}
2279 local last_ost=$(($OSTCOUNT - 1))
2281 local ost_list=$(seq $first_ost $ost_step $last_ost)
2282 local ost_range="$first_ost $last_ost $ost_step"
2284 test_mkdir $DIR/$tdir
2285 pool_add $POOL || error "pool_add failed"
2286 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2289 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2291 [ $MDS1_VERSION -lt $(version_code 2.9.55) -o \
2292 $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2293 skip27D+=" -s 30,31"
2294 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2295 error "llapi_layout_test failed"
2297 destroy_test_pools || error "destroy test pools failed"
2299 run_test 27D "validate llapi_layout API"
2301 # Verify that default_easize is increased from its initial value after
2302 # accessing a widely striped file.
2304 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2305 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2306 skip "client does not have LU-3338 fix"
2308 # 72 bytes is the minimum space required to store striping
2309 # information for a file striped across one OST:
2310 # (sizeof(struct lov_user_md_v3) +
2311 # sizeof(struct lov_user_ost_data_v1))
2313 $LCTL set_param -n llite.*.default_easize $min_easize ||
2314 error "lctl set_param failed"
2315 local easize=$($LCTL get_param -n llite.*.default_easize)
2317 [ $easize -eq $min_easize ] ||
2318 error "failed to set default_easize"
2320 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2321 error "setstripe failed"
2325 easize=$($LCTL get_param -n llite.*.default_easize)
2327 [ $easize -gt $min_easize ] ||
2328 error "default_easize not updated"
2330 run_test 27E "check that default extended attribute size properly increases"
2332 test_27F() { # LU-5346/LU-7975
2333 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2334 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2335 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2336 skip "Need MDS version at least 2.8.51"
2337 remote_ost_nodsh && skip "remote OST with nodsh"
2339 test_mkdir $DIR/$tdir
2341 $SETSTRIPE -c 2 $DIR/$tdir
2343 # stop all OSTs to reproduce situation for LU-7975 ticket
2344 for num in $(seq $OSTCOUNT); do
2348 # open/create f0 with O_LOV_DELAY_CREATE
2349 # truncate f0 to a non-0 size
2351 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2353 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2354 # open/write it again to force delayed layout creation
2355 cat /etc/hosts > $DIR/$tdir/f0 &
2359 for num in $(seq $OSTCOUNT); do
2360 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2361 error "ost$num failed to start"
2364 wait $catpid || error "cat failed"
2366 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2367 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2370 run_test 27F "Client resend delayed layout creation with non-zero size"
2372 test_27G() { #LU-10629
2373 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2374 skip "Need MDS version at least 2.11.51"
2375 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2376 remote_mds_nodsh && skip "remote MDS with nodsh"
2377 local POOL=${POOL:-testpool}
2378 local ostrange="0 0 1"
2380 test_mkdir $DIR/$tdir
2381 pool_add $POOL || error "pool_add failed"
2382 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2383 $LFS setstripe -p $POOL $DIR/$tdir
2385 local pool=$($LFS getstripe -p $DIR/$tdir)
2387 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2389 $LFS setstripe -d $DIR/$tdir
2391 pool=$($LFS getstripe -p $DIR/$tdir)
2395 [ -z "$pool" ] || error "'$pool' is not empty"
2397 run_test 27G "Clear OST pool from stripe"
2400 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2401 skip "Need MDS version newer than 2.11.54"
2402 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2403 test_mkdir $DIR/$tdir
2404 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2405 touch $DIR/$tdir/$tfile
2406 $LFS getstripe -c $DIR/$tdir/$tfile
2407 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2408 error "two-stripe file doesn't have two stripes"
2410 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2411 $LFS getstripe -y $DIR/$tdir/$tfile
2412 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2413 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2414 error "expected l_ost_idx: [02]$ not matched"
2416 # make sure ost list have been cleared
2417 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
2418 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2419 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2421 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2423 run_test 27H "Set specific OSTs stripe"
2426 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2427 skip "Need MDS version >= than 2.12.57"
2428 remote_mds_nodsh && skip "remote MDS with nodsh"
2429 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2431 test_mkdir $DIR/$tdir
2433 # Set default striping on directory
2437 # if we run against a 2.12 server which lacks overstring support
2438 # then the connect_flag will not report overstriping, even if client
2440 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
2441 stripe_opt="-C $setcount"
2442 elif (( $OSTCOUNT >= $setcount )); then
2443 stripe_opt="-c $setcount"
2445 skip "server does not support overstriping"
2447 $LFS setstripe $stripe_opt $DIR/$tdir
2449 echo 1 > $DIR/$tdir/${tfile}.1
2450 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2451 [ $count -eq $setcount ] ||
2452 error "(1) stripe count $count, should be $setcount"
2454 # Capture existing append_stripe_count setting for restore
2455 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2456 local mdts=$(comma_list $(mdts_nodes))
2457 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2459 local appendcount=$orig_count
2460 echo 1 >> $DIR/$tdir/${tfile}.2_append
2461 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2462 [ $count -eq $appendcount ] ||
2463 error "(2)stripe count $count, should be $appendcount for append"
2465 # Disable O_APPEND striping, verify it works
2466 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2468 # Should now get the default striping, which is 4
2470 echo 1 >> $DIR/$tdir/${tfile}.3_append
2471 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2472 [ $count -eq $setcount ] ||
2473 error "(3) stripe count $count, should be $setcount"
2475 # Try changing the stripe count for append files
2476 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2478 # Append striping is now 2 (directory default is still 4)
2480 echo 1 >> $DIR/$tdir/${tfile}.4_append
2481 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2482 [ $count -eq $appendcount ] ||
2483 error "(4) stripe count $count, should be $appendcount for append"
2485 # Test append stripe count of -1
2486 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2487 appendcount=$OSTCOUNT
2488 echo 1 >> $DIR/$tdir/${tfile}.5
2489 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2490 [ $count -eq $appendcount ] ||
2491 error "(5) stripe count $count, should be $appendcount for append"
2493 # Set append striping back to default of 1
2494 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2496 # Try a new default striping, PFL + DOM
2497 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2499 # Create normal DOM file, DOM returns stripe count == 0
2501 touch $DIR/$tdir/${tfile}.6
2502 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2503 [ $count -eq $setcount ] ||
2504 error "(6) stripe count $count, should be $setcount"
2508 echo 1 >> $DIR/$tdir/${tfile}.7_append
2509 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2510 [ $count -eq $appendcount ] ||
2511 error "(7) stripe count $count, should be $appendcount for append"
2513 # Clean up DOM layout
2514 $LFS setstripe -d $DIR/$tdir
2516 save_layout_restore_at_exit $MOUNT
2517 # Now test that append striping works when layout is from root
2518 $LFS setstripe -c 2 $MOUNT
2519 # Make a special directory for this
2520 mkdir $DIR/${tdir}/${tdir}.2
2522 # Verify for normal file
2524 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2525 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2526 [ $count -eq $setcount ] ||
2527 error "(8) stripe count $count, should be $setcount"
2530 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2531 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2532 [ $count -eq $appendcount ] ||
2533 error "(9) stripe count $count, should be $appendcount for append"
2535 # Now test O_APPEND striping with pools
2536 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2537 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2540 pool_add $TESTNAME || error "pool creation failed"
2541 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2543 echo 1 >> $DIR/$tdir/${tfile}.10_append
2545 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2546 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2548 # Check that count is still correct
2550 echo 1 >> $DIR/$tdir/${tfile}.11_append
2551 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2552 [ $count -eq $appendcount ] ||
2553 error "(11) stripe count $count, should be $appendcount for append"
2555 # Disable O_APPEND stripe count, verify pool works separately
2556 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2558 echo 1 >> $DIR/$tdir/${tfile}.12_append
2560 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2561 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2563 # Remove pool setting, verify it's not applied
2564 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
2566 echo 1 >> $DIR/$tdir/${tfile}.13_append
2568 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
2569 [ "$pool" = "" ] || error "(13) pool found: $pool"
2571 run_test 27M "test O_APPEND striping"
2573 # createtest also checks that device nodes are created and
2574 # then visible correctly (#2091)
2575 test_28() { # bug 2091
2577 $CREATETEST $DIR/d28/ct || error "createtest failed"
2579 run_test 28 "create/mknod/mkdir with bad file types ============"
2582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2584 sync; sleep 1; sync # flush out any dirty pages from previous tests
2591 declare -i LOCKCOUNTORIG=0
2592 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2593 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2595 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2597 declare -i LOCKUNUSEDCOUNTORIG=0
2598 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2599 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2606 declare -i LOCKCOUNTCURRENT=0
2607 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2608 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2611 declare -i LOCKUNUSEDCOUNTCURRENT=0
2612 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2613 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2616 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2617 $LCTL set_param -n ldlm.dump_namespaces ""
2618 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2619 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2620 log "dumped log to $TMP/test_29.dk (bug 5793)"
2623 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2624 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2625 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2626 log "dumped log to $TMP/test_29.dk (bug 5793)"
2630 run_test 29 "IT_GETATTR regression ============================"
2632 test_30a() { # was test_30
2633 cp $(which ls) $DIR || cp /bin/ls $DIR
2634 $DIR/ls / || error "Can't execute binary from lustre"
2637 run_test 30a "execute binary from Lustre (execve) =============="
2640 cp `which ls` $DIR || cp /bin/ls $DIR
2642 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2645 run_test 30b "execute binary from Lustre as non-root ==========="
2647 test_30c() { # b=22376
2648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2650 cp `which ls` $DIR || cp /bin/ls $DIR
2652 cancel_lru_locks mdc
2653 cancel_lru_locks osc
2654 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2657 run_test 30c "execute binary from Lustre without read perms ===="
2660 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2661 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2663 run_test 31a "open-unlink file =================================="
2666 touch $DIR/f31 || error "touch $DIR/f31 failed"
2667 ln $DIR/f31 $DIR/f31b || error "ln failed"
2668 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2669 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2671 run_test 31b "unlink file with multiple links while open ======="
2674 touch $DIR/f31 || error "touch $DIR/f31 failed"
2675 ln $DIR/f31 $DIR/f31c || error "ln failed"
2676 multiop_bg_pause $DIR/f31 O_uc ||
2677 error "multiop_bg_pause for $DIR/f31 failed"
2679 $MULTIOP $DIR/f31c Ouc
2680 kill -USR1 $MULTIPID
2683 run_test 31c "open-unlink file with multiple links ============="
2686 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2687 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2689 run_test 31d "remove of open directory ========================="
2691 test_31e() { # bug 2904
2692 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2694 run_test 31e "remove of open non-empty directory ==============="
2696 test_31f() { # bug 4554
2697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2700 test_mkdir $DIR/d31f
2701 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2702 cp /etc/hosts $DIR/d31f
2704 $GETSTRIPE $DIR/d31f/hosts
2705 multiop_bg_pause $DIR/d31f D_c || return 1
2708 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2709 test_mkdir $DIR/d31f
2710 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2711 cp /etc/hosts $DIR/d31f
2713 $GETSTRIPE $DIR/d31f/hosts
2714 multiop_bg_pause $DIR/d31f D_c || return 1
2717 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2718 wait $MULTIPID || error "first opendir $MULTIPID failed"
2722 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2723 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2726 run_test 31f "remove of open directory with open-unlink file ==="
2729 echo "-- cross directory link --"
2730 test_mkdir -c1 $DIR/${tdir}ga
2731 test_mkdir -c1 $DIR/${tdir}gb
2732 touch $DIR/${tdir}ga/f
2733 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2734 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2735 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2736 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2737 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2739 run_test 31g "cross directory link==============="
2742 echo "-- cross directory link --"
2743 test_mkdir -c1 $DIR/${tdir}
2744 test_mkdir -c1 $DIR/${tdir}/dir
2745 touch $DIR/${tdir}/f
2746 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2747 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2748 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2749 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2750 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2752 run_test 31h "cross directory link under child==============="
2755 echo "-- cross directory link --"
2756 test_mkdir -c1 $DIR/$tdir
2757 test_mkdir -c1 $DIR/$tdir/dir
2758 touch $DIR/$tdir/dir/f
2759 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2760 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2761 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2762 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2763 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2765 run_test 31i "cross directory link under parent==============="
2768 test_mkdir -c1 -p $DIR/$tdir
2769 test_mkdir -c1 -p $DIR/$tdir/dir1
2770 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2771 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2772 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2773 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2776 run_test 31j "link for directory==============="
2779 test_mkdir -c1 -p $DIR/$tdir
2781 touch $DIR/$tdir/exist
2782 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2783 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2784 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2785 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2786 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2787 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2788 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2791 run_test 31k "link to file: the same, non-existing, dir==============="
2797 touch $DIR/d31m2/exist
2798 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2799 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2800 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2801 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2802 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2803 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2806 run_test 31m "link to file: the same, non-existing, dir==============="
2809 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2810 nlink=$(stat --format=%h $DIR/$tfile)
2811 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2813 local cmd="exec $fd<$DIR/$tfile"
2816 trap "eval $cmd" EXIT
2817 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2818 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2819 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2820 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2821 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2824 run_test 31n "check link count of unlinked file"
2827 local TEMPNAME=$(mktemp $1_XXXXXX)
2828 mlink $TEMPNAME $1 2> /dev/null &&
2829 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2833 test_31o() { # LU-2901
2834 test_mkdir $DIR/$tdir
2835 for LOOP in $(seq 100); do
2836 rm -f $DIR/$tdir/$tfile*
2837 for THREAD in $(seq 8); do
2838 link_one $DIR/$tdir/$tfile.$LOOP &
2841 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2842 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2843 error "$LINKS duplicate links to $tfile.$LOOP" &&
2847 run_test 31o "duplicate hard links with same filename"
2850 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2852 test_mkdir $DIR/$tdir
2853 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2854 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2856 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2857 error "open unlink test1 failed"
2858 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2859 error "open unlink test2 failed"
2861 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2862 error "test1 still exists"
2863 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2864 error "test2 still exists"
2866 run_test 31p "remove of open striped directory"
2868 cleanup_test32_mount() {
2871 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2872 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2873 losetup -d $loopdev || true
2879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2881 echo "== more mountpoints and symlinks ================="
2882 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2883 trap cleanup_test32_mount EXIT
2884 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2885 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2886 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2887 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2888 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2889 cleanup_test32_mount
2891 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2896 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2897 trap cleanup_test32_mount EXIT
2898 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2899 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2900 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2901 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2902 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2903 cleanup_test32_mount
2905 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2910 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2911 trap cleanup_test32_mount EXIT
2912 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2913 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2914 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2915 test_mkdir -p $DIR/$tdir/d2/test_dir
2916 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2917 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2918 cleanup_test32_mount
2920 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2923 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2925 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2926 trap cleanup_test32_mount EXIT
2927 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2928 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2929 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2930 test_mkdir -p $DIR/$tdir/d2/test_dir
2931 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2932 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2933 cleanup_test32_mount
2935 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2939 test_mkdir -p $DIR/$tdir/tmp
2940 local tmp_dir=$DIR/$tdir/tmp
2941 ln -s $DIR/$tdir $tmp_dir/symlink11
2942 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2943 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2944 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2946 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2950 test_mkdir -p $DIR/$tdir/tmp
2951 local tmp_dir=$DIR/$tdir/tmp
2952 ln -s $DIR/$tdir $tmp_dir/symlink11
2953 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2954 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2955 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2957 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2960 local tmp_dir=$DIR/$tdir/tmp
2961 test_mkdir -p $tmp_dir
2962 test_mkdir $DIR/${tdir}2
2963 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2964 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2965 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2966 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2967 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2968 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2970 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2973 rm -fr $DIR/$tdir $DIR/${tdir}2
2974 tmp_dir=$DIR/$tdir/tmp
2975 test_mkdir -p $tmp_dir
2976 test_mkdir $DIR/${tdir}2
2977 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2978 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2979 ls $tmp_dir/symlink12 || error "listing symlink12"
2980 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2982 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2987 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2988 trap cleanup_test32_mount EXIT
2989 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2990 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2991 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2992 touch $DIR/$tdir/test_file
2993 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2994 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2995 cleanup_test32_mount
2997 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3000 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3002 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3003 trap cleanup_test32_mount EXIT
3004 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3005 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3006 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3007 touch $DIR/$tdir/test_file
3008 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3009 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3010 cleanup_test32_mount
3012 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3015 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3018 trap cleanup_test32_mount EXIT
3019 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3020 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3021 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3022 test_mkdir -p $DIR/$tdir/d2
3023 touch $DIR/$tdir/d2/test_file || error "touch failed"
3024 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3025 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3026 cleanup_test32_mount
3028 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3034 trap cleanup_test32_mount EXIT
3035 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3036 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3037 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3038 test_mkdir -p $DIR/$tdir/d2
3039 touch $DIR/$tdir/d2/test_file || error "touch failed"
3040 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3041 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3042 cleanup_test32_mount
3044 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3048 test_mkdir -p $DIR/d32m/tmp
3049 TMP_DIR=$DIR/d32m/tmp
3050 ln -s $DIR $TMP_DIR/symlink11
3051 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3052 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3053 error "symlink11 not a link"
3054 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3055 error "symlink01 not a link"
3057 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3061 test_mkdir -p $DIR/d32n/tmp
3062 TMP_DIR=$DIR/d32n/tmp
3063 ln -s $DIR $TMP_DIR/symlink11
3064 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3065 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3066 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3068 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3072 test_mkdir -p $DIR/d32o/tmp
3073 TMP_DIR=$DIR/d32o/tmp
3074 ln -s $DIR/$tfile $TMP_DIR/symlink12
3075 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3076 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3077 error "symlink12 not a link"
3078 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3079 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3080 error "$DIR/d32o/tmp/symlink12 not file type"
3081 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3082 error "$DIR/d32o/symlink02 not file type"
3084 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3094 test_mkdir -p $DIR/d32p/tmp
3096 TMP_DIR=$DIR/d32p/tmp
3098 ln -s $DIR/$tfile $TMP_DIR/symlink12
3100 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3102 cat $DIR/d32p/tmp/symlink12 ||
3103 error "Can't open $DIR/d32p/tmp/symlink12"
3105 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3108 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3113 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3114 trap cleanup_test32_mount EXIT
3115 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3116 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3117 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3118 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3119 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3120 cleanup_test32_mount
3122 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3125 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3127 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3128 trap cleanup_test32_mount EXIT
3129 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3130 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3131 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3132 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3133 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3134 cleanup_test32_mount
3136 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3141 chmod 444 $DIR/$tfile
3142 chown $RUNAS_ID $DIR/$tfile
3144 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3147 run_test 33aa "write file with mode 444 (should return error)"
3151 test_mkdir $DIR/$tdir
3152 chown $RUNAS_ID $DIR/$tdir
3153 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3154 error "$RUNAS create $tdir/$tfile failed"
3155 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3156 error "open RDWR" || true
3158 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3162 test_mkdir $DIR/$tdir
3163 chown $RUNAS_ID $DIR/$tdir
3164 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3166 run_test 33b "test open file with malformed flags (No panic)"
3169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3170 remote_ost_nodsh && skip "remote OST with nodsh"
3179 test_mkdir $DIR/$tdir
3180 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3183 for ostnum in $(seq $OSTCOUNT); do
3184 # test-framework's OST numbering is one-based, while Lustre's
3186 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3187 # Parsing llobdstat's output sucks; we could grep the /proc
3188 # path, but that's likely to not be as portable as using the
3189 # llobdstat utility. So we parse lctl output instead.
3190 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3191 obdfilter/$ostname/stats |
3192 awk '/^write_bytes/ {print $7}' )
3193 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3194 if (( ${write_bytes:-0} > 0 ))
3201 $all_zeros || return 0
3204 echo foo > $DIR/$tdir/bar
3208 # Total up write_bytes after writing. We'd better find non-zeros.
3209 for ostnum in $(seq $OSTCOUNT); do
3210 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3211 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3212 obdfilter/$ostname/stats |
3213 awk '/^write_bytes/ {print $7}' )
3214 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3215 if (( ${write_bytes:-0} > 0 ))
3224 for ostnum in $(seq $OSTCOUNT); do
3225 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3226 echo "Check that write_bytes is present in obdfilter/*/stats:"
3227 do_facet ost$ostnum lctl get_param -n \
3228 obdfilter/$ostname/stats
3230 error "OST not keeping write_bytes stats (b22312)"
3233 run_test 33c "test llobdstat and write_bytes"
3236 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3237 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3240 local remote_dir=$DIR/$tdir/remote_dir
3242 test_mkdir $DIR/$tdir
3243 $LFS mkdir -i $MDTIDX $remote_dir ||
3244 error "create remote directory failed"
3246 touch $remote_dir/$tfile
3247 chmod 444 $remote_dir/$tfile
3248 chown $RUNAS_ID $remote_dir/$tfile
3250 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3252 chown $RUNAS_ID $remote_dir
3253 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3254 error "create" || true
3255 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3256 error "open RDWR" || true
3257 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3259 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3262 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3266 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3267 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3268 mkdir $DIR/$tdir/local_dir
3270 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3271 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3272 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3274 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3275 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3277 rmdir $DIR/$tdir/* || error "rmdir failed"
3280 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3281 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3282 mkdir $DIR/$tdir/local_dir
3284 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3285 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3286 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3288 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3289 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3291 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3294 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3295 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3296 mkdir $DIR/$tdir/local_dir
3298 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3299 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3300 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3302 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3303 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3305 run_test 33e "mkdir and striped directory should have same mode"
3309 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3313 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3314 remote_mds_nodsh && skip "remote MDS with nodsh"
3317 chmod go+rwx $DIR/$tdir
3318 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3319 trap cleanup_33f EXIT
3321 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3322 error "cannot create striped directory"
3324 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3325 error "cannot create files in striped directory"
3327 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3328 error "cannot remove files in striped directory"
3330 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3331 error "cannot remove striped directory"
3335 run_test 33f "nonroot user can create, access, and remove a striped directory"
3338 mkdir -p $DIR/$tdir/dir2
3340 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3342 [[ $err =~ "exists" ]] || error "Not exists error"
3344 run_test 33g "nonroot user create already existing root created file"
3346 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3349 $MCREATE $DIR/f34 || error "mcreate failed"
3350 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3351 error "getstripe failed"
3352 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3353 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3354 error "getstripe failed"
3355 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3356 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3358 run_test 34a "truncate file that has not been opened ==========="
3361 [ ! -f $DIR/f34 ] && test_34a
3362 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3363 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3364 $OPENFILE -f O_RDONLY $DIR/f34
3365 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3366 error "getstripe failed"
3367 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3368 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3370 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3373 [ ! -f $DIR/f34 ] && test_34a
3374 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3375 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3376 $OPENFILE -f O_RDWR $DIR/f34
3377 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3378 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3379 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3381 run_test 34c "O_RDWR opening file-with-size works =============="
3384 [ ! -f $DIR/f34 ] && test_34a
3385 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3387 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3388 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3391 run_test 34d "write to sparse file ============================="
3395 $MCREATE $DIR/f34e || error "mcreate failed"
3396 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3397 $CHECKSTAT -s 1000 $DIR/f34e ||
3398 error "Size of $DIR/f34e not equal to 1000 bytes"
3399 $OPENFILE -f O_RDWR $DIR/f34e
3400 $CHECKSTAT -s 1000 $DIR/f34e ||
3401 error "Size of $DIR/f34e not equal to 1000 bytes"
3403 run_test 34e "create objects, some with size and some without =="
3405 test_34f() { # bug 6242, 6243
3406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3410 $MCREATE $DIR/f34f || error "mcreate failed"
3411 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3412 dd if=$DIR/f34f of=$TMP/f34f
3413 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3414 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3415 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3416 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3417 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3419 run_test 34f "read from a file with no objects until EOF ======="
3422 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3424 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3426 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3427 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3428 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3429 cancel_lru_locks osc
3430 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3431 error "wrong size after lock cancel"
3433 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3434 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3435 error "expanding truncate failed"
3436 cancel_lru_locks osc
3437 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3438 error "wrong expanded size after lock cancel"
3440 run_test 34g "truncate long file ==============================="
3443 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3448 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3449 sync # Flush the cache so that multiop below does not block on cache
3450 # flush when getting the group lock
3451 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3454 # Since just timed wait is not good enough, let's do a sync write
3455 # that way we are sure enough time for a roundtrip + processing
3456 # passed + 2 seconds of extra margin.
3457 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3461 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3462 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3466 local nsz=`stat -c %s $DIR/$tfile`
3467 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3469 run_test 34h "ftruncate file under grouplock should not block"
3472 cp /bin/sh $DIR/f35a
3474 chown $RUNAS_ID $DIR/f35a
3475 $RUNAS $DIR/f35a && error || true
3478 run_test 35a "exec file with mode 444 (should return and not leak)"
3482 utime $DIR/f36 || error "utime failed for MDS"
3484 run_test 36a "MDS utime check (mknod, utime)"
3488 utime $DIR/f36 || error "utime failed for OST"
3490 run_test 36b "OST utime check (open, utime)"
3495 chown $RUNAS_ID $DIR/d36
3496 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3498 run_test 36c "non-root MDS utime check (mknod, utime)"
3501 [ ! -d $DIR/d36 ] && test_36c
3502 echo "" > $DIR/d36/f36
3503 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3505 run_test 36d "non-root OST utime check (open, utime)"
3508 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3510 test_mkdir $DIR/$tdir
3511 touch $DIR/$tdir/$tfile
3512 $RUNAS utime $DIR/$tdir/$tfile &&
3513 error "utime worked, expected failure" || true
3515 run_test 36e "utime on non-owned file (should return error)"
3519 local LANG_SAVE=$LANG
3520 local LC_LANG_SAVE=$LC_LANG
3521 export LANG=C LC_LANG=C # for date language
3523 DATESTR="Dec 20 2000"
3524 test_mkdir $DIR/$tdir
3525 lctl set_param fail_loc=$fl
3527 cp /etc/hosts $DIR/$tdir/$tfile
3528 sync & # write RPC generated with "current" inode timestamp, but delayed
3530 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3531 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3532 cancel_lru_locks $OSC
3533 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3535 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3536 echo "BEFORE: $LS_BEFORE" && \
3537 echo "AFTER : $LS_AFTER" && \
3538 echo "WANT : $DATESTR" && \
3539 error "$DIR/$tdir/$tfile timestamps changed" || true
3541 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3545 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3547 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3548 subr_36fh "0x80000214"
3550 run_test 36f "utime on file racing with OST BRW write =========="
3553 remote_ost_nodsh && skip "remote OST with nodsh"
3554 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3555 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3556 skip "Need MDS version at least 2.12.51"
3561 local tgt="obdfilter"
3563 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3565 test_mkdir $DIR/$tdir
3566 fmd_max_age=$(do_facet $facet \
3567 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3570 echo "FMD max age: ${fmd_max_age}s"
3571 touch $DIR/$tdir/$tfile
3572 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3573 gawk '{cnt=cnt+$1} END{print cnt}')
3574 echo "FMD before: $fmd"
3576 error "FMD wasn't create by touch"
3577 sleep $((fmd_max_age + 12))
3578 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3579 gawk '{cnt=cnt+$1} END{print cnt}')
3580 echo "FMD after: $fmd"
3582 error "FMD wasn't expired by ping"
3584 run_test 36g "FMD cache expiry ====================="
3587 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3589 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3590 subr_36fh "0x80000227"
3592 run_test 36h "utime on file racing with OST BRW write =========="
3595 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3597 test_mkdir $DIR/$tdir
3598 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3600 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3601 local new_mtime=$((mtime + 200))
3603 #change Modify time of striped dir
3604 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3605 error "change mtime failed"
3607 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3609 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3611 run_test 36i "change mtime on striped directory"
3613 # test_37 - duplicate with tests 32q 32r
3616 local file=$DIR/$tfile
3618 openfile -f O_DIRECTORY $file
3621 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3622 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3624 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3626 test_39a() { # was test_39
3628 touch $DIR/${tfile}2
3629 # ls -l $DIR/$tfile $DIR/${tfile}2
3630 # ls -lu $DIR/$tfile $DIR/${tfile}2
3631 # ls -lc $DIR/$tfile $DIR/${tfile}2
3633 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3634 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3636 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3638 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3640 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3641 error "O_TRUNC didn't change timestamps"
3644 run_test 39a "mtime changed on create"
3647 test_mkdir -c1 $DIR/$tdir
3648 cp -p /etc/passwd $DIR/$tdir/fopen
3649 cp -p /etc/passwd $DIR/$tdir/flink
3650 cp -p /etc/passwd $DIR/$tdir/funlink
3651 cp -p /etc/passwd $DIR/$tdir/frename
3652 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3655 echo "aaaaaa" >> $DIR/$tdir/fopen
3656 echo "aaaaaa" >> $DIR/$tdir/flink
3657 echo "aaaaaa" >> $DIR/$tdir/funlink
3658 echo "aaaaaa" >> $DIR/$tdir/frename
3660 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3661 local link_new=`stat -c %Y $DIR/$tdir/flink`
3662 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3663 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3665 cat $DIR/$tdir/fopen > /dev/null
3666 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3667 rm -f $DIR/$tdir/funlink2
3668 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3670 for (( i=0; i < 2; i++ )) ; do
3671 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3672 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3673 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3674 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3676 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3677 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3678 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3679 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3681 cancel_lru_locks $OSC
3682 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3685 run_test 39b "mtime change on open, link, unlink, rename ======"
3687 # this should be set to past
3688 TEST_39_MTIME=`date -d "1 year ago" +%s`
3694 local mtime0=`stat -c %Y $DIR1/$tfile`
3696 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3697 local mtime1=`stat -c %Y $DIR1/$tfile`
3698 [ "$mtime1" = $TEST_39_MTIME ] || \
3699 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3702 echo hello >> $DIR1/$tfile
3704 local mtime2=`stat -c %Y $DIR1/$tfile`
3705 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3706 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3708 mv $DIR1/$tfile $DIR1/$tfile-1
3710 for (( i=0; i < 2; i++ )) ; do
3711 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3712 [ "$mtime2" = "$mtime3" ] || \
3713 error "mtime ($mtime2) changed (to $mtime3) on rename"
3715 cancel_lru_locks $OSC
3716 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3719 run_test 39c "mtime change on rename ==========================="
3723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3726 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3728 for (( i=0; i < 2; i++ )) ; do
3729 local mtime=`stat -c %Y $DIR1/$tfile`
3730 [ $mtime = $TEST_39_MTIME ] || \
3731 error "mtime($mtime) is not set to $TEST_39_MTIME"
3733 cancel_lru_locks $OSC
3734 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3737 run_test 39d "create, utime, stat =============================="
3741 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3744 local mtime1=`stat -c %Y $DIR1/$tfile`
3746 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3748 for (( i=0; i < 2; i++ )) ; do
3749 local mtime2=`stat -c %Y $DIR1/$tfile`
3750 [ $mtime2 = $TEST_39_MTIME ] || \
3751 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3753 cancel_lru_locks $OSC
3754 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3757 run_test 39e "create, stat, utime, stat ========================"
3761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3764 mtime1=`stat -c %Y $DIR1/$tfile`
3767 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3769 for (( i=0; i < 2; i++ )) ; do
3770 local mtime2=`stat -c %Y $DIR1/$tfile`
3771 [ $mtime2 = $TEST_39_MTIME ] || \
3772 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3774 cancel_lru_locks $OSC
3775 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3778 run_test 39f "create, stat, sleep, utime, stat ================="
3782 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3784 echo hello >> $DIR1/$tfile
3785 local mtime1=`stat -c %Y $DIR1/$tfile`
3788 chmod o+r $DIR1/$tfile
3790 for (( i=0; i < 2; i++ )) ; do
3791 local mtime2=`stat -c %Y $DIR1/$tfile`
3792 [ "$mtime1" = "$mtime2" ] || \
3793 error "lost mtime: $mtime2, should be $mtime1"
3795 cancel_lru_locks $OSC
3796 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3799 run_test 39g "write, chmod, stat ==============================="
3803 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3809 echo hello >> $DIR1/$tfile
3810 local mtime1=`stat -c %Y $DIR1/$tfile`
3812 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3814 if [ "$d1" != "$d2" ]; then
3815 echo "write and touch not within one second"
3817 for (( i=0; i < 2; i++ )) ; do
3818 local mtime2=`stat -c %Y $DIR1/$tfile`
3819 [ "$mtime2" = $TEST_39_MTIME ] || \
3820 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3822 cancel_lru_locks $OSC
3823 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3827 run_test 39h "write, utime within one second, stat ============="
3830 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3835 echo hello >> $DIR1/$tfile
3836 local mtime1=`stat -c %Y $DIR1/$tfile`
3838 mv $DIR1/$tfile $DIR1/$tfile-1
3840 for (( i=0; i < 2; i++ )) ; do
3841 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3843 [ "$mtime1" = "$mtime2" ] || \
3844 error "lost mtime: $mtime2, should be $mtime1"
3846 cancel_lru_locks $OSC
3847 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3850 run_test 39i "write, rename, stat =============================="
3853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3855 start_full_debug_logging
3859 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3860 lctl set_param fail_loc=0x80000412
3861 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3862 error "multiop failed"
3864 local mtime1=`stat -c %Y $DIR1/$tfile`
3866 mv $DIR1/$tfile $DIR1/$tfile-1
3868 kill -USR1 $multipid
3869 wait $multipid || error "multiop close failed"
3871 for (( i=0; i < 2; i++ )) ; do
3872 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3873 [ "$mtime1" = "$mtime2" ] ||
3874 error "mtime is lost on close: $mtime2, " \
3877 cancel_lru_locks $OSC
3878 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3880 lctl set_param fail_loc=0
3881 stop_full_debug_logging
3883 run_test 39j "write, rename, close, stat ======================="
3886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3891 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3893 local mtime1=`stat -c %Y $DIR1/$tfile`
3895 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3897 kill -USR1 $multipid
3898 wait $multipid || error "multiop close failed"
3900 for (( i=0; i < 2; i++ )) ; do
3901 local mtime2=`stat -c %Y $DIR1/$tfile`
3903 [ "$mtime2" = $TEST_39_MTIME ] || \
3904 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3906 cancel_lru_locks osc
3907 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3910 run_test 39k "write, utime, close, stat ========================"
3912 # this should be set to future
3913 TEST_39_ATIME=`date -d "1 year" +%s`
3916 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3917 remote_mds_nodsh && skip "remote MDS with nodsh"
3919 local atime_diff=$(do_facet $SINGLEMDS \
3920 lctl get_param -n mdd.*MDT0000*.atime_diff)
3924 # test setting directory atime to future
3925 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3926 local atime=$(stat -c %X $DIR/$tdir)
3927 [ "$atime" = $TEST_39_ATIME ] ||
3928 error "atime is not set to future: $atime, $TEST_39_ATIME"
3930 # test setting directory atime from future to now
3931 local now=$(date +%s)
3932 touch -a -d @$now $DIR/$tdir
3934 atime=$(stat -c %X $DIR/$tdir)
3935 [ "$atime" -eq "$now" ] ||
3936 error "atime is not updated from future: $atime, $now"
3938 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3941 # test setting directory atime when now > dir atime + atime_diff
3942 local d1=$(date +%s)
3944 local d2=$(date +%s)
3945 cancel_lru_locks mdc
3946 atime=$(stat -c %X $DIR/$tdir)
3947 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3948 error "atime is not updated : $atime, should be $d2"
3950 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3953 # test not setting directory atime when now < dir atime + atime_diff
3955 cancel_lru_locks mdc
3956 atime=$(stat -c %X $DIR/$tdir)
3957 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3958 error "atime is updated to $atime, should remain $d1<atime<$d2"
3960 do_facet $SINGLEMDS \
3961 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3963 run_test 39l "directory atime update ==========================="
3966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3970 local far_past_mtime=$(date -d "May 29 1953" +%s)
3971 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3973 touch -m -d @$far_past_mtime $DIR1/$tfile
3974 touch -a -d @$far_past_atime $DIR1/$tfile
3976 for (( i=0; i < 2; i++ )) ; do
3977 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3978 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3979 error "atime or mtime set incorrectly"
3981 cancel_lru_locks $OSC
3982 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3985 run_test 39m "test atime and mtime before 1970"
3987 test_39n() { # LU-3832
3988 remote_mds_nodsh && skip "remote MDS with nodsh"
3990 local atime_diff=$(do_facet $SINGLEMDS \
3991 lctl get_param -n mdd.*MDT0000*.atime_diff)
3996 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3999 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4000 atime0=$(stat -c %X $DIR/$tfile)
4003 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4004 atime1=$(stat -c %X $DIR/$tfile)
4007 cancel_lru_locks mdc
4008 cancel_lru_locks osc
4009 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4010 atime2=$(stat -c %X $DIR/$tfile)
4012 do_facet $SINGLEMDS \
4013 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4015 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4016 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4018 run_test 39n "check that O_NOATIME is honored"
4021 TESTDIR=$DIR/$tdir/$tfile
4022 [ -e $TESTDIR ] && rm -rf $TESTDIR
4029 links2=$(stat -c %h .)
4030 [ $(($links1 + 2)) != $links2 ] &&
4031 error "wrong links count $(($links1 + 2)) != $links2"
4033 links3=$(stat -c %h .)
4034 [ $(($links1 + 1)) != $links3 ] &&
4035 error "wrong links count $links1 != $links3"
4038 run_test 39o "directory cached attributes updated after create"
4041 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4044 TESTDIR=$DIR/$tdir/$tdir
4045 [ -e $TESTDIR ] && rm -rf $TESTDIR
4046 test_mkdir -p $TESTDIR
4050 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4051 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4053 links2=$(stat -c %h .)
4054 [ $(($links1 + 2)) != $links2 ] &&
4055 error "wrong links count $(($links1 + 2)) != $links2"
4057 links3=$(stat -c %h .)
4058 [ $(($links1 + 1)) != $links3 ] &&
4059 error "wrong links count $links1 != $links3"
4062 run_test 39p "remote directory cached attributes updated after create ========"
4065 test_39q() { # LU-8041
4066 local testdir=$DIR/$tdir
4068 multiop_bg_pause $testdir D_c || error "multiop failed"
4070 cancel_lru_locks mdc
4071 kill -USR1 $multipid
4072 local atime=$(stat -c %X $testdir)
4073 [ "$atime" -ne 0 ] || error "atime is zero"
4075 run_test 39q "close won't zero out atime"
4078 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4079 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4080 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4081 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4082 error "$tfile is not 4096 bytes in size"
4084 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4088 small_write $DIR/f41 18
4090 run_test 41 "test small file write + fstat ====================="
4092 count_ost_writes() {
4093 lctl get_param -n ${OSC}.*.stats |
4094 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4095 END { printf("%0.0f", writes) }'
4102 BG_DIRTY_RATIO_SAVE=10
4103 MAX_BG_DIRTY_RATIO=25
4107 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4108 # dirty_ratio, dirty_background_ratio
4109 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4110 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4111 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4112 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4114 # if file not here, we are a 2.4 kernel
4115 kill -CONT `pidof kupdated`
4120 # setup the trap first, so someone cannot exit the test at the
4121 # exact wrong time and mess up a machine
4122 trap start_writeback EXIT
4123 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4124 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4125 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4126 sysctl -w vm.dirty_writeback_centisecs=0
4127 sysctl -w vm.dirty_writeback_centisecs=0
4128 # save and increase /proc/sys/vm/dirty_ratio
4129 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4130 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4131 # save and increase /proc/sys/vm/dirty_background_ratio
4132 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4133 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4135 # if file not here, we are a 2.4 kernel
4136 kill -STOP `pidof kupdated`
4140 # ensure that all stripes have some grant before we test client-side cache
4142 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4143 dd if=/dev/zero of=$i bs=4k count=1
4148 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4149 # file truncation, and file removal.
4151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4154 cancel_lru_locks $OSC
4156 sync; sleep 1; sync # just to be safe
4157 BEFOREWRITES=`count_ost_writes`
4158 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4159 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4160 AFTERWRITES=`count_ost_writes`
4161 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4162 error "$BEFOREWRITES < $AFTERWRITES"
4165 run_test 42a "ensure that we don't flush on close"
4168 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4171 cancel_lru_locks $OSC
4174 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4175 BEFOREWRITES=$(count_ost_writes)
4176 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4177 AFTERWRITES=$(count_ost_writes)
4178 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4179 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4181 BEFOREWRITES=$(count_ost_writes)
4182 sync || error "sync: $?"
4183 AFTERWRITES=$(count_ost_writes)
4184 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4185 error "$BEFOREWRITES < $AFTERWRITES on sync"
4187 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4191 run_test 42b "test destroy of file with cached dirty data ======"
4193 # if these tests just want to test the effect of truncation,
4194 # they have to be very careful. consider:
4195 # - the first open gets a {0,EOF}PR lock
4196 # - the first write conflicts and gets a {0, count-1}PW
4197 # - the rest of the writes are under {count,EOF}PW
4198 # - the open for truncate tries to match a {0,EOF}PR
4199 # for the filesize and cancels the PWs.
4200 # any number of fixes (don't get {0,EOF} on open, match
4201 # composite locks, do smarter file size management) fix
4202 # this, but for now we want these tests to verify that
4203 # the cancellation with truncate intent works, so we
4204 # start the file with a full-file pw lock to match against
4205 # until the truncate.
4210 cancel_lru_locks $OSC
4212 # prime the file with 0,EOF PW to match
4216 # now the real test..
4217 dd if=/dev/zero of=$file bs=1024 count=100
4218 BEFOREWRITES=`count_ost_writes`
4219 $TRUNCATE $file $offset
4220 cancel_lru_locks $OSC
4221 AFTERWRITES=`count_ost_writes`
4226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4229 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4230 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4233 run_test 42c "test partial truncate of file with cached dirty data"
4236 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4239 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4240 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4243 run_test 42d "test complete truncate of file with cached dirty data"
4245 test_42e() { # bug22074
4246 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4248 local TDIR=$DIR/${tdir}e
4249 local pages=16 # hardcoded 16 pages, don't change it.
4250 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4251 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4255 test_mkdir $DIR/${tdir}e
4256 $SETSTRIPE -c 1 $TDIR
4257 createmany -o $TDIR/f $files
4259 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4261 # we assume that with $OSTCOUNT files, at least one of them will
4262 # be allocated on OST0.
4263 warmup_files=$((OSTCOUNT * max_dirty_mb))
4264 createmany -o $TDIR/w $warmup_files
4266 # write a large amount of data into one file and sync, to get good
4267 # avail_grant number from OST.
4268 for ((i=0; i<$warmup_files; i++)); do
4269 idx=$($GETSTRIPE -i $TDIR/w$i)
4270 [ $idx -ne 0 ] && continue
4271 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4274 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4276 $LCTL get_param $proc_osc0/cur_dirty_bytes
4277 $LCTL get_param $proc_osc0/cur_grant_bytes
4279 # create as much dirty pages as we can while not to trigger the actual
4280 # RPCs directly. but depends on the env, VFS may trigger flush during this
4281 # period, hopefully we are good.
4282 for ((i=0; i<$warmup_files; i++)); do
4283 idx=$($GETSTRIPE -i $TDIR/w$i)
4284 [ $idx -ne 0 ] && continue
4285 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4287 $LCTL get_param $proc_osc0/cur_dirty_bytes
4288 $LCTL get_param $proc_osc0/cur_grant_bytes
4290 # perform the real test
4291 $LCTL set_param $proc_osc0/rpc_stats 0
4292 for ((;i<$files; i++)); do
4293 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
4294 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4297 $LCTL get_param $proc_osc0/rpc_stats
4300 local have_ppr=false
4301 $LCTL get_param $proc_osc0/rpc_stats |
4302 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4303 # skip lines until we are at the RPC histogram data
4304 [ "$PPR" == "pages" ] && have_ppr=true && continue
4305 $have_ppr || continue
4307 # we only want the percent stat for < 16 pages
4308 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4310 percent=$((percent + WPCT))
4311 if [[ $percent -gt 15 ]]; then
4312 error "less than 16-pages write RPCs" \
4319 run_test 42e "verify sub-RPC writes are not done synchronously"
4321 test_43A() { # was test_43
4322 test_mkdir $DIR/$tdir
4323 cp -p /bin/ls $DIR/$tdir/$tfile
4324 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4326 # give multiop a chance to open
4329 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4332 run_test 43A "execution of file opened for write should return -ETXTBSY"
4335 test_mkdir $DIR/$tdir
4336 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4337 $DIR/$tdir/sleep 60 &
4339 # Make sure exec of $tdir/sleep wins race with truncate
4341 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4344 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4349 test_mkdir $DIR/$tdir
4350 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4351 $DIR/$tdir/sleep 60 &
4353 # Make sure exec of $tdir/sleep wins race with truncate
4355 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4358 run_test 43b "truncate of file being executed should return -ETXTBSY"
4361 local testdir="$DIR/$tdir"
4364 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4365 ( cd $testdir && md5sum -c )
4367 run_test 43c "md5sum of copy into lustre"
4369 test_44A() { # was test_44
4370 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4372 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4373 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4375 run_test 44A "zero length read from a sparse stripe"
4378 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4380 [ -z "$nstripe" ] && skip "can't get stripe info"
4381 [[ $nstripe -gt $OSTCOUNT ]] &&
4382 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4384 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4386 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4387 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4391 OFFSETS="0 $((stride/2)) $((stride-1))"
4392 for offset in $OFFSETS; do
4393 for i in $(seq 0 $((nstripe-1))); do
4394 local GLOBALOFFSETS=""
4396 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4397 local myfn=$DIR/d44a-$size
4398 echo "--------writing $myfn at $size"
4399 ll_sparseness_write $myfn $size ||
4400 error "ll_sparseness_write"
4401 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4402 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4403 error "ll_sparseness_verify $GLOBALOFFSETS"
4405 for j in $(seq 0 $((nstripe-1))); do
4407 size=$((((j + $nstripe )*$stride + $offset)))
4408 ll_sparseness_write $myfn $size ||
4409 error "ll_sparseness_write"
4410 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4412 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4413 error "ll_sparseness_verify $GLOBALOFFSETS"
4418 run_test 44a "test sparse pwrite ==============================="
4422 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4428 before=`dirty_osc_total`
4429 echo executing "\"$*\""
4431 after=`dirty_osc_total`
4432 echo before $before, after $after
4435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4438 # Obtain grants from OST if it supports it
4439 echo blah > ${f}_grant
4442 do_dirty_record "echo blah > $f"
4443 [[ $before -eq $after ]] && error "write wasn't cached"
4444 do_dirty_record "> $f"
4445 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4446 do_dirty_record "echo blah > $f"
4447 [[ $before -eq $after ]] && error "write wasn't cached"
4448 do_dirty_record "sync"
4449 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4450 do_dirty_record "echo blah > $f"
4451 [[ $before -eq $after ]] && error "write wasn't cached"
4452 do_dirty_record "cancel_lru_locks osc"
4453 [[ $before -gt $after ]] ||
4454 error "lock cancellation didn't lower dirty count"
4457 run_test 45 "osc io page accounting ============================"
4459 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4460 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4461 # objects offset and an assert hit when an rpc was built with 1023's mapped
4462 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4464 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4469 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4471 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4472 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4476 run_test 46 "dirtying a previously written page ================"
4478 # test_47 is removed "Device nodes check" is moved to test_28
4480 test_48a() { # bug 2399
4481 [ "$mds1_FSTYPE" = "zfs" ] &&
4482 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4483 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4485 test_mkdir $DIR/$tdir
4487 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4488 test_mkdir $DIR/$tdir
4489 touch foo || error "'touch foo' failed after recreating cwd"
4491 touch .foo || error "'touch .foo' failed after recreating cwd"
4493 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4494 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4495 cd . || error "'cd .' failed after recreating cwd"
4496 mkdir . && error "'mkdir .' worked after recreating cwd"
4497 rmdir . && error "'rmdir .' worked after recreating cwd"
4498 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4499 cd .. || error "'cd ..' failed after recreating cwd"
4501 run_test 48a "Access renamed working dir (should return errors)="
4503 test_48b() { # bug 2399
4505 test_mkdir $DIR/$tdir
4507 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4508 touch foo && error "'touch foo' worked after removing cwd"
4509 mkdir foo && error "'mkdir foo' worked after removing cwd"
4510 touch .foo && error "'touch .foo' worked after removing cwd"
4511 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4512 ls . > /dev/null && error "'ls .' worked after removing cwd"
4513 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4514 mkdir . && error "'mkdir .' worked after removing cwd"
4515 rmdir . && error "'rmdir .' worked after removing cwd"
4516 ln -s . foo && error "'ln -s .' worked after removing cwd"
4517 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4519 run_test 48b "Access removed working dir (should return errors)="
4521 test_48c() { # bug 2350
4522 #lctl set_param debug=-1
4525 test_mkdir -p $DIR/$tdir/dir
4527 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4528 $TRACE touch foo && error "touch foo worked after removing cwd"
4529 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4530 touch .foo && error "touch .foo worked after removing cwd"
4531 mkdir .foo && error "mkdir .foo worked after removing cwd"
4532 $TRACE ls . && error "'ls .' worked after removing cwd"
4533 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4534 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4535 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4536 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4537 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4539 run_test 48c "Access removed working subdir (should return errors)"
4541 test_48d() { # bug 2350
4542 #lctl set_param debug=-1
4545 test_mkdir -p $DIR/$tdir/dir
4547 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4548 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4549 $TRACE touch foo && error "'touch foo' worked after removing parent"
4550 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4551 touch .foo && error "'touch .foo' worked after removing parent"
4552 mkdir .foo && error "mkdir .foo worked after removing parent"
4553 $TRACE ls . && error "'ls .' worked after removing parent"
4554 $TRACE ls .. && error "'ls ..' worked after removing parent"
4555 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4556 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4557 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4560 run_test 48d "Access removed parent subdir (should return errors)"
4562 test_48e() { # bug 4134
4563 #lctl set_param debug=-1
4566 test_mkdir -p $DIR/$tdir/dir
4568 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4569 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4570 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4571 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4572 # On a buggy kernel addition of "touch foo" after cd .. will
4573 # produce kernel oops in lookup_hash_it
4574 touch ../foo && error "'cd ..' worked after recreate parent"
4576 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4578 run_test 48e "Access to recreated parent subdir (should return errors)"
4580 test_49() { # LU-1030
4581 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4582 remote_ost_nodsh && skip "remote OST with nodsh"
4584 # get ost1 size - lustre-OST0000
4585 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4587 # write 800M at maximum
4588 [[ $ost1_size -lt 2 ]] && ost1_size=2
4589 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4591 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4592 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4595 # change max_pages_per_rpc while writing the file
4596 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4597 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4598 # loop until dd process exits
4599 while ps ax -opid | grep -wq $dd_pid; do
4600 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4601 sleep $((RANDOM % 5 + 1))
4603 # restore original max_pages_per_rpc
4604 $LCTL set_param $osc1_mppc=$orig_mppc
4605 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4607 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4611 test_mkdir $DIR/$tdir
4613 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4615 run_test 50 "special situations: /proc symlinks ==============="
4617 test_51a() { # was test_51
4618 # bug 1516 - create an empty entry right after ".." then split dir
4619 test_mkdir -c1 $DIR/$tdir
4620 touch $DIR/$tdir/foo
4621 $MCREATE $DIR/$tdir/bar
4623 createmany -m $DIR/$tdir/longfile 201
4625 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4626 $MCREATE $DIR/$tdir/longfile$FNUM
4631 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4633 run_test 51a "special situations: split htree with empty entry =="
4635 cleanup_print_lfs_df () {
4642 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4644 local dir=$DIR/$tdir
4645 local nrdirs=$((65536 + 100))
4647 # cleanup the directory
4654 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4655 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4656 [[ $numfree -lt $nrdirs ]] &&
4657 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4659 # need to check free space for the directories as well
4660 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4661 numfree=$(( blkfree / $(fs_inode_ksize) ))
4662 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4664 trap cleanup_print_lfs_df EXIT
4667 createmany -d $dir/d $nrdirs || {
4668 unlinkmany $dir/d $nrdirs
4669 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4673 nrdirs=$(ls -U $dir | wc -l)
4675 # unlink all but 100 subdirectories, then check it still works
4677 local delete=$((nrdirs - left))
4682 # for ldiskfs the nlink count should be 1, but this is OSD specific
4683 # and so this is listed for informational purposes only
4684 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4685 unlinkmany -d $dir/d $delete ||
4686 error "unlink of first $delete subdirs failed"
4688 echo "nlink between: $(stat -c %h $dir)"
4689 local found=$(ls -U $dir | wc -l)
4690 [ $found -ne $left ] &&
4691 error "can't find subdirs: found only $found, expected $left"
4693 unlinkmany -d $dir/d $delete $left ||
4694 error "unlink of second $left subdirs failed"
4695 # regardless of whether the backing filesystem tracks nlink accurately
4696 # or not, the nlink count shouldn't be more than "." and ".." here
4697 local after=$(stat -c %h $dir)
4698 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4699 echo "nlink after: $after"
4701 cleanup_print_lfs_df
4703 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4706 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4707 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4709 test_mkdir $DIR/$tdir
4710 createmany -o $DIR/$tdir/t- 1000
4711 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4712 for N in $(seq 0 $((OSTCOUNT - 1))); do
4713 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4714 END { printf("%0.0f", objs) }' $TMP/$tfile)
4715 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4716 '($1 == '$N') { objs += 1 } \
4717 END { printf("%0.0f", objs) }')
4718 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4720 unlinkmany $DIR/$tdir/t- 1000
4723 for N in $(seq 1 $((OSTCOUNT - 1))); do
4724 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4725 error "OST $N has less objects vs OST $NLAST" \
4726 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4727 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4728 error "OST $N has less objects vs OST $NLAST" \
4729 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4731 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4732 error "OST $N has less #0 objects vs OST $NLAST" \
4733 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4734 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4735 error "OST $N has less #0 objects vs OST $NLAST" \
4736 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4741 run_test 51d "check object distribution"
4744 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4745 skip_env "ldiskfs only test"
4748 test_mkdir -c1 $DIR/$tdir
4749 test_mkdir -c1 $DIR/$tdir/d0
4751 touch $DIR/$tdir/d0/foo
4752 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4753 error "file exceed 65000 nlink limit!"
4754 unlinkmany $DIR/$tdir/d0/f- 65001
4757 run_test 51e "check file nlink limit"
4760 test_mkdir $DIR/$tdir
4763 local ulimit_old=$(ulimit -n)
4764 local spare=20 # number of spare fd's for scripts/libraries, etc.
4765 local mdt=$($LFS getstripe -m $DIR/$tdir)
4766 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4768 echo "MDT$mdt numfree=$numfree, max=$max"
4769 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4770 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4771 while ! ulimit -n $((numfree + spare)); do
4772 numfree=$((numfree * 3 / 4))
4774 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4776 echo "left ulimit at $ulimit_old"
4779 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4780 unlinkmany $DIR/$tdir/f $numfree
4781 error "create+open $numfree files in $DIR/$tdir failed"
4783 ulimit -n $ulimit_old
4785 # if createmany exits at 120s there will be fewer than $numfree files
4786 unlinkmany $DIR/$tdir/f $numfree || true
4788 run_test 51f "check many open files limit"
4791 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4792 test_mkdir $DIR/$tdir
4793 touch $DIR/$tdir/foo
4794 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4795 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4796 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4797 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4798 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4800 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4801 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4802 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4804 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4805 cp -r $DIR/$tdir $TMP/
4806 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4808 run_test 52a "append-only flag test (should return errors)"
4811 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4812 test_mkdir $DIR/$tdir
4813 touch $DIR/$tdir/foo
4814 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4815 cat test > $DIR/$tdir/foo && error "cat test worked"
4816 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4817 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4818 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4820 echo foo >> $DIR/$tdir/foo && error "echo worked"
4821 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4822 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4823 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4824 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4826 chattr -i $DIR/$tdir/foo || error "chattr failed"
4828 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4830 run_test 52b "immutable flag test (should return errors) ======="
4833 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4834 remote_mds_nodsh && skip "remote MDS with nodsh"
4835 remote_ost_nodsh && skip "remote OST with nodsh"
4848 local support_last_seq=true
4850 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
4851 support_last_seq=false
4854 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4856 for value in $(do_facet $SINGLEMDS \
4857 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
4858 param=$(echo ${value[0]} | cut -d "=" -f1)
4859 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4861 if $support_last_seq; then
4862 param_seq=$(echo $param |
4863 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4864 mds_last_seq=$(do_facet $SINGLEMDS \
4865 $LCTL get_param -n $param_seq)
4867 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4869 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4870 node=$(facet_active_host ost$((ostnum+1)))
4871 param="obdfilter.$ostname.last_id"
4872 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4873 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4874 ost_last_id=$ost_last
4876 if $support_last_seq; then
4877 ost_last_id=$(echo $ost_last |
4878 awk -F':' '{print $2}' |
4880 ost_last_seq=$(echo $ost_last |
4881 awk -F':' '{print $1}')
4882 [[ $ost_last_seq = $mds_last_seq ]] || continue
4885 if [[ $ost_last_id != $mds_last ]]; then
4886 error "$ost_last_id != $mds_last"
4893 $found || error "can not match last_seq/last_id for $mdtosc"
4896 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4899 perl -MSocket -e ';' || skip "no Socket perl module installed"
4901 $SOCKETSERVER $DIR/socket ||
4902 error "$SOCKETSERVER $DIR/socket failed: $?"
4903 $SOCKETCLIENT $DIR/socket ||
4904 error "$SOCKETCLIENT $DIR/socket failed: $?"
4905 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4907 run_test 54a "unix domain socket test =========================="
4913 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
4915 run_test 54b "char device works in lustre ======================"
4918 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4919 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4920 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4922 for i in $(seq 3 7); do
4923 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4932 loopdev="$DIR/loop54c"
4935 $UMOUNT $DIR/$tdir || rc=$?
4936 losetup -d $loopdev || true
4937 losetup -d $LOOPDEV || true
4938 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4945 loopdev="$DIR/loop54c"
4948 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
4949 trap cleanup_54c EXIT
4950 mknod $loopdev b 7 $LOOPNUM
4951 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4952 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
4953 losetup $loopdev $DIR/$tfile ||
4954 error "can't set up $loopdev for $DIR/$tfile"
4955 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4956 test_mkdir $DIR/$tdir
4957 mount -t ext2 $loopdev $DIR/$tdir ||
4958 error "error mounting $loopdev on $DIR/$tdir"
4959 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
4962 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
4966 run_test 54c "block device works in lustre ====================="
4972 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4974 run_test 54d "fifo device works in lustre ======================"
4979 cp -aL /dev/console $f
4980 echo $string > $f || error "echo $string to $f failed"
4982 run_test 54e "console/tty device works in lustre ======================"
4986 local dir=$DIR/$tdir
4989 test_mkdir -p $dir/dir
4990 for i in $(seq $numfiles); do
4992 touch $dir/dir/file$i
4995 local numcomp=$($LFS getstripe --component-count $dir)
4997 [[ $numcomp == 0 ]] && numcomp=1
4999 # test lfs getstripe with --recursive
5000 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5002 [[ $filenum -eq $((numfiles * 2)) ]] ||
5003 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5004 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5005 [[ $filenum -eq $numfiles ]] ||
5006 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5007 echo "$LFS getstripe showed obdidx or l_ost_idx"
5009 # test lfs getstripe with file instead of dir
5010 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5011 [[ $filenum -eq 1 ]] ||
5012 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5013 echo "$LFS getstripe file1 passed"
5015 #test lfs getstripe with --verbose
5016 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5017 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5018 error "$LFS getstripe --verbose $dir: "\
5019 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5020 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5021 error "$LFS getstripe $dir: showed lmm_magic"
5023 #test lfs getstripe with -v prints lmm_fid
5024 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5025 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5026 error "$LFS getstripe -v $dir: "\
5027 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5028 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5029 error "$LFS getstripe $dir: showed lmm_fid by default"
5030 echo "$LFS getstripe --verbose passed"
5032 #check for FID information
5033 local fid1=$($LFS getstripe --fid $dir/file1)
5034 local fid2=$($LFS getstripe --verbose $dir/file1 |
5035 awk '/lmm_fid: / { print $2; exit; }')
5036 local fid3=$($LFS path2fid $dir/file1)
5038 [ "$fid1" != "$fid2" ] &&
5039 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5040 [ "$fid1" != "$fid3" ] &&
5041 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5042 echo "$LFS getstripe --fid passed"
5044 #test lfs getstripe with --obd
5045 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5046 error "$LFS getstripe --obd wrong_uuid: should return error"
5048 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5051 local obduuid=$(ostuuid_from_index $ostidx)
5052 local found=$($LFS getstripe -r --obd $obduuid $dir |
5053 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5055 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5056 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5058 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5061 [[ $found -eq $filenum ]] ||
5062 error "$LFS getstripe --obd: found $found expect $filenum"
5063 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5064 sed '/^[ ]*'${ostidx}'[ ]/d' |
5065 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5066 error "$LFS getstripe --obd: should not show file on other obd"
5067 echo "$LFS getstripe --obd passed"
5069 run_test 56a "check $LFS getstripe"
5072 local dir=$DIR/$tdir
5076 for i in $(seq $numdirs); do
5077 test_mkdir $dir/dir$i
5080 # test lfs getdirstripe default mode is non-recursion, which is
5081 # different from lfs getstripe
5082 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5084 [[ $dircnt -eq 1 ]] ||
5085 error "$LFS getdirstripe: found $dircnt, not 1"
5086 dircnt=$($LFS getdirstripe --recursive $dir |
5087 grep -c lmv_stripe_count)
5088 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5089 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5091 run_test 56b "check $LFS getdirstripe"
5094 remote_ost_nodsh && skip "remote OST with nodsh"
5097 local ost_name=$(ostname_from_index $ost_idx)
5098 local old_status=$(ost_dev_status $ost_idx)
5100 [[ -z "$old_status" ]] ||
5101 skip_env "OST $ost_name is in $old_status status"
5103 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5104 [[ $OST1_VERSION -ge $(version_code 2.12.3) ]] && do_facet ost1 \
5105 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
5108 local new_status=$(ost_dev_status $ost_idx)
5110 [[ "$new_status" =~ "D" ]] ||
5111 error "$ost_name status is '$new_status', missing 'D'"
5112 if [[ $OST1_VERSION -ge $(version_code 2.12.3) ]]; then
5113 [[ "$new_status" =~ "N" ]] ||
5114 error "$ost_name status is '$new_status', missing 'N'"
5117 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5118 [[ $OST1_VERSION -ge $(version_code 2.12.3) ]] && do_facet ost1 \
5119 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
5122 new_status=$(ost_dev_status $ost_idx)
5123 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
5124 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
5126 run_test 56c "check 'lfs df' showing device status"
5131 local local_tdir="$1"
5132 local local_numfiles="$2"
5133 local local_numdirs="$3"
5134 local dir_params="$4"
5135 local dir_stripe_params="$5"
5137 if [ ! -d "$local_tdir" ] ; then
5138 test_mkdir -p $dir_stripe_params $local_tdir
5139 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5140 for i in $(seq $local_numfiles) ; do
5141 touch $local_tdir/file$i
5143 for i in $(seq $local_numdirs) ; do
5144 test_mkdir $dir_stripe_params $local_tdir/dir$i
5145 for j in $(seq $local_numfiles) ; do
5146 touch $local_tdir/dir$i/file$j
5152 setup_56_special() {
5154 local local_numfiles=$2
5155 local local_numdirs=$3
5157 setup_56 $local_tdir $local_numfiles $local_numdirs
5159 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5160 for i in $(seq $local_numfiles) ; do
5161 mknod $local_tdir/loop${i}b b 7 $i
5162 mknod $local_tdir/null${i}c c 1 3
5163 ln -s $local_tdir/file1 $local_tdir/link${i}
5165 for i in $(seq $local_numdirs) ; do
5166 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5167 mknod $local_tdir/dir$i/null${i}c c 1 3
5168 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5174 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5175 local expected=$(($NUMDIRS + 2))
5177 setup_56 $dir $NUMFILES $NUMDIRS
5179 # test lfs find with -name
5180 for i in $(seq $NUMFILES) ; do
5181 local nums=$($LFS find -name "*$i" $dir | wc -l)
5183 [ $nums -eq $expected ] ||
5184 error "lfs find -name '*$i' $dir wrong: "\
5185 "found $nums, expected $expected"
5188 run_test 56g "check lfs find -name"
5191 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5192 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5194 setup_56 $dir $NUMFILES $NUMDIRS
5196 # test lfs find with ! -name
5197 for i in $(seq $NUMFILES) ; do
5198 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5200 [ $nums -eq $expected ] ||
5201 error "lfs find ! -name '*$i' $dir wrong: "\
5202 "found $nums, expected $expected"
5205 run_test 56h "check lfs find ! -name"
5208 local dir=$DIR/$tdir
5212 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5215 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5217 run_test 56i "check 'lfs find -ost UUID' skips directories"
5220 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5222 setup_56_special $dir $NUMFILES $NUMDIRS
5224 local expected=$((NUMDIRS + 1))
5225 local cmd="$LFS find -type d $dir"
5226 local nums=$($cmd | wc -l)
5228 [ $nums -eq $expected ] ||
5229 error "'$cmd' wrong: found $nums, expected $expected"
5231 run_test 56j "check lfs find -type d"
5234 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5236 setup_56_special $dir $NUMFILES $NUMDIRS
5238 local expected=$(((NUMDIRS + 1) * NUMFILES))
5239 local cmd="$LFS find -type f $dir"
5240 local nums=$($cmd | wc -l)
5242 [ $nums -eq $expected ] ||
5243 error "'$cmd' wrong: found $nums, expected $expected"
5245 run_test 56k "check lfs find -type f"
5248 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5250 setup_56_special $dir $NUMFILES $NUMDIRS
5252 local expected=$((NUMDIRS + NUMFILES))
5253 local cmd="$LFS find -type b $dir"
5254 local nums=$($cmd | wc -l)
5256 [ $nums -eq $expected ] ||
5257 error "'$cmd' wrong: found $nums, expected $expected"
5259 run_test 56l "check lfs find -type b"
5262 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5264 setup_56_special $dir $NUMFILES $NUMDIRS
5266 local expected=$((NUMDIRS + NUMFILES))
5267 local cmd="$LFS find -type c $dir"
5268 local nums=$($cmd | wc -l)
5269 [ $nums -eq $expected ] ||
5270 error "'$cmd' wrong: found $nums, expected $expected"
5272 run_test 56m "check lfs find -type c"
5275 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5276 setup_56_special $dir $NUMFILES $NUMDIRS
5278 local expected=$((NUMDIRS + NUMFILES))
5279 local cmd="$LFS find -type l $dir"
5280 local nums=$($cmd | wc -l)
5282 [ $nums -eq $expected ] ||
5283 error "'$cmd' wrong: found $nums, expected $expected"
5285 run_test 56n "check lfs find -type l"
5288 local dir=$DIR/$tdir
5290 setup_56 $dir $NUMFILES $NUMDIRS
5291 utime $dir/file1 > /dev/null || error "utime (1)"
5292 utime $dir/file2 > /dev/null || error "utime (2)"
5293 utime $dir/dir1 > /dev/null || error "utime (3)"
5294 utime $dir/dir2 > /dev/null || error "utime (4)"
5295 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5296 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5299 local nums=$($LFS find -mtime +0 $dir | wc -l)
5301 [ $nums -eq $expected ] ||
5302 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5305 cmd="$LFS find -mtime 0 $dir"
5306 nums=$($cmd | wc -l)
5307 [ $nums -eq $expected ] ||
5308 error "'$cmd' wrong: found $nums, expected $expected"
5310 run_test 56o "check lfs find -mtime for old files"
5313 [ $RUNAS_ID -eq $UID ] &&
5314 skip_env "RUNAS_ID = UID = $UID -- skipping"
5316 local dir=$DIR/$tdir
5318 setup_56 $dir $NUMFILES $NUMDIRS
5319 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5321 local expected=$NUMFILES
5322 local cmd="$LFS find -uid $RUNAS_ID $dir"
5323 local nums=$($cmd | wc -l)
5325 [ $nums -eq $expected ] ||
5326 error "'$cmd' wrong: found $nums, expected $expected"
5328 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5329 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5330 nums=$($cmd | wc -l)
5331 [ $nums -eq $expected ] ||
5332 error "'$cmd' wrong: found $nums, expected $expected"
5334 run_test 56p "check lfs find -uid and ! -uid"
5337 [ $RUNAS_ID -eq $UID ] &&
5338 skip_env "RUNAS_ID = UID = $UID -- skipping"
5340 local dir=$DIR/$tdir
5342 setup_56 $dir $NUMFILES $NUMDIRS
5343 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5345 local expected=$NUMFILES
5346 local cmd="$LFS find -gid $RUNAS_GID $dir"
5347 local nums=$($cmd | wc -l)
5349 [ $nums -eq $expected ] ||
5350 error "'$cmd' wrong: found $nums, expected $expected"
5352 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5353 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5354 nums=$($cmd | wc -l)
5355 [ $nums -eq $expected ] ||
5356 error "'$cmd' wrong: found $nums, expected $expected"
5358 run_test 56q "check lfs find -gid and ! -gid"
5361 local dir=$DIR/$tdir
5363 setup_56 $dir $NUMFILES $NUMDIRS
5366 local cmd="$LFS find -size 0 -type f -lazy $dir"
5367 local nums=$($cmd | wc -l)
5369 [ $nums -eq $expected ] ||
5370 error "'$cmd' wrong: found $nums, expected $expected"
5371 cmd="$LFS find -size 0 -type f $dir"
5372 nums=$($cmd | wc -l)
5373 [ $nums -eq $expected ] ||
5374 error "'$cmd' wrong: found $nums, expected $expected"
5377 cmd="$LFS find ! -size 0 -type f -lazy $dir"
5378 nums=$($cmd | wc -l)
5379 [ $nums -eq $expected ] ||
5380 error "'$cmd' wrong: found $nums, expected $expected"
5381 cmd="$LFS find ! -size 0 -type f $dir"
5382 nums=$($cmd | wc -l)
5383 [ $nums -eq $expected ] ||
5384 error "'$cmd' wrong: found $nums, expected $expected"
5386 echo "test" > $dir/$tfile
5387 echo "test2" > $dir/$tfile.2 && sync
5389 cmd="$LFS find -size 5 -type f -lazy $dir"
5390 nums=$($cmd | wc -l)
5391 [ $nums -eq $expected ] ||
5392 error "'$cmd' wrong: found $nums, expected $expected"
5393 cmd="$LFS find -size 5 -type f $dir"
5394 nums=$($cmd | wc -l)
5395 [ $nums -eq $expected ] ||
5396 error "'$cmd' wrong: found $nums, expected $expected"
5399 cmd="$LFS find -size +5 -type f -lazy $dir"
5400 nums=$($cmd | wc -l)
5401 [ $nums -eq $expected ] ||
5402 error "'$cmd' wrong: found $nums, expected $expected"
5403 cmd="$LFS find -size +5 -type f $dir"
5404 nums=$($cmd | wc -l)
5405 [ $nums -eq $expected ] ||
5406 error "'$cmd' wrong: found $nums, expected $expected"
5409 cmd="$LFS find -size +0 -type f -lazy $dir"
5410 nums=$($cmd | wc -l)
5411 [ $nums -eq $expected ] ||
5412 error "'$cmd' wrong: found $nums, expected $expected"
5413 cmd="$LFS find -size +0 -type f $dir"
5414 nums=$($cmd | wc -l)
5415 [ $nums -eq $expected ] ||
5416 error "'$cmd' wrong: found $nums, expected $expected"
5419 cmd="$LFS find ! -size -5 -type f -lazy $dir"
5420 nums=$($cmd | wc -l)
5421 [ $nums -eq $expected ] ||
5422 error "'$cmd' wrong: found $nums, expected $expected"
5423 cmd="$LFS find ! -size -5 -type f $dir"
5424 nums=$($cmd | wc -l)
5425 [ $nums -eq $expected ] ||
5426 error "'$cmd' wrong: found $nums, expected $expected"
5429 cmd="$LFS find -size -5 -type f -lazy $dir"
5430 nums=$($cmd | wc -l)
5431 [ $nums -eq $expected ] ||
5432 error "'$cmd' wrong: found $nums, expected $expected"
5433 cmd="$LFS find -size -5 -type f $dir"
5434 nums=$($cmd | wc -l)
5435 [ $nums -eq $expected ] ||
5436 error "'$cmd' wrong: found $nums, expected $expected"
5438 run_test 56r "check lfs find -size works"
5445 cancel_lru_locks $OSC
5447 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5448 local nums=$($cmd | wc -l)
5450 [ $nums -eq $expected ] ||
5451 error "'$cmd' wrong: found $nums, expected $expected"
5453 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5455 if (( rpcs_before + glimpses != rpcs_after )); then
5456 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5457 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
5459 if [[ $glimpses == 0 ]]; then
5460 error "'$cmd' should not send glimpse RPCs to OST"
5462 error "'$cmd' should send $glimpses glimpse RPCs to OST"
5468 [[ $MDS1_VERSION -ge $(version_code 2.12.4) ]] ||
5469 skip "MDS < 2.12.4 doesn't return LSOM data"
5470 local dir=$DIR/$tdir
5472 [[ $OSC == "mdc" ]] && skip "DoM files"
5474 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5475 # open and close all files to ensure LSOM is updated
5476 cancel_lru_locks $OSC
5477 find $dir -type f | xargs cat > /dev/null
5479 # expect_found glimpse_rpcs command_to_run
5480 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
5481 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
5482 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
5483 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
5485 echo "test" > $dir/$tfile
5486 echo "test2" > $dir/$tfile.2 && sync
5487 cancel_lru_locks $OSC
5488 cat $dir/$tfile $dir/$tfile.2 > /dev/null
5490 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
5491 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
5492 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
5493 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
5495 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
5496 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
5497 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
5498 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
5499 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
5500 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
5502 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
5504 test_56s() { # LU-611 #LU-9369
5505 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5507 local dir=$DIR/$tdir
5508 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5510 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5511 for i in $(seq $NUMDIRS); do
5512 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5515 local expected=$NUMDIRS
5516 local cmd="$LFS find -c $OSTCOUNT $dir"
5517 local nums=$($cmd | wc -l)
5519 [ $nums -eq $expected ] || {
5520 $LFS getstripe -R $dir
5521 error "'$cmd' wrong: found $nums, expected $expected"
5524 expected=$((NUMDIRS + onestripe))
5525 cmd="$LFS find -stripe-count +0 -type f $dir"
5526 nums=$($cmd | wc -l)
5527 [ $nums -eq $expected ] || {
5528 $LFS getstripe -R $dir
5529 error "'$cmd' wrong: found $nums, expected $expected"
5533 cmd="$LFS find -stripe-count 1 -type f $dir"
5534 nums=$($cmd | wc -l)
5535 [ $nums -eq $expected ] || {
5536 $LFS getstripe -R $dir
5537 error "'$cmd' wrong: found $nums, expected $expected"
5540 cmd="$LFS find -stripe-count -2 -type f $dir"
5541 nums=$($cmd | wc -l)
5542 [ $nums -eq $expected ] || {
5543 $LFS getstripe -R $dir
5544 error "'$cmd' wrong: found $nums, expected $expected"
5548 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5549 nums=$($cmd | wc -l)
5550 [ $nums -eq $expected ] || {
5551 $LFS getstripe -R $dir
5552 error "'$cmd' wrong: found $nums, expected $expected"
5555 run_test 56s "check lfs find -stripe-count works"
5557 test_56t() { # LU-611 #LU-9369
5558 local dir=$DIR/$tdir
5560 setup_56 $dir 0 $NUMDIRS
5561 for i in $(seq $NUMDIRS); do
5562 $LFS setstripe -S 8M $dir/dir$i/$tfile
5565 local expected=$NUMDIRS
5566 local cmd="$LFS find -S 8M $dir"
5567 local nums=$($cmd | wc -l)
5569 [ $nums -eq $expected ] || {
5570 $LFS getstripe -R $dir
5571 error "'$cmd' wrong: found $nums, expected $expected"
5575 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5577 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5579 expected=$(((NUMDIRS + 1) * NUMFILES))
5580 cmd="$LFS find -stripe-size 512k -type f $dir"
5581 nums=$($cmd | wc -l)
5582 [ $nums -eq $expected ] ||
5583 error "'$cmd' wrong: found $nums, expected $expected"
5585 cmd="$LFS find -stripe-size +320k -type f $dir"
5586 nums=$($cmd | wc -l)
5587 [ $nums -eq $expected ] ||
5588 error "'$cmd' wrong: found $nums, expected $expected"
5590 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5591 cmd="$LFS find -stripe-size +200k -type f $dir"
5592 nums=$($cmd | wc -l)
5593 [ $nums -eq $expected ] ||
5594 error "'$cmd' wrong: found $nums, expected $expected"
5596 cmd="$LFS find -stripe-size -640k -type f $dir"
5597 nums=$($cmd | wc -l)
5598 [ $nums -eq $expected ] ||
5599 error "'$cmd' wrong: found $nums, expected $expected"
5602 cmd="$LFS find -stripe-size 256k -type f $dir"
5603 nums=$($cmd | wc -l)
5604 [ $nums -eq $expected ] ||
5605 error "'$cmd' wrong: found $nums, expected $expected"
5607 cmd="$LFS find -stripe-size -320k -type f $dir"
5608 nums=$($cmd | wc -l)
5609 [ $nums -eq $expected ] ||
5610 error "'$cmd' wrong: found $nums, expected $expected"
5613 cmd="$LFS find -stripe-size 1024k -type f $dir"
5614 nums=$($cmd | wc -l)
5615 [ $nums -eq $expected ] ||
5616 error "'$cmd' wrong: found $nums, expected $expected"
5618 run_test 56t "check lfs find -stripe-size works"
5620 test_56u() { # LU-611
5621 local dir=$DIR/$tdir
5623 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5625 if [[ $OSTCOUNT -gt 1 ]]; then
5626 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5632 local expected=$(((NUMDIRS + 1) * NUMFILES))
5633 local cmd="$LFS find -stripe-index 0 -type f $dir"
5634 local nums=$($cmd | wc -l)
5636 [ $nums -eq $expected ] ||
5637 error "'$cmd' wrong: found $nums, expected $expected"
5640 cmd="$LFS find -stripe-index 1 -type f $dir"
5641 nums=$($cmd | wc -l)
5642 [ $nums -eq $expected ] ||
5643 error "'$cmd' wrong: found $nums, expected $expected"
5645 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5646 nums=$($cmd | wc -l)
5647 [ $nums -eq $expected ] ||
5648 error "'$cmd' wrong: found $nums, expected $expected"
5651 # This should produce an error and not return any files
5652 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5653 nums=$($cmd 2>/dev/null | wc -l)
5654 [ $nums -eq $expected ] ||
5655 error "'$cmd' wrong: found $nums, expected $expected"
5657 if [[ $OSTCOUNT -gt 1 ]]; then
5658 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5659 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5660 nums=$($cmd | wc -l)
5661 [ $nums -eq $expected ] ||
5662 error "'$cmd' wrong: found $nums, expected $expected"
5665 run_test 56u "check lfs find -stripe-index works"
5669 local dir=$DIR/$tdir
5671 setup_56 $dir $NUMFILES $NUMDIRS
5673 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5674 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5676 for file in $($LFS find -m $UUID $dir); do
5677 file_midx=$($LFS getstripe -m $file)
5678 [ $file_midx -eq $mdt_idx ] ||
5679 error "lfs find -m $UUID != getstripe -m $file_midx"
5682 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5685 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5686 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5688 local dir=$DIR/$tdir
5690 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5692 local stripe_size=$($LFS getstripe -S -d $dir) ||
5693 error "$LFS getstripe -S -d $dir failed"
5694 stripe_size=${stripe_size%% *}
5696 local file_size=$((stripe_size * OSTCOUNT))
5697 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5698 local required_space=$((file_num * file_size))
5699 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5701 [[ $free_space -le $((required_space / 1024)) ]] &&
5702 skip_env "need $required_space, have $free_space kbytes"
5705 local dd_count=$((file_size / dd_bs))
5707 # write data into the files
5712 for i in $(seq $NUMFILES); do
5714 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5715 error "write data into $file failed"
5717 for i in $(seq $NUMDIRS); do
5718 for j in $(seq $NUMFILES); do
5719 file=$dir/dir$i/file$j
5720 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5721 error "write data into $file failed"
5725 # $LFS_MIGRATE will fail if hard link migration is unsupported
5726 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5727 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5728 error "creating links to $dir/dir1/file1 failed"
5733 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5736 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5739 eval $cmd || error "$cmd failed"
5741 check_stripe_count $dir/file1 $expected
5743 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
5745 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5746 # OST 1 if it is on OST 0. This file is small enough to
5747 # be on only one stripe.
5748 file=$dir/migr_1_ost
5749 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5750 error "write data into $file failed"
5751 local obdidx=$($LFS getstripe -i $file)
5752 local oldmd5=$(md5sum $file)
5755 [[ $obdidx -eq 0 ]] && newobdidx=1
5756 cmd="$LFS migrate -i $newobdidx $file"
5758 eval $cmd || error "$cmd failed"
5760 local realobdix=$($LFS getstripe -i $file)
5761 local newmd5=$(md5sum $file)
5763 [[ $newobdidx -ne $realobdix ]] &&
5764 error "new OST is different (was=$obdidx, "\
5765 "wanted=$newobdidx, got=$realobdix)"
5766 [[ "$oldmd5" != "$newmd5" ]] &&
5767 error "md5sum differ: $oldmd5, $newmd5"
5771 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5773 eval $cmd || error "$cmd failed"
5775 for j in $(seq $NUMFILES); do
5776 check_stripe_count $dir/dir1/file$j $expected
5779 # lfs_migrate works with lfs find
5780 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5781 $LFS_MIGRATE -y -c $expected"
5783 eval $cmd || error "$cmd failed"
5785 for i in $(seq 2 $NUMFILES); do
5786 check_stripe_count $dir/file$i $expected
5788 for i in $(seq 2 $NUMDIRS); do
5789 for j in $(seq $NUMFILES); do
5790 check_stripe_count $dir/dir$i/file$j $expected
5794 run_test 56w "check lfs_migrate -c stripe_count works"
5797 local file1=$DIR/$tdir/file1
5798 local create_pool=false
5799 local initial_pool=$($LFS getstripe -p $DIR)
5803 echo -n "Creating test dir..."
5804 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5807 echo -n "Creating test file..."
5808 touch $file1 || error "cannot create file"
5811 echo -n "Detecting existing pools..."
5812 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5814 if [ ${#pool_list[@]} -gt 0 ]; then
5815 echo "${pool_list[@]}"
5816 for thispool in "${pool_list[@]}"; do
5817 if [[ -z "$initial_pool" ||
5818 "$initial_pool" != "$thispool" ]]; then
5820 echo "Using existing pool '$pool'"
5825 echo "none detected."
5827 if [ -z "$pool" ]; then
5828 pool=${POOL:-testpool}
5829 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5830 echo -n "Creating pool '$pool'..."
5832 pool_add $pool &> /dev/null ||
5833 error "pool_add failed"
5836 echo -n "Adding target to pool..."
5837 pool_add_targets $pool 0 0 1 &> /dev/null ||
5838 error "pool_add_targets failed"
5842 echo -n "Setting pool using -p option..."
5843 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5844 error "migrate failed rc = $?"
5847 echo -n "Verifying test file is in pool after migrating..."
5848 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5849 error "file was not migrated to pool $pool"
5852 echo -n "Removing test file from pool '$pool'..."
5853 # "lfs migrate $file" won't remove the file from the pool
5854 # until some striping information is changed.
5855 $LFS migrate -c 1 $file1 &> /dev/null ||
5856 error "cannot remove from pool"
5857 [ "$($LFS getstripe -p $file1)" ] &&
5858 error "pool still set"
5861 echo -n "Setting pool using --pool option..."
5862 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5863 error "migrate failed rc = $?"
5868 if $create_pool; then
5869 destroy_test_pools 2> /dev/null ||
5870 error "destroy test pools failed"
5873 run_test 56wb "check lfs_migrate pool support"
5876 local file1="$DIR/$tdir/file1"
5883 echo -n "Creating test dir..."
5884 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5885 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5886 error "cannot set stripe by '-S 1M -c 1'"
5889 echo -n "Setting initial stripe for test file..."
5890 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5891 error "cannot set stripe"
5892 cur_ssize=$($LFS getstripe -S "$file1")
5893 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
5896 # File currently set to -S 512K -c 1
5898 # Ensure -c and -S options are rejected when -R is set
5899 echo -n "Verifying incompatible options are detected..."
5900 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5901 error "incompatible -c and -R options not detected"
5902 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5903 error "incompatible -S and -R options not detected"
5906 # Ensure unrecognized options are passed through to 'lfs migrate'
5907 echo -n "Verifying -S option is passed through to lfs migrate..."
5908 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5909 error "migration failed"
5910 cur_ssize=$($LFS getstripe -S "$file1")
5911 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
5914 # File currently set to -S 1M -c 1
5916 # Ensure long options are supported
5917 echo -n "Verifying long options supported..."
5918 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5919 error "long option without argument not supported"
5920 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5921 error "long option with argument not supported"
5922 cur_ssize=$($LFS getstripe -S "$file1")
5923 [ $cur_ssize -eq 524288 ] ||
5924 error "migrate --stripe-size $cur_ssize != 524288"
5927 # File currently set to -S 512K -c 1
5929 if [ "$OSTCOUNT" -gt 1 ]; then
5930 echo -n "Verifying explicit stripe count can be set..."
5931 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5932 error "migrate failed"
5933 cur_scount=$($LFS getstripe -c "$file1")
5934 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
5938 # File currently set to -S 512K -c 1 or -S 512K -c 2
5940 # Ensure parent striping is used if -R is set, and no stripe
5941 # count or size is specified
5942 echo -n "Setting stripe for parent directory..."
5943 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5944 error "cannot set stripe '-S 2M -c 1'"
5947 echo -n "Verifying restripe option uses parent stripe settings..."
5948 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5949 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
5950 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5951 error "migrate failed"
5952 cur_ssize=$($LFS getstripe -S "$file1")
5953 [ $cur_ssize -eq $parent_ssize ] ||
5954 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
5955 cur_scount=$($LFS getstripe -c "$file1")
5956 [ $cur_scount -eq $parent_scount ] ||
5957 error "migrate -R stripe_count $cur_scount != $parent_scount"
5960 # File currently set to -S 1M -c 1
5962 # Ensure striping is preserved if -R is not set, and no stripe
5963 # count or size is specified
5964 echo -n "Verifying striping size preserved when not specified..."
5965 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
5966 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5967 error "cannot set stripe on parent directory"
5968 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5969 error "migrate failed"
5970 cur_ssize=$($LFS getstripe -S "$file1")
5971 [ $cur_ssize -eq $orig_ssize ] ||
5972 error "migrate by default $cur_ssize != $orig_ssize"
5975 # Ensure file name properly detected when final option has no argument
5976 echo -n "Verifying file name properly detected..."
5977 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5978 error "file name interpreted as option argument"
5984 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5987 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5989 local file1=$DIR/$tdir/file1
5991 echo -n "Creating test dir..."
5992 test_mkdir $DIR/$tdir || error "cannot create dir"
5995 echo -n "Creating test file..."
5999 # Ensure 'lfs migrate' will fail by using a non-existent option,
6000 # and make sure rsync is not called to recover
6001 echo -n "Make sure --no-rsync option works..."
6002 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
6003 grep -q 'refusing to fall back to rsync' ||
6004 error "rsync was called with --no-rsync set"
6007 # Ensure rsync is called without trying 'lfs migrate' first
6008 echo -n "Make sure --rsync option works..."
6009 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
6010 grep -q 'falling back to rsync' &&
6011 error "lfs migrate was called with --rsync set"
6014 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6015 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6016 grep -q 'at the same time' ||
6017 error "--rsync and --no-rsync accepted concurrently"
6023 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6026 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6027 check_swap_layouts_support
6029 local dir=$DIR/$tdir
6030 local ref1=/etc/passwd
6031 local file1=$dir/file1
6033 test_mkdir $dir || error "creating dir $dir"
6034 $LFS setstripe -c 2 $file1
6036 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6037 stripe=$($LFS getstripe -c $file1)
6038 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6039 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6044 run_test 56x "lfs migration support"
6047 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6048 check_swap_layouts_support
6050 local dir=$DIR/$tdir/$testnum
6054 local ref1=/etc/passwd
6055 local file1=$dir/file1
6057 $LFS setstripe -c 2 $file1
6059 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6061 local stripe=$($LFS getstripe -c $file1)
6063 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6064 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6069 run_test 56xa "lfs migration --block support"
6071 check_migrate_links() {
6073 local file1="$dir/file1"
6076 local total_count=$(($begin + $count - 1))
6077 local symlink_count=10
6080 if [ ! -f "$file1" ]; then
6081 echo -n "creating initial file..."
6082 $LFS setstripe -c 1 -S "512k" "$file1" ||
6083 error "cannot setstripe initial file"
6086 echo -n "creating symlinks..."
6087 for s in $(seq 1 $symlink_count); do
6088 ln -s "$file1" "$dir/slink$s" ||
6089 error "cannot create symlinks"
6093 echo -n "creating nonlinked files..."
6094 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6095 error "cannot create nonlinked files"
6100 if [ ! -f "$dir/file$total_count" ]; then
6101 echo -n "creating hard links $begin:$total_count..."
6102 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6103 /dev/null || error "cannot create hard links"
6107 echo -n "checking number of hard links listed in xattrs..."
6108 local fid=$($LFS getstripe -F "$file1")
6109 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6112 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6113 skip "hard link list has unexpected size, skipping test"
6115 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6116 error "link names should exceed xattrs size"
6119 echo -n "migrating files..."
6120 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
6122 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6125 # make sure all links have been properly migrated
6126 echo -n "verifying files..."
6127 fid=$($LFS getstripe -F "$file1") ||
6128 error "cannot get fid for file $file1"
6129 for i in $(seq 2 $total_count); do
6130 local fid2=$($LFS getstripe -F $dir/file$i)
6132 [ "$fid2" == "$fid" ] ||
6133 error "migrated hard link has mismatched FID"
6136 # make sure hard links were properly detected, and migration was
6137 # performed only once for the entire link set; nonlinked files should
6139 local actual=$(grep -c 'done' <<< "$migrate_out")
6140 local expected=$(($uniq_count + 1))
6142 [ "$actual" -eq "$expected" ] ||
6143 error "hard links individually migrated ($actual != $expected)"
6145 # make sure the correct number of hard links are present
6146 local hardlinks=$(stat -c '%h' "$file1")
6148 [ $hardlinks -eq $total_count ] ||
6149 error "num hard links $hardlinks != $total_count"
6156 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6157 skip "Need MDS version at least 2.10.55"
6159 local dir="$DIR/$tdir"
6161 test_mkdir "$dir" || error "cannot create dir $dir"
6163 echo "testing lfs migrate mode when all links fit within xattrs"
6164 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6166 echo "testing rsync mode when all links fit within xattrs"
6167 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6169 echo "testing lfs migrate mode when all links do not fit within xattrs"
6170 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6172 echo "testing rsync mode when all links do not fit within xattrs"
6173 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6179 run_test 56xb "lfs migration hard link support"
6182 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6184 local dir="$DIR/$tdir"
6186 test_mkdir "$dir" || error "cannot create dir $dir"
6188 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6189 echo -n "Setting initial stripe for 20MB test file..."
6190 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6191 error "cannot setstripe 20MB file"
6193 echo -n "Sizing 20MB test file..."
6194 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6196 echo -n "Verifying small file autostripe count is 1..."
6197 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6198 error "cannot migrate 20MB file"
6199 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6200 error "cannot get stripe for $dir/20mb"
6201 [ $stripe_count -eq 1 ] ||
6202 error "unexpected stripe count $stripe_count for 20MB file"
6206 # Test 2: File is small enough to fit within the available space on
6207 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6208 # have at least an additional 1KB for each desired stripe for test 3
6209 echo -n "Setting stripe for 1GB test file..."
6210 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
6212 echo -n "Sizing 1GB test file..."
6213 # File size is 1GB + 3KB
6214 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
6217 # need at least 512MB per OST for 1GB file to fit in 2 stripes
6218 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
6219 if (( avail > 524288 * OSTCOUNT )); then
6220 echo -n "Migrating 1GB file..."
6221 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
6222 error "cannot migrate 1GB file"
6224 echo -n "Verifying autostripe count is sqrt(n) + 1..."
6225 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
6226 error "cannot getstripe for 1GB file"
6227 [ $stripe_count -eq 2 ] ||
6228 error "unexpected stripe count $stripe_count != 2"
6232 # Test 3: File is too large to fit within the available space on
6233 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
6234 if [ $OSTCOUNT -ge 3 ]; then
6235 # The required available space is calculated as
6236 # file size (1GB + 3KB) / OST count (3).
6237 local kb_per_ost=349526
6239 echo -n "Migrating 1GB file with limit..."
6240 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
6241 error "cannot migrate 1GB file with limit"
6244 stripe_count=$($LFS getstripe -c "$dir/1gb")
6245 echo -n "Verifying 1GB autostripe count with limited space..."
6246 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
6247 error "unexpected stripe count $stripe_count (min 3)"
6254 run_test 56xc "lfs migration autostripe"
6257 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6259 local dir=$DIR/$tdir
6260 local f_mgrt=$dir/$tfile.mgrt
6261 local f_yaml=$dir/$tfile.yaml
6262 local f_copy=$dir/$tfile.copy
6263 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6264 local layout_copy="-c 2 -S 2M -i 1"
6265 local yamlfile=$dir/yamlfile
6266 local layout_before;
6269 test_mkdir "$dir" || error "cannot create dir $dir"
6270 $LFS setstripe $layout_yaml $f_yaml ||
6271 error "cannot setstripe $f_yaml with layout $layout_yaml"
6272 $LFS getstripe --yaml $f_yaml > $yamlfile
6273 $LFS setstripe $layout_copy $f_copy ||
6274 error "cannot setstripe $f_copy with layout $layout_copy"
6276 dd if=/dev/zero of=$f_mgrt bs=1M count=4
6278 # 1. test option --yaml
6279 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
6280 error "cannot migrate $f_mgrt with --yaml $yamlfile"
6281 layout_before=$(get_layout_param $f_yaml)
6282 layout_after=$(get_layout_param $f_mgrt)
6283 [ "$layout_after" == "$layout_before" ] ||
6284 error "lfs_migrate --yaml: $layout_after != $layout_before"
6286 # 2. test option --copy
6287 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
6288 error "cannot migrate $f_mgrt with --copy $f_copy"
6289 layout_before=$(get_layout_param $f_copy)
6290 layout_after=$(get_layout_param $f_mgrt)
6291 [ "$layout_after" == "$layout_before" ] ||
6292 error "lfs_migrate --copy: $layout_after != $layout_before"
6294 run_test 56xd "check lfs_migrate --yaml and --copy support"
6297 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6299 local dir=$DIR/$tdir
6300 local f_comp=$dir/$tfile
6301 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6302 local layout_before=""
6303 local layout_after=""
6305 test_mkdir "$dir" || error "cannot create dir $dir"
6306 $LFS setstripe $layout $f_comp ||
6307 error "cannot setstripe $f_comp with layout $layout"
6308 layout_before=$(get_layout_param $f_comp)
6309 dd if=/dev/zero of=$f_comp bs=1M count=4
6311 # 1. migrate a comp layout file by lfs_migrate
6312 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
6313 layout_after=$(get_layout_param $f_comp)
6314 [ "$layout_before" == "$layout_after" ] ||
6315 error "lfs_migrate: $layout_before != $layout_after"
6317 # 2. migrate a comp layout file by lfs migrate
6318 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
6319 layout_after=$(get_layout_param $f_comp)
6320 [ "$layout_before" == "$layout_after" ] ||
6321 error "lfs migrate: $layout_before != $layout_after"
6323 run_test 56xe "migrate a composite layout file"
6326 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
6327 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
6330 local dir=$DIR/$tdir
6334 test_mkdir -p $dir || error "creating dir $dir"
6335 touch $f1 || error "creating std file $f1"
6336 $MULTIOP $f2 H2c || error "creating released file $f2"
6338 # a directory can be raid0, so ask only for files
6339 res=$($LFS find $dir -L raid0 -type f | wc -l)
6340 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
6342 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
6343 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
6345 # only files can be released, so no need to force file search
6346 res=$($LFS find $dir -L released)
6347 [[ $res == $f2 ]] || error "search released: found $res != $f2"
6349 res=$($LFS find $dir -type f \! -L released)
6350 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
6352 run_test 56y "lfs find -L raid0|released"
6354 test_56z() { # LU-4824
6355 # This checks to make sure 'lfs find' continues after errors
6356 # There are two classes of errors that should be caught:
6357 # - If multiple paths are provided, all should be searched even if one
6359 # - If errors are encountered during the search, it should not terminate
6361 local dir=$DIR/$tdir
6365 for i in d{0..9}; do
6367 touch $dir/$i/$tfile
6369 $LFS find $DIR/non_existent_dir $dir &&
6370 error "$LFS find did not return an error"
6371 # Make a directory unsearchable. This should NOT be the last entry in
6372 # directory order. Arbitrarily pick the 6th entry
6373 chmod 700 $($LFS find $dir -type d | sed '6!d')
6375 $RUNAS $LFS find $DIR/non_existent $dir
6376 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
6378 # The user should be able to see 10 directories and 9 files
6379 (( count == 19 )) ||
6380 error "$LFS find found $count != 19 entries after error"
6382 run_test 56z "lfs find should continue after an error"
6384 test_56aa() { # LU-5937
6385 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
6387 local dir=$DIR/$tdir
6390 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
6392 createmany -o $dir/striped_dir/${tfile}- 1024
6393 local dirs=$($LFS find --size +8k $dir/)
6395 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
6397 run_test 56aa "lfs find --size under striped dir"
6399 test_56ab() { # LU-10705
6400 test_mkdir $DIR/$tdir
6401 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
6402 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
6403 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
6404 # Flush writes to ensure valid blocks. Need to be more thorough for
6405 # ZFS, since blocks are not allocated/returned to client immediately.
6407 wait_zfs_commit ost1 2
6408 cancel_lru_locks osc
6411 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
6413 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
6415 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
6416 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
6418 rm -f $DIR/$tdir/$tfile.[123]
6420 run_test 56ab "lfs find --blocks"
6423 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
6424 skip "Need MDS version at least 2.10.50"
6426 # Create composite files with one component
6427 local dir=$DIR/$tdir
6429 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
6430 # Create composite files with three components
6431 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
6432 # Create non-composite files
6433 createmany -o $dir/${tfile}- 10
6435 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
6437 [[ $nfiles == 10 ]] ||
6438 error "lfs find -E 1M found $nfiles != 10 files"
6440 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
6441 [[ $nfiles == 25 ]] ||
6442 error "lfs find ! -E 1M found $nfiles != 25 files"
6444 # All files have a component that starts at 0
6445 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
6446 [[ $nfiles == 35 ]] ||
6447 error "lfs find --component-start 0 - $nfiles != 35 files"
6449 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
6450 [[ $nfiles == 15 ]] ||
6451 error "lfs find --component-start 2M - $nfiles != 15 files"
6453 # All files created here have a componenet that does not starts at 2M
6454 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
6455 [[ $nfiles == 35 ]] ||
6456 error "lfs find ! --component-start 2M - $nfiles != 35 files"
6458 # Find files with a specified number of components
6459 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
6460 [[ $nfiles == 15 ]] ||
6461 error "lfs find --component-count 3 - $nfiles != 15 files"
6463 # Remember non-composite files have a component count of zero
6464 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
6465 [[ $nfiles == 10 ]] ||
6466 error "lfs find --component-count 0 - $nfiles != 10 files"
6468 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
6469 [[ $nfiles == 20 ]] ||
6470 error "lfs find ! --component-count 3 - $nfiles != 20 files"
6472 # All files have a flag called "init"
6473 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
6474 [[ $nfiles == 35 ]] ||
6475 error "lfs find --component-flags init - $nfiles != 35 files"
6477 # Multi-component files will have a component not initialized
6478 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
6479 [[ $nfiles == 15 ]] ||
6480 error "lfs find !--component-flags init - $nfiles != 15 files"
6485 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
6488 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
6489 skip "Need MDS version at least 2.10.57"
6499 # create mirrored directories and mirrored files
6500 mkdir $td || error "mkdir $td failed"
6501 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
6502 createmany -o $tf- 10 || error "create $tf- failed"
6504 for i in $(seq 2); do
6506 mkdir $dir || error "mkdir $dir failed"
6507 $LFS mirror create -N$((3 + i)) $dir ||
6508 error "create mirrored dir $dir failed"
6509 createmany -o $dir/$tfile- 10 ||
6510 error "create $dir/$tfile- failed"
6513 # change the states of some mirrored files
6515 for i in $(seq 2); do
6517 for j in $(seq 4 9); do
6518 echo foo > $dir/$tfile-$j
6522 # find mirrored files with specific mirror count
6523 cmd="$LFS find --mirror-count 3 --type f $td"
6524 nfiles=$($cmd | wc -l)
6525 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
6527 cmd="$LFS find ! --mirror-count 3 --type f $td"
6528 nfiles=$($cmd | wc -l)
6529 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
6531 cmd="$LFS find --mirror-count +2 --type f $td"
6532 nfiles=$($cmd | wc -l)
6533 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6535 cmd="$LFS find --mirror-count -6 --type f $td"
6536 nfiles=$($cmd | wc -l)
6537 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6539 # find mirrored files with specific file state
6540 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
6541 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
6543 cmd="$LFS find --mirror-state=ro --type f $td"
6544 nfiles=$($cmd | wc -l)
6545 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6547 cmd="$LFS find ! --mirror-state=ro --type f $td"
6548 nfiles=$($cmd | wc -l)
6549 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6551 cmd="$LFS find --mirror-state=wp --type f $td"
6552 nfiles=$($cmd | wc -l)
6553 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6555 cmd="$LFS find ! --mirror-state=sp --type f $td"
6556 nfiles=$($cmd | wc -l)
6557 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6559 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6563 # note test will not do anything if MDS is not local
6564 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6565 skip_env "ldiskfs only test"
6567 remote_mds_nodsh && skip "remote MDS with nodsh"
6569 local MNTDEV="osd*.*MDT*.mntdev"
6570 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6571 [ -z "$DEV" ] && error "can't access $MNTDEV"
6572 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6573 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6574 error "can't access $DEV"
6575 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6576 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6580 run_test 57a "verify MDS filesystem created with large inodes =="
6583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6584 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6585 skip_env "ldiskfs only test"
6587 remote_mds_nodsh && skip "remote MDS with nodsh"
6589 local dir=$DIR/$tdir
6592 local fileN=$dir/f$filecount
6594 rm -rf $dir || error "removing $dir"
6596 local mdtidx=$($LFS getstripe -m $dir)
6597 local mdtname=MDT$(printf %04x $mdtidx)
6598 local facet=mds$((mdtidx + 1))
6600 echo "mcreating $filecount files"
6601 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6603 # verify that files do not have EAs yet
6604 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6605 error "$file1 has an EA"
6606 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6607 error "$fileN has an EA"
6611 df $dir #make sure we get new statfs data
6612 local mdsfree=$(do_facet $facet \
6613 lctl get_param -n osd*.*$mdtname.kbytesfree)
6614 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6617 echo "opening files to create objects/EAs"
6618 for file in $(seq -f $dir/f%g 1 $filecount); do
6619 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6620 error "opening $file"
6623 # verify that files have EAs now
6624 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6625 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6627 sleep 1 #make sure we get new statfs data
6629 local mdsfree2=$(do_facet $facet \
6630 lctl get_param -n osd*.*$mdtname.kbytesfree)
6631 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6633 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6634 if [ "$mdsfree" != "$mdsfree2" ]; then
6635 error "MDC before $mdcfree != after $mdcfree2"
6637 echo "MDC before $mdcfree != after $mdcfree2"
6638 echo "unable to confirm if MDS has large inodes"
6643 run_test 57b "default LOV EAs are stored inside large inodes ==="
6646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6647 [ -z "$(which wiretest 2>/dev/null)" ] &&
6648 skip_env "could not find wiretest"
6652 run_test 58 "verify cross-platform wire constants =============="
6655 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6657 echo "touch 130 files"
6658 createmany -o $DIR/f59- 130
6660 unlinkmany $DIR/f59- 130
6662 # wait for commitment of removal
6663 wait_delete_completed
6665 run_test 59 "verify cancellation of llog records async ========="
6667 TEST60_HEAD="test_60 run $RANDOM"
6669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6670 remote_mgs_nodsh && skip "remote MGS with nodsh"
6671 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6672 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6673 skip_env "missing subtest run-llog.sh"
6675 log "$TEST60_HEAD - from kernel mode"
6676 do_facet mgs "$LCTL dk > /dev/null"
6677 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6678 do_facet mgs $LCTL dk > $TMP/$tfile
6680 # LU-6388: test llog_reader
6681 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6682 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6683 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6684 skip_env "missing llog_reader"
6685 local fstype=$(facet_fstype mgs)
6686 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6687 skip_env "Only for ldiskfs or zfs type mgs"
6689 local mntpt=$(facet_mntpt mgs)
6690 local mgsdev=$(mgsdevname 1)
6702 #get fid and record list
6703 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6705 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6707 #remount mgs as ldiskfs or zfs type
6708 stop mgs || error "stop mgs failed"
6709 mount_fstype mgs || error "remount mgs failed"
6710 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6713 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6714 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6719 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6721 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6723 echo "obj_file is $obj_file"
6724 do_facet mgs $llog_reader $obj_file
6726 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6727 awk '{ print $3 }' | sed -e "s/^type=//g")
6728 if [ $rec_type != $rec ]; then
6729 echo "FAILED test_60a wrong record type $rec_type," \
6735 #check obj path if record type is LLOG_LOGID_MAGIC
6736 if [ "$rec" == "1064553b" ]; then
6737 path=$(do_facet mgs $llog_reader $obj_file |
6738 grep "path=" | awk '{ print $NF }' |
6739 sed -e "s/^path=//g")
6740 if [ $obj_file != $mntpt/$path ]; then
6741 echo "FAILED test_60a wrong obj path" \
6742 "$montpt/$path, should be $obj_file"
6749 #restart mgs before "error", otherwise it will block the next test
6750 stop mgs || error "stop mgs failed"
6751 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6752 $pass || error "test failed, see FAILED test_60a messages for specifics"
6754 run_test 60a "llog_test run from kernel module and test llog_reader"
6756 test_60b() { # bug 6411
6757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6760 LLOG_COUNT=$(do_facet mgs dmesg |
6761 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6762 /llog_[a-z]*.c:[0-9]/ {
6774 [[ $LLOG_COUNT -gt 120 ]] &&
6775 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6777 run_test 60b "limit repeated messages from CERROR/CWARN"
6780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6782 echo "create 5000 files"
6783 createmany -o $DIR/f60c- 5000
6784 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6785 lctl set_param fail_loc=0x80000137
6786 unlinkmany $DIR/f60c- 5000
6787 lctl set_param fail_loc=0
6789 run_test 60c "unlink file when mds full"
6792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6794 SAVEPRINTK=$(lctl get_param -n printk)
6795 # verify "lctl mark" is even working"
6796 MESSAGE="test message ID $RANDOM $$"
6797 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6798 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6800 lctl set_param printk=0 || error "set lnet.printk failed"
6801 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6802 MESSAGE="new test message ID $RANDOM $$"
6803 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6804 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6805 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6807 lctl set_param -n printk="$SAVEPRINTK"
6809 run_test 60d "test printk console message masking"
6812 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6813 remote_mds_nodsh && skip "remote MDS with nodsh"
6816 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6817 do_facet mds1 lctl set_param fail_loc=0x15b
6820 run_test 60e "no space while new llog is being created"
6825 test_mkdir -c $MDSCOUNT $DIR/$tdir
6826 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir
6831 mkdir $DIR/$tdir/subdir$index 2>/dev/null
6832 rmdir $DIR/$tdir/subdir$index 2>/dev/null
6833 index=$((index + 1))
6839 for i in $(seq 100); do
6840 # define OBD_FAIL_OSD_TXN_START 0x19a
6841 do_facet mds1 lctl set_param fail_loc=0x8000019a
6847 mkdir $DIR/$tdir/new || error "mkdir failed"
6848 rmdir $DIR/$tdir/new || error "rmdir failed"
6850 run_test 60g "transaction abort won't cause MDT hung"
6853 [ $MDS1_VERSION -le $(version_code 2.12.4) ] &&
6854 skip "Need MDS version at least 2.12.4"
6855 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
6859 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
6860 #define OBD_FAIL_MDS_STRIPE_FID 0x189
6861 for fail_loc in 0x80000188 0x80000189; do
6862 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
6863 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
6864 error "mkdir $dir-$fail_loc failed"
6865 for i in {0..10}; do
6866 # create may fail on missing stripe
6867 echo $i > $DIR/$tdir-$fail_loc/$i
6869 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6870 error "getdirstripe $tdir-$fail_loc failed"
6871 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
6872 error "migrate $tdir-$fail_loc failed"
6873 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6874 error "getdirstripe $tdir-$fail_loc failed"
6875 pushd $DIR/$tdir-$fail_loc
6877 echo $f | cmp $f - || error "$f data mismatch"
6880 rm -rf $DIR/$tdir-$fail_loc
6883 run_test 60h "striped directory with missing stripes can be accessed"
6886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6889 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
6890 cancel_lru_locks osc
6891 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6894 run_test 61a "mmap() writes don't make sync hang ================"
6897 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
6899 run_test 61b "mmap() of unstriped file is successful"
6901 # bug 2330 - insufficient obd_match error checking causes LBUG
6903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6907 cancel_lru_locks osc
6908 lctl set_param fail_loc=0x405
6909 cat $f && error "cat succeeded, expect -EIO"
6910 lctl set_param fail_loc=0
6912 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6913 # match every page all of the time.
6914 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6916 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6917 # Though this test is irrelevant anymore, it helped to reveal some
6918 # other grant bugs (LU-4482), let's keep it.
6919 test_63a() { # was test_63
6920 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6922 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6924 for i in `seq 10` ; do
6925 dd if=/dev/zero of=$DIR/f63 bs=8k &
6931 rm -f $DIR/f63 || true
6933 run_test 63a "Verify oig_wait interruption does not crash ======="
6935 # bug 2248 - async write errors didn't return to application on sync
6936 # bug 3677 - async write errors left page locked
6938 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6941 lctl set_param debug=-1
6943 # ensure we have a grant to do async writes
6944 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6947 sync # sync lest earlier test intercept the fail_loc
6949 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6950 lctl set_param fail_loc=0x80000406
6951 $MULTIOP $DIR/$tfile Owy && \
6952 error "sync didn't return ENOMEM"
6953 sync; sleep 2; sync # do a real sync this time to flush page
6954 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6955 error "locked page left in cache after async error" || true
6958 run_test 63b "async write errors should be returned to fsync ==="
6961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6964 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6966 run_test 64a "verify filter grant calculations (in kernel) ====="
6969 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6971 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6973 run_test 64b "check out-of-space detection on client"
6976 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6978 run_test 64c "verify grant shrink"
6984 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
6987 # this does exactly what osc_request.c:osc_announce_cached() does in
6988 # order to calculate max amount of grants to ask from server
6992 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
6993 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
6995 ((rpc_in_flight++));
6996 nrpages=$((nrpages * rpc_in_flight))
6998 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
7000 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
7002 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
7003 local undirty=$((nrpages * PAGE_SIZE))
7005 local max_extent_pages
7006 max_extent_pages=$(import_param $tgt grant_max_extent_size)
7007 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
7008 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
7009 local grant_extent_tax
7010 grant_extent_tax=$(import_param $tgt grant_extent_tax)
7012 undirty=$((undirty + nrextents * grant_extent_tax))
7017 # this is size of unit for grant allocation. It should be equal to
7018 # what tgt_grant.c:tgt_grant_chunk() calculates
7022 local grant_extent_tax
7024 max_brw_size=$(import_param $tgt max_brw_size)
7026 grant_extent_tax=$(import_param $tgt grant_extent_tax)
7028 echo $(((max_brw_size + grant_extent_tax) * 2))
7032 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
7033 skip "OST < 2.10.55 doesn't limit grants enough"
7035 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7037 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
7038 skip "no grant_param connect flag"
7040 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
7042 $LCTL set_param -n -n debug="$OLDDEBUG" || true
7043 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
7046 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7047 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
7049 $LFS setstripe $DIR/$tfile -i 0 -c 1
7050 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
7053 while kill -0 $ddpid; do
7054 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
7056 if [[ $cur_grant -gt $max_cur_granted ]]; then
7058 error "cur_grant $cur_grant > $max_cur_granted"
7064 run_test 64d "check grant limit exceed"
7070 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
7072 ((cur_grants == expected)) ||
7073 error "$msg: grants mismatch: $cur_grants, expected $expected"
7077 echo $((($1 + $2 - 1) & ~($2 - 1)))
7081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7082 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
7083 skip "Need OSS version at least 2.11.56"
7085 # Remount client to reset grant
7086 remount_client $MOUNT || error "failed to remount client"
7087 local osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7088 local init_grants=$(import_param $osc_tgt initial_grant)
7090 check_grants $osc_tgt $init_grants "init grants"
7092 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
7093 local max_brw_size=$(import_param $osc_tgt max_brw_size)
7094 local gbs=$(import_param $osc_tgt grant_block_size)
7096 # write random number of bytes from max_brw_size / 4 to max_brw_size
7097 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
7098 # align for direct io
7099 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
7100 # round to grant consumption unit
7101 local wb_round_up=$(round_up_p2 $write_bytes gbs)
7103 local grants=$((wb_round_up + extent_tax))
7105 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7107 # define OBD_FAIL_TGT_NO_GRANT 0x725
7108 # make the server not grant more back
7109 do_facet ost1 $LCTL set_param fail_loc=0x725
7110 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
7112 do_facet ost1 $LCTL set_param fail_loc=0
7114 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
7116 rm -f $DIR/$tfile || error "rm failed"
7118 # Remount client to reset grant
7119 remount_client $MOUNT || error "failed to remount client"
7120 osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7122 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7124 # define OBD_FAIL_TGT_NO_GRANT 0x725
7125 # make the server not grant more back
7126 do_facet ost1 $LCTL set_param fail_loc=0x725
7127 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
7128 do_facet ost1 $LCTL set_param fail_loc=0
7130 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
7132 run_test 64e "check grant consumption (no grant allocation)"
7135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7137 # Remount client to reset grant
7138 remount_client $MOUNT || error "failed to remount client"
7139 local osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7141 local init_grants=$(import_param $osc_tgt initial_grant)
7142 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
7143 local max_brw_size=$(import_param $osc_tgt max_brw_size)
7144 local gbs=$(import_param $osc_tgt grant_block_size)
7145 local chunk=$(grant_chunk $osc_tgt)
7147 # write random number of bytes from max_brw_size / 4 to max_brw_size
7148 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
7149 # align for direct io
7150 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
7151 # round to grant consumption unit
7152 local wb_round_up=$(round_up_p2 $write_bytes gbs)
7154 local grants=$((wb_round_up + extent_tax))
7156 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7157 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
7158 error "error writing to $DIR/$tfile"
7160 check_grants $osc_tgt $((init_grants - grants + chunk)) \
7161 "direct io with grant allocation"
7163 rm -f $DIR/$tfile || error "rm failed"
7165 # Remount client to reset grant
7166 remount_client $MOUNT || error "failed to remount client"
7167 osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7169 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7171 local cmd="oO_WRONLY:w${write_bytes}_yc"
7173 $MULTIOP $DIR/$tfile $cmd &
7177 check_grants $osc_tgt $((init_grants - grants)) \
7178 "buffered io, not write rpc"
7180 kill -USR1 $MULTIPID
7183 check_grants $osc_tgt $((init_grants - grants + chunk)) \
7184 "buffered io, one RPC"
7186 run_test 64f "check grant consumption (with grant allocation)"
7189 local cli=$($LFS getname $DIR); cli=${cli%% *}; cli=${cli#*-}
7190 local osc_tgt="$FSNAME-OST0000-osc-$cli"
7191 local num_exps=$(do_facet ost1 \
7192 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
7193 local max_brw_size=$(import_param $osc_tgt max_brw_size)
7194 local avail=$($LCTL get_param -n osc.*OST0000-osc-$cli.kbytesavail)
7195 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7197 # 10MiB is for file to be written, max_brw_size * 16 *
7198 # num_exps is space reserve so that tgt_grant_shrink() decided
7200 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
7201 (( avail * 1024 < expect )) &&
7202 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
7204 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
7205 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
7206 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
7207 $LCTL set_param osc.*OST0000*.grant_shrink=1
7208 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
7210 $LFS setstripe -c 1 -i 0 $DIR/$tfile
7211 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
7213 # drop cache so that coming read would do rpc
7214 cancel_lru_locks osc
7216 # shrink interval is set to 10, pause for 7 seconds so that
7217 # grant thread did not wake up yet but coming read entered
7218 # shrink mode for rpc (osc_should_shrink_grant())
7221 declare -a cur_grant_bytes
7222 declare -a tot_granted
7223 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
7224 tot_granted[0]=$(do_facet ost1 \
7225 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
7227 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
7229 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
7230 tot_granted[1]=$(do_facet ost1 \
7231 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
7233 # grant change should be equal on both sides
7234 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
7235 tot_granted[0] - tot_granted[1])) ||
7236 error "grant change mismatch, " \
7237 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
7238 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
7240 run_test 64h "grant shrink on read"
7246 local testid=${TESTNAME/_/ }
7248 (( $OST1_VERSION >= $(version_code 2.12.7) )) ||
7249 skip "need OST at least 2.12.7 to avoid grant shrink on replay"
7251 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7252 remote_ost_nodsh && skip "remote OSTs with nodsh"
7254 $LFS setstripe -c 1 -i 0 $DIR/$tfile
7256 dd if=/dev/zero of=$DIR/$tfile bs=1M count=64
7258 # lustre-ffff9fc75e850800 /mnt/lustre -> ffff9fc75e850800
7259 cli=$($LFS getname $DIR); cli=${cli%% *}; cli=${cli##*-}
7260 osc_tgt="$FSNAME-OST0000-osc-$cli"
7261 cgb=$($LCTL get_param -n osc.$osc_tgt.cur_grant_bytes)
7263 # shrink grants and simulate rpc loss
7264 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
7265 do_facet ost1 "$LCTL set_param fail_loc=0x80000513 fail_val=17"
7266 $LCTL set_param osc.$osc_tgt.cur_grant_bytes=$((cgb/2))
7270 dd if=/dev/zero of=$DIR/$tfile oflag=append bs=1M count=8 conv=notrunc
7272 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
7273 grep "GRANT, real grant" &&
7274 error "client has more grants then it owns" || true
7276 run_test 64i "shrink on reconnect"
7278 # bug 1414 - set/get directories' stripe info
7280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7282 test_mkdir $DIR/$tdir
7284 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7286 run_test 65a "directory with no stripe info"
7289 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7291 test_mkdir $DIR/$tdir
7292 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7294 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7297 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7299 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7302 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7303 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7305 test_mkdir $DIR/$tdir
7306 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
7308 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7309 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7311 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7313 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7316 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7318 test_mkdir $DIR/$tdir
7319 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
7320 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7322 if [[ $STRIPECOUNT -le 0 ]]; then
7324 elif [[ $STRIPECOUNT -gt 2000 ]]; then
7325 #LOV_MAX_STRIPE_COUNT is 2000
7326 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
7328 sc=$(($STRIPECOUNT - 1))
7330 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7331 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7332 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7333 error "lverify failed"
7335 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7338 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7340 test_mkdir $DIR/$tdir
7342 $SETSTRIPE $DIR/$tdir || error "setstripe"
7343 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
7344 error "no stripe info failed"
7346 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
7348 run_test 65e "directory setstripe defaults"
7351 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7353 test_mkdir $DIR/${tdir}f
7354 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
7356 run_test 65f "dir setstripe permission (should return error) ==="
7359 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7361 test_mkdir $DIR/$tdir
7362 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7364 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7365 error "setstripe -S failed"
7366 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7367 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7368 error "delete default stripe failed"
7370 run_test 65g "directory setstripe -d"
7373 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7375 test_mkdir $DIR/$tdir
7376 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7378 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7379 error "setstripe -S failed"
7380 test_mkdir $DIR/$tdir/dd1
7381 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
7382 error "stripe info inherit failed"
7384 run_test 65h "directory stripe info inherit ===================="
7387 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7389 save_layout_restore_at_exit $MOUNT
7391 # bug6367: set non-default striping on root directory
7392 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7394 # bug12836: getstripe on -1 default directory striping
7395 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7397 # bug12836: getstripe -v on -1 default directory striping
7398 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7400 # bug12836: new find on -1 default directory striping
7401 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7403 run_test 65i "various tests to set root directory striping"
7405 test_65j() { # bug6367
7406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7410 # if we aren't already remounting for each test, do so for this test
7411 if [ "$I_MOUNTED" = "yes" ]; then
7412 cleanup || error "failed to unmount"
7416 save_layout_restore_at_exit $MOUNT
7418 $SETSTRIPE -d $MOUNT || error "setstripe failed"
7420 run_test 65j "set default striping on root directory (bug 6367)="
7424 wait_delete_completed
7425 do_facet $SINGLEMDS "lctl set_param -n \
7426 osp.$ost*MDT0000.max_create_count=$max_count"
7427 do_facet $SINGLEMDS "lctl set_param -n \
7428 osp.$ost*MDT0000.create_count=$count"
7429 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7430 echo $INACTIVE_OSC "is Activate"
7432 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7435 test_65k() { # bug11679
7436 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7437 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7438 remote_mds_nodsh && skip "remote MDS with nodsh"
7440 local disable_precreate=true
7441 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7442 disable_precreate=false
7444 echo "Check OST status: "
7445 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7446 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7448 for OSC in $MDS_OSCS; do
7449 echo $OSC "is active"
7450 do_facet $SINGLEMDS lctl --device %$OSC activate
7453 for INACTIVE_OSC in $MDS_OSCS; do
7454 local ost=$(osc_to_ost $INACTIVE_OSC)
7455 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7456 lov.*md*.target_obd |
7457 awk -F: /$ost/'{ print $1 }' | head -n 1)
7460 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
7461 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7463 echo "Deactivate: " $INACTIVE_OSC
7464 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7466 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7467 osp.$ost*MDT0000.create_count")
7468 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7469 osp.$ost*MDT0000.max_create_count")
7470 $disable_precreate &&
7471 do_facet $SINGLEMDS "lctl set_param -n \
7472 osp.$ost*MDT0000.max_create_count=0"
7474 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7475 [ -f $DIR/$tdir/$idx ] && continue
7476 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
7477 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
7479 error "setstripe $idx should succeed"; }
7480 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7482 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7485 do_facet $SINGLEMDS "lctl set_param -n \
7486 osp.$ost*MDT0000.max_create_count=$max_count"
7487 do_facet $SINGLEMDS "lctl set_param -n \
7488 osp.$ost*MDT0000.create_count=$count"
7489 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7490 echo $INACTIVE_OSC "is Activate"
7492 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7495 run_test 65k "validate manual striping works properly with deactivated OSCs"
7497 test_65l() { # bug 12836
7498 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7500 test_mkdir -p $DIR/$tdir/test_dir
7501 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
7502 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7504 run_test 65l "lfs find on -1 stripe dir ========================"
7507 local layout=$(save_layout $MOUNT)
7508 $RUNAS $SETSTRIPE -c 2 $MOUNT && {
7509 restore_layout $MOUNT $layout
7510 error "setstripe should fail by non-root users"
7514 run_test 65m "normal user can't set filesystem default stripe"
7517 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.0) ]] ||
7518 skip "Need MDS version at least 2.12.0"
7519 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7521 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7522 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7523 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7525 save_layout_restore_at_exit $MOUNT
7527 # new subdirectory under root directory should not inherit
7528 # the default layout from root
7529 local dir1=$MOUNT/$tdir-1
7530 mkdir $dir1 || error "mkdir $dir1 failed"
7531 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7532 error "$dir1 shouldn't have LOV EA"
7534 # delete the default layout on root directory
7535 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7537 local dir2=$MOUNT/$tdir-2
7538 mkdir $dir2 || error "mkdir $dir2 failed"
7539 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7540 error "$dir2 shouldn't have LOV EA"
7542 # set a new striping pattern on root directory
7543 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7544 local new_def_stripe_size=$((def_stripe_size * 2))
7545 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7546 error "set stripe size on $MOUNT failed"
7548 # new file created in $dir2 should inherit the new stripe size from
7549 # the filesystem default
7550 local file2=$dir2/$tfile-2
7551 touch $file2 || error "touch $file2 failed"
7553 local file2_stripe_size=$($LFS getstripe -S $file2)
7554 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
7555 error "$file2 didn't inherit stripe size $new_def_stripe_size"
7557 local dir3=$MOUNT/$tdir-3
7558 mkdir $dir3 || error "mkdir $dir3 failed"
7559 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
7560 # the root layout, which is the actual default layout that will be used
7561 # when new files are created in $dir3.
7562 local dir3_layout=$(get_layout_param $dir3)
7563 local root_dir_layout=$(get_layout_param $MOUNT)
7564 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
7565 error "$dir3 should show the default layout from $MOUNT"
7567 # set OST pool on root directory
7568 local pool=$TESTNAME
7569 pool_add $pool || error "add $pool failed"
7570 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
7571 error "add targets to $pool failed"
7573 $LFS setstripe -p $pool $MOUNT ||
7574 error "set OST pool on $MOUNT failed"
7576 # new file created in $dir3 should inherit the pool from
7577 # the filesystem default
7578 local file3=$dir3/$tfile-3
7579 touch $file3 || error "touch $file3 failed"
7581 local file3_pool=$($LFS getstripe -p $file3)
7582 [[ "$file3_pool" = "$pool" ]] ||
7583 error "$file3 didn't inherit OST pool $pool"
7585 local dir4=$MOUNT/$tdir-4
7586 mkdir $dir4 || error "mkdir $dir4 failed"
7587 local dir4_layout=$(get_layout_param $dir4)
7588 root_dir_layout=$(get_layout_param $MOUNT)
7589 echo "$LFS getstripe -d $dir4"
7590 $LFS getstripe -d $dir4
7591 echo "$LFS getstripe -d $MOUNT"
7592 $LFS getstripe -d $MOUNT
7593 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
7594 error "$dir4 should show the default layout from $MOUNT"
7596 # new file created in $dir4 should inherit the pool from
7597 # the filesystem default
7598 local file4=$dir4/$tfile-4
7599 touch $file4 || error "touch $file4 failed"
7601 local file4_pool=$($LFS getstripe -p $file4)
7602 [[ "$file4_pool" = "$pool" ]] ||
7603 error "$file4 didn't inherit OST pool $pool"
7605 # new subdirectory under non-root directory should inherit
7606 # the default layout from its parent directory
7607 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
7608 error "set directory layout on $dir4 failed"
7610 local dir5=$dir4/$tdir-5
7611 mkdir $dir5 || error "mkdir $dir5 failed"
7613 dir4_layout=$(get_layout_param $dir4)
7614 local dir5_layout=$(get_layout_param $dir5)
7615 [[ "$dir4_layout" = "$dir5_layout" ]] ||
7616 error "$dir5 should inherit the default layout from $dir4"
7618 # though subdir under ROOT doesn't inherit default layout, but
7619 # its sub dir/file should be created with default layout.
7620 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
7621 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
7622 [[ $MDS1_VERSION -ge $(version_code 2.12.3) &&
7623 $MDS1_VERSION -lt $(version_code 2.12.50) ]] ||
7624 skip "Need MDS version at least 2.12.3 or 2.12.59"
7626 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
7627 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
7628 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
7630 if [ $default_lmv_hash == "none" ]; then
7631 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
7633 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
7634 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
7637 $LFS setdirstripe -D -c 2 $MOUNT ||
7638 error "setdirstripe -D -c 2 failed"
7639 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
7640 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
7641 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
7643 run_test 65n "don't inherit default layout from root for new subdirectories"
7645 # bug 2543 - update blocks count on client
7647 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7650 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
7651 sync; sync_all_data; sync; sync_all_data
7652 cancel_lru_locks osc
7653 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
7654 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
7656 run_test 66 "update inode blocks count on client ==============="
7659 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
7663 swapon -s | awk '($1 == "'$1'") { print $4 }'
7666 # bug5265, obdfilter oa2dentry return -ENOENT
7667 # #define OBD_FAIL_SRV_ENOENT 0x217
7669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7670 remote_ost_nodsh && skip "remote OST with nodsh"
7673 $SETSTRIPE -c 1 -i 0 $f
7675 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
7677 do_facet ost1 lctl set_param fail_loc=0x217
7678 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
7679 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
7681 do_facet ost1 lctl set_param fail_loc=0
7682 $DIRECTIO write $f 0 2 || error "write error"
7684 cancel_lru_locks osc
7685 $DIRECTIO read $f 0 1 || error "read error"
7687 do_facet ost1 lctl set_param fail_loc=0x217
7688 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
7690 do_facet ost1 lctl set_param fail_loc=0
7693 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
7696 test_mkdir $DIR/$tdir
7697 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
7698 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
7700 run_test 71 "Running dbench on lustre (don't segment fault) ===="
7702 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
7703 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7704 [ "$RUNAS_ID" = "$UID" ] &&
7705 skip_env "RUNAS_ID = UID = $UID -- skipping"
7706 # Check that testing environment is properly set up. Skip if not
7707 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
7708 skip_env "User $RUNAS_ID does not exist - skipping"
7711 chmod 777 $DIR/$tfile
7712 chmod ug+s $DIR/$tfile
7713 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
7714 error "$RUNAS dd $DIR/$tfile failed"
7715 # See if we are still setuid/sgid
7716 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7717 error "S/gid is not dropped on write"
7718 # Now test that MDS is updated too
7719 cancel_lru_locks mdc
7720 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7721 error "S/gid is not dropped on MDS"
7724 run_test 72a "Test that remove suid works properly (bug5695) ===="
7726 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7729 [ "$RUNAS_ID" = "$UID" ] &&
7730 skip_env "RUNAS_ID = UID = $UID -- skipping"
7731 [ "$RUNAS_ID" -eq 0 ] &&
7732 skip_env "RUNAS_ID = 0 -- skipping"
7733 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7734 # Check that testing environment is properly set up. Skip if not
7735 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7736 skip_env "User $RUNAS_ID does not exist - skipping"
7738 touch $DIR/${tfile}-f{g,u}
7739 test_mkdir $DIR/${tfile}-dg
7740 test_mkdir $DIR/${tfile}-du
7741 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7742 chmod g+s $DIR/${tfile}-{f,d}g
7743 chmod u+s $DIR/${tfile}-{f,d}u
7744 for perm in 777 2777 4777; do
7745 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7746 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7747 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7748 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7752 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7754 # bug 3462 - multiple simultaneous MDC requests
7756 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7758 test_mkdir $DIR/d73-1
7759 test_mkdir $DIR/d73-2
7760 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7763 lctl set_param fail_loc=0x80000129
7764 $MULTIOP $DIR/d73-1/f73-2 Oc &
7766 lctl set_param fail_loc=0
7768 $MULTIOP $DIR/d73-2/f73-3 Oc &
7772 wait $pid1 || return 1
7776 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
7777 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
7778 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
7782 run_test 73 "multiple MDC requests (should not deadlock)"
7784 test_74a() { # bug 6149, 6184
7785 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7788 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7790 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7791 # will spin in a tight reconnection loop
7792 $LCTL set_param fail_loc=0x8000030e
7793 # get any lock that won't be difficult - lookup works.
7795 $LCTL set_param fail_loc=0
7799 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
7801 test_74b() { # bug 13310
7802 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7804 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7806 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7807 # will spin in a tight reconnection loop
7808 $LCTL set_param fail_loc=0x8000030e
7809 # get a "difficult" lock
7811 $LCTL set_param fail_loc=0
7815 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
7818 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7820 #define OBD_FAIL_LDLM_NEW_LOCK
7821 $LCTL set_param fail_loc=0x319
7822 touch $DIR/$tfile && error "touch successful"
7823 $LCTL set_param fail_loc=0
7826 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
7829 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
7832 test_76() { # Now for bug 20433, added originally in bug 1443
7833 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7835 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
7837 cancel_lru_locks osc
7838 BEFORE_INODES=$(num_inodes)
7839 echo "before inodes: $BEFORE_INODES"
7841 [ "$SLOW" = "no" ] && COUNT=100
7842 for i in $(seq $COUNT); do
7846 cancel_lru_locks osc
7847 AFTER_INODES=$(num_inodes)
7848 echo "after inodes: $AFTER_INODES"
7850 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
7852 AFTER_INODES=$(num_inodes)
7854 echo "wait $wait seconds inodes: $AFTER_INODES"
7855 if [ $wait -gt 30 ]; then
7856 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
7860 run_test 76 "confirm clients recycle inodes properly ===="
7866 # Note: in sptlrpc modes which enable its own bulk checksum, the
7867 # original crc32_le bulk checksum will be automatically disabled,
7868 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
7869 # will be checked by sptlrpc code against sptlrpc bulk checksum.
7870 # In this case set_checksums() will not be no-op, because sptlrpc
7871 # bulk checksum will be enabled all through the test.
7873 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
7874 lctl set_param -n osc.*.checksums $1
7878 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7879 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
7880 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7881 tr -d [] | head -n1)}
7884 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
7885 log "set checksum type to $1"
7888 F77_TMP=$TMP/f77-temp
7891 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
7892 error "error writing to $F77_TMP"
7895 test_77a() { # bug 10889
7896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7897 $GSS && skip_env "could not run with gss"
7899 [ ! -f $F77_TMP ] && setup_f77
7901 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
7905 run_test 77a "normal checksum read/write operation"
7907 test_77b() { # bug 10889
7908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7909 $GSS && skip_env "could not run with gss"
7911 [ ! -f $F77_TMP ] && setup_f77
7912 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7913 $LCTL set_param fail_loc=0x80000409
7916 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7917 error "dd error: $?"
7918 $LCTL set_param fail_loc=0
7920 for algo in $CKSUM_TYPES; do
7921 cancel_lru_locks osc
7922 set_checksum_type $algo
7923 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7924 $LCTL set_param fail_loc=0x80000408
7925 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7926 $LCTL set_param fail_loc=0
7929 set_checksum_type $ORIG_CSUM_TYPE
7932 run_test 77b "checksum error on client write, read"
7937 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7939 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7940 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7941 $check_ost && [ -n "$ost_file_prefix" ] &&
7942 do_facet ost1 rm -f ${ost_file_prefix}\*
7946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7947 $GSS && skip_env "could not run with gss"
7948 remote_ost_nodsh && skip "remote OST with nodsh"
7951 local osc_file_prefix
7953 local check_ost=false
7954 local ost_file_prefix
7960 # ensure corruption will occur on first OSS/OST
7961 $LFS setstripe -i 0 $DIR/$tfile
7963 [ ! -f $F77_TMP ] && setup_f77
7964 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7965 error "dd write error: $?"
7966 fid=$($LFS path2fid $DIR/$tfile)
7968 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
7971 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7972 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7974 echo "OSS do not support bulk pages dump upon error"
7977 osc_file_prefix=$($LCTL get_param -n debug_path)
7978 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7980 trap cleanup_77c EXIT
7983 # enable bulk pages dump upon error on Client
7984 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7985 # enable bulk pages dump upon error on OSS
7987 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7989 # flush Client cache to allow next read to reach OSS
7990 cancel_lru_locks osc
7992 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7993 $LCTL set_param fail_loc=0x80000408
7994 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7995 $LCTL set_param fail_loc=0
7999 # check cksum dump on Client
8000 osc_file=$(ls ${osc_file_prefix}*)
8001 [ -n "$osc_file" ] || error "no checksum dump file on Client"
8002 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
8003 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
8004 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
8005 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
8007 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
8008 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8009 error "dump content does not match on Client"
8011 $check_ost || skip "No need to check cksum dump on OSS"
8013 # check cksum dump on OSS
8014 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
8015 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
8016 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
8017 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
8018 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8019 error "dump content does not match on OSS"
8023 run_test 77c "checksum error on client read with debug"
8025 test_77d() { # bug 10889
8026 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8027 $GSS && skip_env "could not run with gss"
8029 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8030 $LCTL set_param fail_loc=0x80000409
8032 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8033 error "direct write: rc=$?"
8034 $LCTL set_param fail_loc=0
8037 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8038 $LCTL set_param fail_loc=0x80000408
8040 cancel_lru_locks osc
8041 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8042 error "direct read: rc=$?"
8043 $LCTL set_param fail_loc=0
8046 run_test 77d "checksum error on OST direct write, read"
8048 test_77f() { # bug 10889
8049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8050 $GSS && skip_env "could not run with gss"
8053 for algo in $CKSUM_TYPES; do
8054 cancel_lru_locks osc
8055 set_checksum_type $algo
8056 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8057 $LCTL set_param fail_loc=0x409
8058 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
8059 error "direct write succeeded"
8060 $LCTL set_param fail_loc=0
8062 set_checksum_type $ORIG_CSUM_TYPE
8065 run_test 77f "repeat checksum error on write (expect error)"
8067 test_77g() { # bug 10889
8068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8069 $GSS && skip_env "could not run with gss"
8070 remote_ost_nodsh && skip "remote OST with nodsh"
8072 [ ! -f $F77_TMP ] && setup_f77
8074 local file=$DIR/$tfile
8075 stack_trap "rm -f $file" EXIT
8077 $SETSTRIPE -c 1 -i 0 $file
8078 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
8079 do_facet ost1 lctl set_param fail_loc=0x8000021a
8081 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
8082 error "write error: rc=$?"
8083 do_facet ost1 lctl set_param fail_loc=0
8086 cancel_lru_locks osc
8087 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
8088 do_facet ost1 lctl set_param fail_loc=0x8000021b
8090 cmp $F77_TMP $file || error "file compare failed"
8091 do_facet ost1 lctl set_param fail_loc=0
8094 run_test 77g "checksum error on OST write, read"
8096 test_77k() { # LU-10906
8097 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8098 $GSS && skip_env "could not run with gss"
8100 local cksum_param="osc.$FSNAME*.checksums"
8101 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
8105 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
8106 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
8107 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
8111 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
8112 error "failed to set checksum=$i on MGS"
8113 wait_update $HOSTNAME "$get_checksum" $i
8115 echo "remount client, checksum should be $i"
8116 remount_client $MOUNT || error "failed to remount client"
8117 checksum=$(eval $get_checksum)
8118 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8121 for opt in "checksum" "nochecksum"; do
8122 #remount with mount option
8123 echo "remount client with option $opt, checksum should be $i"
8124 umount_client $MOUNT || error "failed to umount client"
8125 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8126 error "failed to mount client with option '$opt'"
8127 checksum=$(eval $get_checksum)
8128 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8132 remount_client $MOUNT || error "failed to remount client"
8134 run_test 77k "enable/disable checksum correctly"
8136 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8145 test_78() { # bug 10901
8146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8147 remote_ost || skip_env "local OST"
8150 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8151 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8152 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8153 echo "MemTotal: $MEMTOTAL"
8155 # reserve 256MB of memory for the kernel and other running processes,
8156 # and then take 1/2 of the remaining memory for the read/write buffers.
8157 if [ $MEMTOTAL -gt 512 ] ;then
8158 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8160 # for those poor memory-starved high-end clusters...
8161 MEMTOTAL=$((MEMTOTAL / 2))
8163 echo "Mem to use for directio: $MEMTOTAL"
8165 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8166 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8167 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8168 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8170 echo "Smallest OST: $SMALLESTOST"
8171 [[ $SMALLESTOST -lt 10240 ]] &&
8172 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8174 trap cleanup_test_78 EXIT
8176 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8177 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8179 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8180 echo "File size: $F78SIZE"
8181 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8182 for i in $(seq 1 $NSEQ); do
8183 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8184 echo directIO rdwr round $i of $NSEQ
8185 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8190 run_test 78 "handle large O_DIRECT writes correctly ============"
8192 test_79() { # bug 12743
8193 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8195 wait_delete_completed
8197 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8198 BKFREE=$(calc_osc_kbytes kbytesfree)
8199 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8201 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8202 DFTOTAL=`echo $STRING | cut -d, -f1`
8203 DFUSED=`echo $STRING | cut -d, -f2`
8204 DFAVAIL=`echo $STRING | cut -d, -f3`
8205 DFFREE=$(($DFTOTAL - $DFUSED))
8207 ALLOWANCE=$((64 * $OSTCOUNT))
8209 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8210 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8211 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8213 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8214 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8215 error "df free($DFFREE) mismatch OST free($BKFREE)"
8217 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8218 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8219 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8222 run_test 79 "df report consistency check ======================="
8224 test_80() { # bug 10718
8225 remote_ost_nodsh && skip "remote OST with nodsh"
8226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8228 # relax strong synchronous semantics for slow backends like ZFS
8229 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8230 local soc="obdfilter.*.sync_lock_cancel"
8231 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8233 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
8234 if [ -z "$save" ]; then
8235 soc="obdfilter.*.sync_on_lock_cancel"
8236 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8239 if [ "$save" != "never" ]; then
8240 local hosts=$(comma_list $(osts_nodes))
8242 do_nodes $hosts $LCTL set_param $soc=never
8243 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
8247 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
8249 local before=$(date +%s)
8250 cancel_lru_locks osc
8251 local after=$(date +%s)
8252 local diff=$((after - before))
8253 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
8257 run_test 80 "Page eviction is equally fast at high offsets too"
8259 test_81a() { # LU-456
8260 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8261 remote_ost_nodsh && skip "remote OST with nodsh"
8263 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8264 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8265 do_facet ost1 lctl set_param fail_loc=0x80000228
8267 # write should trigger a retry and success
8268 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
8269 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8271 if [ $RC -ne 0 ] ; then
8272 error "write should success, but failed for $RC"
8275 run_test 81a "OST should retry write when get -ENOSPC ==============="
8277 test_81b() { # LU-456
8278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8279 remote_ost_nodsh && skip "remote OST with nodsh"
8281 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8282 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8283 do_facet ost1 lctl set_param fail_loc=0x228
8285 # write should retry several times and return -ENOSPC finally
8286 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
8287 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8290 if [ $RC -ne $ENOSPC ] ; then
8291 error "dd should fail for -ENOSPC, but succeed."
8294 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8296 test_82() { # LU-1031
8297 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
8301 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
8303 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
8305 kill -USR1 $MULTIPID2
8307 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
8308 error "First grouplock does not block second one"
8310 echo "Second grouplock blocks first one"
8312 kill -USR1 $MULTIPID1
8316 run_test 82 "Basic grouplock test"
8319 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
8321 test_mkdir $DIR/$tdir.cvsroot
8322 chown $RUNAS_ID $DIR/$tdir.cvsroot
8325 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
8328 # some versions of cvs import exit(1) when asked to import links or
8329 # files they can't read. ignore those files.
8330 local toignore=$(find . -type l -printf '-I %f\n' -o \
8331 ! -perm /4 -printf '-I %f\n')
8332 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
8333 $tdir.reposname vtag rtag
8336 test_mkdir $DIR/$tdir.reposname
8337 chown $RUNAS_ID $DIR/$tdir.reposname
8338 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
8340 cd $DIR/$tdir.reposname
8342 $RUNAS cvs add -m 'addmsg' foo99
8344 $RUNAS cvs commit -m 'nomsg' foo99
8345 rm -fr $DIR/$tdir.cvsroot
8347 run_test 99 "cvs strange file/directory operations"
8350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8351 [[ "$NETTYPE" =~ tcp ]] ||
8352 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
8353 remote_ost_nodsh && skip "remote OST with nodsh"
8354 remote_mds_nodsh && skip "remote MDS with nodsh"
8356 skip "useless for local single node setup"
8358 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
8359 [ "$PROT" != "tcp" ] && continue
8360 RPORT=$(echo $REMOTE | cut -d: -f2)
8361 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
8364 LPORT=`echo $LOCAL | cut -d: -f2`
8365 if [ $LPORT -ge 1024 ]; then
8366 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
8368 error_exit "local: $LPORT > 1024, remote: $RPORT"
8371 [ "$rc" = 0 ] || error_exit "privileged port not found" )
8373 run_test 100 "check local port using privileged port ==========="
8375 function get_named_value()
8384 echo $line | sed "s/^$tag[ ]*//"
8391 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
8392 awk '/^max_cached_mb/ { print $2 }')
8395 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
8400 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8401 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
8406 local cache_limit=32
8408 $LCTL set_param -n osc.*-osc*.rpc_stats 0
8409 trap cleanup_101a EXIT
8410 $LCTL set_param -n llite.*.read_ahead_stats 0
8411 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
8414 # randomly read 10000 of 64K chunks from file 3x 32MB in size
8416 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
8417 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
8420 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
8421 get_named_value 'read but discarded' | cut -d" " -f1); do
8422 discard=$(($discard + $s))
8426 if [[ $(($discard * 10)) -gt $nreads ]]; then
8427 $LCTL get_param osc.*-osc*.rpc_stats
8428 $LCTL get_param llite.*.read_ahead_stats
8429 error "too many ($discard) discarded pages"
8431 rm -f $DIR/$tfile || true
8433 run_test 101a "check read-ahead for random reads"
8436 test_mkdir $DIR/$tdir
8437 local STRIPE_SIZE=$1
8438 local FILE_LENGTH=$2
8441 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
8443 local list=$(comma_list $(osts_nodes))
8444 set_osd_param $list '' read_cache_enable 0
8445 set_osd_param $list '' writethrough_cache_enable 0
8447 trap cleanup_test101bc EXIT
8448 # prepare the read-ahead file
8449 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8451 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
8452 count=$FILE_SIZE_MB 2> /dev/null
8456 cleanup_test101bc() {
8461 local list=$(comma_list $(osts_nodes))
8462 set_osd_param $list '' read_cache_enable 1
8463 set_osd_param $list '' writethrough_cache_enable 1
8467 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8472 local STRIPE_SIZE=$2
8473 local FILE_LENGTH=$3
8474 local RA_INC=1048576
8475 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8476 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8477 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8478 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8479 get_named_value 'read but discarded' |
8480 cut -d" " -f1 | calc_total)
8481 if [[ $DISCARD -gt $discard_limit ]]; then
8482 $LCTL get_param llite.*.read_ahead_stats
8483 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8485 echo "Read-ahead success for size ${READ_SIZE}"
8490 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8491 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8493 local STRIPE_SIZE=1048576
8494 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8496 if [ $SLOW == "yes" ]; then
8497 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8499 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8502 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8504 # prepare the read-ahead file
8505 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8506 cancel_lru_locks osc
8507 for BIDX in 2 4 8 16 32 64 128 256
8509 local BSIZE=$((BIDX*4096))
8510 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
8511 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
8512 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
8513 $LCTL set_param -n llite.*.read_ahead_stats 0
8514 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
8515 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
8516 cancel_lru_locks osc
8517 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
8522 run_test 101b "check stride-io mode read-ahead ================="
8525 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8527 local STRIPE_SIZE=1048576
8528 local FILE_LENGTH=$((STRIPE_SIZE*100))
8533 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8535 cancel_lru_locks osc
8536 $LCTL set_param osc.*.rpc_stats 0
8537 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
8538 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
8539 local stats=$($LCTL get_param -n $osc_rpc_stats)
8540 local lines=$(echo "$stats" | awk 'END {print NR;}')
8543 if [ $lines -le 20 ]; then
8546 for size in 1 2 4 8; do
8547 local rpc=$(echo "$stats" |
8548 awk '($1 == "'$size':") {print $2; exit; }')
8549 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
8550 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
8552 echo "$osc_rpc_stats check passed!"
8557 run_test 101c "check stripe_size aligned read-ahead ================="
8560 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
8561 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
8565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8567 local file=$DIR/$tfile
8568 local sz_MB=${FILESIZE_101d:-500}
8569 local ra_MB=${READAHEAD_MB:-40}
8571 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
8572 [ $free_MB -lt $sz_MB ] &&
8573 skip "Need free space ${sz_MB}M, have ${free_MB}M"
8575 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
8576 $SETSTRIPE -c -1 $file || error "setstripe failed"
8578 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
8579 echo Cancel LRU locks on lustre client to flush the client cache
8580 cancel_lru_locks osc
8582 echo Disable read-ahead
8583 local old_READAHEAD=$(set_read_ahead 0)
8585 echo Reading the test file $file with read-ahead disabled
8586 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8588 echo Cancel LRU locks on lustre client to flush the client cache
8589 cancel_lru_locks osc
8590 echo Enable read-ahead with ${ra_MB}MB
8591 set_read_ahead $ra_MB
8593 echo Reading the test file $file with read-ahead enabled
8594 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8596 echo "read-ahead disabled time read $raOFF"
8597 echo "read-ahead enabled time read $raON"
8599 set_read_ahead $old_READAHEAD
8601 wait_delete_completed
8603 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
8604 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
8606 run_test 101d "file read with and without read-ahead enabled"
8609 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8611 local file=$DIR/$tfile
8612 local size_KB=500 #KB
8616 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
8617 local need_KB=$((count * size_KB))
8618 [[ $free_KB -le $need_KB ]] &&
8619 skip_env "Need free space $need_KB, have $free_KB"
8621 echo "Creating $count ${size_KB}K test files"
8622 for ((i = 0; i < $count; i++)); do
8623 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
8626 echo "Cancel LRU locks on lustre client to flush the client cache"
8627 cancel_lru_locks $OSC
8629 echo "Reset readahead stats"
8630 $LCTL set_param -n llite.*.read_ahead_stats 0
8632 for ((i = 0; i < $count; i++)); do
8633 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
8636 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8637 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8639 for ((i = 0; i < $count; i++)); do
8640 rm -rf $file.$i 2>/dev/null
8643 #10000 means 20% reads are missing in readahead
8644 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
8646 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
8649 which iozone || skip_env "no iozone installed"
8651 local old_debug=$($LCTL get_param debug)
8652 old_debug=${old_debug#*=}
8653 $LCTL set_param debug="reada mmap"
8655 # create a test file
8656 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
8658 echo Cancel LRU locks on lustre client to flush the client cache
8659 cancel_lru_locks osc
8661 echo Reset readahead stats
8662 $LCTL set_param -n llite.*.read_ahead_stats 0
8664 echo mmap read the file with small block size
8665 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
8668 echo checking missing pages
8669 $LCTL get_param llite.*.read_ahead_stats
8670 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8671 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8673 $LCTL set_param debug="$old_debug"
8674 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
8677 run_test 101f "check mmap read performance"
8679 test_101g_brw_size_test() {
8681 local pages=$((mb * 1048576 / PAGE_SIZE))
8682 local file=$DIR/$tfile
8684 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
8685 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
8686 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
8687 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
8691 stack_trap "rm -f $file" EXIT
8692 $LCTL set_param -n osc.*.rpc_stats=0
8694 # 10 RPCs should be enough for the test
8696 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
8697 { error "dd write ${mb} MB blocks failed"; return 3; }
8698 cancel_lru_locks osc
8699 dd of=/dev/null if=$file bs=${mb}M count=$count ||
8700 { error "dd write ${mb} MB blocks failed"; return 4; }
8702 # calculate number of full-sized read and write RPCs
8703 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
8704 sed -n '/pages per rpc/,/^$/p' |
8705 awk '/'$pages':/ { reads += $2; writes += $6 }; \
8706 END { print reads,writes }'))
8707 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
8709 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
8716 remote_ost_nodsh && skip "remote OST with nodsh"
8719 local osts=$(get_facets OST)
8720 local list=$(comma_list $(osts_nodes))
8721 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8722 local brw_size="obdfilter.*.brw_size"
8724 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8726 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
8727 if [ $OST1_VERSION -ge $(version_code 2.8.52) -o \
8728 \( $OST1_VERSION -ge $(version_code 2.7.17) -a \
8729 $OST1_VERSION -lt $(version_code 2.7.50) \) ] &&
8730 [ $CLIENT_VERSION -ge $(version_code 2.8.52) -o \
8731 \( $CLIENT_VERSION -ge $(version_code 2.7.17) -a \
8732 $CLIENT_VERSION -lt $(version_code 2.7.50) \) ]; then
8733 [ $OST1_VERSION -ge $(version_code 2.9.52) ] && suffix="M"
8734 if [[ $orig_mb -lt 16 ]]; then
8735 save_lustre_params $osts "$brw_size" > $p
8736 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
8737 error "set 16MB RPC size failed"
8739 echo "remount client to enable new RPC size"
8740 remount_client $MOUNT || error "remount_client failed"
8743 test_101g_brw_size_test 16 || error "16MB RPC test failed"
8744 # should be able to set brw_size=12, but no rpc_stats for that
8745 test_101g_brw_size_test 8 || error "8MB RPC test failed"
8748 test_101g_brw_size_test 4 || error "4MB RPC test failed"
8750 if [[ $orig_mb -lt 16 ]]; then
8751 restore_lustre_params < $p
8752 remount_client $MOUNT || error "remount_client restore failed"
8755 rm -f $p $DIR/$tfile
8757 run_test 101g "Big bulk(4/16 MiB) readahead"
8760 test_mkdir $DIR/$tdir
8761 chown $RUNAS_ID $DIR/$tdir
8764 STRIPE_COUNT=$OSTCOUNT
8765 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
8767 trap cleanup_test102 EXIT
8769 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
8771 for num in 1 2 3 4; do
8772 for count in $(seq 1 $STRIPE_COUNT); do
8773 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
8774 local size=`expr $STRIPE_SIZE \* $num`
8775 local file=file"$num-$idx-$count"
8776 $1 $SETSTRIPE -S $size -i $idx -c $count $file
8782 $1 tar cf $TMP/f102.tar $tdir --xattrs
8788 rm -rf $DIR/d0.sanity/d102
8792 [ "$UID" != 0 ] && skip "must run as root"
8793 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
8794 skip_env "must have user_xattr"
8796 [ -z "$(which setfattr 2>/dev/null)" ] &&
8797 skip_env "could not find setfattr"
8799 local testfile=$DIR/$tfile
8802 echo "set/get xattr..."
8803 setfattr -n trusted.name1 -v value1 $testfile ||
8804 error "setfattr -n trusted.name1=value1 $testfile failed"
8805 getfattr -n trusted.name1 $testfile 2> /dev/null |
8806 grep "trusted.name1=.value1" ||
8807 error "$testfile missing trusted.name1=value1"
8809 setfattr -n user.author1 -v author1 $testfile ||
8810 error "setfattr -n user.author1=author1 $testfile failed"
8811 getfattr -n user.author1 $testfile 2> /dev/null |
8812 grep "user.author1=.author1" ||
8813 error "$testfile missing trusted.author1=author1"
8816 setfattr -n trusted.name2 -v value2 $testfile ||
8817 error "$testfile unable to set trusted.name2"
8818 setfattr -n trusted.name3 -v value3 $testfile ||
8819 error "$testfile unable to set trusted.name3"
8820 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
8821 grep "trusted.name" | wc -l) -eq 3 ] ||
8822 error "$testfile missing 3 trusted.name xattrs"
8824 setfattr -n user.author2 -v author2 $testfile ||
8825 error "$testfile unable to set user.author2"
8826 setfattr -n user.author3 -v author3 $testfile ||
8827 error "$testfile unable to set user.author3"
8828 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
8829 grep "user.author" | wc -l) -eq 3 ] ||
8830 error "$testfile missing 3 user.author xattrs"
8832 echo "remove xattr..."
8833 setfattr -x trusted.name1 $testfile ||
8834 error "$testfile error deleting trusted.name1"
8835 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
8836 error "$testfile did not delete trusted.name1 xattr"
8838 setfattr -x user.author1 $testfile ||
8839 error "$testfile error deleting user.author1"
8840 echo "set lustre special xattr ..."
8841 $LFS setstripe -c1 $testfile
8842 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
8843 awk -F "=" '/trusted.lov/ { print $2 }' )
8844 setfattr -n "trusted.lov" -v $lovea $testfile ||
8845 error "$testfile doesn't ignore setting trusted.lov again"
8846 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
8847 error "$testfile allow setting invalid trusted.lov"
8850 run_test 102a "user xattr test =================================="
8852 check_102b_layout() {
8854 local testfile=$DIR/$tfile
8856 echo "test layout '$layout'"
8857 $LFS setstripe $layout $testfile || error "setstripe failed"
8858 $LFS getstripe -y $testfile
8860 echo "get/set/list trusted.lov xattr ..." # b=10930
8861 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
8862 [[ "$value" =~ "trusted.lov" ]] ||
8863 error "can't get trusted.lov from $testfile"
8864 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
8865 error "getstripe failed"
8867 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
8869 value=$(cut -d= -f2 <<<$value)
8870 # LU-13168: truncated xattr should fail if short lov_user_md header
8871 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
8872 lens="${#value}" || lens="$(seq 4 2 ${#value})"
8873 for len in $lens; do
8874 echo "setfattr $len $testfile.2"
8875 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
8876 [ $len -lt 66 ] && error "short xattr len=$len worked"
8878 local stripe_size=$($LFS getstripe -S $testfile.2)
8879 local stripe_count=$($LFS getstripe -c $testfile.2)
8880 [[ $stripe_size -eq 65536 ]] ||
8881 error "stripe size $stripe_size != 65536"
8882 [[ $stripe_count -eq $stripe_count_orig ]] ||
8883 error "stripe count $stripe_count != $stripe_count_orig"
8884 rm $testfile $testfile.2
8888 [ -z "$(which setfattr 2>/dev/null)" ] &&
8889 skip_env "could not find setfattr"
8890 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8892 # check plain layout
8893 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
8895 # and also check composite layout
8896 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
8899 run_test 102b "getfattr/setfattr for trusted.lov EAs"
8902 [ -z "$(which setfattr 2>/dev/null)" ] &&
8903 skip_env "could not find setfattr"
8904 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8906 # b10930: get/set/list lustre.lov xattr
8907 echo "get/set/list lustre.lov xattr ..."
8908 test_mkdir $DIR/$tdir
8909 chown $RUNAS_ID $DIR/$tdir
8910 local testfile=$DIR/$tdir/$tfile
8911 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8912 error "setstripe failed"
8913 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
8914 error "getstripe failed"
8915 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
8916 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8918 local testfile2=${testfile}2
8919 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8920 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8922 $RUNAS $MCREATE $testfile2
8923 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8924 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
8925 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
8926 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8927 [ $stripe_count -eq $STRIPECOUNT ] ||
8928 error "stripe count $stripe_count != $STRIPECOUNT"
8930 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8932 compare_stripe_info1() {
8933 local stripe_index_all_zero=true
8935 for num in 1 2 3 4; do
8936 for count in $(seq 1 $STRIPE_COUNT); do
8937 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8938 local size=$((STRIPE_SIZE * num))
8939 local file=file"$num-$offset-$count"
8940 stripe_size=$($LFS getstripe -S $PWD/$file)
8941 [[ $stripe_size -ne $size ]] &&
8942 error "$file: size $stripe_size != $size"
8943 stripe_count=$($LFS getstripe -c $PWD/$file)
8944 # allow fewer stripes to be created, ORI-601
8945 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8946 error "$file: count $stripe_count != $count"
8947 stripe_index=$($LFS getstripe -i $PWD/$file)
8948 [[ $stripe_index -ne 0 ]] &&
8949 stripe_index_all_zero=false
8953 $stripe_index_all_zero &&
8954 error "all files are being extracted starting from OST index 0"
8958 have_xattrs_include() {
8959 tar --help | grep -q xattrs-include &&
8960 echo --xattrs-include="lustre.*"
8964 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8965 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8967 XINC=$(have_xattrs_include)
8969 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8971 compare_stripe_info1
8973 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8976 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8977 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8979 XINC=$(have_xattrs_include)
8981 test_mkdir $DIR/$tdir.restore
8983 tar cf - --xattrs $tdir | tar xf - \
8984 -C $DIR/$tdir.restore --xattrs $XINC
8985 cd $DIR/$tdir.restore/$tdir
8986 compare_stripe_info1
8988 run_test 102f "tar copy files, not keep osts"
8991 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8992 skip "must have user_xattr"
8993 [ -z "$(which setfattr 2>/dev/null)" ] &&
8994 skip_env "could not find setfattr"
8995 [ -z "$(which getfattr 2>/dev/null)" ] &&
8996 skip_env "could not find getfattr"
8998 local xsize=${1:-1024} # in bytes
8999 local file=$DIR/$tfile
9000 local value="$(generate_string $xsize)"
9001 local xbig=trusted.big
9004 log "save $xbig on $file"
9005 setfattr -n $xbig -v $value $file ||
9006 error "saving $xbig on $file failed"
9008 local orig=$(get_xattr_value $xbig $file)
9009 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
9011 local xsml=trusted.sml
9012 log "save $xsml on $file"
9013 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
9015 local new=$(get_xattr_value $xbig $file)
9016 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
9018 log "grow $xsml on $file"
9019 setfattr -n $xsml -v "$value" $file ||
9020 error "growing $xsml on $file failed"
9022 new=$(get_xattr_value $xbig $file)
9023 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
9024 log "$xbig still valid after growing $xsml"
9029 test_102h() { # bug 15777
9032 run_test 102h "grow xattr from inside inode to external block"
9035 large_xattr_enabled || skip_env "ea_inode feature disabled"
9037 grow_xattr $(max_xattr_size)
9039 run_test 102ha "grow xattr from inside inode to external inode"
9041 test_102i() { # bug 17038
9042 [ -z "$(which getfattr 2>/dev/null)" ] &&
9043 skip "could not find getfattr"
9046 ln -s $DIR/$tfile $DIR/${tfile}link
9047 getfattr -n trusted.lov $DIR/$tfile ||
9048 error "lgetxattr on $DIR/$tfile failed"
9049 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
9050 grep -i "no such attr" ||
9051 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
9052 rm -f $DIR/$tfile $DIR/${tfile}link
9054 run_test 102i "lgetxattr test on symbolic link ============"
9057 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9058 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9060 XINC=$(have_xattrs_include)
9061 setup_test102 "$RUNAS"
9062 chown $RUNAS_ID $DIR/$tdir
9063 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9065 compare_stripe_info1 "$RUNAS"
9067 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
9070 [ -z "$(which setfattr 2>/dev/null)" ] &&
9071 skip "could not find setfattr"
9074 # b22187 just check that does not crash for regular file.
9075 setfattr -n trusted.lov $DIR/$tfile
9076 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9077 local test_kdir=$DIR/$tdir
9078 test_mkdir $test_kdir
9079 local default_size=$($LFS getstripe -S $test_kdir)
9080 local default_count=$($LFS getstripe -c $test_kdir)
9081 local default_offset=$($LFS getstripe -i $test_kdir)
9082 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9083 error 'dir setstripe failed'
9084 setfattr -n trusted.lov $test_kdir
9085 local stripe_size=$($LFS getstripe -S $test_kdir)
9086 local stripe_count=$($LFS getstripe -c $test_kdir)
9087 local stripe_offset=$($LFS getstripe -i $test_kdir)
9088 [ $stripe_size -eq $default_size ] ||
9089 error "stripe size $stripe_size != $default_size"
9090 [ $stripe_count -eq $default_count ] ||
9091 error "stripe count $stripe_count != $default_count"
9092 [ $stripe_offset -eq $default_offset ] ||
9093 error "stripe offset $stripe_offset != $default_offset"
9094 rm -rf $DIR/$tfile $test_kdir
9096 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9099 [ -z "$(which getfattr 2>/dev/null)" ] &&
9100 skip "could not find getfattr"
9102 # LU-532 trusted. xattr is invisible to non-root
9103 local testfile=$DIR/$tfile
9107 echo "listxattr as user..."
9108 chown $RUNAS_ID $testfile
9109 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9110 grep -q "trusted" &&
9111 error "$testfile trusted xattrs are user visible"
9115 run_test 102l "listxattr size test =================================="
9117 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9118 local path=$DIR/$tfile
9121 listxattr_size_check $path || error "listattr_size_check $path failed"
9123 run_test 102m "Ensure listxattr fails on small bufffer ========"
9127 getxattr() { # getxattr path name
9128 # Return the base64 encoding of the value of xattr name on path.
9132 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9134 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9136 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9138 getfattr --absolute-names --encoding=base64 --name=$name $path |
9139 awk -F= -v name=$name '$1 == name {
9140 print substr($0, index($0, "=") + 1);
9144 test_102n() { # LU-4101 mdt: protect internal xattrs
9145 [ -z "$(which setfattr 2>/dev/null)" ] &&
9146 skip "could not find setfattr"
9147 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9149 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
9152 local file0=$DIR/$tfile.0
9153 local file1=$DIR/$tfile.1
9154 local xattr0=$TMP/$tfile.0
9155 local xattr1=$TMP/$tfile.1
9156 local namelist="lov lma lmv link fid version som hsm"
9160 rm -rf $file0 $file1 $xattr0 $xattr1
9163 # Get 'before' xattrs of $file1.
9164 getfattr --absolute-names --dump --match=- $file1 > $xattr0
9166 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
9167 namelist+=" lfsck_namespace"
9168 for name in $namelist; do
9169 # Try to copy xattr from $file0 to $file1.
9170 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9172 setfattr --name=trusted.$name --value="$value" $file1 ||
9173 error "setxattr 'trusted.$name' failed"
9175 # Try to set a garbage xattr.
9176 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9178 if [[ x$name == "xlov" ]]; then
9179 setfattr --name=trusted.lov --value="$value" $file1 &&
9180 error "setxattr invalid 'trusted.lov' success"
9182 setfattr --name=trusted.$name --value="$value" $file1 ||
9183 error "setxattr invalid 'trusted.$name' failed"
9186 # Try to remove the xattr from $file1. We don't care if this
9187 # appears to succeed or fail, we just don't want there to be
9188 # any changes or crashes.
9189 setfattr --remove=$trusted.$name $file1 2> /dev/null
9192 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
9195 # Try to copy xattr from $file0 to $file1.
9196 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9198 setfattr --name=trusted.$name --value="$value" $file1 ||
9199 error "setxattr 'trusted.$name' failed"
9201 # Try to set a garbage xattr.
9202 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9204 setfattr --name=trusted.$name --value="$value" $file1 ||
9205 error "setxattr 'trusted.$name' failed"
9207 # Try to remove the xattr from $file1. We don't care if this
9208 # appears to succeed or fail, we just don't want there to be
9209 # any changes or crashes.
9210 setfattr --remove=$trusted.$name $file1 2> /dev/null
9213 # Get 'after' xattrs of file1.
9214 getfattr --absolute-names --dump --match=- $file1 > $xattr1
9216 if ! diff $xattr0 $xattr1; then
9217 error "before and after xattrs of '$file1' differ"
9220 rm -rf $file0 $file1 $xattr0 $xattr1
9224 run_test 102n "silently ignore setxattr on internal trusted xattrs"
9226 test_102p() { # LU-4703 setxattr did not check ownership
9227 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
9228 skip "MDS needs to be at least 2.5.56"
9230 local testfile=$DIR/$tfile
9234 echo "setfacl as user..."
9235 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
9236 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
9238 echo "setfattr as user..."
9239 setfacl -m "u:$RUNAS_ID:---" $testfile
9240 $RUNAS setfattr -x system.posix_acl_access $testfile
9241 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
9243 run_test 102p "check setxattr(2) correctly fails without permission"
9246 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
9247 skip "MDS needs to be at least 2.6.92"
9249 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
9251 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
9254 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
9255 skip "MDS needs to be at least 2.6.93"
9257 touch $DIR/$tfile || error "touch"
9258 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
9259 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
9260 rm $DIR/$tfile || error "rm"
9263 mkdir -p $DIR/$tdir || error "mkdir"
9264 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9265 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9266 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9267 error "$testfile error deleting user.author1"
9268 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9269 grep "user.$(basename $tdir)" &&
9270 error "$tdir did not delete user.$(basename $tdir)"
9271 rmdir $DIR/$tdir || error "rmdir"
9274 test_mkdir $DIR/$tdir
9275 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9276 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9277 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9278 error "$testfile error deleting user.author1"
9279 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9280 grep "user.$(basename $tdir)" &&
9281 error "$tdir did not delete user.$(basename $tdir)"
9282 rmdir $DIR/$tdir || error "rm striped dir"
9284 run_test 102r "set EAs with empty values"
9287 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9288 skip "MDS needs to be at least 2.11.52"
9290 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9292 save_lustre_params client "llite.*.xattr_cache" > $save
9294 for cache in 0 1; do
9295 lctl set_param llite.*.xattr_cache=$cache
9298 touch $DIR/$tfile || error "touch"
9299 for prefix in lustre security system trusted user; do
9300 # Note getxattr() may fail with 'Operation not
9301 # supported' or 'No such attribute' depending
9302 # on prefix and cache.
9303 getfattr -n $prefix.n102s $DIR/$tfile &&
9304 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
9308 restore_lustre_params < $save
9310 run_test 102s "getting nonexistent xattrs should fail"
9313 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9314 skip "MDS needs to be at least 2.11.52"
9316 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9318 save_lustre_params client "llite.*.xattr_cache" > $save
9320 for cache in 0 1; do
9321 lctl set_param llite.*.xattr_cache=$cache
9323 for buf_size in 0 256; do
9325 touch $DIR/$tfile || error "touch"
9326 setfattr -n user.multiop $DIR/$tfile
9327 $MULTIOP $DIR/$tfile oa$buf_size ||
9328 error "cannot get zero length xattr value (buf_size = $buf_size)"
9332 restore_lustre_params < $save
9334 run_test 102t "zero length xattr values handled correctly"
9338 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
9343 [ "$UID" != 0 ] && skip "must run as root"
9344 $GSS && skip_env "could not run under gss"
9345 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
9346 skip_env "must have acl enabled"
9347 [ -z "$(which setfacl 2>/dev/null)" ] &&
9348 skip_env "could not find setfacl"
9349 remote_mds_nodsh && skip "remote MDS with nodsh"
9351 gpasswd -a daemon bin # LU-5641
9352 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
9354 declare -a identity_old
9356 for num in $(seq $MDSCOUNT); do
9357 switch_identity $num true || identity_old[$num]=$?
9365 echo "performing cp ..."
9366 run_acl_subtest cp || error "run_acl_subtest cp failed"
9367 echo "performing getfacl-noacl..."
9368 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
9369 echo "performing misc..."
9370 run_acl_subtest misc || error "misc test failed"
9371 echo "performing permissions..."
9372 run_acl_subtest permissions || error "permissions failed"
9373 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
9374 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
9375 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
9376 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
9378 echo "performing permissions xattr..."
9379 run_acl_subtest permissions_xattr ||
9380 error "permissions_xattr failed"
9382 echo "performing setfacl..."
9383 run_acl_subtest setfacl || error "setfacl test failed"
9385 # inheritance test got from HP
9386 echo "performing inheritance..."
9387 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
9388 chmod +x make-tree || error "chmod +x failed"
9389 run_acl_subtest inheritance || error "inheritance test failed"
9392 echo "LU-974 ignore umask when acl is enabled..."
9393 run_acl_subtest 974 || error "LU-974 umask test failed"
9394 if [ $MDSCOUNT -ge 2 ]; then
9395 run_acl_subtest 974_remote ||
9396 error "LU-974 umask test failed under remote dir"
9399 echo "LU-2561 newly created file is same size as directory..."
9400 if [ "$mds1_FSTYPE" != "zfs" ]; then
9401 run_acl_subtest 2561 || error "LU-2561 test failed"
9403 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
9406 run_acl_subtest 4924 || error "LU-4924 test failed"
9411 for num in $(seq $MDSCOUNT); do
9412 if [ "${identity_old[$num]}" = 1 ]; then
9413 switch_identity $num false || identity_old[$num]=$?
9417 run_test 103a "acl test"
9423 for U in {0..511}; do
9425 local O=$(printf "%04o" $U)
9427 umask $(printf "%04o" $((511 ^ $O)))
9428 $LFS setstripe -c 1 $DIR/$tfile.s$O
9429 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9431 (( $S == ($O & 0666) )) ||
9432 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9434 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9435 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9436 (( $S == ($O & 0666) )) ||
9437 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9439 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9440 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9441 (( $S == ($O & 0666) )) ||
9442 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9443 rm -f $DIR/$tfile.[smp]$0
9447 # limit the concurrently running threads to 64. LU-11878
9448 local idx=$((U % 64))
9449 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9454 run_test 103b "umask lfs setstripe"
9458 cp -rp $DIR/$tdir $DIR/$tdir.bak
9460 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9461 error "$DIR/$tdir shouldn't contain default ACL"
9462 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9463 error "$DIR/$tdir.bak shouldn't contain default ACL"
9466 run_test 103c "'cp -rp' won't set empty acl"
9469 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9472 lfs df || error "lfs df failed"
9473 lfs df -ih || error "lfs df -ih failed"
9474 lfs df -h $DIR || error "lfs df -h $DIR failed"
9475 lfs df -i $DIR || error "lfs df -i $DIR failed"
9476 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9477 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9479 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9480 lctl --device %$OSC deactivate
9481 lfs df || error "lfs df with deactivated OSC failed"
9482 lctl --device %$OSC activate
9483 # wait the osc back to normal
9484 wait_osc_import_ready client ost
9486 lfs df || error "lfs df with reactivated OSC failed"
9489 run_test 104a "lfs df [-ih] [path] test ========================="
9492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9493 [ $RUNAS_ID -eq $UID ] &&
9494 skip_env "RUNAS_ID = UID = $UID -- skipping"
9496 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
9497 grep "Permission denied" | wc -l)))
9498 if [ $denied_cnt -ne 0 ]; then
9499 error "lfs check servers test failed"
9502 run_test 104b "$RUNAS lfs check servers test ===================="
9505 # Verify $1 is within range of $2.
9506 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
9507 # $1 is <= 2% of $2. Else Fail.
9510 # Strip all units (M, G, T)
9511 actual=$(echo $1 | tr -d A-Z)
9512 expect=$(echo $2 | tr -d A-Z)
9514 expect_lo=$(($expect * 98 / 100)) # 2% below
9515 expect_hi=$(($expect * 102 / 100)) # 2% above
9517 # permit 2% drift above and below
9518 (( $actual >= $expect_lo && $actual <= $expect_hi ))
9522 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9523 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
9525 local ost_param="osd-zfs.$FSNAME-OST0000."
9526 local mdt_param="osd-zfs.$FSNAME-MDT0000."
9527 local ofacets=$(get_facets OST)
9528 local mfacets=$(get_facets MDS)
9529 local saved_ost_blocks=
9530 local saved_mdt_blocks=
9532 echo "Before recordsize change"
9533 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
9534 df=($(df -h | grep "/mnt/lustre"$))
9537 echo "lfs output : ${lfs_df[*]}"
9538 echo "df output : ${df[*]}"
9540 for facet in ${ofacets//,/ }; do
9541 if [ -z $saved_ost_blocks ]; then
9542 saved_ost_blocks=$(do_facet $facet \
9543 lctl get_param -n $ost_param.blocksize)
9544 echo "OST Blocksize: $saved_ost_blocks"
9546 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
9547 do_facet $facet zfs set recordsize=32768 $ost
9550 # BS too small. Sufficient for functional testing.
9551 for facet in ${mfacets//,/ }; do
9552 if [ -z $saved_mdt_blocks ]; then
9553 saved_mdt_blocks=$(do_facet $facet \
9554 lctl get_param -n $mdt_param.blocksize)
9555 echo "MDT Blocksize: $saved_mdt_blocks"
9557 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
9558 do_facet $facet zfs set recordsize=32768 $mdt
9561 # Give new values chance to reflect change
9564 echo "After recordsize change"
9565 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
9566 df_after=($(df -h | grep "/mnt/lustre"$))
9569 echo "lfs output : ${lfs_df_after[*]}"
9570 echo "df output : ${df_after[*]}"
9573 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
9574 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
9575 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
9576 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
9577 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
9578 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
9581 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
9582 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
9583 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
9584 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
9585 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
9586 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
9588 # Restore MDT recordize back to original
9589 for facet in ${mfacets//,/ }; do
9590 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
9591 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
9594 # Restore OST recordize back to original
9595 for facet in ${ofacets//,/ }; do
9596 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
9597 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
9602 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
9605 # doesn't work on 2.4 kernels
9607 if $(flock_is_enabled); then
9608 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
9610 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
9614 run_test 105a "flock when mounted without -o flock test ========"
9618 if $(flock_is_enabled); then
9619 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
9621 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
9625 run_test 105b "fcntl when mounted without -o flock test ========"
9629 if $(flock_is_enabled); then
9630 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
9632 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
9636 run_test 105c "lockf when mounted without -o flock test"
9638 test_105d() { # bug 15924
9639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9641 test_mkdir $DIR/$tdir
9642 flock_is_enabled || skip_env "mount w/o flock enabled"
9643 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
9644 $LCTL set_param fail_loc=0x80000315
9645 flocks_test 2 $DIR/$tdir
9647 run_test 105d "flock race (should not freeze) ========"
9649 test_105e() { # bug 22660 && 22040
9650 flock_is_enabled || skip_env "mount w/o flock enabled"
9653 flocks_test 3 $DIR/$tfile
9655 run_test 105e "Two conflicting flocks from same process"
9657 test_106() { #bug 10921
9658 test_mkdir $DIR/$tdir
9659 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
9660 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
9662 run_test 106 "attempt exec of dir followed by chown of that dir"
9665 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9673 local save_pattern=$(sysctl -n kernel.core_pattern)
9674 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
9675 sysctl -w kernel.core_pattern=$file
9676 sysctl -w kernel.core_uses_pid=0
9684 kill -s 11 $SLEEPPID
9686 if [ -e $file ]; then
9687 size=`stat -c%s $file`
9688 [ $size -eq 0 ] && error "Fail to create core file $file"
9690 error "Fail to create core file $file"
9693 sysctl -w kernel.core_pattern=$save_pattern
9694 sysctl -w kernel.core_uses_pid=$save_uses_pid
9697 run_test 107 "Coredump on SIG"
9700 test_mkdir $DIR/$tdir
9701 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
9702 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
9703 error "mkdir with 256 char should fail, but did not"
9704 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
9705 error "create with 255 char failed"
9706 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
9707 error "create with 256 char should fail, but did not"
9712 run_test 110 "filename length checking"
9715 # Purpose: To verify dynamic thread (OSS) creation.
9718 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9719 remote_ost_nodsh && skip "remote OST with nodsh"
9721 # Lustre does not stop service threads once they are started.
9722 # Reset number of running threads to default.
9727 local save_params="$TMP/sanity-$TESTNAME.parameters"
9729 # Get ll_ost_io count before I/O
9730 OSTIO_pre=$(do_facet ost1 \
9731 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9732 # Exit if lustre is not running (ll_ost_io not running).
9733 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9735 echo "Starting with $OSTIO_pre threads"
9736 local thread_max=$((OSTIO_pre * 2))
9737 local rpc_in_flight=$((thread_max * 2))
9738 # Number of I/O Process proposed to be started.
9740 local facets=$(get_facets OST)
9742 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9743 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9745 # Set in_flight to $rpc_in_flight
9746 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9747 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9748 nfiles=${rpc_in_flight}
9749 # Set ost thread_max to $thread_max
9750 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
9752 # 5 Minutes should be sufficient for max number of OSS
9753 # threads(thread_max) to be created.
9757 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
9758 test_mkdir $DIR/$tdir
9759 for i in $(seq $nfiles); do
9760 local file=$DIR/$tdir/${tfile}-$i
9761 $LFS setstripe -c -1 -i 0 $file
9762 ($WTL $file $timeout)&
9765 # I/O Started - Wait for thread_started to reach thread_max or report
9766 # error if thread_started is more than thread_max.
9767 echo "Waiting for thread_started to reach thread_max"
9768 local thread_started=0
9769 local end_time=$((SECONDS + timeout))
9771 while [ $SECONDS -le $end_time ] ; do
9773 # Get ost i/o thread_started count.
9774 thread_started=$(do_facet ost1 \
9776 ost.OSS.ost_io.threads_started | cut -d= -f2")
9777 # Break out if thread_started is equal/greater than thread_max
9778 if [[ $thread_started -ge $thread_max ]]; then
9779 echo ll_ost_io thread_started $thread_started, \
9780 equal/greater than thread_max $thread_max
9786 # Cleanup - We have the numbers, Kill i/o jobs if running.
9787 jobcount=($(jobs -p))
9788 for i in $(seq 0 $((${#jobcount[@]}-1)))
9790 kill -9 ${jobcount[$i]}
9791 if [ $? -ne 0 ] ; then
9793 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
9797 # Cleanup files left by WTL binary.
9798 for i in $(seq $nfiles); do
9799 local file=$DIR/$tdir/${tfile}-$i
9801 if [ $? -ne 0 ] ; then
9802 echo "Warning: Failed to delete file $file"
9806 restore_lustre_params <$save_params
9807 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
9809 # Error out if no new thread has started or Thread started is greater
9811 if [[ $thread_started -le $OSTIO_pre ||
9812 $thread_started -gt $thread_max ]]; then
9813 error "ll_ost_io: thread_started $thread_started" \
9814 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
9815 "No new thread started or thread started greater " \
9819 run_test 115 "verify dynamic thread creation===================="
9822 wait_delete_completed
9823 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
9824 echo "OST kbytes available: ${AVAIL[@]}"
9829 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
9830 #echo OST $i: ${AVAIL[i]}kb
9831 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
9835 if [[ ${AVAIL[i]} -lt $MINV ]]; then
9840 echo "Min free space: OST $MINI: $MINV"
9841 echo "Max free space: OST $MAXI: $MAXV"
9844 test_116a() { # was previously test_116()
9845 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9846 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9847 remote_mds_nodsh && skip "remote MDS with nodsh"
9849 echo -n "Free space priority "
9850 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
9855 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
9856 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
9857 trap simple_cleanup_common EXIT
9859 # Check if we need to generate uneven OSTs
9860 test_mkdir -p $DIR/$tdir/OST${MINI}
9861 local FILL=$((MINV / 4))
9862 local DIFF=$((MAXV - MINV))
9863 local DIFF2=$((DIFF * 100 / MINV))
9865 local threshold=$(do_facet $SINGLEMDS \
9866 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
9867 threshold=${threshold%%%}
9868 echo -n "Check for uneven OSTs: "
9869 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
9871 if [[ $DIFF2 -gt $threshold ]]; then
9873 echo "Don't need to fill OST$MINI"
9875 # generate uneven OSTs. Write 2% over the QOS threshold value
9877 DIFF=$((threshold - DIFF2 + 2))
9878 DIFF2=$((MINV * DIFF / 100))
9879 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
9880 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
9881 error "setstripe failed"
9882 DIFF=$((DIFF2 / 2048))
9884 while [ $i -lt $DIFF ]; do
9886 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
9887 bs=2M count=1 2>/dev/null
9896 DIFF=$((MAXV - MINV))
9897 DIFF2=$((DIFF * 100 / MINV))
9898 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
9899 if [ $DIFF2 -gt $threshold ]; then
9902 echo "failed - QOS mode won't be used"
9903 simple_cleanup_common
9904 skip "QOS imbalance criteria not met"
9912 # now fill using QOS
9913 $SETSTRIPE -c 1 $DIR/$tdir
9914 FILL=$((FILL / 200))
9915 if [ $FILL -gt 600 ]; then
9918 echo "writing $FILL files to QOS-assigned OSTs"
9920 while [ $i -lt $FILL ]; do
9922 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
9926 echo "wrote $i 200k files"
9930 echo "Note: free space may not be updated, so measurements might be off"
9932 DIFF2=$((MAXV - MINV))
9933 echo "free space delta: orig $DIFF final $DIFF2"
9934 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
9935 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
9936 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
9937 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
9938 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
9939 if [[ $DIFF -gt 0 ]]; then
9940 FILL=$((DIFF2 * 100 / DIFF - 100))
9941 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
9944 # Figure out which files were written where
9945 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9946 awk '/'$MINI1': / {print $2; exit}')
9948 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9949 echo "$MINC files created on smaller OST $MINI1"
9950 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9951 awk '/'$MAXI1': / {print $2; exit}')
9953 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9954 echo "$MAXC files created on larger OST $MAXI1"
9955 if [[ $MINC -gt 0 ]]; then
9956 FILL=$((MAXC * 100 / MINC - 100))
9957 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
9959 [[ $MAXC -gt $MINC ]] ||
9960 error_ignore LU-9 "stripe QOS didn't balance free space"
9961 simple_cleanup_common
9963 run_test 116a "stripe QOS: free space balance ==================="
9965 test_116b() { # LU-2093
9966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9967 remote_mds_nodsh && skip "remote MDS with nodsh"
9969 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
9970 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
9971 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
9972 [ -z "$old_rr" ] && skip "no QOS"
9973 do_facet $SINGLEMDS lctl set_param \
9974 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
9976 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
9977 createmany -o $DIR/$tdir/f- 20 || error "can't create"
9978 do_facet $SINGLEMDS lctl set_param fail_loc=0
9980 do_facet $SINGLEMDS lctl set_param \
9981 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
9983 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
9985 test_117() # bug 10891
9987 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9989 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
9990 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
9991 lctl set_param fail_loc=0x21e
9992 > $DIR/$tfile || error "truncate failed"
9993 lctl set_param fail_loc=0
9994 echo "Truncate succeeded."
9997 run_test 117 "verify osd extend =========="
9999 NO_SLOW_RESENDCOUNT=4
10000 export OLD_RESENDCOUNT=""
10001 set_resend_count () {
10002 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
10003 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
10004 lctl set_param -n $PROC_RESENDCOUNT $1
10005 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
10008 # for reduce test_118* time (b=14842)
10009 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10011 # Reset async IO behavior after error case
10013 FILE=$DIR/reset_async
10015 # Ensure all OSCs are cleared
10016 $SETSTRIPE -c -1 $FILE
10017 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
10022 test_118a() #bug 11710
10024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10028 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10029 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10030 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10032 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10033 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10038 run_test 118a "verify O_SYNC works =========="
10042 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10043 remote_ost_nodsh && skip "remote OST with nodsh"
10047 #define OBD_FAIL_SRV_ENOENT 0x217
10048 set_nodes_failloc "$(osts_nodes)" 0x217
10049 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10051 set_nodes_failloc "$(osts_nodes)" 0
10052 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10053 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10056 if [[ $RC -eq 0 ]]; then
10057 error "Must return error due to dropped pages, rc=$RC"
10061 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10062 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10066 echo "Dirty pages not leaked on ENOENT"
10068 # Due to the above error the OSC will issue all RPCs syncronously
10069 # until a subsequent RPC completes successfully without error.
10070 $MULTIOP $DIR/$tfile Ow4096yc
10075 run_test 118b "Reclaim dirty pages on fatal error =========="
10079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10081 # for 118c, restore the original resend count, LU-1940
10082 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
10083 set_resend_count $OLD_RESENDCOUNT
10084 remote_ost_nodsh && skip "remote OST with nodsh"
10088 #define OBD_FAIL_OST_EROFS 0x216
10089 set_nodes_failloc "$(osts_nodes)" 0x216
10091 # multiop should block due to fsync until pages are written
10092 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10096 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10097 error "Multiop failed to block on fsync, pid=$MULTIPID"
10100 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10102 if [[ $WRITEBACK -eq 0 ]]; then
10103 error "No page in writeback, writeback=$WRITEBACK"
10106 set_nodes_failloc "$(osts_nodes)" 0
10109 if [[ $RC -ne 0 ]]; then
10110 error "Multiop fsync failed, rc=$RC"
10113 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10114 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10116 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10117 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10121 echo "Dirty pages flushed via fsync on EROFS"
10124 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
10126 # continue to use small resend count to reduce test_118* time (b=14842)
10127 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10132 remote_ost_nodsh && skip "remote OST with nodsh"
10136 #define OBD_FAIL_OST_BRW_PAUSE_BULK
10137 set_nodes_failloc "$(osts_nodes)" 0x214
10138 # multiop should block due to fsync until pages are written
10139 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10143 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10144 error "Multiop failed to block on fsync, pid=$MULTIPID"
10147 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10149 if [[ $WRITEBACK -eq 0 ]]; then
10150 error "No page in writeback, writeback=$WRITEBACK"
10153 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
10154 set_nodes_failloc "$(osts_nodes)" 0
10156 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10157 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10159 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10160 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10164 echo "Dirty pages gaurenteed flushed via fsync"
10167 run_test 118d "Fsync validation inject a delay of the bulk =========="
10170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10174 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10175 lctl set_param fail_loc=0x8000040a
10177 # Should simulate EINVAL error which is fatal
10178 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10180 if [[ $RC -eq 0 ]]; then
10181 error "Must return error due to dropped pages, rc=$RC"
10184 lctl set_param fail_loc=0x0
10186 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10187 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10188 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10190 if [[ $LOCKED -ne 0 ]]; then
10191 error "Locked pages remain in cache, locked=$LOCKED"
10194 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10195 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10199 echo "No pages locked after fsync"
10204 run_test 118f "Simulate unrecoverable OSC side error =========="
10207 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10211 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10212 lctl set_param fail_loc=0x406
10214 # simulate local -ENOMEM
10215 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10218 lctl set_param fail_loc=0
10219 if [[ $RC -eq 0 ]]; then
10220 error "Must return error due to dropped pages, rc=$RC"
10223 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10224 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10225 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10227 if [[ $LOCKED -ne 0 ]]; then
10228 error "Locked pages remain in cache, locked=$LOCKED"
10231 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10232 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10236 echo "No pages locked after fsync"
10241 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10244 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10245 remote_ost_nodsh && skip "remote OST with nodsh"
10249 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10250 set_nodes_failloc "$(osts_nodes)" 0x20e
10251 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10252 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10255 set_nodes_failloc "$(osts_nodes)" 0
10256 if [[ $RC -eq 0 ]]; then
10257 error "Must return error due to dropped pages, rc=$RC"
10260 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10261 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10262 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10264 if [[ $LOCKED -ne 0 ]]; then
10265 error "Locked pages remain in cache, locked=$LOCKED"
10268 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10269 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10273 echo "No pages locked after fsync"
10277 run_test 118h "Verify timeout in handling recoverables errors =========="
10279 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10282 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10283 remote_ost_nodsh && skip "remote OST with nodsh"
10287 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10288 set_nodes_failloc "$(osts_nodes)" 0x20e
10290 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10291 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10294 set_nodes_failloc "$(osts_nodes)" 0
10298 if [[ $RC -ne 0 ]]; then
10299 error "got error, but should be not, rc=$RC"
10302 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10303 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10304 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10305 if [[ $LOCKED -ne 0 ]]; then
10306 error "Locked pages remain in cache, locked=$LOCKED"
10309 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10310 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10314 echo "No pages locked after fsync"
10318 run_test 118i "Fix error before timeout in recoverable error =========="
10320 [ "$SLOW" = "no" ] && set_resend_count 4
10323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10324 remote_ost_nodsh && skip "remote OST with nodsh"
10328 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
10329 set_nodes_failloc "$(osts_nodes)" 0x220
10331 # return -EIO from OST
10332 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10334 set_nodes_failloc "$(osts_nodes)" 0x0
10335 if [[ $RC -eq 0 ]]; then
10336 error "Must return error due to dropped pages, rc=$RC"
10339 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10340 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10341 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10342 if [[ $LOCKED -ne 0 ]]; then
10343 error "Locked pages remain in cache, locked=$LOCKED"
10346 # in recoverable error on OST we want resend and stay until it finished
10347 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10348 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10352 echo "No pages locked after fsync"
10356 run_test 118j "Simulate unrecoverable OST side error =========="
10360 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10361 remote_ost_nodsh && skip "remote OSTs with nodsh"
10363 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10364 set_nodes_failloc "$(osts_nodes)" 0x20e
10365 test_mkdir $DIR/$tdir
10367 for ((i=0;i<10;i++)); do
10368 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
10369 error "dd to $DIR/$tdir/$tfile-$i failed" )&
10376 set_nodes_failloc "$(osts_nodes)" 0
10379 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
10381 test_118l() # LU-646
10383 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10385 test_mkdir $DIR/$tdir
10386 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
10389 run_test 118l "fsync dir"
10391 test_118m() # LU-3066
10393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10395 test_mkdir $DIR/$tdir
10396 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
10399 run_test 118m "fdatasync dir ========="
10401 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10408 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10409 remote_ost_nodsh && skip "remote OSTs with nodsh"
10411 # Sleep to avoid a cached response.
10412 #define OBD_STATFS_CACHE_SECONDS 1
10415 # Inject a 10 second delay in the OST_STATFS handler.
10416 #define OBD_FAIL_OST_STATFS_DELAY 0x242
10417 set_nodes_failloc "$(osts_nodes)" 0x242
10420 stat --file-system $MOUNT > /dev/null
10423 set_nodes_failloc "$(osts_nodes)" 0
10425 if ((end - begin > 20)); then
10426 error "statfs took $((end - begin)) seconds, expected 10"
10429 run_test 118n "statfs() sends OST_STATFS requests in parallel"
10431 test_119a() # bug 11737
10433 BSIZE=$((512 * 1024))
10434 directio write $DIR/$tfile 0 1 $BSIZE
10435 # We ask to read two blocks, which is more than a file size.
10436 # directio will indicate an error when requested and actual
10437 # sizes aren't equeal (a normal situation in this case) and
10438 # print actual read amount.
10439 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
10440 if [ "$NOB" != "$BSIZE" ]; then
10441 error "read $NOB bytes instead of $BSIZE"
10445 run_test 119a "Short directIO read must return actual read amount"
10447 test_119b() # bug 11737
10449 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10451 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
10452 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
10454 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
10455 error "direct read failed"
10458 run_test 119b "Sparse directIO read must return actual read amount"
10460 test_119c() # bug 13099
10463 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
10464 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
10467 run_test 119c "Testing for direct read hitting hole"
10469 test_119d() # bug 15950
10471 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10473 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
10474 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
10476 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
10477 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
10478 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
10479 lctl set_param fail_loc=0x40d
10480 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
10483 cat $DIR/$tfile > /dev/null &
10484 lctl set_param fail_loc=0
10487 log "the DIO writes have completed, now wait for the reads (should not block very long)"
10489 [ -n "`ps h -p $pid_reads -o comm`" ] && \
10490 error "the read rpcs have not completed in 2s"
10492 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
10494 run_test 119d "The DIO path should try to send a new rpc once one is completed"
10497 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10498 remote_mds_nodsh && skip "remote MDS with nodsh"
10499 test_mkdir $DIR/$tdir
10500 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10501 skip_env "no early lock cancel on server"
10503 lru_resize_disable mdc
10504 lru_resize_disable osc
10505 cancel_lru_locks mdc
10506 # asynchronous object destroy at MDT could cause bl ast to client
10507 cancel_lru_locks osc
10509 stat $DIR/$tdir > /dev/null
10510 can1=$(do_facet $SINGLEMDS \
10511 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10512 awk '/ldlm_cancel/ {print $2}')
10513 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10514 awk '/ldlm_bl_callback/ {print $2}')
10515 test_mkdir -c1 $DIR/$tdir/d1
10516 can2=$(do_facet $SINGLEMDS \
10517 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10518 awk '/ldlm_cancel/ {print $2}')
10519 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10520 awk '/ldlm_bl_callback/ {print $2}')
10521 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10522 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10523 lru_resize_enable mdc
10524 lru_resize_enable osc
10526 run_test 120a "Early Lock Cancel: mkdir test"
10529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10530 remote_mds_nodsh && skip "remote MDS with nodsh"
10531 test_mkdir $DIR/$tdir
10532 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10533 skip_env "no early lock cancel on server"
10535 lru_resize_disable mdc
10536 lru_resize_disable osc
10537 cancel_lru_locks mdc
10538 stat $DIR/$tdir > /dev/null
10539 can1=$(do_facet $SINGLEMDS \
10540 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10541 awk '/ldlm_cancel/ {print $2}')
10542 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10543 awk '/ldlm_bl_callback/ {print $2}')
10544 touch $DIR/$tdir/f1
10545 can2=$(do_facet $SINGLEMDS \
10546 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10547 awk '/ldlm_cancel/ {print $2}')
10548 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10549 awk '/ldlm_bl_callback/ {print $2}')
10550 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10551 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10552 lru_resize_enable mdc
10553 lru_resize_enable osc
10555 run_test 120b "Early Lock Cancel: create test"
10558 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10559 remote_mds_nodsh && skip "remote MDS with nodsh"
10560 test_mkdir -c1 $DIR/$tdir
10561 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10562 skip "no early lock cancel on server"
10564 lru_resize_disable mdc
10565 lru_resize_disable osc
10566 test_mkdir -c1 $DIR/$tdir/d1
10567 test_mkdir -c1 $DIR/$tdir/d2
10568 touch $DIR/$tdir/d1/f1
10569 cancel_lru_locks mdc
10570 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10571 can1=$(do_facet $SINGLEMDS \
10572 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10573 awk '/ldlm_cancel/ {print $2}')
10574 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10575 awk '/ldlm_bl_callback/ {print $2}')
10576 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10577 can2=$(do_facet $SINGLEMDS \
10578 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10579 awk '/ldlm_cancel/ {print $2}')
10580 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10581 awk '/ldlm_bl_callback/ {print $2}')
10582 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10583 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10584 lru_resize_enable mdc
10585 lru_resize_enable osc
10587 run_test 120c "Early Lock Cancel: link test"
10590 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10591 remote_mds_nodsh && skip "remote MDS with nodsh"
10592 test_mkdir -c1 $DIR/$tdir
10593 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10594 skip_env "no early lock cancel on server"
10596 lru_resize_disable mdc
10597 lru_resize_disable osc
10599 cancel_lru_locks mdc
10600 stat $DIR/$tdir > /dev/null
10601 can1=$(do_facet $SINGLEMDS \
10602 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10603 awk '/ldlm_cancel/ {print $2}')
10604 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10605 awk '/ldlm_bl_callback/ {print $2}')
10606 chmod a+x $DIR/$tdir
10607 can2=$(do_facet $SINGLEMDS \
10608 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10609 awk '/ldlm_cancel/ {print $2}')
10610 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10611 awk '/ldlm_bl_callback/ {print $2}')
10612 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10613 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10614 lru_resize_enable mdc
10615 lru_resize_enable osc
10617 run_test 120d "Early Lock Cancel: setattr test"
10620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10621 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10622 skip_env "no early lock cancel on server"
10623 remote_mds_nodsh && skip "remote MDS with nodsh"
10625 local dlmtrace_set=false
10627 test_mkdir -c1 $DIR/$tdir
10628 lru_resize_disable mdc
10629 lru_resize_disable osc
10630 ! $LCTL get_param debug | grep -q dlmtrace &&
10631 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
10632 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
10633 cancel_lru_locks mdc
10634 cancel_lru_locks osc
10635 dd if=$DIR/$tdir/f1 of=/dev/null
10636 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
10637 # XXX client can not do early lock cancel of OST lock
10638 # during unlink (LU-4206), so cancel osc lock now.
10640 cancel_lru_locks osc
10641 can1=$(do_facet $SINGLEMDS \
10642 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10643 awk '/ldlm_cancel/ {print $2}')
10644 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10645 awk '/ldlm_bl_callback/ {print $2}')
10646 unlink $DIR/$tdir/f1
10648 can2=$(do_facet $SINGLEMDS \
10649 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10650 awk '/ldlm_cancel/ {print $2}')
10651 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10652 awk '/ldlm_bl_callback/ {print $2}')
10653 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
10654 $LCTL dk $TMP/cancel.debug.txt
10655 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
10656 $LCTL dk $TMP/blocking.debug.txt
10657 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
10658 lru_resize_enable mdc
10659 lru_resize_enable osc
10661 run_test 120e "Early Lock Cancel: unlink test"
10664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10665 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10666 skip_env "no early lock cancel on server"
10667 remote_mds_nodsh && skip "remote MDS with nodsh"
10669 test_mkdir -c1 $DIR/$tdir
10670 lru_resize_disable mdc
10671 lru_resize_disable osc
10672 test_mkdir -c1 $DIR/$tdir/d1
10673 test_mkdir -c1 $DIR/$tdir/d2
10674 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
10675 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
10676 cancel_lru_locks mdc
10677 cancel_lru_locks osc
10678 dd if=$DIR/$tdir/d1/f1 of=/dev/null
10679 dd if=$DIR/$tdir/d2/f2 of=/dev/null
10680 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
10681 # XXX client can not do early lock cancel of OST lock
10682 # during rename (LU-4206), so cancel osc lock now.
10684 cancel_lru_locks osc
10685 can1=$(do_facet $SINGLEMDS \
10686 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10687 awk '/ldlm_cancel/ {print $2}')
10688 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10689 awk '/ldlm_bl_callback/ {print $2}')
10690 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10692 can2=$(do_facet $SINGLEMDS \
10693 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10694 awk '/ldlm_cancel/ {print $2}')
10695 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10696 awk '/ldlm_bl_callback/ {print $2}')
10697 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10698 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10699 lru_resize_enable mdc
10700 lru_resize_enable osc
10702 run_test 120f "Early Lock Cancel: rename test"
10705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10706 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10707 skip_env "no early lock cancel on server"
10708 remote_mds_nodsh && skip "remote MDS with nodsh"
10710 lru_resize_disable mdc
10711 lru_resize_disable osc
10713 echo create $count files
10714 test_mkdir $DIR/$tdir
10715 cancel_lru_locks mdc
10716 cancel_lru_locks osc
10719 can0=$(do_facet $SINGLEMDS \
10720 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10721 awk '/ldlm_cancel/ {print $2}')
10722 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10723 awk '/ldlm_bl_callback/ {print $2}')
10724 createmany -o $DIR/$tdir/f $count
10726 can1=$(do_facet $SINGLEMDS \
10727 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10728 awk '/ldlm_cancel/ {print $2}')
10729 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10730 awk '/ldlm_bl_callback/ {print $2}')
10732 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
10733 echo rm $count files
10736 can2=$(do_facet $SINGLEMDS \
10737 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10738 awk '/ldlm_cancel/ {print $2}')
10739 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10740 awk '/ldlm_bl_callback/ {print $2}')
10742 echo total: $count removes in $((t2-t1))
10743 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
10745 # wait for commitment of removal
10746 lru_resize_enable mdc
10747 lru_resize_enable osc
10749 run_test 120g "Early Lock Cancel: performance test"
10751 test_121() { #bug #10589
10752 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10755 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
10756 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
10757 lctl set_param fail_loc=0x310
10758 cancel_lru_locks osc > /dev/null
10759 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
10760 lctl set_param fail_loc=0
10761 [[ $reads -eq $writes ]] ||
10762 error "read $reads blocks, must be $writes blocks"
10764 run_test 121 "read cancel race ========="
10766 test_123a() { # was test 123, statahead(bug 11401)
10767 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10770 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
10771 log "testing UP system. Performance may be lower than expected."
10776 test_mkdir $DIR/$tdir
10777 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
10778 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
10780 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
10781 createmany -o $DIR/$tdir/$tfile $j $((i - j))
10783 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10784 lctl set_param -n llite.*.statahead_max 0
10785 lctl get_param llite.*.statahead_max
10786 cancel_lru_locks mdc
10787 cancel_lru_locks osc
10789 time ls -l $DIR/$tdir | wc -l
10791 delta=$((etime - stime))
10792 log "ls $i files without statahead: $delta sec"
10793 lctl set_param llite.*.statahead_max=$max
10795 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10796 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
10797 cancel_lru_locks mdc
10798 cancel_lru_locks osc
10800 time ls -l $DIR/$tdir | wc -l
10802 delta_sa=$((etime - stime))
10803 log "ls $i files with statahead: $delta_sa sec"
10804 lctl get_param -n llite.*.statahead_stats
10805 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10807 [[ $swrong -lt $ewrong ]] &&
10808 log "statahead was stopped, maybe too many locks held!"
10809 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
10811 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10812 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10813 lctl set_param -n llite.*.statahead_max 0
10814 lctl get_param llite.*.statahead_max
10815 cancel_lru_locks mdc
10816 cancel_lru_locks osc
10818 time ls -l $DIR/$tdir | wc -l
10820 delta=$((etime - stime))
10821 log "ls $i files again without statahead: $delta sec"
10822 lctl set_param llite.*.statahead_max=$max
10823 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10824 if [ $SLOWOK -eq 0 ]; then
10825 error "ls $i files is slower with statahead!"
10827 log "ls $i files is slower with statahead!"
10833 [ $delta -gt 20 ] && break
10834 [ $delta -gt 8 ] && MULT=$((50 / delta))
10835 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
10843 delta=$((etime - stime))
10844 log "rm -r $DIR/$tdir/: $delta seconds"
10846 lctl get_param -n llite.*.statahead_stats
10848 run_test 123a "verify statahead work"
10850 test_123b () { # statahead(bug 15027)
10851 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10853 test_mkdir $DIR/$tdir
10854 createmany -o $DIR/$tdir/$tfile-%d 1000
10856 cancel_lru_locks mdc
10857 cancel_lru_locks osc
10859 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
10860 lctl set_param fail_loc=0x80000803
10861 ls -lR $DIR/$tdir > /dev/null
10863 lctl set_param fail_loc=0x0
10864 lctl get_param -n llite.*.statahead_stats
10869 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
10872 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
10874 test_mkdir -i 0 -c 1 $DIR/$tdir.0
10875 test_mkdir -i 1 -c 1 $DIR/$tdir.1
10876 touch $DIR/$tdir.1/{1..3}
10877 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
10879 remount_client $MOUNT
10881 $MULTIOP $DIR/$tdir.0 Q
10883 # let statahead to complete
10884 ls -l $DIR/$tdir.0 > /dev/null
10886 testid=$(echo $TESTNAME | tr '_' ' ')
10887 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
10888 error "statahead warning" || true
10890 run_test 123c "Can not initialize inode warning on DNE statahead"
10893 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10894 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10895 skip_env "no lru resize on server"
10899 test_mkdir $DIR/$tdir
10901 log "create $NR files at $DIR/$tdir"
10902 createmany -o $DIR/$tdir/f $NR ||
10903 error "failed to create $NR files in $DIR/$tdir"
10905 cancel_lru_locks mdc
10906 ls -l $DIR/$tdir > /dev/null
10910 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
10911 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
10912 LRU_SIZE=$($LCTL get_param -n $PARAM)
10913 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
10914 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
10916 log "NS=$(basename $NSDIR)"
10921 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
10922 skip "Not enough cached locks created!"
10924 log "LRU=$LRU_SIZE"
10928 # We know that lru resize allows one client to hold $LIMIT locks
10929 # for 10h. After that locks begin to be killed by client.
10931 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
10933 if [ $LIMIT -lt $LRU_SIZE ]; then
10934 skip "Limit is too small $LIMIT"
10937 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
10938 # killing locks. Some time was spent for creating locks. This means
10939 # that up to the moment of sleep finish we must have killed some of
10940 # them (10-100 locks). This depends on how fast ther were created.
10941 # Many of them were touched in almost the same moment and thus will
10942 # be killed in groups.
10943 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
10945 # Use $LRU_SIZE_B here to take into account real number of locks
10946 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
10947 local LRU_SIZE_B=$LRU_SIZE
10949 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
10950 log "OLD_LVF=$OLD_LVF"
10951 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
10953 # Let's make sure that we really have some margin. Client checks
10954 # cached locks every 10 sec.
10955 SLEEP=$((SLEEP+20))
10956 log "Sleep ${SLEEP} sec"
10958 while ((SEC<$SLEEP)); do
10962 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
10963 echo -n "$LRU_SIZE"
10966 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
10967 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
10969 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
10970 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
10971 unlinkmany $DIR/$tdir/f $NR
10975 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
10976 log "unlink $NR files at $DIR/$tdir"
10977 unlinkmany $DIR/$tdir/f $NR
10979 run_test 124a "lru resize ======================================="
10981 get_max_pool_limit()
10983 local limit=$($LCTL get_param \
10984 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
10986 for l in $limit; do
10987 if [[ $l -gt $max ]]; then
10995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10996 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10997 skip_env "no lru resize on server"
10999 LIMIT=$(get_max_pool_limit)
11001 NR=$(($(default_lru_size)*20))
11002 if [[ $NR -gt $LIMIT ]]; then
11003 log "Limit lock number by $LIMIT locks"
11007 IFree=$(mdsrate_inodes_available)
11008 if [ $IFree -lt $NR ]; then
11009 log "Limit lock number by $IFree inodes"
11013 lru_resize_disable mdc
11014 test_mkdir -p $DIR/$tdir/disable_lru_resize
11016 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
11017 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
11018 cancel_lru_locks mdc
11021 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11024 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11027 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11031 nolruresize_delta=$((etime-stime))
11032 log "ls -la time: $nolruresize_delta seconds"
11033 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11034 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
11036 lru_resize_enable mdc
11037 test_mkdir -p $DIR/$tdir/enable_lru_resize
11039 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
11040 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
11041 cancel_lru_locks mdc
11044 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11047 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11050 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11054 lruresize_delta=$((etime-stime))
11055 log "ls -la time: $lruresize_delta seconds"
11056 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11058 if [ $lruresize_delta -gt $nolruresize_delta ]; then
11059 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
11060 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
11061 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
11063 log "lru resize performs the same with no lru resize"
11065 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
11067 run_test 124b "lru resize (performance test) ======================="
11070 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11071 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11072 skip_env "no lru resize on server"
11074 # cache ununsed locks on client
11076 cancel_lru_locks mdc
11077 test_mkdir $DIR/$tdir
11078 createmany -o $DIR/$tdir/f $nr ||
11079 error "failed to create $nr files in $DIR/$tdir"
11080 ls -l $DIR/$tdir > /dev/null
11082 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11083 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11084 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11085 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11086 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11088 # set lru_max_age to 1 sec
11089 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11090 echo "sleep $((recalc_p * 2)) seconds..."
11091 sleep $((recalc_p * 2))
11093 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11094 # restore lru_max_age
11095 $LCTL set_param -n $nsdir.lru_max_age $max_age
11096 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11097 unlinkmany $DIR/$tdir/f $nr
11099 run_test 124c "LRUR cancel very aged locks"
11102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11103 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11104 skip_env "no lru resize on server"
11106 # cache ununsed locks on client
11109 lru_resize_disable mdc
11110 stack_trap "lru_resize_enable mdc" EXIT
11112 cancel_lru_locks mdc
11114 # asynchronous object destroy at MDT could cause bl ast to client
11115 test_mkdir $DIR/$tdir
11116 createmany -o $DIR/$tdir/f $nr ||
11117 error "failed to create $nr files in $DIR/$tdir"
11118 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
11120 ls -l $DIR/$tdir > /dev/null
11122 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11123 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11124 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11125 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11127 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11129 # set lru_max_age to 1 sec
11130 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11131 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
11133 echo "sleep $((recalc_p * 2)) seconds..."
11134 sleep $((recalc_p * 2))
11136 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11138 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11140 run_test 124d "cancel very aged locks if lru-resize diasbaled"
11142 test_125() { # 13358
11143 $LCTL get_param -n llite.*.client_type | grep -q local ||
11144 skip "must run as local client"
11145 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
11146 skip_env "must have acl enabled"
11147 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11149 test_mkdir $DIR/$tdir
11150 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
11151 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
11152 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
11154 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
11156 test_126() { # bug 12829/13455
11157 $GSS && skip_env "must run as gss disabled"
11158 $LCTL get_param -n llite.*.client_type | grep -q local ||
11159 skip "must run as local client"
11160 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
11162 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
11163 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
11165 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
11167 run_test 126 "check that the fsgid provided by the client is taken into account"
11169 test_127a() { # bug 15521
11170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11172 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
11173 $LCTL set_param osc.*.stats=0
11174 FSIZE=$((2048 * 1024))
11175 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
11176 cancel_lru_locks osc
11177 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
11179 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
11180 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
11181 echo "got $COUNT $NAME"
11182 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
11183 eval $NAME=$COUNT || error "Wrong proc format"
11186 read_bytes|write_bytes)
11187 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
11188 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
11189 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
11190 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
11191 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
11192 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
11193 error "sumsquare is too small: $SUMSQ"
11194 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
11195 error "sumsquare is too big: $SUMSQ"
11199 done < $DIR/${tfile}.tmp
11201 #check that we actually got some stats
11202 [ "$read_bytes" ] || error "Missing read_bytes stats"
11203 [ "$write_bytes" ] || error "Missing write_bytes stats"
11204 [ "$read_bytes" != 0 ] || error "no read done"
11205 [ "$write_bytes" != 0 ] || error "no write done"
11207 run_test 127a "verify the client stats are sane"
11209 test_127b() { # bug LU-333
11210 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11211 local name count samp unit min max sum sumsq
11213 $LCTL set_param llite.*.stats=0
11215 # perform 2 reads and writes so MAX is different from SUM.
11216 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11217 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11218 cancel_lru_locks osc
11219 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11220 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11222 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11223 while read name count samp unit min max sum sumsq; do
11224 echo "got $count $name"
11225 eval $name=$count || error "Wrong proc format"
11229 [ $count -ne 2 ] && error "count is not 2: $count"
11230 [ $min -ne $PAGE_SIZE ] &&
11231 error "min is not $PAGE_SIZE: $min"
11232 [ $max -ne $PAGE_SIZE ] &&
11233 error "max is incorrect: $max"
11234 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11235 error "sum is wrong: $sum"
11238 [ $count -ne 2 ] && error "count is not 2: $count"
11239 [ $min -ne $PAGE_SIZE ] &&
11240 error "min is not $PAGE_SIZE: $min"
11241 [ $max -ne $PAGE_SIZE ] &&
11242 error "max is incorrect: $max"
11243 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11244 error "sum is wrong: $sum"
11248 done < $TMP/$tfile.tmp
11250 #check that we actually got some stats
11251 [ "$read_bytes" ] || error "Missing read_bytes stats"
11252 [ "$write_bytes" ] || error "Missing write_bytes stats"
11253 [ "$read_bytes" != 0 ] || error "no read done"
11254 [ "$write_bytes" != 0 ] || error "no write done"
11256 rm -f $TMP/${tfile}.tmp
11258 run_test 127b "verify the llite client stats are sane"
11260 test_127c() { # LU-12394
11261 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11268 $LCTL set_param llite.*.extents_stats=1
11269 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
11271 # Use two stripes so there is enough space in default config
11272 $LFS setstripe -c 2 $DIR/$tfile
11274 # Extent stats start at 0-4K and go in power of two buckets
11275 # LL_HIST_START = 12 --> 2^12 = 4K
11276 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
11277 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
11279 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
11281 # Write and read, 2x each, second time at a non-zero offset
11282 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
11283 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
11284 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
11285 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
11289 $LCTL get_param llite.*.extents_stats
11292 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
11294 local bucket=$($LCTL get_param -n llite.*.extents_stats |
11296 reads=$(echo $bucket | awk '{print $5}')
11297 writes=$(echo $bucket | awk '{print $9}')
11298 [ "$reads" -eq $count ] ||
11299 error "$reads reads in < $bsize bucket, expect $count"
11300 [ "$writes" -eq $count ] ||
11301 error "$writes writes in < $bsize bucket, expect $count"
11304 # Test mmap write and read
11305 $LCTL set_param llite.*.extents_stats=c
11307 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
11308 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
11309 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
11311 $LCTL get_param llite.*.extents_stats
11313 count=$(((size*1024) / PAGE_SIZE))
11315 bsize=$((2 * PAGE_SIZE / 1024))K
11317 bucket=$($LCTL get_param -n llite.*.extents_stats |
11319 reads=$(echo $bucket | awk '{print $5}')
11320 writes=$(echo $bucket | awk '{print $9}')
11321 # mmap writes fault in the page first, creating an additonal read
11322 [ "$reads" -eq $((2 * count)) ] ||
11323 error "$reads reads in < $bsize bucket, expect $count"
11324 [ "$writes" -eq $count ] ||
11325 error "$writes writes in < $bsize bucket, expect $count"
11327 run_test 127c "test llite extent stats with regular & mmap i/o"
11329 test_128() { # bug 15212
11331 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
11336 result=$(grep error $TMP/$tfile.log)
11337 rm -f $DIR/$tfile $TMP/$tfile.log
11338 [ -z "$result" ] ||
11339 error "consecutive find's under interactive lfs failed"
11341 run_test 128 "interactive lfs for 2 consecutive find's"
11343 set_dir_limits () {
11348 local ldproc=/proc/fs/ldiskfs
11349 local facets=$(get_facets MDS)
11351 for facet in ${facets//,/ }; do
11352 canondev=$(ldiskfs_canon \
11353 *.$(convert_facet2label $facet).mntdev $facet)
11354 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
11355 ldproc=/sys/fs/ldiskfs
11356 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
11357 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
11361 check_mds_dmesg() {
11362 local facets=$(get_facets MDS)
11363 for facet in ${facets//,/ }; do
11364 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
11370 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11371 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
11372 skip "Need MDS version with at least 2.5.56"
11373 if [ "$mds1_FSTYPE" != ldiskfs ]; then
11374 skip_env "ldiskfs only test"
11376 remote_mds_nodsh && skip "remote MDS with nodsh"
11380 local has_warning=false
11383 mkdir -p $DIR/$tdir
11385 # block size of mds1
11386 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
11387 set_dir_limits $maxsize $maxsize
11388 local dirsize=$(stat -c%s "$DIR/$tdir")
11390 while [[ $dirsize -le $maxsize ]]; do
11391 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
11393 if ! $has_warning; then
11394 check_mds_dmesg '"is approaching"' && has_warning=true
11396 # check two errors:
11397 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
11398 # EFBIG for previous versions included in ldiskfs series
11399 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
11401 echo "return code $rc received as expected"
11403 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
11404 error_exit "create failed w/o dir size limit"
11406 check_mds_dmesg '"has reached"' ||
11407 error_exit "reached message should be output"
11409 [ $has_warning = "false" ] &&
11410 error_exit "warning message should be output"
11412 dirsize=$(stat -c%s "$DIR/$tdir")
11414 [[ $dirsize -ge $maxsize ]] && return 0
11415 error_exit "current dir size $dirsize, " \
11416 "previous limit $maxsize"
11417 elif [ $rc -ne 0 ]; then
11419 error_exit "return $rc received instead of expected " \
11420 "$EFBIG or $ENOSPC, files in dir $dirsize"
11422 nfiles=$((nfiles + 1))
11423 dirsize=$(stat -c%s "$DIR/$tdir")
11427 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
11429 run_test 129 "test directory size limit ========================"
11438 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11439 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11441 trap cleanup_130 EXIT RETURN
11443 local fm_file=$DIR/$tfile
11444 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
11445 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
11446 error "dd failed for $fm_file"
11448 # LU-1795: test filefrag/FIEMAP once, even if unsupported
11449 filefrag -ves $fm_file
11451 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11452 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11453 [ $RC != 0 ] && error "filefrag $fm_file failed"
11455 filefrag_op=$(filefrag -ve -k $fm_file |
11456 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11457 lun=$($GETSTRIPE -i $fm_file)
11459 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
11462 for line in $filefrag_op
11464 frag_lun=`echo $line | cut -d: -f5`
11465 ext_len=`echo $line | cut -d: -f4`
11466 if (( $frag_lun != $lun )); then
11468 error "FIEMAP on 1-stripe file($fm_file) failed"
11471 (( tot_len += ext_len ))
11474 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
11476 error "FIEMAP on 1-stripe file($fm_file) failed;"
11482 echo "FIEMAP on single striped file succeeded"
11484 run_test 130a "FIEMAP (1-stripe file)"
11487 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11489 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11490 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11492 trap cleanup_130 EXIT RETURN
11494 local fm_file=$DIR/$tfile
11495 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
11496 error "setstripe on $fm_file"
11497 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11498 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11500 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
11501 error "dd failed on $fm_file"
11503 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11504 filefrag_op=$(filefrag -ve -k $fm_file |
11505 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11507 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11508 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11513 for line in $filefrag_op
11515 frag_lun=$(echo $line | cut -d: -f5 |
11516 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11517 ext_len=$(echo $line | cut -d: -f4)
11518 if (( $frag_lun != $last_lun )); then
11519 if (( tot_len != 1024 )); then
11521 error "FIEMAP on $fm_file failed; returned " \
11522 "len $tot_len for OST $last_lun instead of 1024"
11525 (( num_luns += 1 ))
11529 (( tot_len += ext_len ))
11532 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
11534 error "FIEMAP on $fm_file failed; returned wrong number of " \
11535 "luns or wrong len for OST $last_lun"
11541 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
11543 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
11546 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11548 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11549 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11551 trap cleanup_130 EXIT RETURN
11553 local fm_file=$DIR/$tfile
11554 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
11555 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11556 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11558 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
11559 error "dd failed on $fm_file"
11561 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11562 filefrag_op=$(filefrag -ve -k $fm_file |
11563 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11565 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11566 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11571 for line in $filefrag_op
11573 frag_lun=$(echo $line | cut -d: -f5 |
11574 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11575 ext_len=$(echo $line | cut -d: -f4)
11576 if (( $frag_lun != $last_lun )); then
11577 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
11578 if (( logical != 512 )); then
11580 error "FIEMAP on $fm_file failed; returned " \
11581 "logical start for lun $logical instead of 512"
11584 if (( tot_len != 512 )); then
11586 error "FIEMAP on $fm_file failed; returned " \
11587 "len $tot_len for OST $last_lun instead of 1024"
11590 (( num_luns += 1 ))
11594 (( tot_len += ext_len ))
11597 if (( num_luns != 2 || tot_len != 512 )); then
11599 error "FIEMAP on $fm_file failed; returned wrong number of " \
11600 "luns or wrong len for OST $last_lun"
11606 echo "FIEMAP on 2-stripe file with hole succeeded"
11608 run_test 130c "FIEMAP (2-stripe file with hole)"
11611 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
11613 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11614 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11616 trap cleanup_130 EXIT RETURN
11618 local fm_file=$DIR/$tfile
11619 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
11620 error "setstripe on $fm_file"
11621 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11622 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11624 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
11625 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
11626 error "dd failed on $fm_file"
11628 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11629 filefrag_op=$(filefrag -ve -k $fm_file |
11630 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11632 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11633 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11638 for line in $filefrag_op
11640 frag_lun=$(echo $line | cut -d: -f5 |
11641 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11642 ext_len=$(echo $line | cut -d: -f4)
11643 if (( $frag_lun != $last_lun )); then
11644 if (( tot_len != 1024 )); then
11646 error "FIEMAP on $fm_file failed; returned " \
11647 "len $tot_len for OST $last_lun instead of 1024"
11650 (( num_luns += 1 ))
11654 (( tot_len += ext_len ))
11657 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
11659 error "FIEMAP on $fm_file failed; returned wrong number of " \
11660 "luns or wrong len for OST $last_lun"
11666 echo "FIEMAP on N-stripe file succeeded"
11668 run_test 130d "FIEMAP (N-stripe file)"
11671 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11673 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11674 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11676 trap cleanup_130 EXIT RETURN
11678 local fm_file=$DIR/$tfile
11679 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
11680 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11681 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11684 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
11685 for ((i = 0; i < $NUM_BLKS; i++))
11687 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
11690 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11691 filefrag_op=$(filefrag -ve -k $fm_file |
11692 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11694 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11695 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11700 for line in $filefrag_op
11702 frag_lun=$(echo $line | cut -d: -f5 |
11703 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11704 ext_len=$(echo $line | cut -d: -f4)
11705 if (( $frag_lun != $last_lun )); then
11706 if (( tot_len != $EXPECTED_LEN )); then
11708 error "FIEMAP on $fm_file failed; returned " \
11709 "len $tot_len for OST $last_lun instead " \
11713 (( num_luns += 1 ))
11717 (( tot_len += ext_len ))
11720 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
11722 error "FIEMAP on $fm_file failed; returned wrong number " \
11723 "of luns or wrong len for OST $last_lun"
11729 echo "FIEMAP with continuation calls succeeded"
11731 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
11734 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11735 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11737 local fm_file=$DIR/$tfile
11738 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
11739 error "multiop create with lov_delay_create on $fm_file"
11741 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11742 filefrag_extents=$(filefrag -vek $fm_file |
11743 awk '/extents? found/ { print $2 }')
11744 if [[ "$filefrag_extents" != "0" ]]; then
11745 error "FIEMAP on $fm_file failed; " \
11746 "returned $filefrag_extents expected 0"
11751 run_test 130f "FIEMAP (unstriped file)"
11753 # Test for writev/readv
11755 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
11756 error "writev test failed"
11757 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
11758 error "readv failed"
11761 run_test 131a "test iov's crossing stripe boundary for writev/readv"
11764 local fsize=$((524288 + 1048576 + 1572864))
11765 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
11766 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11767 error "append writev test failed"
11769 ((fsize += 1572864 + 1048576))
11770 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
11771 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11772 error "append writev test failed"
11775 run_test 131b "test append writev"
11778 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
11781 run_test 131c "test read/write on file w/o objects"
11784 rwv -f $DIR/$tfile -w -n 1 1572864
11785 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
11786 if [ "$NOB" != 1572864 ]; then
11787 error "Short read filed: read $NOB bytes instead of 1572864"
11791 run_test 131d "test short read"
11794 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
11795 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
11796 error "read hitting hole failed"
11799 run_test 131e "test read hitting hole"
11808 mds*) res=$(do_facet $facet \
11809 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
11811 ost*) res=$(do_facet $facet \
11812 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
11814 *) error "Wrong facet '$facet'" ;;
11816 [ "$res" ] || error "The counter for $op on $facet was not incremented"
11817 # if the argument $3 is zero, it means any stat increment is ok.
11818 if [[ $want -gt 0 ]]; then
11819 local count=$(echo $res | awk '{ print $2 }')
11820 [[ $count -ne $want ]] &&
11821 error "The $op counter on $facet is $count, not $want"
11826 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11827 remote_ost_nodsh && skip "remote OST with nodsh"
11828 remote_mds_nodsh && skip "remote MDS with nodsh"
11829 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11830 skip_env "MDS doesn't support rename stats"
11832 local testdir=$DIR/${tdir}/stats_testdir
11834 mkdir -p $DIR/${tdir}
11837 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11838 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11840 # verify mdt stats first.
11841 mkdir ${testdir} || error "mkdir failed"
11842 check_stats $SINGLEMDS "mkdir" 1
11843 touch ${testdir}/${tfile} || error "touch failed"
11844 check_stats $SINGLEMDS "open" 1
11845 check_stats $SINGLEMDS "close" 1
11846 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
11847 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
11848 check_stats $SINGLEMDS "mknod" 2
11850 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
11851 check_stats $SINGLEMDS "unlink" 1
11852 rm -f ${testdir}/${tfile} || error "file remove failed"
11853 check_stats $SINGLEMDS "unlink" 2
11855 # remove working dir and check mdt stats again.
11856 rmdir ${testdir} || error "rmdir failed"
11857 check_stats $SINGLEMDS "rmdir" 1
11859 local testdir1=$DIR/${tdir}/stats_testdir1
11860 mkdir -p ${testdir}
11861 mkdir -p ${testdir1}
11862 touch ${testdir1}/test1
11863 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
11864 check_stats $SINGLEMDS "crossdir_rename" 1
11866 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
11867 check_stats $SINGLEMDS "samedir_rename" 1
11869 rm -rf $DIR/${tdir}
11871 run_test 133a "Verifying MDT stats ========================================"
11876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11877 remote_ost_nodsh && skip "remote OST with nodsh"
11878 remote_mds_nodsh && skip "remote MDS with nodsh"
11880 local testdir=$DIR/${tdir}/stats_testdir
11882 mkdir -p ${testdir} || error "mkdir failed"
11883 touch ${testdir}/${tfile} || error "touch failed"
11884 cancel_lru_locks mdc
11887 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11888 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11890 # extra mdt stats verification.
11891 chmod 444 ${testdir}/${tfile} || error "chmod failed"
11892 check_stats $SINGLEMDS "setattr" 1
11893 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11894 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
11896 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
11897 check_stats $SINGLEMDS "getattr" 1
11899 rm -rf $DIR/${tdir}
11901 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
11902 # so the check below is not reliable
11903 [ $MDSCOUNT -eq 1 ] || return 0
11905 # Sleep to avoid a cached response.
11906 #define OBD_STATFS_CACHE_SECONDS 1
11908 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11909 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11910 $LFS df || error "lfs failed"
11911 check_stats $SINGLEMDS "statfs" 1
11913 # check aggregated statfs (LU-10018)
11914 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
11916 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
11919 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11920 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11922 check_stats $SINGLEMDS "statfs" 1
11924 # We want to check that the client didn't send OST_STATFS to
11925 # ost1 but the MDT also uses OST_STATFS for precreate. So some
11926 # extra care is needed here.
11927 if remote_mds; then
11928 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
11929 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
11931 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
11932 [ "$res" ] && error "OST got STATFS"
11937 run_test 133b "Verifying extra MDT stats =================================="
11940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11941 remote_ost_nodsh && skip "remote OST with nodsh"
11942 remote_mds_nodsh && skip "remote MDS with nodsh"
11944 local testdir=$DIR/$tdir/stats_testdir
11946 test_mkdir -p $testdir
11948 # verify obdfilter stats.
11949 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
11951 cancel_lru_locks osc
11952 wait_delete_completed
11955 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11956 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11958 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
11961 cancel_lru_locks osc
11962 check_stats ost1 "write" 1
11964 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
11965 check_stats ost1 "read" 1
11967 > $testdir/$tfile || error "truncate failed"
11968 check_stats ost1 "punch" 1
11970 rm -f $testdir/$tfile || error "file remove failed"
11971 wait_delete_completed
11972 check_stats ost1 "destroy" 1
11976 run_test 133c "Verifying OST stats ========================================"
11983 while [ $value -ge 2 ]; do
11988 if [ $orig -gt $order ]; then
11996 local size=('K' 'M' 'G' 'T');
11998 local size_string=$value
12000 while [ $value -ge 1024 ]; do
12001 if [ $i -gt 3 ]; then
12002 #T is the biggest unit we get here, if that is bigger,
12004 size_string=${value}T
12007 value=$((value >> 10))
12008 if [ $value -lt 1024 ]; then
12009 size_string=${value}${size[$i]}
12018 get_rename_size() {
12020 local context=${2:-.}
12021 local sample=$(do_facet $SINGLEMDS $LCTL \
12022 get_param mdt.$FSNAME-MDT0000.rename_stats |
12023 grep -A1 $context |
12024 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
12029 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12030 remote_ost_nodsh && skip "remote OST with nodsh"
12031 remote_mds_nodsh && skip "remote MDS with nodsh"
12032 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12033 skip_env "MDS doesn't support rename stats"
12035 local testdir1=$DIR/${tdir}/stats_testdir1
12036 local testdir2=$DIR/${tdir}/stats_testdir2
12037 mkdir -p $DIR/${tdir}
12039 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12041 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
12042 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
12044 createmany -o $testdir1/test 512 || error "createmany failed"
12046 # check samedir rename size
12047 mv ${testdir1}/test0 ${testdir1}/test_0
12049 local testdir1_size=$(ls -l $DIR/${tdir} |
12050 awk '/stats_testdir1/ {print $5}')
12051 local testdir2_size=$(ls -l $DIR/${tdir} |
12052 awk '/stats_testdir2/ {print $5}')
12054 testdir1_size=$(order_2 $testdir1_size)
12055 testdir2_size=$(order_2 $testdir2_size)
12057 testdir1_size=$(size_in_KMGT $testdir1_size)
12058 testdir2_size=$(size_in_KMGT $testdir2_size)
12060 echo "source rename dir size: ${testdir1_size}"
12061 echo "target rename dir size: ${testdir2_size}"
12063 local cmd="do_facet $SINGLEMDS $LCTL "
12064 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
12066 eval $cmd || error "$cmd failed"
12067 local samedir=$($cmd | grep 'same_dir')
12068 local same_sample=$(get_rename_size $testdir1_size)
12069 [ -z "$samedir" ] && error "samedir_rename_size count error"
12070 [[ $same_sample -eq 1 ]] ||
12071 error "samedir_rename_size error $same_sample"
12072 echo "Check same dir rename stats success"
12074 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12076 # check crossdir rename size
12077 mv ${testdir1}/test_0 ${testdir2}/test_0
12079 testdir1_size=$(ls -l $DIR/${tdir} |
12080 awk '/stats_testdir1/ {print $5}')
12081 testdir2_size=$(ls -l $DIR/${tdir} |
12082 awk '/stats_testdir2/ {print $5}')
12084 testdir1_size=$(order_2 $testdir1_size)
12085 testdir2_size=$(order_2 $testdir2_size)
12087 testdir1_size=$(size_in_KMGT $testdir1_size)
12088 testdir2_size=$(size_in_KMGT $testdir2_size)
12090 echo "source rename dir size: ${testdir1_size}"
12091 echo "target rename dir size: ${testdir2_size}"
12093 eval $cmd || error "$cmd failed"
12094 local crossdir=$($cmd | grep 'crossdir')
12095 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
12096 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
12097 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
12098 [[ $src_sample -eq 1 ]] ||
12099 error "crossdir_rename_size error $src_sample"
12100 [[ $tgt_sample -eq 1 ]] ||
12101 error "crossdir_rename_size error $tgt_sample"
12102 echo "Check cross dir rename stats success"
12103 rm -rf $DIR/${tdir}
12105 run_test 133d "Verifying rename_stats ========================================"
12108 remote_mds_nodsh && skip "remote MDS with nodsh"
12109 remote_ost_nodsh && skip "remote OST with nodsh"
12110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12112 local testdir=$DIR/${tdir}/stats_testdir
12113 local ctr f0 f1 bs=32768 count=42 sum
12115 mkdir -p ${testdir} || error "mkdir failed"
12117 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
12119 for ctr in {write,read}_bytes; do
12121 cancel_lru_locks osc
12123 do_facet ost1 $LCTL set_param -n \
12124 "obdfilter.*.exports.clear=clear"
12126 if [ $ctr = write_bytes ]; then
12128 f1=${testdir}/${tfile}
12130 f0=${testdir}/${tfile}
12134 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
12137 cancel_lru_locks osc
12139 sum=$(do_facet ost1 $LCTL get_param \
12140 "obdfilter.*.exports.*.stats" |
12141 awk -v ctr=$ctr 'BEGIN { sum = 0 }
12142 $1 == ctr { sum += $7 }
12143 END { printf("%0.0f", sum) }')
12145 if ((sum != bs * count)); then
12146 error "Bad $ctr sum, expected $((bs * count)), got $sum"
12150 rm -rf $DIR/${tdir}
12152 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
12154 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
12156 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
12157 # not honor the -ignore_readdir_race option correctly. So we call
12158 # error_ignore() rather than error() in these cases. See LU-11152.
12160 if (find --version; do_facet mds1 find --version) |
12161 grep -q '\b4\.5\.1[1-4]\b'; then
12162 error_ignore LU-11152 "$@"
12169 # First without trusting modes.
12170 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
12171 echo "proc_dirs='$proc_dirs'"
12172 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
12173 find $proc_dirs -exec cat '{}' \; &> /dev/null
12175 # Second verifying readability.
12176 $LCTL get_param -R '*' &> /dev/null
12178 # Verifing writability with badarea_io.
12180 -ignore_readdir_race \
12182 -not -name force_lbug \
12183 -not -name changelog_mask \
12184 -exec badarea_io '{}' \; ||
12185 error_133 "find $proc_dirs failed"
12187 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
12190 remote_mds_nodsh && skip "remote MDS with nodsh"
12191 remote_ost_nodsh && skip "remote OST with nodsh"
12193 # eventually, this can also be replaced with "lctl get_param -R",
12194 # but not until that option is always available on the server
12196 for facet in mds1 ost1; do
12197 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
12198 skip_noexit "Too old lustre on $facet"
12199 local facet_proc_dirs=$(do_facet $facet \
12200 \\\ls -d $proc_regexp 2>/dev/null)
12201 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12202 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12203 do_facet $facet find $facet_proc_dirs \
12204 ! -name req_history \
12205 -exec cat '{}' \\\; &> /dev/null
12207 do_facet $facet find $facet_proc_dirs \
12208 ! -name req_history \
12210 -exec cat '{}' \\\; &> /dev/null ||
12211 error "proc file read failed"
12213 do_facet $facet find $facet_proc_dirs \
12214 -ignore_readdir_race \
12216 -not -name force_lbug \
12217 -not -name changelog_mask \
12218 -exec badarea_io '{}' \\\; ||
12219 error_133 "$facet find $facet_proc_dirs failed"
12222 # remount the FS in case writes/reads /proc break the FS
12223 cleanup || error "failed to unmount"
12224 setup || error "failed to setup"
12227 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12230 remote_mds_nodsh && skip "remote MDS with nodsh"
12231 remote_ost_nodsh && skip "remote OST with nodsh"
12232 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12233 skip "Need MDS version at least 2.9.54"
12237 for facet in client mds1 ost1; do
12238 local facet_proc_dirs=$(do_facet $facet \
12239 \\\ls -d $proc_regexp 2> /dev/null)
12240 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12241 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12242 # Get the list of files that are missing the terminating newline
12243 local missing=($(do_facet $facet \
12244 find ${facet_proc_dirs} -type f \| \
12245 while read F\; do \
12246 awk -v FS='\v' -v RS='\v\v' \
12247 "'END { if(NR>0 && \
12248 \\\$NF !~ /.*\\\n\$/) \
12249 print FILENAME}'" \
12252 [ ${#missing[*]} -eq 0 ] ||
12253 error "files do not end with newline: ${missing[*]}"
12256 run_test 133h "Proc files should end with newlines"
12259 remote_mds_nodsh && skip "remote MDS with nodsh"
12260 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12261 skip "Need MDS version at least 2.7.54"
12263 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12264 cancel_lru_locks mdc
12266 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12267 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12268 [ $unused -eq 0 ] || error "$unused locks are not cleared"
12271 createmany -o $DIR/$tdir/f $nr ||
12272 error "failed to create $nr files in $DIR/$tdir"
12273 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12275 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
12276 do_facet mds1 $LCTL set_param fail_loc=0x327
12277 do_facet mds1 $LCTL set_param fail_val=500
12280 echo "sleep 10 seconds ..."
12282 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
12284 do_facet mds1 $LCTL set_param fail_loc=0
12285 do_facet mds1 $LCTL set_param fail_val=0
12286 [ $lck_cnt -lt $unused ] ||
12287 error "No locks reclaimed, before:$unused, after:$lck_cnt"
12290 unlinkmany $DIR/$tdir/f $nr
12292 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
12295 remote_mds_nodsh && skip "remote MDS with nodsh"
12296 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12297 skip "Need MDS version at least 2.7.54"
12299 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12300 cancel_lru_locks mdc
12302 local low_wm=$(do_facet mds1 $LCTL get_param -n \
12303 ldlm.lock_reclaim_threshold_mb)
12304 # disable reclaim temporarily
12305 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
12307 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
12308 do_facet mds1 $LCTL set_param fail_loc=0x328
12309 do_facet mds1 $LCTL set_param fail_val=500
12311 $LCTL set_param debug=+trace
12314 createmany -o $DIR/$tdir/f $nr &
12315 local create_pid=$!
12317 echo "Sleep $TIMEOUT seconds ..."
12319 if ! ps -p $create_pid > /dev/null 2>&1; then
12320 do_facet mds1 $LCTL set_param fail_loc=0
12321 do_facet mds1 $LCTL set_param fail_val=0
12322 do_facet mds1 $LCTL set_param \
12323 ldlm.lock_reclaim_threshold_mb=${low_wm}m
12324 error "createmany finished incorrectly!"
12326 do_facet mds1 $LCTL set_param fail_loc=0
12327 do_facet mds1 $LCTL set_param fail_val=0
12328 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
12329 wait $create_pid || return 1
12331 unlinkmany $DIR/$tdir/f $nr
12333 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
12335 test_140() { #bug-17379
12336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12338 test_mkdir $DIR/$tdir
12339 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
12340 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
12342 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
12343 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
12345 while i=$((i + 1)); do
12347 cd $i || error "Changing to $i"
12348 ln -s ../stat stat || error "Creating stat symlink"
12349 # Read the symlink until ELOOP present,
12350 # not LBUGing the system is considered success,
12351 # we didn't overrun the stack.
12352 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
12353 if [ $ret -ne 0 ]; then
12354 if [ $ret -eq 40 ]; then
12357 error "Open stat symlink"
12363 echo "The symlink depth = $i"
12364 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
12365 error "Invalid symlink depth"
12367 # Test recursive symlink
12368 ln -s symlink_self symlink_self
12369 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
12370 echo "open symlink_self returns $ret"
12371 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
12373 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
12376 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12378 local TF="$TMP/$tfile"
12380 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12382 cancel_lru_locks $OSC
12383 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
12384 remount_client $MOUNT
12386 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
12389 $TRUNCATE $DIR/$tfile 6000
12390 cancel_lru_locks $OSC
12391 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
12394 echo "12345" >>$DIR/$tfile
12395 cancel_lru_locks $OSC
12396 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
12399 echo "12345" >>$DIR/$tfile
12400 cancel_lru_locks $OSC
12401 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
12406 run_test 150 "truncate/append tests"
12408 #LU-2902 roc_hit was not able to read all values from lproc
12409 function roc_hit_init() {
12410 local list=$(comma_list $(osts_nodes))
12411 local dir=$DIR/$tdir-check
12412 local file=$dir/$tfile
12418 #use setstripe to do a write to every ost
12419 for i in $(seq 0 $((OSTCOUNT-1))); do
12420 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
12421 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
12422 idx=$(printf %04x $i)
12423 BEFORE=$(get_osd_param $list *OST*$idx stats |
12424 awk '$1 == "cache_access" {sum += $7}
12425 END { printf("%0.0f", sum) }')
12427 cancel_lru_locks osc
12428 cat $file >/dev/null
12430 AFTER=$(get_osd_param $list *OST*$idx stats |
12431 awk '$1 == "cache_access" {sum += $7}
12432 END { printf("%0.0f", sum) }')
12434 echo BEFORE:$BEFORE AFTER:$AFTER
12435 if ! let "AFTER - BEFORE == 4"; then
12437 error "roc_hit is not safe to use"
12445 function roc_hit() {
12446 local list=$(comma_list $(osts_nodes))
12447 echo $(get_osd_param $list '' stats |
12448 awk '$1 == "cache_hit" {sum += $7}
12449 END { printf("%0.0f", sum) }')
12452 function set_cache() {
12455 if [ "$2" == "off" ]; then
12458 local list=$(comma_list $(osts_nodes))
12459 set_osd_param $list '' $1_cache_enable $on
12461 cancel_lru_locks osc
12465 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12466 remote_ost_nodsh && skip "remote OST with nodsh"
12469 local list=$(comma_list $(osts_nodes))
12471 # check whether obdfilter is cache capable at all
12472 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
12473 skip "not cache-capable obdfilter"
12476 # check cache is enabled on all obdfilters
12477 if get_osd_param $list '' read_cache_enable | grep 0; then
12478 skip "oss cache is disabled"
12481 set_osd_param $list '' writethrough_cache_enable 1
12483 # check write cache is enabled on all obdfilters
12484 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
12485 skip "oss write cache is NOT enabled"
12490 #define OBD_FAIL_OBD_NO_LRU 0x609
12491 do_nodes $list $LCTL set_param fail_loc=0x609
12493 # pages should be in the case right after write
12494 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
12497 local BEFORE=$(roc_hit)
12498 cancel_lru_locks osc
12499 cat $DIR/$tfile >/dev/null
12500 local AFTER=$(roc_hit)
12502 do_nodes $list $LCTL set_param fail_loc=0
12504 if ! let "AFTER - BEFORE == CPAGES"; then
12505 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12508 # the following read invalidates the cache
12509 cancel_lru_locks osc
12510 set_osd_param $list '' read_cache_enable 0
12511 cat $DIR/$tfile >/dev/null
12513 # now data shouldn't be found in the cache
12515 cancel_lru_locks osc
12516 cat $DIR/$tfile >/dev/null
12518 if let "AFTER - BEFORE != 0"; then
12519 error "IN CACHE: before: $BEFORE, after: $AFTER"
12522 set_osd_param $list '' read_cache_enable 1
12525 run_test 151 "test cache on oss and controls ==============================="
12528 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12530 local TF="$TMP/$tfile"
12532 # simulate ENOMEM during write
12533 #define OBD_FAIL_OST_NOMEM 0x226
12534 lctl set_param fail_loc=0x80000226
12535 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12537 sync || error "sync failed"
12538 lctl set_param fail_loc=0
12540 # discard client's cache
12541 cancel_lru_locks osc
12543 # simulate ENOMEM during read
12544 lctl set_param fail_loc=0x80000226
12545 cmp $TF $DIR/$tfile || error "cmp failed"
12546 lctl set_param fail_loc=0
12550 run_test 152 "test read/write with enomem ============================"
12553 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
12555 run_test 153 "test if fdatasync does not crash ======================="
12557 dot_lustre_fid_permission_check() {
12559 local ffid=$MOUNT/.lustre/fid/$fid
12562 echo "stat fid $fid"
12563 stat $ffid > /dev/null || error "stat $ffid failed."
12564 echo "touch fid $fid"
12565 touch $ffid || error "touch $ffid failed."
12566 echo "write to fid $fid"
12567 cat /etc/hosts > $ffid || error "write $ffid failed."
12568 echo "read fid $fid"
12569 diff /etc/hosts $ffid || error "read $ffid failed."
12570 echo "append write to fid $fid"
12571 cat /etc/hosts >> $ffid || error "append write $ffid failed."
12572 echo "rename fid $fid"
12573 mv $ffid $test_dir/$tfile.1 &&
12574 error "rename $ffid to $tfile.1 should fail."
12575 touch $test_dir/$tfile.1
12576 mv $test_dir/$tfile.1 $ffid &&
12577 error "rename $tfile.1 to $ffid should fail."
12578 rm -f $test_dir/$tfile.1
12579 echo "truncate fid $fid"
12580 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
12581 echo "link fid $fid"
12582 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
12583 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
12584 echo "setfacl fid $fid"
12585 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
12586 echo "getfacl fid $fid"
12587 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
12589 echo "unlink fid $fid"
12590 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
12591 echo "mknod fid $fid"
12592 mknod $ffid c 1 3 && error "mknod $ffid should fail."
12594 fid=[0xf00000400:0x1:0x0]
12595 ffid=$MOUNT/.lustre/fid/$fid
12597 echo "stat non-exist fid $fid"
12598 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
12599 echo "write to non-exist fid $fid"
12600 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
12601 echo "link new fid $fid"
12602 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
12604 mkdir -p $test_dir/$tdir
12605 touch $test_dir/$tdir/$tfile
12606 fid=$($LFS path2fid $test_dir/$tdir)
12609 error "error: could not get fid for $test_dir/$dir/$tfile."
12611 ffid=$MOUNT/.lustre/fid/$fid
12614 ls $ffid > /dev/null || error "ls $ffid failed."
12615 echo "touch $fid/$tfile.1"
12616 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
12618 echo "touch $MOUNT/.lustre/fid/$tfile"
12619 touch $MOUNT/.lustre/fid/$tfile && \
12620 error "touch $MOUNT/.lustre/fid/$tfile should fail."
12622 echo "setxattr to $MOUNT/.lustre/fid"
12623 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
12625 echo "listxattr for $MOUNT/.lustre/fid"
12626 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
12628 echo "delxattr from $MOUNT/.lustre/fid"
12629 setfattr -x trusted.name1 $MOUNT/.lustre/fid
12631 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
12632 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
12633 error "touch invalid fid should fail."
12635 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
12636 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
12637 error "touch non-normal fid should fail."
12639 echo "rename $tdir to $MOUNT/.lustre/fid"
12640 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
12641 error "rename to $MOUNT/.lustre/fid should fail."
12643 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
12645 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
12646 local new_obf_mode=777
12648 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
12649 chmod $new_obf_mode $DIR/.lustre/fid ||
12650 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
12652 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
12653 [ $obf_mode -eq $new_obf_mode ] ||
12654 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
12656 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
12657 chmod $old_obf_mode $DIR/.lustre/fid ||
12658 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
12661 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
12662 fid=$($LFS path2fid $test_dir/$tfile-2)
12664 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
12666 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
12667 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
12668 error "create lov data thru .lustre failed"
12670 echo "cp /etc/passwd $test_dir/$tfile-2"
12671 cp /etc/passwd $test_dir/$tfile-2 ||
12672 error "copy to $test_dir/$tfile-2 failed."
12673 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
12674 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
12675 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
12677 rm -rf $test_dir/tfile.lnk
12678 rm -rf $test_dir/$tfile-2
12682 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12683 skip "Need MDS version at least 2.4.1"
12685 local tf=$DIR/$tfile
12688 local fid=$($LFS path2fid $tf)
12689 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
12691 # check that we get the same pathname back
12692 local found=$($LFS fid2path $MOUNT "$fid")
12693 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
12694 [ "$found" == "$tf" ] ||
12695 error "fid2path($fid=path2fid($tf)) = $found != $tf"
12697 run_test 154A "lfs path2fid and fid2path basic checks"
12700 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12701 skip "Need MDS version at least 2.4.1"
12703 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
12704 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
12705 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
12706 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
12708 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
12709 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
12711 # check that we get the same pathname
12712 echo "PFID: $PFID, name: $name"
12713 local FOUND=$($LFS fid2path $MOUNT "$PFID")
12714 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
12715 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
12716 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
12718 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
12720 run_test 154B "verify the ll_decode_linkea tool"
12723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12724 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12725 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12726 skip "Need MDS version at least 2.2.51"
12727 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12729 cp /etc/hosts $DIR/$tfile
12731 fid=$($LFS path2fid $DIR/$tfile)
12733 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
12735 dot_lustre_fid_permission_check "$fid" $DIR ||
12736 error "dot lustre permission check $fid failed"
12738 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
12740 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
12742 touch $MOUNT/.lustre/file &&
12743 error "creation is not allowed under .lustre"
12745 mkdir $MOUNT/.lustre/dir &&
12746 error "mkdir is not allowed under .lustre"
12750 run_test 154a "Open-by-FID"
12753 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12754 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12755 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12756 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12757 skip "Need MDS version at least 2.2.51"
12759 local remote_dir=$DIR/$tdir/remote_dir
12763 mkdir -p $DIR/$tdir
12764 $LFS mkdir -i $MDTIDX $remote_dir ||
12765 error "create remote directory failed"
12767 cp /etc/hosts $remote_dir/$tfile
12769 fid=$($LFS path2fid $remote_dir/$tfile)
12771 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
12773 dot_lustre_fid_permission_check "$fid" $remote_dir ||
12774 error "dot lustre permission check $fid failed"
12777 run_test 154b "Open-by-FID for remote directory"
12780 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12781 skip "Need MDS version at least 2.4.1"
12783 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
12784 local FID1=$($LFS path2fid $DIR/$tfile.1)
12785 local FID2=$($LFS path2fid $DIR/$tfile.2)
12786 local FID3=$($LFS path2fid $DIR/$tfile.3)
12789 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
12790 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
12791 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
12793 [ "$FID" = "${!want}" ] ||
12794 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
12798 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
12800 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
12801 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
12805 run_test 154c "lfs path2fid and fid2path multiple arguments"
12808 remote_mds_nodsh && skip "remote MDS with nodsh"
12809 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
12810 skip "Need MDS version at least 2.5.53"
12812 if remote_mds; then
12813 nid=$($LCTL list_nids | sed "s/\./\\\./g")
12817 local proc_ofile="mdt.*.exports.'$nid'.open_files"
12824 local fid=$($LFS path2fid $DIR/$tfile)
12827 cmd="exec $fd<$DIR/$tfile"
12829 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
12830 echo "$fid_list" | grep "$fid"
12833 cmd="exec $fd>/dev/null"
12835 if [ $rc -ne 0 ]; then
12836 error "FID $fid not found in open files list $fid_list"
12839 run_test 154d "Verify open file fid"
12843 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
12844 skip "Need MDS version at least 2.6.50"
12846 if ls -a $MOUNT | grep -q '^\.lustre$'; then
12847 error ".lustre returned by readdir"
12850 run_test 154e ".lustre is not returned by readdir"
12853 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12855 # create parent directory on a single MDT to avoid cross-MDT hardlinks
12856 test_mkdir -p -c1 $DIR/$tdir/d
12857 # test dirs inherit from its stripe
12858 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
12859 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
12860 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
12861 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
12864 # get fid of parents
12865 local FID0=$($LFS path2fid $DIR/$tdir/d)
12866 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
12867 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
12868 local FID3=$($LFS path2fid $DIR)
12870 # check that path2fid --parents returns expected <parent_fid>/name
12871 # 1) test for a directory (single parent)
12872 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
12873 [ "$parent" == "$FID0/foo1" ] ||
12874 error "expected parent: $FID0/foo1, got: $parent"
12876 # 2) test for a file with nlink > 1 (multiple parents)
12877 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
12878 echo "$parent" | grep -F "$FID1/$tfile" ||
12879 error "$FID1/$tfile not returned in parent list"
12880 echo "$parent" | grep -F "$FID2/link" ||
12881 error "$FID2/link not returned in parent list"
12883 # 3) get parent by fid
12884 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
12885 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12886 echo "$parent" | grep -F "$FID1/$tfile" ||
12887 error "$FID1/$tfile not returned in parent list (by fid)"
12888 echo "$parent" | grep -F "$FID2/link" ||
12889 error "$FID2/link not returned in parent list (by fid)"
12891 # 4) test for entry in root directory
12892 parent=$($LFS path2fid --parents $DIR/f)
12893 echo "$parent" | grep -F "$FID3/f" ||
12894 error "$FID3/f not returned in parent list"
12896 # 5) test it on root directory
12897 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
12898 error "$MOUNT should not have parents"
12900 # enable xattr caching and check that linkea is correctly updated
12901 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12902 save_lustre_params client "llite.*.xattr_cache" > $save
12903 lctl set_param llite.*.xattr_cache 1
12905 # 6.1) linkea update on rename
12906 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
12908 # get parents by fid
12909 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12910 # foo1 should no longer be returned in parent list
12911 echo "$parent" | grep -F "$FID1" &&
12912 error "$FID1 should no longer be in parent list"
12913 # the new path should appear
12914 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
12915 error "$FID2/$tfile.moved is not in parent list"
12917 # 6.2) linkea update on unlink
12918 rm -f $DIR/$tdir/d/foo2/link
12919 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12920 # foo2/link should no longer be returned in parent list
12921 echo "$parent" | grep -F "$FID2/link" &&
12922 error "$FID2/link should no longer be in parent list"
12926 restore_lustre_params < $save
12929 run_test 154f "get parent fids by reading link ea"
12933 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12934 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
12935 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
12936 skip "Need MDS version at least 2.6.92"
12938 mkdir -p $DIR/$tdir
12939 llapi_fid_test -d $DIR/$tdir
12941 run_test 154g "various llapi FID tests"
12943 test_155_small_load() {
12944 local temp=$TMP/$tfile
12945 local file=$DIR/$tfile
12947 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
12948 error "dd of=$temp bs=6096 count=1 failed"
12950 cancel_lru_locks $OSC
12951 cmp $temp $file || error "$temp $file differ"
12953 $TRUNCATE $temp 6000
12954 $TRUNCATE $file 6000
12955 cmp $temp $file || error "$temp $file differ (truncate1)"
12957 echo "12345" >>$temp
12958 echo "12345" >>$file
12959 cmp $temp $file || error "$temp $file differ (append1)"
12961 echo "12345" >>$temp
12962 echo "12345" >>$file
12963 cmp $temp $file || error "$temp $file differ (append2)"
12969 test_155_big_load() {
12970 remote_ost_nodsh && skip "remote OST with nodsh"
12972 local temp=$TMP/$tfile
12973 local file=$DIR/$tfile
12976 local cache_size=$(do_facet ost$((MAXI+1)) \
12977 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
12978 local large_file_size=$((cache_size * 2))
12980 echo "OSS cache size: $cache_size KB"
12981 echo "Large file size: $large_file_size KB"
12983 [ $MAXV -le $large_file_size ] &&
12984 skip_env "max available OST size needs > $large_file_size KB"
12986 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
12988 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
12989 error "dd of=$temp bs=$large_file_size count=1k failed"
12992 cancel_lru_locks osc
12993 cmp $temp $file || error "$temp $file differ"
12999 save_writethrough() {
13000 local facets=$(get_facets OST)
13002 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
13006 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13008 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13010 save_writethrough $p
13013 set_cache writethrough on
13014 test_155_small_load
13015 restore_lustre_params < $p
13018 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
13021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13023 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13025 save_writethrough $p
13028 set_cache writethrough off
13029 test_155_small_load
13030 restore_lustre_params < $p
13033 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
13036 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13038 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13040 save_writethrough $p
13043 set_cache writethrough on
13044 test_155_small_load
13045 restore_lustre_params < $p
13048 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
13051 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13053 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13055 save_writethrough $p
13058 set_cache writethrough off
13059 test_155_small_load
13060 restore_lustre_params < $p
13063 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
13066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13068 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13070 save_writethrough $p
13073 set_cache writethrough on
13075 restore_lustre_params < $p
13078 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
13081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13083 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13085 save_writethrough $p
13088 set_cache writethrough off
13090 restore_lustre_params < $p
13093 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
13096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13098 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13100 save_writethrough $p
13103 set_cache writethrough on
13105 restore_lustre_params < $p
13108 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
13111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13113 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13115 save_writethrough $p
13118 set_cache writethrough off
13120 restore_lustre_params < $p
13123 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
13126 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13127 remote_ost_nodsh && skip "remote OST with nodsh"
13128 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
13129 skip "stats not implemented on old servers"
13130 [ "$ost1_FSTYPE" = "zfs" ] &&
13131 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
13136 local file="$DIR/$tfile"
13137 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13139 save_writethrough $p
13142 log "Turn on read and write cache"
13144 set_cache writethrough on
13146 log "Write data and read it back."
13147 log "Read should be satisfied from the cache."
13148 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13150 cancel_lru_locks osc
13151 cat $file >/dev/null
13153 if ! let "AFTER - BEFORE == CPAGES"; then
13154 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13156 log "cache hits:: before: $BEFORE, after: $AFTER"
13159 log "Read again; it should be satisfied from the cache."
13161 cancel_lru_locks osc
13162 cat $file >/dev/null
13164 if ! let "AFTER - BEFORE == CPAGES"; then
13165 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13167 log "cache hits:: before: $BEFORE, after: $AFTER"
13170 log "Turn off the read cache and turn on the write cache"
13172 set_cache writethrough on
13174 log "Read again; it should be satisfied from the cache."
13176 cancel_lru_locks osc
13177 cat $file >/dev/null
13179 if ! let "AFTER - BEFORE == CPAGES"; then
13180 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13182 log "cache hits:: before: $BEFORE, after: $AFTER"
13185 log "Read again; it should not be satisfied from the cache."
13187 cancel_lru_locks osc
13188 cat $file >/dev/null
13190 if ! let "AFTER - BEFORE == 0"; then
13191 error "IN CACHE: before: $BEFORE, after: $AFTER"
13193 log "cache hits:: before: $BEFORE, after: $AFTER"
13196 log "Write data and read it back."
13197 log "Read should be satisfied from the cache."
13198 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13200 cancel_lru_locks osc
13201 cat $file >/dev/null
13203 if ! let "AFTER - BEFORE == CPAGES"; then
13204 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13206 log "cache hits:: before: $BEFORE, after: $AFTER"
13209 log "Read again; it should not be satisfied from the cache."
13211 cancel_lru_locks osc
13212 cat $file >/dev/null
13214 if ! let "AFTER - BEFORE == 0"; then
13215 error "IN CACHE: before: $BEFORE, after: $AFTER"
13217 log "cache hits:: before: $BEFORE, after: $AFTER"
13220 log "Turn off read and write cache"
13222 set_cache writethrough off
13224 log "Write data and read it back"
13225 log "It should not be satisfied from the cache."
13227 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13228 cancel_lru_locks osc
13230 cat $file >/dev/null
13232 if ! let "AFTER - BEFORE == 0"; then
13233 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13235 log "cache hits:: before: $BEFORE, after: $AFTER"
13238 log "Turn on the read cache and turn off the write cache"
13240 set_cache writethrough off
13242 log "Write data and read it back"
13243 log "It should not be satisfied from the cache."
13245 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13247 cancel_lru_locks osc
13248 cat $file >/dev/null
13250 if ! let "AFTER - BEFORE == 0"; then
13251 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13253 log "cache hits:: before: $BEFORE, after: $AFTER"
13256 log "Read again; it should be satisfied from the cache."
13258 cancel_lru_locks osc
13259 cat $file >/dev/null
13261 if ! let "AFTER - BEFORE == CPAGES"; then
13262 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13264 log "cache hits:: before: $BEFORE, after: $AFTER"
13267 restore_lustre_params < $p
13270 run_test 156 "Verification of tunables"
13273 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13274 remote_mds_nodsh && skip "remote MDS with nodsh"
13275 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13276 skip "Need MDS version at least 2.2.0"
13278 changelog_register || error "changelog_register failed"
13279 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13280 changelog_users $SINGLEMDS | grep -q $cl_user ||
13281 error "User $cl_user not found in changelog_users"
13284 test_mkdir -p $DIR/$tdir/pics/2008/zachy
13285 changelog_clear 0 || error "changelog_clear failed"
13286 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
13287 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
13288 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
13289 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
13290 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
13291 rm $DIR/$tdir/pics/desktop.jpg
13293 changelog_dump | tail -10
13295 echo "verifying changelog mask"
13296 changelog_chmask "-MKDIR"
13297 changelog_chmask "-CLOSE"
13299 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
13300 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
13302 changelog_chmask "+MKDIR"
13303 changelog_chmask "+CLOSE"
13305 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
13306 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
13308 changelog_dump | tail -10
13309 MKDIRS=$(changelog_dump | grep -c "MKDIR")
13310 CLOSES=$(changelog_dump | grep -c "CLOSE")
13311 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
13312 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
13315 echo "verifying target fid"
13316 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
13317 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
13318 [ "$fidc" == "$fidf" ] ||
13319 error "changelog '$tfile' fid $fidc != file fid $fidf"
13320 echo "verifying parent fid"
13321 # The FID returned from the Changelog may be the directory shard on
13322 # a different MDT, and not the FID returned by path2fid on the parent.
13323 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
13324 # since this is what will matter when recreating this file in the tree.
13325 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
13326 local pathp=$($LFS fid2path $MOUNT "$fidp")
13327 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
13328 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
13330 echo "getting records for $cl_user"
13331 changelog_users $SINGLEMDS
13332 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
13334 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
13335 error "changelog_clear failed"
13336 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
13337 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
13338 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
13339 error "user index expect $user_rec1 + $nclr != $user_rec2"
13341 local min0_rec=$(changelog_users $SINGLEMDS |
13342 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
13343 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
13344 awk '{ print $1; exit; }')
13346 changelog_dump | tail -n 5
13347 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
13348 [ $first_rec == $((min0_rec + 1)) ] ||
13349 error "first index should be $min0_rec + 1 not $first_rec"
13351 # LU-3446 changelog index reset on MDT restart
13352 local cur_rec1=$(changelog_users $SINGLEMDS |
13353 awk '/^current.index:/ { print $NF }')
13354 changelog_clear 0 ||
13355 error "clear all changelog records for $cl_user failed"
13356 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
13357 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
13358 error "Fail to start $SINGLEMDS"
13359 local cur_rec2=$(changelog_users $SINGLEMDS |
13360 awk '/^current.index:/ { print $NF }')
13361 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
13362 [ $cur_rec1 == $cur_rec2 ] ||
13363 error "current index should be $cur_rec1 not $cur_rec2"
13365 echo "verifying users from this test are deregistered"
13366 changelog_deregister || error "changelog_deregister failed"
13367 changelog_users $SINGLEMDS | grep -q $cl_user &&
13368 error "User '$cl_user' still in changelog_users"
13370 # lctl get_param -n mdd.*.changelog_users
13371 # current index: 144
13372 # ID index (idle seconds)
13374 if ! changelog_users $SINGLEMDS | grep "^cl"; then
13375 # this is the normal case where all users were deregistered
13376 # make sure no new records are added when no users are present
13377 local last_rec1=$(changelog_users $SINGLEMDS |
13378 awk '/^current.index:/ { print $NF }')
13379 touch $DIR/$tdir/chloe
13380 local last_rec2=$(changelog_users $SINGLEMDS |
13381 awk '/^current.index:/ { print $NF }')
13382 echo "verify changelogs are off: $last_rec1 == $last_rec2"
13383 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
13385 # any changelog users must be leftovers from a previous test
13386 changelog_users $SINGLEMDS
13387 echo "other changelog users; can't verify off"
13390 run_test 160a "changelog sanity"
13392 test_160b() { # LU-3587
13393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13394 remote_mds_nodsh && skip "remote MDS with nodsh"
13395 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13396 skip "Need MDS version at least 2.2.0"
13398 changelog_register || error "changelog_register failed"
13399 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13400 changelog_users $SINGLEMDS | grep -q $cl_user ||
13401 error "User '$cl_user' not found in changelog_users"
13403 local longname1=$(str_repeat a 255)
13404 local longname2=$(str_repeat b 255)
13407 echo "creating very long named file"
13408 touch $longname1 || error "create of '$longname1' failed"
13409 echo "renaming very long named file"
13410 mv $longname1 $longname2
13412 changelog_dump | grep RENME | tail -n 5
13415 run_test 160b "Verify that very long rename doesn't crash in changelog"
13418 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13419 remote_mds_nodsh && skip "remote MDS with nodsh"
13421 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
13422 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
13423 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
13424 skip "Need MDS version at least 2.5.58 or 2.5.2+"
13428 # Registration step
13429 changelog_register || error "changelog_register failed"
13432 mkdir -p $DIR/$tdir
13433 $MCREATE $DIR/$tdir/foo_160c
13434 changelog_chmask "-TRUNC"
13435 $TRUNCATE $DIR/$tdir/foo_160c 200
13436 changelog_chmask "+TRUNC"
13437 $TRUNCATE $DIR/$tdir/foo_160c 199
13438 changelog_dump | tail -n 5
13439 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
13440 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
13442 run_test 160c "verify that changelog log catch the truncate event"
13445 remote_mds_nodsh && skip "remote MDS with nodsh"
13446 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13447 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13448 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
13449 skip "Need MDS version at least 2.7.60"
13451 # Registration step
13452 changelog_register || error "changelog_register failed"
13454 mkdir -p $DIR/$tdir/migrate_dir
13455 changelog_clear 0 || error "changelog_clear failed"
13457 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
13458 changelog_dump | tail -n 5
13459 local migrates=$(changelog_dump | grep -c "MIGRT")
13460 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
13462 run_test 160d "verify that changelog log catch the migrate event"
13465 remote_mds_nodsh && skip "remote MDS with nodsh"
13468 changelog_register || error "changelog_register failed"
13470 # Delete a future user (expect fail)
13471 local MDT0=$(facet_svc $SINGLEMDS)
13472 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
13475 if [ $rc -eq 0 ]; then
13476 error "Deleted non-existant user cl77"
13477 elif [ $rc -ne 2 ]; then
13478 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
13481 # Clear to a bad index (1 billion should be safe)
13482 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
13485 if [ $rc -eq 0 ]; then
13486 error "Successfully cleared to invalid CL index"
13487 elif [ $rc -ne 22 ]; then
13488 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
13491 run_test 160e "changelog negative testing (should return errors)"
13494 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13495 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13496 skip "Need MDS version at least 2.10.56"
13498 local mdts=$(comma_list $(mdts_nodes))
13501 changelog_register || error "first changelog_register failed"
13502 changelog_register || error "second changelog_register failed"
13504 declare -A cl_user1
13505 declare -A cl_user2
13510 # generate some changelog records to accumulate on each MDT
13511 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13512 log "$(date +%s): creating first files"
13513 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13514 error "create $DIR/$tdir/$tfile failed"
13516 # check changelogs have been generated
13517 local start=$SECONDS
13518 local idle_time=$((MDSCOUNT * 5 + 5))
13519 local nbcl=$(changelog_dump | wc -l)
13520 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13522 for param in "changelog_max_idle_time=$idle_time" \
13524 "changelog_min_gc_interval=2" \
13525 "changelog_min_free_cat_entries=3"; do
13526 local MDT0=$(facet_svc $SINGLEMDS)
13527 local var="${param%=*}"
13528 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13530 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13531 do_nodes $mdts $LCTL set_param mdd.*.$param
13534 # force cl_user2 to be idle (1st part), but also cancel the
13535 # cl_user1 records so that it is not evicted later in the test.
13536 local sleep1=$((idle_time / 2))
13537 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
13540 # simulate changelog catalog almost full
13541 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13542 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13544 for i in $(seq $MDSCOUNT); do
13545 cl_users=(${CL_USERS[mds$i]})
13546 cl_user1[mds$i]="${cl_users[0]}"
13547 cl_user2[mds$i]="${cl_users[1]}"
13549 [ -n "${cl_user1[mds$i]}" ] ||
13550 error "mds$i: no user registered"
13551 [ -n "${cl_user2[mds$i]}" ] ||
13552 error "mds$i: only ${cl_user2[mds$i]} is registered"
13554 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13555 [ -n "$user_rec1" ] ||
13556 error "mds$i: User ${cl_user1[mds$i]} not registered"
13557 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13558 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13559 [ -n "$user_rec2" ] ||
13560 error "mds$i: User ${cl_user1[mds$i]} not registered"
13561 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13562 "$user_rec1 + 2 == $user_rec2"
13563 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13564 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13565 "$user_rec1 + 2, but is $user_rec2"
13566 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13567 [ -n "$user_rec2" ] ||
13568 error "mds$i: User ${cl_user2[mds$i]} not registered"
13569 [ $user_rec1 == $user_rec2 ] ||
13570 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13571 "$user_rec1, but is $user_rec2"
13574 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
13575 local sleep2=$((idle_time - (SECONDS - start) + 1))
13576 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
13579 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
13580 # cl_user1 should be OK because it recently processed records.
13581 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
13582 createmany -m $DIR/$tdir/${tfile}b $((MDSCOUNT * 2)) ||
13583 error "create $DIR/$tdir/${tfile}b failed"
13585 # ensure gc thread is done
13586 for i in $(mdts_nodes); do
13588 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13589 error "$i: GC-thread not done"
13593 for i in $(seq $MDSCOUNT); do
13594 # check cl_user1 still registered
13595 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13596 error "mds$i: User ${cl_user1[mds$i]} not registered"
13597 # check cl_user2 unregistered
13598 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13599 error "mds$i: User ${cl_user2[mds$i]} still registered"
13601 # check changelogs are present and starting at $user_rec1 + 1
13602 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13603 [ -n "$user_rec1" ] ||
13604 error "mds$i: User ${cl_user1[mds$i]} not registered"
13605 first_rec=$($LFS changelog $(facet_svc mds$i) |
13606 awk '{ print $1; exit; }')
13608 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13609 [ $((user_rec1 + 1)) == $first_rec ] ||
13610 error "mds$i: first index should be $user_rec1 + 1, " \
13611 "but is $first_rec"
13614 run_test 160f "changelog garbage collect (timestamped users)"
13617 remote_mds_nodsh && skip "remote MDS with nodsh"
13618 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13619 skip "Need MDS version at least 2.10.56"
13621 local mdts=$(comma_list $(mdts_nodes))
13623 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
13624 do_nodes $mdts $LCTL set_param fail_loc=0x1314
13627 changelog_register || error "first changelog_register failed"
13628 changelog_register || error "second changelog_register failed"
13630 declare -A cl_user1
13631 declare -A cl_user2
13636 # generate some changelog records to accumulate on each MDT
13637 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13638 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13639 error "create $DIR/$tdir/$tfile failed"
13641 # check changelogs have been generated
13642 local nbcl=$(changelog_dump | wc -l)
13643 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13645 # reduce the max_idle_indexes value to make sure we exceed it
13646 max_ndx=$((nbcl / 2 - 1))
13648 for param in "changelog_max_idle_indexes=$max_ndx" \
13650 "changelog_min_gc_interval=2" \
13651 "changelog_min_free_cat_entries=3"; do
13652 local MDT0=$(facet_svc $SINGLEMDS)
13653 local var="${param%=*}"
13654 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13656 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13657 do_nodes $mdts $LCTL set_param mdd.*.$param ||
13658 error "unable to set mdd.*.$param"
13661 # simulate changelog catalog almost full
13662 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13663 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13665 for i in $(seq $MDSCOUNT); do
13666 cl_users=(${CL_USERS[mds$i]})
13667 cl_user1[mds$i]="${cl_users[0]}"
13668 cl_user2[mds$i]="${cl_users[1]}"
13670 [ -n "${cl_user1[mds$i]}" ] ||
13671 error "mds$i: no user registered"
13672 [ -n "${cl_user2[mds$i]}" ] ||
13673 error "mds$i: only ${cl_user1[mds$i]} is registered"
13675 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13676 [ -n "$user_rec1" ] ||
13677 error "mds$i: User ${cl_user1[mds$i]} not registered"
13678 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13679 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13680 [ -n "$user_rec2" ] ||
13681 error "mds$i: User ${cl_user1[mds$i]} not registered"
13682 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13683 "$user_rec1 + 2 == $user_rec2"
13684 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13685 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13686 "$user_rec1 + 2, but is $user_rec2"
13687 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13688 [ -n "$user_rec2" ] ||
13689 error "mds$i: User ${cl_user2[mds$i]} not registered"
13690 [ $user_rec1 == $user_rec2 ] ||
13691 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13692 "$user_rec1, but is $user_rec2"
13695 # ensure we are past the previous changelog_min_gc_interval set above
13698 # generate one more changelog to trigger fail_loc
13699 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13700 error "create $DIR/$tdir/${tfile}bis failed"
13702 # ensure gc thread is done
13703 for i in $(mdts_nodes); do
13705 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13706 error "$i: GC-thread not done"
13710 for i in $(seq $MDSCOUNT); do
13711 # check cl_user1 still registered
13712 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13713 error "mds$i: User ${cl_user1[mds$i]} not registered"
13714 # check cl_user2 unregistered
13715 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13716 error "mds$i: User ${cl_user2[mds$i]} still registered"
13718 # check changelogs are present and starting at $user_rec1 + 1
13719 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13720 [ -n "$user_rec1" ] ||
13721 error "mds$i: User ${cl_user1[mds$i]} not registered"
13722 first_rec=$($LFS changelog $(facet_svc mds$i) |
13723 awk '{ print $1; exit; }')
13725 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13726 [ $((user_rec1 + 1)) == $first_rec ] ||
13727 error "mds$i: first index should be $user_rec1 + 1, " \
13728 "but is $first_rec"
13731 run_test 160g "changelog garbage collect (old users)"
13734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13735 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13736 skip "Need MDS version at least 2.10.56"
13738 local mdts=$(comma_list $(mdts_nodes))
13741 changelog_register || error "first changelog_register failed"
13742 changelog_register || error "second changelog_register failed"
13744 declare -A cl_user1
13745 declare -A cl_user2
13750 # generate some changelog records to accumulate on each MDT
13751 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13752 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13753 error "create $DIR/$tdir/$tfile failed"
13755 # check changelogs have been generated
13756 local nbcl=$(changelog_dump | wc -l)
13757 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13759 for param in "changelog_max_idle_time=10" \
13761 "changelog_min_gc_interval=2"; do
13762 local MDT0=$(facet_svc $SINGLEMDS)
13763 local var="${param%=*}"
13764 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13766 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13767 do_nodes $mdts $LCTL set_param mdd.*.$param
13770 # force cl_user2 to be idle (1st part)
13773 for i in $(seq $MDSCOUNT); do
13774 cl_users=(${CL_USERS[mds$i]})
13775 cl_user1[mds$i]="${cl_users[0]}"
13776 cl_user2[mds$i]="${cl_users[1]}"
13778 [ -n "${cl_user1[mds$i]}" ] ||
13779 error "mds$i: no user registered"
13780 [ -n "${cl_user2[mds$i]}" ] ||
13781 error "mds$i: only ${cl_user2[mds$i]} is registered"
13783 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13784 [ -n "$user_rec1" ] ||
13785 error "mds$i: User ${cl_user1[mds$i]} not registered"
13786 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13787 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13788 [ -n "$user_rec2" ] ||
13789 error "mds$i: User ${cl_user1[mds$i]} not registered"
13790 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13791 "$user_rec1 + 2 == $user_rec2"
13792 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13793 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13794 "$user_rec1 + 2, but is $user_rec2"
13795 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13796 [ -n "$user_rec2" ] ||
13797 error "mds$i: User ${cl_user2[mds$i]} not registered"
13798 [ $user_rec1 == $user_rec2 ] ||
13799 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13800 "$user_rec1, but is $user_rec2"
13803 # force cl_user2 to be idle (2nd part) and to reach
13804 # changelog_max_idle_time
13807 # force each GC-thread start and block then
13808 # one per MDT/MDD, set fail_val accordingly
13809 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
13810 do_nodes $mdts $LCTL set_param fail_loc=0x1316
13812 # generate more changelogs to trigger fail_loc
13813 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13814 error "create $DIR/$tdir/${tfile}bis failed"
13816 # stop MDT to stop GC-thread, should be done in back-ground as it will
13817 # block waiting for the thread to be released and exit
13818 declare -A stop_pids
13819 for i in $(seq $MDSCOUNT); do
13821 stop_pids[mds$i]=$!
13824 for i in $(mdts_nodes); do
13827 local facets=$(facets_up_on_host $i)
13829 for facet in ${facets//,/ }; do
13830 if [[ $facet == mds* ]]; then
13834 # ensure each MDS's gc threads are still present and all in "R"
13835 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
13836 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
13837 error "$i: expected $nb GC-thread"
13839 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
13841 error "$i: GC-thread not found in R-state"
13842 # check umounts of each MDT on MDS have reached kthread_stop()
13843 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
13844 error "$i: expected $nb umount"
13846 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
13847 error "$i: umount not found in D-state"
13850 # release all GC-threads
13851 do_nodes $mdts $LCTL set_param fail_loc=0
13853 # wait for MDT stop to complete
13854 for i in $(seq $MDSCOUNT); do
13855 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
13859 # may try to check if any orphan changelog records are present
13860 # via ldiskfs/zfs and llog_reader...
13862 # re-start/mount MDTs
13863 for i in $(seq $MDSCOUNT); do
13864 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
13865 error "Fail to start mds$i"
13869 for i in $(seq $MDSCOUNT); do
13870 # check cl_user1 still registered
13871 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13872 error "mds$i: User ${cl_user1[mds$i]} not registered"
13873 # check cl_user2 unregistered
13874 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13875 error "mds$i: User ${cl_user2[mds$i]} still registered"
13877 # check changelogs are present and starting at $user_rec1 + 1
13878 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13879 [ -n "$user_rec1" ] ||
13880 error "mds$i: User ${cl_user1[mds$i]} not registered"
13881 first_rec=$($LFS changelog $(facet_svc mds$i) |
13882 awk '{ print $1; exit; }')
13884 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13885 [ $((user_rec1 + 1)) == $first_rec ] ||
13886 error "mds$i: first index should be $user_rec1 + 1, " \
13887 "but is $first_rec"
13890 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
13895 local mdts=$(comma_list $(mdts_nodes))
13897 changelog_register || error "first changelog_register failed"
13899 # generate some changelog records to accumulate on each MDT
13900 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13901 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13902 error "create $DIR/$tdir/$tfile failed"
13904 # check changelogs have been generated
13905 local nbcl=$(changelog_dump | wc -l)
13906 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13908 # simulate race between register and unregister
13909 # XXX as fail_loc is set per-MDS, with DNE configs the race
13910 # simulation will only occur for one MDT per MDS and for the
13911 # others the normal race scenario will take place
13912 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
13913 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
13914 do_nodes $mdts $LCTL set_param fail_val=1
13916 # unregister 1st user
13917 changelog_deregister &
13919 # wait some time for deregister work to reach race rdv
13921 # register 2nd user
13922 changelog_register || error "2nd user register failed"
13924 wait $pid1 || error "1st user deregister failed"
13928 declare -A LAST_REC
13929 for i in $(seq $MDSCOUNT); do
13930 if changelog_users mds$i | grep "^cl"; then
13931 # make sure new records are added with one user present
13932 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
13933 awk '/^current.index:/ { print $NF }')
13935 error "mds$i has no user registered"
13939 # generate more changelog records to accumulate on each MDT
13940 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13941 error "create $DIR/$tdir/${tfile}bis failed"
13943 for i in $(seq $MDSCOUNT); do
13944 last_rec=$(changelog_users $SINGLEMDS |
13945 awk '/^current.index:/ { print $NF }')
13946 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
13947 [ $last_rec != ${LAST_REC[mds$i]} ] ||
13948 error "changelogs are off on mds$i"
13951 run_test 160i "changelog user register/unregister race"
13954 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13955 remote_mds_nodsh && skip "remote MDS with nodsh"
13957 mkdir -p $DIR/$tdir/1/1
13959 changelog_register || error "changelog_register failed"
13960 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13962 changelog_users $SINGLEMDS | grep -q $cl_user ||
13963 error "User '$cl_user' not found in changelog_users"
13964 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
13965 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
13966 rmdir $DIR/$tdir/1/1 & sleep 1
13968 touch $DIR/$tdir/2/2
13969 rm -rf $DIR/$tdir/2
13974 changelog_dump | grep rmdir || error "rmdir not recorded"
13977 changelog_deregister
13979 run_test 160k "Verify that changelog records are not lost"
13982 remote_mds_nodsh && skip "remote MDS with nodsh"
13983 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
13984 skip "Need MDS version at least 2.12.56"
13986 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
13988 changelog_register || error "first changelog_register failed"
13990 # generate some changelog
13991 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13992 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13993 error "create $DIR/$tdir/${tfile}bis failed"
13995 # open the changelog device
13996 exec 3>/dev/changelog-$FSNAME-MDT0000
13997 exec 4</dev/changelog-$FSNAME-MDT0000
13999 # umount the first lustre mount
14003 cat <&4 >/dev/null || error "read changelog failed"
14006 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14007 changelog_users $SINGLEMDS | grep -q $cl_user ||
14008 error "User $cl_user not found in changelog_users"
14010 printf 'clear:'$cl_user':0' >&3
14017 changelog_deregister || error "changelog_deregister failed"
14020 mount_client $MOUNT || error "mount_client on $MOUNT failed"
14022 run_test 160j "client can be umounted while its chanangelog is being used"
14025 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14026 [[ $MDS1_VERSION -ge $(version_code 2.12.7) ]] ||
14027 skip "Need MDS version at least 2.12.7"
14034 changelog_register || error "first changelog_register failed"
14035 changelog_register || error "second changelog_register failed"
14037 cl_users=(${CL_USERS[mds1]})
14038 cl_user1="${cl_users[0]}"
14039 cl_user2="${cl_users[1]}"
14040 # generate some changelog records to accumulate on MDT0
14041 test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
14042 createmany -m $DIR/$tdir/$tfile 50 ||
14043 error "create $DIR/$tdir/$tfile failed"
14044 unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
14047 # check changelogs have been generated
14048 local nbcl=$(changelog_dump | wc -l)
14049 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14051 #define OBD_FAIL_MDS_CHANGELOG_RACE 0x15f
14052 do_facet mds1 $LCTL set_param fail_loc=0x8000015f fail_val=0
14054 __changelog_clear mds1 $cl_user1 +10
14055 __changelog_clear mds1 $cl_user2 0 &
14058 __changelog_clear mds1 $cl_user1 0 ||
14059 error "fail to cancel record for $cl_user1"
14061 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
14063 run_test 160m "Changelog clear race"
14066 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14067 [[ $MDS1_VERSION -ge $(version_code 2.12.7) ]] ||
14068 skip "Need MDS version at least 2.12.7"
14077 changelog_register || error "first changelog_register failed"
14079 cl_users=(${CL_USERS[mds1]})
14080 cl_user1="${cl_users[0]}"
14082 # generate some changelog records to accumulate on MDT0
14083 test_mkdir -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
14084 first_rec=$(changelog_users $SINGLEMDS |
14085 awk '/^current.index:/ { print $NF }')
14086 while (( last_rec < (( first_rec + 65000)) )); do
14087 createmany -m $DIR/$tdir/$tfile 10000 ||
14088 error "create $DIR/$tdir/$tfile failed"
14090 for i in $(seq 0 10000); do
14091 mrename $DIR/$tdir/$tfile$i $DIR/$tdir/$tfile-new$i \
14095 unlinkmany $DIR/$tdir/$tfile-new 10000 ||
14096 error "unlinkmany failed unlink"
14097 last_rec=$(changelog_users $SINGLEMDS |
14098 awk '/^current.index:/ { print $NF }')
14099 echo last record $last_rec
14100 (( last_rec == 0 )) && error "no changelog found"
14103 #define OBD_FAIL_MDS_CHANGELOG_DEL 0x16c
14104 do_facet mds1 $LCTL set_param fail_loc=0x8000016c fail_val=0
14106 __changelog_clear mds1 $cl_user1 0 &
14109 __changelog_clear mds1 $cl_user1 0 ||
14110 error "fail to cancel record for $cl_user1"
14112 [[ $? -eq 0 ]] || error "fail to cancel record for $cl_user2"
14114 run_test 160n "Changelog destroy race"
14117 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14119 test_mkdir -c1 $DIR/$tdir
14120 cp /etc/hosts $DIR/$tdir/$tfile
14121 test_mkdir -c1 $DIR/$tdir/foo1
14122 test_mkdir -c1 $DIR/$tdir/foo2
14123 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
14124 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
14125 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
14126 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
14127 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
14128 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14129 $LFS fid2path $DIR $FID
14130 error "bad link ea"
14133 rm $DIR/$tdir/foo2/zachary
14135 rm $DIR/$tdir/foo2/thor
14137 rm $DIR/$tdir/$tfile
14139 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
14140 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
14141 { $LFS fid2path $DIR $FID; error "bad link rename"; }
14142 rm $DIR/$tdir/foo2/maggie
14145 local longname=$tfile.avg_len_is_thirty_two_
14146 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
14147 error_noexit 'failed to unlink many hardlinks'" EXIT
14148 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
14149 error "failed to hardlink many files"
14150 links=$($LFS fid2path $DIR $FID | wc -l)
14151 echo -n "${links}/1000 links in link EA"
14152 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
14154 run_test 161a "link ea sanity"
14157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14158 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
14161 local remote_dir=$DIR/$tdir/remote_dir
14163 mkdir -p $DIR/$tdir
14164 $LFS mkdir -i $MDTIDX $remote_dir ||
14165 error "create remote directory failed"
14167 cp /etc/hosts $remote_dir/$tfile
14168 mkdir -p $remote_dir/foo1
14169 mkdir -p $remote_dir/foo2
14170 ln $remote_dir/$tfile $remote_dir/foo1/sofia
14171 ln $remote_dir/$tfile $remote_dir/foo2/zachary
14172 ln $remote_dir/$tfile $remote_dir/foo1/luna
14173 ln $remote_dir/$tfile $remote_dir/foo2/thor
14175 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
14177 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14178 $LFS fid2path $DIR $FID
14179 error "bad link ea"
14182 rm $remote_dir/foo2/zachary
14184 rm $remote_dir/foo2/thor
14186 rm $remote_dir/$tfile
14188 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
14189 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
14190 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
14191 $LFS fid2path $DIR $FID
14192 error "bad link rename"
14194 rm $remote_dir/foo2/maggie
14197 local longname=filename_avg_len_is_thirty_two_
14198 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
14199 error "failed to hardlink many files"
14200 links=$($LFS fid2path $DIR $FID | wc -l)
14201 echo -n "${links}/1000 links in link EA"
14202 [[ ${links} -gt 60 ]] ||
14203 error "expected at least 60 links in link EA"
14204 unlinkmany $remote_dir/foo2/$longname 1000 ||
14205 error "failed to unlink many hardlinks"
14207 run_test 161b "link ea sanity under remote directory"
14210 remote_mds_nodsh && skip "remote MDS with nodsh"
14211 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14212 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
14213 skip "Need MDS version at least 2.1.5"
14215 # define CLF_RENAME_LAST 0x0001
14216 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
14217 changelog_register || error "changelog_register failed"
14220 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
14221 touch $DIR/$tdir/foo_161c
14222 touch $DIR/$tdir/bar_161c
14223 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14224 changelog_dump | grep RENME | tail -n 5
14225 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14226 changelog_clear 0 || error "changelog_clear failed"
14227 if [ x$flags != "x0x1" ]; then
14228 error "flag $flags is not 0x1"
14231 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
14232 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
14233 touch $DIR/$tdir/foo_161c
14234 touch $DIR/$tdir/bar_161c
14235 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14236 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14237 changelog_dump | grep RENME | tail -n 5
14238 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14239 changelog_clear 0 || error "changelog_clear failed"
14240 if [ x$flags != "x0x0" ]; then
14241 error "flag $flags is not 0x0"
14243 echo "rename overwrite a target having nlink > 1," \
14244 "changelog record has flags of $flags"
14246 # rename doesn't overwrite a target (changelog flag 0x0)
14247 touch $DIR/$tdir/foo_161c
14248 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
14249 changelog_dump | grep RENME | tail -n 5
14250 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
14251 changelog_clear 0 || error "changelog_clear failed"
14252 if [ x$flags != "x0x0" ]; then
14253 error "flag $flags is not 0x0"
14255 echo "rename doesn't overwrite a target," \
14256 "changelog record has flags of $flags"
14258 # define CLF_UNLINK_LAST 0x0001
14259 # unlink a file having nlink = 1 (changelog flag 0x1)
14260 rm -f $DIR/$tdir/foo2_161c
14261 changelog_dump | grep UNLNK | tail -n 5
14262 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14263 changelog_clear 0 || error "changelog_clear failed"
14264 if [ x$flags != "x0x1" ]; then
14265 error "flag $flags is not 0x1"
14267 echo "unlink a file having nlink = 1," \
14268 "changelog record has flags of $flags"
14270 # unlink a file having nlink > 1 (changelog flag 0x0)
14271 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14272 rm -f $DIR/$tdir/foobar_161c
14273 changelog_dump | grep UNLNK | tail -n 5
14274 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14275 changelog_clear 0 || error "changelog_clear failed"
14276 if [ x$flags != "x0x0" ]; then
14277 error "flag $flags is not 0x0"
14279 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
14281 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
14284 remote_mds_nodsh && skip "remote MDS with nodsh"
14289 changelog_register || error "changelog_register failed"
14291 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
14292 # interfer with $MOUNT/.lustre/fid/ access
14294 [[ $? -eq 0 ]] || error "mkdir failed"
14296 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
14297 $LCTL set_param fail_loc=0x8000140c
14299 $LCTL set_param fail_val=5
14302 echo foofoo > $DIR/$tdir/$tfile &
14305 # wait for create to be delayed
14309 [[ $? -eq 0 ]] || error "create should be blocked"
14311 local tempfile=$(mktemp)
14312 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
14313 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
14314 # some delay may occur during ChangeLog publishing and file read just
14315 # above, that could allow file write to happen finally
14316 [[ -s $tempfile ]] && echo "file should be empty"
14318 $LCTL set_param fail_loc=0
14321 [[ $? -eq 0 ]] || error "create failed"
14323 run_test 161d "create with concurrent .lustre/fid access"
14326 local expected="$1"
14331 path=$($LFS fid2path "$@")
14334 if [ $rc -ne 0 ]; then
14335 error "path looked up of '$expected' failed: rc=$rc"
14336 elif [ "$path" != "$expected" ]; then
14337 error "path looked up '$path' instead of '$expected'"
14339 echo "FID '$fid' resolves to path '$path' as expected"
14343 test_162a() { # was test_162
14344 test_mkdir -p -c1 $DIR/$tdir/d2
14345 touch $DIR/$tdir/d2/$tfile
14346 touch $DIR/$tdir/d2/x1
14347 touch $DIR/$tdir/d2/x2
14348 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
14349 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
14351 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
14352 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
14355 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
14356 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
14357 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
14359 # softlink to wrong file
14360 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
14361 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
14362 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
14365 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
14366 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
14367 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
14368 # fid2path dir/fsname should both work
14369 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
14370 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
14372 # hardlink count: check that there are 2 links
14373 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
14374 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
14376 # hardlink indexing: remove the first link
14377 rm $DIR/$tdir/d2/p/q/r/hlink
14378 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
14380 run_test 162a "path lookup sanity"
14383 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14384 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14387 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
14388 error "create striped dir failed"
14390 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
14391 tail -n 1 | awk '{print $2}')
14392 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
14394 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
14395 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
14398 for ((i=0;i<5;i++)); do
14399 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
14400 error "get fid for f$i failed"
14401 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
14403 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
14404 error "get fid for d$i failed"
14405 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
14410 run_test 162b "striped directory path lookup sanity"
14412 # LU-4239: Verify fid2path works with paths 100 or more directories deep
14414 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
14415 skip "Need MDS version at least 2.7.51"
14417 local lpath=$tdir.local
14418 local rpath=$tdir.remote
14420 test_mkdir $DIR/$lpath
14421 test_mkdir $DIR/$rpath
14423 for ((i = 0; i <= 101; i++)); do
14426 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
14427 error "get fid for local directory $DIR/$lpath failed"
14428 check_path "$DIR/$lpath" $MOUNT $FID --link 0
14431 test_mkdir $DIR/$rpath
14432 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
14433 error "get fid for remote directory $DIR/$rpath failed"
14434 check_path "$DIR/$rpath" $MOUNT $FID --link 0
14439 run_test 162c "fid2path works with paths 100 or more directories deep"
14442 # do directio so as not to populate the page cache
14443 log "creating a 10 Mb file"
14444 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14445 log "starting reads"
14446 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14447 log "truncating the file"
14448 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14450 kill %+ || true # reads might have finished
14451 echo "wait until dd is finished"
14453 log "removing the temporary file"
14454 rm -rf $DIR/$tfile || error "tmp file removal failed"
14456 run_test 169 "parallel read and truncate should not deadlock"
14459 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14461 $LCTL clear # bug 18514
14462 $LCTL debug_daemon start $TMP/${tfile}_log_good
14464 $LCTL debug_daemon stop
14465 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
14466 error "sed failed to read log_good"
14468 $LCTL debug_daemon start $TMP/${tfile}_log_good
14470 $LCTL debug_daemon stop
14472 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
14473 error "lctl df log_bad failed"
14475 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14476 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14478 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
14479 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
14481 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
14482 error "bad_line good_line1 good_line2 are empty"
14484 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14485 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
14486 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14488 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
14489 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14490 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14492 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
14493 error "bad_line_new good_line_new are empty"
14495 local expected_good=$((good_line1 + good_line2*2))
14497 rm -f $TMP/${tfile}*
14498 # LU-231, short malformed line may not be counted into bad lines
14499 if [ $bad_line -ne $bad_line_new ] &&
14500 [ $bad_line -ne $((bad_line_new - 1)) ]; then
14501 error "expected $bad_line bad lines, but got $bad_line_new"
14505 if [ $expected_good -ne $good_line_new ]; then
14506 error "expected $expected_good good lines, but got $good_line_new"
14511 run_test 170 "test lctl df to handle corrupted log ====================="
14513 test_171() { # bug20592
14514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14516 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
14517 $LCTL set_param fail_loc=0x50e
14518 $LCTL set_param fail_val=3000
14519 multiop_bg_pause $DIR/$tfile O_s || true
14521 kill -USR1 $MULTIPID
14525 if dmesg | grep "recursive fault"; then
14526 error "caught a recursive fault"
14528 $LCTL set_param fail_loc=0
14531 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
14533 # it would be good to share it with obdfilter-survey/iokit-libecho code
14534 setup_obdecho_osc () {
14537 local obdfilter_name=$2
14538 echo "Creating new osc for $obdfilter_name on $ost_nid"
14539 # make sure we can find loopback nid
14540 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
14542 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
14543 ${obdfilter_name}_osc_UUID || rc=2; }
14544 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
14545 ${obdfilter_name}_UUID $ost_nid || rc=3; }
14549 cleanup_obdecho_osc () {
14550 local obdfilter_name=$1
14551 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
14552 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
14559 local pages=${3:-64}
14564 local obd_size=$(get_obd_size $node $OBD)
14565 local page_size=$(get_page_size $node)
14566 if [[ -n "$obd_size" ]]; then
14567 local new_count=$((obd_size / (pages * page_size / 1024)))
14568 [[ $new_count -ge $count ]] || count=$new_count
14571 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
14572 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
14574 if [ $rc -eq 0 ]; then
14575 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
14576 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
14578 echo "New object id is $id"
14579 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
14581 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
14582 "test_brw $count w v $pages $id" || rc=4; }
14583 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
14585 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
14586 "cleanup" || rc=5; }
14587 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
14588 "detach" || rc=6; }
14589 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
14594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14596 if ! module_loaded obdecho; then
14597 load_module obdecho/obdecho &&
14598 stack_trap "rmmod obdecho" EXIT ||
14599 error "unable to load obdecho on client"
14602 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
14603 local host=$($LCTL get_param -n osc.$osc.import |
14604 awk '/current_connection:/ { print $2 }' )
14605 local target=$($LCTL get_param -n osc.$osc.import |
14606 awk '/target:/ { print $2 }' )
14607 target=${target%_UUID}
14609 if [ -n "$target" ]; then
14610 setup_obdecho_osc $host $target &&
14611 stack_trap "cleanup_obdecho_osc $target" EXIT ||
14612 { error "obdecho setup failed with $?"; return; }
14614 obdecho_test ${target}_osc client ||
14615 error "obdecho_test failed on ${target}_osc"
14617 $LCTL get_param osc.$osc.import
14618 error "there is no osc.$osc.import target"
14621 run_test 180a "test obdecho on osc"
14624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14625 remote_ost_nodsh && skip "remote OST with nodsh"
14627 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14628 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14629 error "failed to load module obdecho"
14631 local target=$(do_facet ost1 $LCTL dl |
14632 awk '/obdfilter/ { print $4; exit; }')
14634 if [ -n "$target" ]; then
14635 obdecho_test $target ost1 || error "obdecho_test failed with $?"
14637 do_facet ost1 $LCTL dl
14638 error "there is no obdfilter target on ost1"
14641 run_test 180b "test obdecho directly on obdfilter"
14643 test_180c() { # LU-2598
14644 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14645 remote_ost_nodsh && skip "remote OST with nodsh"
14646 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
14647 skip "Need MDS version at least 2.4.0"
14649 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14650 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14651 error "failed to load module obdecho"
14653 local target=$(do_facet ost1 $LCTL dl |
14654 awk '/obdfilter/ { print $4; exit; }')
14656 if [ -n "$target" ]; then
14657 local pages=16384 # 64MB bulk I/O RPC size
14659 obdecho_test "$target" ost1 "$pages" ||
14660 error "obdecho_test with pages=$pages failed with $?"
14662 do_facet ost1 $LCTL dl
14663 error "there is no obdfilter target on ost1"
14666 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
14668 test_181() { # bug 22177
14669 test_mkdir $DIR/$tdir
14670 # create enough files to index the directory
14671 createmany -o $DIR/$tdir/foobar 4000
14672 # print attributes for debug purpose
14675 multiop_bg_pause $DIR/$tdir D_Sc || return 1
14677 # remove the files & current working dir
14678 unlinkmany $DIR/$tdir/foobar 4000
14680 kill -USR1 $MULTIPID
14682 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
14685 run_test 181 "Test open-unlinked dir ========================"
14691 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14693 $LCTL set_param mdc.*.rpc_stats=clear
14695 for (( i = 0; i < $tcount; i++ )) ; do
14696 mkdir $DIR/$tdir/$i
14699 for (( i = 0; i < $tcount; i++ )) ; do
14700 createmany -o $DIR/$tdir/$i/f- $fcount &
14704 for (( i = 0; i < $tcount; i++ )) ; do
14705 unlinkmany $DIR/$tdir/$i/f- $fcount &
14709 $LCTL get_param mdc.*.rpc_stats
14713 run_test 182 "Test parallel modify metadata operations ================"
14715 test_183() { # LU-2275
14716 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14717 remote_mds_nodsh && skip "remote MDS with nodsh"
14718 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
14719 skip "Need MDS version at least 2.3.56"
14721 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14722 echo aaa > $DIR/$tdir/$tfile
14724 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
14725 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
14727 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
14728 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
14730 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14732 # Flush negative dentry cache
14733 touch $DIR/$tdir/$tfile
14735 # We are not checking for any leaked references here, they'll
14736 # become evident next time we do cleanup with module unload.
14739 run_test 183 "No crash or request leak in case of strange dispositions ========"
14741 # test suite 184 is for LU-2016, LU-2017
14743 check_swap_layouts_support
14745 dir0=$DIR/$tdir/$testnum
14746 test_mkdir -p -c1 $dir0
14751 $SETSTRIPE -c1 $file1
14753 $SETSTRIPE -c2 $file2
14755 gen1=$($GETSTRIPE -g $file1)
14756 gen2=$($GETSTRIPE -g $file2)
14758 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
14759 gen=$($GETSTRIPE -g $file1)
14760 [[ $gen1 != $gen ]] ||
14761 "Layout generation on $file1 does not change"
14762 gen=$($GETSTRIPE -g $file2)
14763 [[ $gen2 != $gen ]] ||
14764 "Layout generation on $file2 does not change"
14766 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
14767 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14769 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
14771 run_test 184a "Basic layout swap"
14774 check_swap_layouts_support
14776 dir0=$DIR/$tdir/$testnum
14777 mkdir -p $dir0 || error "creating dir $dir0"
14784 $SETSTRIPE -c1 $file1
14785 $SETSTRIPE -c2 $file2
14786 $SETSTRIPE -c1 $file3
14787 chown $RUNAS_ID $file3
14788 gen1=$($GETSTRIPE -g $file1)
14789 gen2=$($GETSTRIPE -g $file2)
14791 $LFS swap_layouts $dir1 $dir2 &&
14792 error "swap of directories layouts should fail"
14793 $LFS swap_layouts $dir1 $file1 &&
14794 error "swap of directory and file layouts should fail"
14795 $RUNAS $LFS swap_layouts $file1 $file2 &&
14796 error "swap of file we cannot write should fail"
14797 $LFS swap_layouts $file1 $file3 &&
14798 error "swap of file with different owner should fail"
14799 /bin/true # to clear error code
14801 run_test 184b "Forbidden layout swap (will generate errors)"
14804 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
14805 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
14806 check_swap_layouts_support
14808 local dir0=$DIR/$tdir/$testnum
14809 mkdir -p $dir0 || error "creating dir $dir0"
14811 local ref1=$dir0/ref1
14812 local ref2=$dir0/ref2
14813 local file1=$dir0/file1
14814 local file2=$dir0/file2
14815 # create a file large enough for the concurrent test
14816 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
14817 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
14818 echo "ref file size: ref1($(stat -c %s $ref1))," \
14819 "ref2($(stat -c %s $ref2))"
14822 dd if=$ref1 of=$file1 bs=16k &
14825 # Make sure dd starts to copy file
14826 while [ ! -f $file1 ]; do sleep 0.1; done
14828 $LFS swap_layouts $file1 $file2
14831 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
14832 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
14834 # how many bytes copied before swapping layout
14835 local copied=$(stat -c %s $file2)
14836 local remaining=$(stat -c %s $ref1)
14837 remaining=$((remaining - copied))
14838 echo "Copied $copied bytes before swapping layout..."
14840 cmp -n $copied $file1 $ref2 | grep differ &&
14841 error "Content mismatch [0, $copied) of ref2 and file1"
14842 cmp -n $copied $file2 $ref1 ||
14843 error "Content mismatch [0, $copied) of ref1 and file2"
14844 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
14845 error "Content mismatch [$copied, EOF) of ref1 and file1"
14848 rm -f $ref1 $ref2 $file1 $file2
14850 run_test 184c "Concurrent write and layout swap"
14853 check_swap_layouts_support
14854 [ -z "$(which getfattr 2>/dev/null)" ] &&
14855 skip_env "no getfattr command"
14857 local file1=$DIR/$tdir/$tfile-1
14858 local file2=$DIR/$tdir/$tfile-2
14859 local file3=$DIR/$tdir/$tfile-3
14863 mkdir -p $DIR/$tdir
14864 touch $file1 || error "create $file1 failed"
14865 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14866 error "create $file2 failed"
14867 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14868 error "create $file3 failed"
14869 lovea1=$(get_layout_param $file1)
14871 $LFS swap_layouts $file2 $file3 ||
14872 error "swap $file2 $file3 layouts failed"
14873 $LFS swap_layouts $file1 $file2 ||
14874 error "swap $file1 $file2 layouts failed"
14876 lovea2=$(get_layout_param $file2)
14879 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
14881 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14882 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
14884 run_test 184d "allow stripeless layouts swap"
14887 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
14888 skip "Need MDS version at least 2.6.94"
14889 check_swap_layouts_support
14890 [ -z "$(which getfattr 2>/dev/null)" ] &&
14891 skip_env "no getfattr command"
14893 local file1=$DIR/$tdir/$tfile-1
14894 local file2=$DIR/$tdir/$tfile-2
14895 local file3=$DIR/$tdir/$tfile-3
14898 mkdir -p $DIR/$tdir
14899 touch $file1 || error "create $file1 failed"
14900 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14901 error "create $file2 failed"
14902 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14903 error "create $file3 failed"
14905 $LFS swap_layouts $file1 $file2 ||
14906 error "swap $file1 $file2 layouts failed"
14908 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14909 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
14911 echo 123 > $file1 || error "Should be able to write into $file1"
14913 $LFS swap_layouts $file1 $file3 ||
14914 error "swap $file1 $file3 layouts failed"
14916 echo 123 > $file1 || error "Should be able to write into $file1"
14918 rm -rf $file1 $file2 $file3
14920 run_test 184e "Recreate layout after stripeless layout swaps"
14923 # Create a file with name longer than sizeof(struct stat) ==
14924 # 144 to see if we can get chars from the file name to appear
14925 # in the returned striping. Note that 'f' == 0x66.
14926 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
14928 mkdir -p $DIR/$tdir
14929 mcreate $DIR/$tdir/$file
14930 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
14931 error "IOC_MDC_GETFILEINFO returned garbage striping"
14934 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
14936 test_185() { # LU-2441
14937 # LU-3553 - no volatile file support in old servers
14938 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
14939 skip "Need MDS version at least 2.3.60"
14941 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14942 touch $DIR/$tdir/spoo
14943 local mtime1=$(stat -c "%Y" $DIR/$tdir)
14944 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
14945 error "cannot create/write a volatile file"
14946 [ "$FILESET" == "" ] &&
14947 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
14948 error "FID is still valid after close"
14950 multiop_bg_pause $DIR/$tdir vVw4096_c
14957 # assume that the next FID for this client is sequential, since stdout
14958 # is unfortunately eaten by multiop_bg_pause
14959 local n=$((${fidv[1]} + 1))
14960 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
14961 if [ "$FILESET" == "" ]; then
14962 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
14963 error "FID is missing before close"
14965 kill -USR1 $multi_pid
14966 # 1 second delay, so if mtime change we will see it
14968 local mtime2=$(stat -c "%Y" $DIR/$tdir)
14969 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
14971 run_test 185 "Volatile file support"
14973 function create_check_volatile() {
14977 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
14980 local FID=$(cat /tmp/${tfile}.fid)
14981 [ "$FID" == "" ] && error "can't get FID for volatile"
14982 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
14983 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
14984 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
14988 cancel_lru_locks mdc # flush opencache
14989 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
14994 # LU-12516 - volatile creation via .lustre
14995 [[ $MDS1_VERSION -ge $(version_code 2.12.2) ]] ||
14996 skip "Need MDS version at least 2.12.2"
14998 create_check_volatile 0
14999 [ $MDSCOUNT -lt 2 ] && return 0
15002 create_check_volatile 1
15006 run_test 185a "Volatile file creation in .lustre/fid/"
15009 remote_mds_nodsh && skip "remote MDS with nodsh"
15010 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15011 skip "Need MDS version at least 2.3.0"
15013 local dir0=$DIR/$tdir/$testnum
15014 mkdir -p $dir0 || error "creating dir $dir0"
15016 local file=$dir0/file1
15017 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
15018 local dv1=$($LFS data_version $file)
15019 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
15020 local dv2=$($LFS data_version $file)
15021 [[ $dv1 != $dv2 ]] ||
15022 error "data version did not change on write $dv1 == $dv2"
15027 run_test 187a "Test data version change"
15030 remote_mds_nodsh && skip "remote MDS with nodsh"
15031 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15032 skip "Need MDS version at least 2.3.0"
15034 local dir0=$DIR/$tdir/$testnum
15035 mkdir -p $dir0 || error "creating dir $dir0"
15037 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
15038 [[ ${DV[0]} != ${DV[1]} ]] ||
15039 error "data version did not change on write"\
15040 " ${DV[0]} == ${DV[1]}"
15045 run_test 187b "Test data version change on volatile file"
15048 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15049 remote_mgs_nodsh && skip "remote MGS with nodsh"
15050 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15052 local POOL=${POOL:-cea1}
15053 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
15054 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
15057 local last_ost=$(($OSTCOUNT - 1))
15059 local ost_list=$(seq $first_ost $ost_step $last_ost)
15060 local ost_range="$first_ost $last_ost $ost_step"
15061 local test_path=$POOL_ROOT/$POOL_DIR_NAME
15062 local file_dir=$POOL_ROOT/file_tst
15063 local subdir=$test_path/subdir
15067 # former test_200a test_200b
15068 pool_add $POOL || { rc=$? ; break; }
15069 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
15070 # former test_200c test_200d
15071 mkdir -p $test_path
15072 pool_set_dir $POOL $test_path || { rc=$? ; break; }
15073 pool_check_dir $POOL $test_path || { rc=$? ; break; }
15075 pool_check_dir $POOL $subdir || { rc=$? ; break; }
15076 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
15077 || { rc=$? ; break; }
15078 # former test_200e test_200f
15079 local files=$((OSTCOUNT*3))
15080 pool_alloc_files $POOL $test_path $files "$ost_list" \
15081 || { rc=$? ; break; }
15082 pool_create_files $POOL $file_dir $files "$ost_list" \
15083 || { rc=$? ; break; }
15084 # former test_200g test_200h
15085 pool_lfs_df $POOL || { rc=$? ; break; }
15086 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
15088 # former test_201a test_201b test_201c
15089 pool_remove_first_target $POOL || { rc=$? ; break; }
15091 local f=$test_path/$tfile
15092 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
15093 pool_remove $POOL $f || { rc=$? ; break; }
15101 run_test 200 "OST pools"
15103 # usage: default_attr <count | size | offset>
15105 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
15108 # usage: check_default_stripe_attr
15109 check_default_stripe_attr() {
15110 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
15113 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
15115 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
15119 error "unknown getstripe attr '$1'"
15122 [ $ACTUAL == $EXPECTED ] ||
15123 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
15127 test_mkdir $DIR/$tdir
15128 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
15130 check_default_stripe_attr --stripe-count
15131 check_default_stripe_attr --stripe-size
15132 check_default_stripe_attr --stripe-index
15134 run_test 204a "Print default stripe attributes"
15137 test_mkdir $DIR/$tdir
15138 $SETSTRIPE --stripe-count 1 $DIR/$tdir
15140 check_default_stripe_attr --stripe-size
15141 check_default_stripe_attr --stripe-index
15143 run_test 204b "Print default stripe size and offset"
15146 test_mkdir $DIR/$tdir
15147 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
15149 check_default_stripe_attr --stripe-count
15150 check_default_stripe_attr --stripe-index
15152 run_test 204c "Print default stripe count and offset"
15155 test_mkdir $DIR/$tdir
15156 $SETSTRIPE --stripe-index 0 $DIR/$tdir
15158 check_default_stripe_attr --stripe-count
15159 check_default_stripe_attr --stripe-size
15161 run_test 204d "Print default stripe count and size"
15164 test_mkdir $DIR/$tdir
15165 $SETSTRIPE -d $DIR/$tdir
15167 check_default_stripe_attr --stripe-count --raw
15168 check_default_stripe_attr --stripe-size --raw
15169 check_default_stripe_attr --stripe-index --raw
15171 run_test 204e "Print raw stripe attributes"
15174 test_mkdir $DIR/$tdir
15175 $SETSTRIPE --stripe-count 1 $DIR/$tdir
15177 check_default_stripe_attr --stripe-size --raw
15178 check_default_stripe_attr --stripe-index --raw
15180 run_test 204f "Print raw stripe size and offset"
15183 test_mkdir $DIR/$tdir
15184 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
15186 check_default_stripe_attr --stripe-count --raw
15187 check_default_stripe_attr --stripe-index --raw
15189 run_test 204g "Print raw stripe count and offset"
15192 test_mkdir $DIR/$tdir
15193 $SETSTRIPE --stripe-index 0 $DIR/$tdir
15195 check_default_stripe_attr --stripe-count --raw
15196 check_default_stripe_attr --stripe-size --raw
15198 run_test 204h "Print raw stripe count and size"
15200 # Figure out which job scheduler is being used, if any,
15201 # or use a fake one
15202 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
15203 JOBENV=SLURM_JOB_ID
15204 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
15206 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
15208 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
15209 JOBENV=LOADL_STEP_ID
15210 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
15213 $LCTL list_param jobid_name > /dev/null 2>&1
15214 if [ $? -eq 0 ]; then
15220 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
15222 verify_jobstats() {
15227 # we don't really need to clear the stats for this test to work, since each
15228 # command has a unique jobid, but it makes debugging easier if needed.
15229 # for facet in $facets; do
15230 # local dev=$(convert_facet2label $facet)
15231 # # clear old jobstats
15232 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
15235 # use a new JobID for each test, or we might see an old one
15236 [ "$JOBENV" = "FAKE_JOBID" ] &&
15237 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
15239 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
15241 [ "$JOBENV" = "nodelocal" ] && {
15242 FAKE_JOBID=id.$testnum.%e.$RANDOM
15243 $LCTL set_param jobid_name=$FAKE_JOBID
15244 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
15247 log "Test: ${cmd[*]}"
15248 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
15250 if [ $JOBENV = "FAKE_JOBID" ]; then
15251 FAKE_JOBID=$JOBVAL ${cmd[*]}
15256 # all files are created on OST0000
15257 for facet in $facets; do
15258 local stats="*.$(convert_facet2label $facet).job_stats"
15260 # strip out libtool wrappers for in-tree executables
15261 if [ $(do_facet $facet lctl get_param $stats |
15262 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
15263 do_facet $facet lctl get_param $stats
15264 error "No jobstats for $JOBVAL found on $facet::$stats"
15270 local new_jobenv=$1
15272 set_persistent_param_and_check client "jobid_var" \
15273 "$FSNAME.sys.jobid_var" $new_jobenv
15276 test_205a() { # Job stats
15277 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15278 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
15279 skip "Need MDS version with at least 2.7.1"
15280 remote_mgs_nodsh && skip "remote MGS with nodsh"
15281 remote_mds_nodsh && skip "remote MDS with nodsh"
15282 remote_ost_nodsh && skip "remote OST with nodsh"
15283 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
15284 skip "Server doesn't support jobstats"
15285 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
15287 local old_jobenv=$($LCTL get_param -n jobid_var)
15288 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
15290 if [[ $PERM_CMD = *"set_param -P"* ]]; then
15291 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
15293 stack_trap "do_facet mgs $PERM_CMD \
15294 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
15298 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
15299 mdt.*.job_cleanup_interval | head -n 1)
15300 local new_interval=5
15301 do_facet $SINGLEMDS \
15302 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
15303 stack_trap "do_facet $SINGLEMDS \
15304 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
15305 local start=$SECONDS
15309 cmd="mkdir $DIR/$tdir"
15310 verify_jobstats "$cmd" "$SINGLEMDS"
15312 cmd="rmdir $DIR/$tdir"
15313 verify_jobstats "$cmd" "$SINGLEMDS"
15314 # mkdir on secondary MDT
15315 if [ $MDSCOUNT -gt 1 ]; then
15316 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
15317 verify_jobstats "$cmd" "mds2"
15320 cmd="mknod $DIR/$tfile c 1 3"
15321 verify_jobstats "$cmd" "$SINGLEMDS"
15323 cmd="rm -f $DIR/$tfile"
15324 verify_jobstats "$cmd" "$SINGLEMDS"
15325 # create all files on OST0000 so verify_jobstats can find OST stats
15327 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
15328 verify_jobstats "$cmd" "$SINGLEMDS"
15330 cmd="touch $DIR/$tfile"
15331 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15333 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
15334 verify_jobstats "$cmd" "ost1"
15336 cancel_lru_locks osc
15337 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
15338 verify_jobstats "$cmd" "ost1"
15340 cmd="$TRUNCATE $DIR/$tfile 0"
15341 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15343 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
15344 verify_jobstats "$cmd" "$SINGLEMDS"
15345 # jobstats expiry - sleep until old stats should be expired
15346 local left=$((new_interval + 5 - (SECONDS - start)))
15347 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
15348 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
15350 cmd="mkdir $DIR/$tdir.expire"
15351 verify_jobstats "$cmd" "$SINGLEMDS"
15352 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
15353 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
15355 # Ensure that jobid are present in changelog (if supported by MDS)
15356 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
15357 changelog_dump | tail -10
15358 jobids=$(changelog_dump | tail -9 | grep -c "j=")
15359 [ $jobids -eq 9 ] ||
15360 error "Wrong changelog jobid count $jobids != 9"
15364 jobstats_set $JOBENV
15366 changelog_dump | grep $tfile
15367 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
15368 [ $jobids -eq 0 ] ||
15369 error "Unexpected jobids when jobid_var=$JOBENV"
15372 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
15373 JOBENV="JOBCOMPLEX"
15374 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
15376 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
15378 run_test 205a "Verify job stats"
15382 $LCTL set_param jobid_var=USER jobid_name="%e.%u"
15383 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
15384 do_facet $SINGLEMDS $LCTL get_param mdt.*.job_stats |
15385 grep job_id: | grep foolish &&
15386 error "Unexpected jobid found"
15389 run_test 205b "Verify job stats jobid parsing"
15391 # LU-1480, LU-1773 and LU-1657
15393 mkdir -p $DIR/$tdir
15394 $SETSTRIPE -c -1 $DIR/$tdir
15395 #define OBD_FAIL_LOV_INIT 0x1403
15396 $LCTL set_param fail_loc=0xa0001403
15397 $LCTL set_param fail_val=1
15398 touch $DIR/$tdir/$tfile || true
15400 run_test 206 "fail lov_init_raid0() doesn't lbug"
15403 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15404 local fsz=`stat -c %s $DIR/$tfile`
15405 cancel_lru_locks mdc
15407 # do not return layout in getattr intent
15408 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
15409 $LCTL set_param fail_loc=0x170
15410 local sz=`stat -c %s $DIR/$tfile`
15412 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
15416 run_test 207a "can refresh layout at glimpse"
15419 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15420 local cksum=`md5sum $DIR/$tfile`
15421 local fsz=`stat -c %s $DIR/$tfile`
15422 cancel_lru_locks mdc
15423 cancel_lru_locks osc
15425 # do not return layout in getattr intent
15426 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
15427 $LCTL set_param fail_loc=0x171
15429 # it will refresh layout after the file is opened but before read issues
15430 echo checksum is "$cksum"
15431 echo "$cksum" |md5sum -c --quiet || error "file differs"
15435 run_test 207b "can refresh layout at open"
15438 # FIXME: in this test suite, only RD lease is used. This is okay
15439 # for now as only exclusive open is supported. After generic lease
15440 # is done, this test suite should be revised. - Jinshan
15442 remote_mds_nodsh && skip "remote MDS with nodsh"
15443 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
15444 skip "Need MDS version at least 2.4.52"
15446 echo "==== test 1: verify get lease work"
15447 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
15449 echo "==== test 2: verify lease can be broken by upcoming open"
15450 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15454 $MULTIOP $DIR/$tfile oO_RDONLY:c
15455 kill -USR1 $PID && wait $PID || error "break lease error"
15457 echo "==== test 3: verify lease can't be granted if an open already exists"
15458 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
15462 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
15463 kill -USR1 $PID && wait $PID || error "open file error"
15465 echo "==== test 4: lease can sustain over recovery"
15466 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
15472 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
15474 echo "==== test 5: lease broken can't be regained by replay"
15475 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15479 # open file to break lease and then recovery
15480 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
15483 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
15487 run_test 208 "Exclusive open"
15490 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
15491 skip_env "must have disp_stripe"
15494 sync; sleep 5; sync;
15496 echo 3 > /proc/sys/vm/drop_caches
15497 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15499 # open/close 500 times
15500 for i in $(seq 500); do
15504 echo 3 > /proc/sys/vm/drop_caches
15505 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15507 echo "before: $req_before, after: $req_after"
15508 [ $((req_after - req_before)) -ge 300 ] &&
15509 error "open/close requests are not freed"
15512 run_test 209 "read-only open/close requests should be freed promptly"
15516 size=$((size % 8192 + 1))
15517 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
15518 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
15519 rm -f $DIR/f212 $DIR/f212.xyz
15521 run_test 212 "Sendfile test ============================================"
15524 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
15525 cancel_lru_locks osc
15526 lctl set_param fail_loc=0x8000040f
15527 # generate a read lock
15528 cat $DIR/$tfile > /dev/null
15529 # write to the file, it will try to cancel the above read lock.
15530 cat /etc/hosts >> $DIR/$tfile
15532 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
15534 test_214() { # for bug 20133
15535 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
15536 for (( i=0; i < 340; i++ )) ; do
15537 touch $DIR/$tdir/d214c/a$i
15540 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
15541 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
15542 ls $DIR/d214c || error "ls $DIR/d214c failed"
15543 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
15544 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
15546 run_test 214 "hash-indexed directory test - bug 20133"
15548 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
15549 create_lnet_proc_files() {
15550 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
15553 # counterpart of create_lnet_proc_files
15554 remove_lnet_proc_files() {
15555 rm -f $TMP/lnet_$1.sys
15558 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15559 # 3rd arg as regexp for body
15560 check_lnet_proc_stats() {
15561 local l=$(cat "$TMP/lnet_$1" |wc -l)
15562 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
15564 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
15567 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15568 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
15569 # optional and can be regexp for 2nd line (lnet.routes case)
15570 check_lnet_proc_entry() {
15571 local blp=2 # blp stands for 'position of 1st line of body'
15572 [ -z "$5" ] || blp=3 # lnet.routes case
15574 local l=$(cat "$TMP/lnet_$1" |wc -l)
15575 # subtracting one from $blp because the body can be empty
15576 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
15578 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
15579 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
15581 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
15582 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
15584 # bail out if any unexpected line happened
15585 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
15586 [ "$?" != 0 ] || error "$2 misformatted"
15589 test_215() { # for bugs 18102, 21079, 21517
15590 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15592 local N='(0|[1-9][0-9]*)' # non-negative numeric
15593 local P='[1-9][0-9]*' # positive numeric
15594 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
15595 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
15596 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
15597 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
15599 local L1 # regexp for 1st line
15600 local L2 # regexp for 2nd line (optional)
15601 local BR # regexp for the rest (body)
15603 # lnet.stats should look as 11 space-separated non-negative numerics
15604 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
15605 create_lnet_proc_files "stats"
15606 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
15607 remove_lnet_proc_files "stats"
15609 # lnet.routes should look like this:
15610 # Routing disabled/enabled
15611 # net hops priority state router
15612 # where net is a string like tcp0, hops > 0, priority >= 0,
15613 # state is up/down,
15614 # router is a string like 192.168.1.1@tcp2
15615 L1="^Routing (disabled|enabled)$"
15616 L2="^net +hops +priority +state +router$"
15617 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
15618 create_lnet_proc_files "routes"
15619 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
15620 remove_lnet_proc_files "routes"
15622 # lnet.routers should look like this:
15623 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
15624 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
15625 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
15626 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
15627 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
15628 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
15629 create_lnet_proc_files "routers"
15630 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
15631 remove_lnet_proc_files "routers"
15633 # lnet.peers should look like this:
15634 # nid refs state last max rtr min tx min queue
15635 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
15636 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
15637 # numeric (0 or >0 or <0), queue >= 0.
15638 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
15639 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
15640 create_lnet_proc_files "peers"
15641 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
15642 remove_lnet_proc_files "peers"
15644 # lnet.buffers should look like this:
15645 # pages count credits min
15646 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
15647 L1="^pages +count +credits +min$"
15648 BR="^ +$N +$N +$I +$I$"
15649 create_lnet_proc_files "buffers"
15650 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
15651 remove_lnet_proc_files "buffers"
15653 # lnet.nis should look like this:
15654 # nid status alive refs peer rtr max tx min
15655 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
15656 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
15657 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
15658 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
15659 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
15660 create_lnet_proc_files "nis"
15661 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
15662 remove_lnet_proc_files "nis"
15664 # can we successfully write to lnet.stats?
15665 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
15667 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
15669 test_216() { # bug 20317
15670 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15671 remote_ost_nodsh && skip "remote OST with nodsh"
15674 local facets=$(get_facets OST)
15675 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15677 save_lustre_params client "osc.*.contention_seconds" > $p
15678 save_lustre_params $facets \
15679 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
15680 save_lustre_params $facets \
15681 "ldlm.namespaces.filter-*.contended_locks" >> $p
15682 save_lustre_params $facets \
15683 "ldlm.namespaces.filter-*.contention_seconds" >> $p
15684 clear_stats osc.*.osc_stats
15686 # agressive lockless i/o settings
15687 do_nodes $(comma_list $(osts_nodes)) \
15688 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
15689 ldlm.namespaces.filter-*.contended_locks=0 \
15690 ldlm.namespaces.filter-*.contention_seconds=60"
15691 lctl set_param -n osc.*.contention_seconds=60
15693 $DIRECTIO write $DIR/$tfile 0 10 4096
15694 $CHECKSTAT -s 40960 $DIR/$tfile
15696 # disable lockless i/o
15697 do_nodes $(comma_list $(osts_nodes)) \
15698 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
15699 ldlm.namespaces.filter-*.contended_locks=32 \
15700 ldlm.namespaces.filter-*.contention_seconds=0"
15701 lctl set_param -n osc.*.contention_seconds=0
15702 clear_stats osc.*.osc_stats
15704 dd if=/dev/zero of=$DIR/$tfile count=0
15705 $CHECKSTAT -s 0 $DIR/$tfile
15707 restore_lustre_params <$p
15711 run_test 216 "check lockless direct write updates file size and kms correctly"
15713 test_217() { # bug 22430
15714 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15719 for node in $(nodes_list); do
15720 nid=$(host_nids_address $node $NETTYPE)
15721 if [[ $nid = *-* ]] ; then
15722 echo "lctl ping $(h2nettype $nid)"
15723 lctl ping $(h2nettype $nid)
15725 echo "skipping $node (no hyphen detected)"
15729 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
15732 # do directio so as not to populate the page cache
15733 log "creating a 10 Mb file"
15734 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
15735 log "starting reads"
15736 dd if=$DIR/$tfile of=/dev/null bs=4096 &
15737 log "truncating the file"
15738 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
15740 kill %+ || true # reads might have finished
15741 echo "wait until dd is finished"
15743 log "removing the temporary file"
15744 rm -rf $DIR/$tfile || error "tmp file removal failed"
15746 run_test 218 "parallel read and truncate should not deadlock"
15749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15751 # write one partial page
15752 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
15753 # set no grant so vvp_io_commit_write will do sync write
15754 $LCTL set_param fail_loc=0x411
15755 # write a full page at the end of file
15756 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
15758 $LCTL set_param fail_loc=0
15759 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
15760 $LCTL set_param fail_loc=0x411
15761 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
15764 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
15765 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
15767 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
15769 test_220() { #LU-325
15770 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15771 remote_ost_nodsh && skip "remote OST with nodsh"
15772 remote_mds_nodsh && skip "remote MDS with nodsh"
15773 remote_mgs_nodsh && skip "remote MGS with nodsh"
15777 # create on MDT0000 so the last_id and next_id are correct
15779 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
15783 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
15784 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
15785 osp.$mdtosc_proc1.prealloc_last_id)
15786 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
15787 osp.$mdtosc_proc1.prealloc_next_id)
15791 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
15792 #define OBD_FAIL_OST_ENOINO 0x229
15793 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
15794 create_pool $FSNAME.$TESTNAME || return 1
15795 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
15797 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
15799 MDSOBJS=$((last_id - next_id))
15800 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
15802 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
15803 echo "OST still has $count kbytes free"
15805 echo "create $MDSOBJS files @next_id..."
15806 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
15808 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15809 osp.$mdtosc_proc1.prealloc_last_id)
15810 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15811 osp.$mdtosc_proc1.prealloc_next_id)
15813 echo "after creation, last_id=$last_id2, next_id=$next_id2"
15818 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
15819 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
15821 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
15822 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
15823 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15824 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
15825 echo "unlink $MDSOBJS files @$next_id..."
15826 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
15828 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
15831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15833 dd if=`which date` of=$MOUNT/date oflag=sync
15834 chmod +x $MOUNT/date
15836 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
15837 $LCTL set_param fail_loc=0x80001401
15839 $MOUNT/date > /dev/null
15842 run_test 221 "make sure fault and truncate race to not cause OOM"
15845 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15848 test_mkdir $DIR/$tdir
15849 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15850 createmany -o $DIR/$tdir/$tfile 10
15851 cancel_lru_locks mdc
15852 cancel_lru_locks osc
15853 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15854 $LCTL set_param fail_loc=0x31a
15855 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
15856 $LCTL set_param fail_loc=0
15859 run_test 222a "AGL for ls should not trigger CLIO lock failure"
15862 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15865 test_mkdir $DIR/$tdir
15866 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15867 createmany -o $DIR/$tdir/$tfile 10
15868 cancel_lru_locks mdc
15869 cancel_lru_locks osc
15870 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15871 $LCTL set_param fail_loc=0x31a
15872 rm -r $DIR/$tdir || error "AGL for rmdir failed"
15873 $LCTL set_param fail_loc=0
15875 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
15878 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15881 test_mkdir $DIR/$tdir
15882 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15883 createmany -o $DIR/$tdir/$tfile 10
15884 cancel_lru_locks mdc
15885 cancel_lru_locks osc
15886 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
15887 $LCTL set_param fail_loc=0x31b
15888 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
15889 $LCTL set_param fail_loc=0
15892 run_test 223 "osc reenqueue if without AGL lock granted ======================="
15894 test_224a() { # LU-1039, MRP-303
15895 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15897 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
15898 $LCTL set_param fail_loc=0x508
15899 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
15900 $LCTL set_param fail_loc=0
15903 run_test 224a "Don't panic on bulk IO failure"
15905 test_224b() { # LU-1039, MRP-303
15906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15908 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
15909 cancel_lru_locks osc
15910 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
15911 $LCTL set_param fail_loc=0x515
15912 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
15913 $LCTL set_param fail_loc=0
15916 run_test 224b "Don't panic on bulk IO failure"
15918 test_224c() { # LU-6441
15919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15920 remote_mds_nodsh && skip "remote MDS with nodsh"
15922 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15923 save_writethrough $p
15924 set_cache writethrough on
15926 local pages_per_rpc=$($LCTL get_param \
15927 osc.*.max_pages_per_rpc)
15928 local at_max=$($LCTL get_param -n at_max)
15929 local timeout=$($LCTL get_param -n timeout)
15930 local test_at="at_max"
15931 local param_at="$FSNAME.sys.at_max"
15932 local test_timeout="timeout"
15933 local param_timeout="$FSNAME.sys.timeout"
15935 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
15937 set_persistent_param_and_check client "$test_at" "$param_at" 0
15938 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
15940 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
15941 do_facet ost1 $LCTL set_param fail_loc=0x520
15942 $LFS setstripe -c 1 -i 0 $DIR/$tfile
15943 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
15945 do_facet ost1 $LCTL set_param fail_loc=0
15947 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
15948 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
15951 $LCTL set_param -n $pages_per_rpc
15952 restore_lustre_params < $p
15955 run_test 224c "Don't hang if one of md lost during large bulk RPC"
15957 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
15959 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15960 if [ -z ${MDSSURVEY} ]; then
15961 skip_env "mds-survey not found"
15963 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15964 skip "Need MDS version at least 2.2.51"
15966 local mds=$(facet_host $SINGLEMDS)
15967 local target=$(do_nodes $mds 'lctl dl' |
15968 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15970 local cmd1="file_count=1000 thrhi=4"
15971 local cmd2="dir_count=2 layer=mdd stripe_count=0"
15972 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15973 local cmd="$cmd1 $cmd2 $cmd3"
15975 rm -f ${TMP}/mds_survey*
15977 eval $cmd || error "mds-survey with zero-stripe failed"
15978 cat ${TMP}/mds_survey*
15979 rm -f ${TMP}/mds_survey*
15981 run_test 225a "Metadata survey sanity with zero-stripe"
15984 if [ -z ${MDSSURVEY} ]; then
15985 skip_env "mds-survey not found"
15987 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15988 skip "Need MDS version at least 2.2.51"
15989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15990 remote_mds_nodsh && skip "remote MDS with nodsh"
15991 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
15992 skip_env "Need to mount OST to test"
15995 local mds=$(facet_host $SINGLEMDS)
15996 local target=$(do_nodes $mds 'lctl dl' |
15997 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15999 local cmd1="file_count=1000 thrhi=4"
16000 local cmd2="dir_count=2 layer=mdd stripe_count=1"
16001 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16002 local cmd="$cmd1 $cmd2 $cmd3"
16004 rm -f ${TMP}/mds_survey*
16006 eval $cmd || error "mds-survey with stripe_count failed"
16007 cat ${TMP}/mds_survey*
16008 rm -f ${TMP}/mds_survey*
16010 run_test 225b "Metadata survey sanity with stripe_count = 1"
16012 mcreate_path2fid () {
16018 local path=$DIR/$tdir/$name
16023 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
16024 error "cannot create $desc"
16026 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
16028 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
16030 fid_path=$($LFS fid2path $MOUNT $fid)
16032 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
16034 [ "$path" == "$fid_path" ] ||
16035 error "fid2path returned $fid_path, expected $path"
16037 echo "pass with $path and $fid"
16042 mkdir -p $DIR/$tdir
16044 mcreate_path2fid 0010666 0 0 fifo "FIFO"
16045 mcreate_path2fid 0020666 1 3 null "character special file (null)"
16046 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
16047 mcreate_path2fid 0040666 0 0 dir "directory"
16048 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
16049 mcreate_path2fid 0100666 0 0 file "regular file"
16050 mcreate_path2fid 0120666 0 0 link "symbolic link"
16051 mcreate_path2fid 0140666 0 0 sock "socket"
16053 run_test 226a "call path2fid and fid2path on files of all type"
16056 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16061 mkdir -p $DIR/$tdir
16062 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
16063 error "create remote directory failed"
16064 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
16065 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
16066 "character special file (null)"
16067 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
16068 "character special file (no device)"
16069 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
16070 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
16071 "block special file (loop)"
16072 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
16073 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
16074 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
16076 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
16078 # LU-1299 Executing or running ldd on a truncated executable does not
16079 # cause an out-of-memory condition.
16081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16082 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
16084 dd if=$(which date) of=$MOUNT/date bs=1k count=1
16085 chmod +x $MOUNT/date
16087 $MOUNT/date > /dev/null
16088 ldd $MOUNT/date > /dev/null
16091 run_test 227 "running truncated executable does not cause OOM"
16093 # LU-1512 try to reuse idle OI blocks
16095 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16096 remote_mds_nodsh && skip "remote MDS with nodsh"
16097 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16099 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16100 local myDIR=$DIR/$tdir
16103 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16104 $LCTL set_param fail_loc=0x80001002
16105 createmany -o $myDIR/t- 10000
16106 $LCTL set_param fail_loc=0
16107 # The guard is current the largest FID holder
16109 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16111 local IDX=$(($SEQ % 64))
16113 do_facet $SINGLEMDS sync
16114 # Make sure journal flushed.
16116 local blk1=$(do_facet $SINGLEMDS \
16117 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16118 grep Blockcount | awk '{print $4}')
16120 # Remove old files, some OI blocks will become idle.
16121 unlinkmany $myDIR/t- 10000
16122 # Create new files, idle OI blocks should be reused.
16123 createmany -o $myDIR/t- 2000
16124 do_facet $SINGLEMDS sync
16125 # Make sure journal flushed.
16127 local blk2=$(do_facet $SINGLEMDS \
16128 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16129 grep Blockcount | awk '{print $4}')
16131 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16133 run_test 228a "try to reuse idle OI blocks"
16136 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16137 remote_mds_nodsh && skip "remote MDS with nodsh"
16138 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16140 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16141 local myDIR=$DIR/$tdir
16144 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16145 $LCTL set_param fail_loc=0x80001002
16146 createmany -o $myDIR/t- 10000
16147 $LCTL set_param fail_loc=0
16148 # The guard is current the largest FID holder
16150 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16152 local IDX=$(($SEQ % 64))
16154 do_facet $SINGLEMDS sync
16155 # Make sure journal flushed.
16157 local blk1=$(do_facet $SINGLEMDS \
16158 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16159 grep Blockcount | awk '{print $4}')
16161 # Remove old files, some OI blocks will become idle.
16162 unlinkmany $myDIR/t- 10000
16165 stop $SINGLEMDS || error "Fail to stop MDT."
16167 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
16169 df $MOUNT || error "Fail to df."
16170 # Create new files, idle OI blocks should be reused.
16171 createmany -o $myDIR/t- 2000
16172 do_facet $SINGLEMDS sync
16173 # Make sure journal flushed.
16175 local blk2=$(do_facet $SINGLEMDS \
16176 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16177 grep Blockcount | awk '{print $4}')
16179 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16181 run_test 228b "idle OI blocks can be reused after MDT restart"
16185 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16186 remote_mds_nodsh && skip "remote MDS with nodsh"
16187 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16189 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16190 local myDIR=$DIR/$tdir
16193 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16194 $LCTL set_param fail_loc=0x80001002
16195 # 20000 files can guarantee there are index nodes in the OI file
16196 createmany -o $myDIR/t- 20000
16197 $LCTL set_param fail_loc=0
16198 # The guard is current the largest FID holder
16200 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16202 local IDX=$(($SEQ % 64))
16204 do_facet $SINGLEMDS sync
16205 # Make sure journal flushed.
16207 local blk1=$(do_facet $SINGLEMDS \
16208 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16209 grep Blockcount | awk '{print $4}')
16211 # Remove old files, some OI blocks will become idle.
16212 unlinkmany $myDIR/t- 20000
16214 # The OI file should become empty now
16216 # Create new files, idle OI blocks should be reused.
16217 createmany -o $myDIR/t- 2000
16218 do_facet $SINGLEMDS sync
16219 # Make sure journal flushed.
16221 local blk2=$(do_facet $SINGLEMDS \
16222 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16223 grep Blockcount | awk '{print $4}')
16225 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16227 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
16229 test_229() { # LU-2482, LU-3448
16230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16231 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
16232 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
16233 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
16237 # Create a file with a released layout and stripe count 2.
16238 $MULTIOP $DIR/$tfile H2c ||
16239 error "failed to create file with released layout"
16241 $GETSTRIPE -v $DIR/$tfile
16243 local pattern=$($GETSTRIPE -L $DIR/$tfile)
16244 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
16246 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
16247 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
16248 stat $DIR/$tfile || error "failed to stat released file"
16250 chown $RUNAS_ID $DIR/$tfile ||
16251 error "chown $RUNAS_ID $DIR/$tfile failed"
16253 chgrp $RUNAS_ID $DIR/$tfile ||
16254 error "chgrp $RUNAS_ID $DIR/$tfile failed"
16256 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
16257 rm $DIR/$tfile || error "failed to remove released file"
16259 run_test 229 "getstripe/stat/rm/attr changes work on released files"
16262 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16263 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16264 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16265 skip "Need MDS version at least 2.11.52"
16269 test_mkdir $DIR/$tdir
16270 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
16271 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
16272 [ $mdt_idx -ne 0 ] &&
16273 error "create local directory on wrong MDT $mdt_idx"
16275 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
16276 error "create remote directory failed"
16277 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
16278 [ $mdt_idx -ne $MDTIDX ] &&
16279 error "create remote directory on wrong MDT $mdt_idx"
16281 createmany -o $DIR/$tdir/test_230/t- 10 ||
16282 error "create files on remote directory failed"
16283 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
16284 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
16285 rm -r $DIR/$tdir || error "unlink remote directory failed"
16287 run_test 230a "Create remote directory and files under the remote directory"
16290 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16291 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16292 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16293 skip "Need MDS version at least 2.11.52"
16301 local migrate_dir=$DIR/$tdir/migrate_dir
16302 local other_dir=$DIR/$tdir/other_dir
16304 test_mkdir $DIR/$tdir
16305 test_mkdir -i0 -c1 $migrate_dir
16306 test_mkdir -i0 -c1 $other_dir
16307 for ((i=0; i<10; i++)); do
16308 mkdir -p $migrate_dir/dir_${i}
16309 createmany -o $migrate_dir/dir_${i}/f 10 ||
16310 error "create files under remote dir failed $i"
16313 cp /etc/passwd $migrate_dir/$tfile
16314 cp /etc/passwd $other_dir/$tfile
16315 chattr +SAD $migrate_dir
16316 chattr +SAD $migrate_dir/$tfile
16318 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16319 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16320 local old_dir_mode=$(stat -c%f $migrate_dir)
16321 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
16323 mkdir -p $migrate_dir/dir_default_stripe2
16324 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
16325 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
16327 mkdir -p $other_dir
16328 ln $migrate_dir/$tfile $other_dir/luna
16329 ln $migrate_dir/$tfile $migrate_dir/sofia
16330 ln $other_dir/$tfile $migrate_dir/david
16331 ln -s $migrate_dir/$tfile $other_dir/zachary
16332 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
16333 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
16339 for len in 58 59 60; do
16340 lnktgt=$(str_repeat 'l' $len)
16341 touch $migrate_dir/$lnktgt
16342 ln -s $lnktgt $migrate_dir/${len}char_ln
16346 for len in 4094 4095; do
16347 lnktgt=$(str_repeat 'l' $len)
16348 ln -s $lnktgt $migrate_dir/${len}char_ln
16352 for len in 254 255; do
16353 touch $migrate_dir/$(str_repeat 'l' $len)
16356 $LFS migrate -m $MDTIDX $migrate_dir ||
16357 error "fails on migrating remote dir to MDT1"
16359 echo "migratate to MDT1, then checking.."
16360 for ((i = 0; i < 10; i++)); do
16361 for file in $(find $migrate_dir/dir_${i}); do
16362 mdt_index=$($LFS getstripe -m $file)
16363 # broken symlink getstripe will fail
16364 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
16365 error "$file is not on MDT${MDTIDX}"
16369 # the multiple link file should still in MDT0
16370 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
16371 [ $mdt_index == 0 ] ||
16372 error "$file is not on MDT${MDTIDX}"
16374 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16375 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16376 error " expect $old_dir_flag get $new_dir_flag"
16378 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16379 [ "$old_file_flag" = "$new_file_flag" ] ||
16380 error " expect $old_file_flag get $new_file_flag"
16382 local new_dir_mode=$(stat -c%f $migrate_dir)
16383 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16384 error "expect mode $old_dir_mode get $new_dir_mode"
16386 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16387 [ "$old_file_mode" = "$new_file_mode" ] ||
16388 error "expect mode $old_file_mode get $new_file_mode"
16390 diff /etc/passwd $migrate_dir/$tfile ||
16391 error "$tfile different after migration"
16393 diff /etc/passwd $other_dir/luna ||
16394 error "luna different after migration"
16396 diff /etc/passwd $migrate_dir/sofia ||
16397 error "sofia different after migration"
16399 diff /etc/passwd $migrate_dir/david ||
16400 error "david different after migration"
16402 diff /etc/passwd $other_dir/zachary ||
16403 error "zachary different after migration"
16405 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16406 error "${tfile}_ln different after migration"
16408 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16409 error "${tfile}_ln_other different after migration"
16411 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
16412 [ $stripe_count = 2 ] ||
16413 error "dir strpe_count $d != 2 after migration."
16415 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
16416 [ $stripe_count = 2 ] ||
16417 error "file strpe_count $d != 2 after migration."
16419 #migrate back to MDT0
16422 $LFS migrate -m $MDTIDX $migrate_dir ||
16423 error "fails on migrating remote dir to MDT0"
16425 echo "migrate back to MDT0, checking.."
16426 for file in $(find $migrate_dir); do
16427 mdt_index=$($LFS getstripe -m $file)
16428 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
16429 error "$file is not on MDT${MDTIDX}"
16432 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16433 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16434 error " expect $old_dir_flag get $new_dir_flag"
16436 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16437 [ "$old_file_flag" = "$new_file_flag" ] ||
16438 error " expect $old_file_flag get $new_file_flag"
16440 local new_dir_mode=$(stat -c%f $migrate_dir)
16441 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16442 error "expect mode $old_dir_mode get $new_dir_mode"
16444 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16445 [ "$old_file_mode" = "$new_file_mode" ] ||
16446 error "expect mode $old_file_mode get $new_file_mode"
16448 diff /etc/passwd ${migrate_dir}/$tfile ||
16449 error "$tfile different after migration"
16451 diff /etc/passwd ${other_dir}/luna ||
16452 error "luna different after migration"
16454 diff /etc/passwd ${migrate_dir}/sofia ||
16455 error "sofia different after migration"
16457 diff /etc/passwd ${other_dir}/zachary ||
16458 error "zachary different after migration"
16460 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16461 error "${tfile}_ln different after migration"
16463 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16464 error "${tfile}_ln_other different after migration"
16466 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
16467 [ $stripe_count = 2 ] ||
16468 error "dir strpe_count $d != 2 after migration."
16470 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
16471 [ $stripe_count = 2 ] ||
16472 error "file strpe_count $d != 2 after migration."
16474 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16476 run_test 230b "migrate directory"
16479 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16480 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16481 remote_mds_nodsh && skip "remote MDS with nodsh"
16482 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16483 skip "Need MDS version at least 2.11.52"
16489 local migrate_dir=$DIR/$tdir/migrate_dir
16491 #If migrating directory fails in the middle, all entries of
16492 #the directory is still accessiable.
16493 test_mkdir $DIR/$tdir
16494 test_mkdir -i0 -c1 $migrate_dir
16495 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
16497 createmany -o $migrate_dir/f $total ||
16498 error "create files under ${migrate_dir} failed"
16500 # fail after migrating top dir, and this will fail only once, so the
16501 # first sub file migration will fail (currently f3), others succeed.
16502 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
16503 do_facet mds1 lctl set_param fail_loc=0x1801
16504 local t=$(ls $migrate_dir | wc -l)
16505 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
16506 error "migrate should fail"
16507 local u=$(ls $migrate_dir | wc -l)
16508 [ "$u" == "$t" ] || error "$u != $t during migration"
16510 # add new dir/file should succeed
16511 mkdir $migrate_dir/dir ||
16512 error "mkdir failed under migrating directory"
16513 touch $migrate_dir/file ||
16514 error "create file failed under migrating directory"
16516 # add file with existing name should fail
16517 for file in $migrate_dir/f*; do
16518 stat $file > /dev/null || error "stat $file failed"
16519 $OPENFILE -f O_CREAT:O_EXCL $file &&
16520 error "open(O_CREAT|O_EXCL) $file should fail"
16521 $MULTIOP $file m && error "create $file should fail"
16522 touch $DIR/$tdir/remote_dir/$tfile ||
16523 error "touch $tfile failed"
16524 ln $DIR/$tdir/remote_dir/$tfile $file &&
16525 error "link $file should fail"
16526 mdt_index=$($LFS getstripe -m $file)
16527 if [ $mdt_index == 0 ]; then
16528 # file failed to migrate is not allowed to rename to
16529 mv $DIR/$tdir/remote_dir/$tfile $file &&
16530 error "rename to $file should fail"
16532 mv $DIR/$tdir/remote_dir/$tfile $file ||
16533 error "rename to $file failed"
16535 echo hello >> $file || error "write $file failed"
16538 # resume migration with different options should fail
16539 $LFS migrate -m 0 $migrate_dir &&
16540 error "migrate -m 0 $migrate_dir should fail"
16542 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
16543 error "migrate -c 2 $migrate_dir should fail"
16545 # resume migration should succeed
16546 $LFS migrate -m $MDTIDX $migrate_dir ||
16547 error "migrate $migrate_dir failed"
16549 echo "Finish migration, then checking.."
16550 for file in $(find $migrate_dir); do
16551 mdt_index=$($LFS getstripe -m $file)
16552 [ $mdt_index == $MDTIDX ] ||
16553 error "$file is not on MDT${MDTIDX}"
16556 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16558 run_test 230c "check directory accessiblity if migration failed"
16561 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16562 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16563 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16564 skip "Need MDS version at least 2.11.52"
16566 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
16568 local migrate_dir=$DIR/$tdir/migrate_dir
16578 old_index=$((RANDOM % MDSCOUNT))
16579 old_count=$((MDSCOUNT - old_index))
16580 new_index=$((RANDOM % MDSCOUNT))
16581 new_count=$((MDSCOUNT - new_index))
16582 new_hash="all_char"
16584 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
16585 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
16587 test_mkdir $DIR/$tdir
16588 test_mkdir -i $old_index -c $old_count $migrate_dir
16590 for ((i=0; i<100; i++)); do
16591 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
16592 createmany -o $migrate_dir/dir_${i}/f 100 ||
16593 error "create files under remote dir failed $i"
16596 echo -n "Migrate from MDT$old_index "
16597 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
16598 echo -n "to MDT$new_index"
16599 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
16602 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
16603 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
16604 error "migrate remote dir error"
16606 echo "Finish migration, then checking.."
16607 for file in $(find $migrate_dir); do
16608 mdt_index=$($LFS getstripe -m $file)
16609 if [ $mdt_index -lt $new_index ] ||
16610 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
16611 error "$file is on MDT$mdt_index"
16615 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16617 run_test 230d "check migrate big directory"
16620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16621 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16622 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16623 skip "Need MDS version at least 2.11.52"
16630 mkdir -p $DIR/$tdir
16631 mkdir $DIR/$tdir/migrate_dir
16632 mkdir $DIR/$tdir/other_dir
16633 touch $DIR/$tdir/migrate_dir/a
16634 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
16635 ls $DIR/$tdir/other_dir
16637 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16638 error "migrate dir fails"
16640 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16641 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16643 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16644 [ $mdt_index == 0 ] || error "a is not on MDT0"
16646 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
16647 error "migrate dir fails"
16649 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
16650 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
16652 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16653 [ $mdt_index == 1 ] || error "a is not on MDT1"
16655 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
16656 [ $mdt_index == 1 ] || error "b is not on MDT1"
16658 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16659 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
16661 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
16663 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16665 run_test 230e "migrate mulitple local link files"
16668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16669 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16670 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16671 skip "Need MDS version at least 2.11.52"
16676 mkdir -p $DIR/$tdir
16677 mkdir $DIR/$tdir/migrate_dir
16678 $LFS mkdir -i1 $DIR/$tdir/other_dir
16679 touch $DIR/$tdir/migrate_dir/a
16680 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
16681 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
16682 ls $DIR/$tdir/other_dir
16684 # a should be migrated to MDT1, since no other links on MDT0
16685 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16686 error "#1 migrate dir fails"
16687 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16688 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16689 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16690 [ $mdt_index == 1 ] || error "a is not on MDT1"
16692 # a should stay on MDT1, because it is a mulitple link file
16693 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16694 error "#2 migrate dir fails"
16695 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16696 [ $mdt_index == 1 ] || error "a is not on MDT1"
16698 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16699 error "#3 migrate dir fails"
16701 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16702 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
16703 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
16705 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
16706 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
16708 # a should be migrated to MDT0, since no other links on MDT1
16709 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16710 error "#4 migrate dir fails"
16711 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16712 [ $mdt_index == 0 ] || error "a is not on MDT0"
16714 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16716 run_test 230f "migrate mulitple remote link files"
16719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16720 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16721 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16722 skip "Need MDS version at least 2.11.52"
16724 mkdir -p $DIR/$tdir/migrate_dir
16726 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
16727 error "migrating dir to non-exist MDT succeeds"
16730 run_test 230g "migrate dir to non-exist MDT"
16733 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16734 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16735 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16736 skip "Need MDS version at least 2.11.52"
16740 mkdir -p $DIR/$tdir/migrate_dir
16742 $LFS migrate -m1 $DIR &&
16743 error "migrating mountpoint1 should fail"
16745 $LFS migrate -m1 $DIR/$tdir/.. &&
16746 error "migrating mountpoint2 should fail"
16749 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
16750 error "migrating $tdir/migrate_dir/.. should fail"
16754 run_test 230h "migrate .. and root"
16757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16758 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16759 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16760 skip "Need MDS version at least 2.11.52"
16762 mkdir -p $DIR/$tdir/migrate_dir
16764 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
16765 error "migration fails with a tailing slash"
16767 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
16768 error "migration fails with two tailing slashes"
16770 run_test 230i "lfs migrate -m tolerates trailing slashes"
16773 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16774 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16775 skip "Need MDS version at least 2.11.52"
16777 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
16778 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
16779 error "create $tfile failed"
16780 cat /etc/passwd > $DIR/$tdir/$tfile
16782 $LFS migrate -m 1 $DIR/$tdir
16784 cmp /etc/passwd $DIR/$tdir/$tfile ||
16785 error "DoM file mismatch after migration"
16787 run_test 230j "DoM file data not changed after dir migration"
16790 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
16791 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16792 skip "Need MDS version at least 2.11.56"
16795 local files_on_starting_mdt=0
16797 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
16798 $LFS getdirstripe $DIR/$tdir
16799 for i in $(seq $total); do
16800 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
16801 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16802 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16805 echo "$files_on_starting_mdt files on MDT0"
16807 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
16808 $LFS getdirstripe $DIR/$tdir
16810 files_on_starting_mdt=0
16811 for i in $(seq $total); do
16812 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16813 error "file $tfile.$i mismatch after migration"
16814 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
16815 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16818 echo "$files_on_starting_mdt files on MDT1 after migration"
16819 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
16821 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
16822 $LFS getdirstripe $DIR/$tdir
16824 files_on_starting_mdt=0
16825 for i in $(seq $total); do
16826 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16827 error "file $tfile.$i mismatch after 2nd migration"
16828 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16829 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16832 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
16833 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
16837 run_test 230k "file data not changed after dir migration"
16840 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16841 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16842 skip "Need MDS version at least 2.11.56"
16844 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
16845 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
16846 error "create files under remote dir failed $i"
16847 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
16849 run_test 230l "readdir between MDTs won't crash"
16852 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16853 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16854 skip "Need MDS version at least 2.11.56"
16857 local mig_dir=$DIR/$tdir/migrate_dir
16858 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
16862 echo "Creating files and dirs with xattrs"
16863 test_mkdir $DIR/$tdir
16864 test_mkdir -i0 -c1 $mig_dir
16866 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
16867 error "cannot set xattr attr1 on dir"
16868 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
16869 error "cannot set xattr attr2 on dir"
16870 touch $mig_dir/dir/f0
16871 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
16872 error "cannot set xattr attr1 on file"
16873 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
16874 error "cannot set xattr attr2 on file"
16875 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
16876 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
16877 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
16878 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
16879 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
16880 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
16881 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
16882 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
16883 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
16885 echo "Migrating to MDT1"
16886 $LFS migrate -m $MDTIDX $mig_dir ||
16887 error "fails on migrating dir to MDT1"
16889 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
16890 echo "Checking xattrs"
16891 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
16892 [ "$val" = $longstr ] ||
16893 error "expecting xattr1 $longstr on dir, found $val"
16894 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
16895 [ "$val" = $shortstr ] ||
16896 error "expecting xattr2 $shortstr on dir, found $val"
16897 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
16898 [ "$val" = $longstr ] ||
16899 error "expecting xattr1 $longstr on file, found $val"
16900 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
16901 [ "$val" = $shortstr ] ||
16902 error "expecting xattr2 $shortstr on file, found $val"
16904 run_test 230m "xattrs not changed after dir migration"
16907 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16908 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
16909 [[ $MDS1_VERSION -ge $(version_code 2.12.5) ]] ||
16910 skip "Need MDS version at least 2.12.5"
16912 # maximum amount of local locks:
16913 # parent striped dir - 2 locks
16914 # new stripe in parent to migrate to - 1 lock
16915 # source and target - 2 locks
16916 # Total 5 locks for regular file
16917 mkdir -p $DIR/$tdir
16918 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
16919 touch $DIR/$tdir/dir1/eee
16921 # create 4 hardlink for 4 more locks
16922 # Total: 9 locks > RS_MAX_LOCKS (8)
16923 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
16924 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
16925 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
16926 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
16927 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
16928 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
16929 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
16930 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
16932 cancel_lru_locks mdc
16934 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
16935 error "migrate dir fails"
16937 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16939 run_test 230r "migrate with too many local locks"
16943 # For simplicity this test assumes that max_pages_per_rpc
16944 # is the same across all OSCs
16945 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
16946 local bulk_size=$((max_pages * PAGE_SIZE))
16947 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
16950 mkdir -p $DIR/$tdir
16951 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
16952 error "failed to set stripe with -S ${brw_size}M option"
16954 # clear the OSC stats
16955 $LCTL set_param osc.*.stats=0 &>/dev/null
16958 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
16959 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
16960 oflag=direct &>/dev/null || error "dd failed"
16962 sync; sleep 1; sync # just to be safe
16963 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
16964 if [ x$nrpcs != "x1" ]; then
16965 $LCTL get_param osc.*.stats
16966 error "found $nrpcs ost_write RPCs, not 1 as expected"
16970 # Drop the OSC cache, otherwise we will read from it
16971 cancel_lru_locks osc
16973 # clear the OSC stats
16974 $LCTL set_param osc.*.stats=0 &>/dev/null
16976 # Client reads $bulk_size.
16977 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
16978 iflag=direct &>/dev/null || error "dd failed"
16980 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
16981 if [ x$nrpcs != "x1" ]; then
16982 $LCTL get_param osc.*.stats
16983 error "found $nrpcs ost_read RPCs, not 1 as expected"
16986 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
16989 mkdir -p $DIR/$tdir
16991 for i in {0..1023}; do
16992 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
16993 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
16994 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
16998 run_test 231b "must not assert on fully utilized OST request buffer"
17001 mkdir -p $DIR/$tdir
17002 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
17004 #define OBD_FAIL_LDLM_OST_LVB 0x31c
17005 do_facet ost1 $LCTL set_param fail_loc=0x31c
17007 # ignore dd failure
17008 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
17010 do_facet ost1 $LCTL set_param fail_loc=0
17011 umount_client $MOUNT || error "umount failed"
17012 mount_client $MOUNT || error "mount failed"
17013 stop ost1 || error "cannot stop ost1"
17014 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17016 run_test 232a "failed lock should not block umount"
17019 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
17020 skip "Need MDS version at least 2.10.58"
17022 mkdir -p $DIR/$tdir
17023 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
17024 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
17026 cancel_lru_locks osc
17028 #define OBD_FAIL_LDLM_OST_LVB 0x31c
17029 do_facet ost1 $LCTL set_param fail_loc=0x31c
17032 $LFS data_version $DIR/$tdir/$tfile || true
17034 do_facet ost1 $LCTL set_param fail_loc=0
17035 umount_client $MOUNT || error "umount failed"
17036 mount_client $MOUNT || error "mount failed"
17037 stop ost1 || error "cannot stop ost1"
17038 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17040 run_test 232b "failed data version lock should not block umount"
17043 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
17044 skip "Need MDS version at least 2.3.64"
17045 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
17047 local fid=$($LFS path2fid $MOUNT)
17049 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17050 error "cannot access $MOUNT using its FID '$fid'"
17052 run_test 233a "checking that OBF of the FS root succeeds"
17055 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
17056 skip "Need MDS version at least 2.5.90"
17057 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
17059 local fid=$($LFS path2fid $MOUNT/.lustre)
17061 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17062 error "cannot access $MOUNT/.lustre using its FID '$fid'"
17064 fid=$($LFS path2fid $MOUNT/.lustre/fid)
17065 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17066 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
17068 run_test 233b "checking that OBF of the FS .lustre succeeds"
17071 local p="$TMP/sanityN-$TESTNAME.parameters"
17072 save_lustre_params client "llite.*.xattr_cache" > $p
17073 lctl set_param llite.*.xattr_cache 1 ||
17074 skip_env "xattr cache is not supported"
17076 mkdir -p $DIR/$tdir || error "mkdir failed"
17077 touch $DIR/$tdir/$tfile || error "touch failed"
17078 # OBD_FAIL_LLITE_XATTR_ENOMEM
17079 $LCTL set_param fail_loc=0x1405
17080 getfattr -n user.attr $DIR/$tdir/$tfile &&
17081 error "getfattr should have failed with ENOMEM"
17082 $LCTL set_param fail_loc=0x0
17085 restore_lustre_params < $p
17088 run_test 234 "xattr cache should not crash on ENOMEM"
17091 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
17092 skip "Need MDS version at least 2.4.52"
17094 flock_deadlock $DIR/$tfile
17099 124) error "process hangs on a deadlock"
17101 *) error "error executing flock_deadlock $DIR/$tfile"
17105 run_test 235 "LU-1715: flock deadlock detection does not work properly"
17109 check_swap_layouts_support
17111 local ref1=/etc/passwd
17112 local ref2=/etc/group
17113 local file1=$DIR/$tdir/f1
17114 local file2=$DIR/$tdir/f2
17116 test_mkdir -c1 $DIR/$tdir
17117 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
17118 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
17119 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
17120 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
17121 local fd=$(free_fd)
17122 local cmd="exec $fd<>$file2"
17125 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
17126 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
17129 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
17134 run_test 236 "Layout swap on open unlinked file"
17136 # LU-4659 linkea consistency
17138 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
17139 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
17140 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
17141 skip "Need MDS version at least 2.5.58 or 2.5.2+"
17144 ln $DIR/$tfile $DIR/$tfile.lnk
17145 touch $DIR/$tfile.new
17146 mv $DIR/$tfile.new $DIR/$tfile
17147 local fid1=$($LFS path2fid $DIR/$tfile)
17148 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
17149 local path1=$($LFS fid2path $FSNAME "$fid1")
17150 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
17151 local path2=$($LFS fid2path $FSNAME "$fid2")
17152 [ $tfile.lnk == $path2 ] ||
17153 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
17156 run_test 238 "Verify linkea consistency"
17158 test_239A() { # was test_239
17159 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
17160 skip "Need MDS version at least 2.5.60"
17162 local list=$(comma_list $(mdts_nodes))
17164 mkdir -p $DIR/$tdir
17165 createmany -o $DIR/$tdir/f- 5000
17166 unlinkmany $DIR/$tdir/f- 5000
17167 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
17168 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
17169 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
17170 osp.*MDT*.sync_in_flight" | calc_sum)
17171 [ "$changes" -eq 0 ] || error "$changes not synced"
17173 run_test 239A "osp_sync test"
17175 test_239a() { #LU-5297
17176 remote_mds_nodsh && skip "remote MDS with nodsh"
17179 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
17180 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
17181 chgrp $RUNAS_GID $DIR/$tfile
17182 wait_delete_completed
17184 run_test 239a "process invalid osp sync record correctly"
17186 test_239b() { #LU-5297
17187 remote_mds_nodsh && skip "remote MDS with nodsh"
17190 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
17191 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
17192 chgrp $RUNAS_GID $DIR/$tfile1
17193 wait_delete_completed
17194 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17196 chgrp $RUNAS_GID $DIR/$tfile2
17197 wait_delete_completed
17199 run_test 239b "process osp sync record with ENOMEM error correctly"
17202 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17203 remote_mds_nodsh && skip "remote MDS with nodsh"
17205 mkdir -p $DIR/$tdir
17207 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
17208 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
17209 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
17210 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
17212 umount_client $MOUNT || error "umount failed"
17213 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
17214 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
17215 mount_client $MOUNT || error "failed to mount client"
17217 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
17218 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
17220 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
17226 for LOOP in $(seq $count); do
17227 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
17228 cancel_lru_locks $OSC || true
17236 for LOOP in $(seq $1); do
17237 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
17242 test_241a() { # was test_241
17243 local bsize=$PAGE_SIZE
17245 (( bsize < 40960 )) && bsize=40960
17246 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17248 cancel_lru_locks $OSC
17249 test_241_bio 1000 $bsize &
17251 test_241_dio 1000 $bsize
17254 run_test 241a "bio vs dio"
17257 local bsize=$PAGE_SIZE
17259 (( bsize < 40960 )) && bsize=40960
17260 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17262 test_241_dio 1000 $bsize &
17264 test_241_dio 1000 $bsize
17267 run_test 241b "dio vs dio"
17270 remote_mds_nodsh && skip "remote MDS with nodsh"
17272 mkdir -p $DIR/$tdir
17273 touch $DIR/$tdir/$tfile
17275 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
17276 do_facet mds1 lctl set_param fail_loc=0x105
17277 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
17279 do_facet mds1 lctl set_param fail_loc=0
17280 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
17282 run_test 242 "mdt_readpage failure should not cause directory unreadable"
17286 test_mkdir $DIR/$tdir
17287 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
17289 run_test 243 "various group lock tests"
17293 test_mkdir $DIR/$tdir
17294 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
17295 sendfile_grouplock $DIR/$tdir/$tfile || \
17296 error "sendfile+grouplock failed"
17299 run_test 244 "sendfile with group lock tests"
17302 local flagname="multi_mod_rpcs"
17303 local connect_data_name="max_mod_rpcs"
17306 # check if multiple modify RPCs flag is set
17307 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
17308 grep "connect_flags:")
17311 echo "$out" | grep -qw $flagname
17312 if [ $? -ne 0 ]; then
17313 echo "connect flag $flagname is not set"
17317 # check if multiple modify RPCs data is set
17318 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
17321 echo "$out" | grep -qw $connect_data_name ||
17322 error "import should have connect data $connect_data_name"
17324 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
17326 test_246() { # LU-7371
17327 remote_ost_nodsh && skip "remote OST with nodsh"
17328 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
17329 skip "Need OST version >= 2.7.62"
17331 do_facet ost1 $LCTL set_param fail_val=4095
17332 #define OBD_FAIL_OST_READ_SIZE 0x234
17333 do_facet ost1 $LCTL set_param fail_loc=0x234
17334 $LFS setstripe $DIR/$tfile -i 0 -c 1
17335 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
17336 cancel_lru_locks $FSNAME-OST0000
17337 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
17339 run_test 246 "Read file of size 4095 should return right length"
17345 umount_client $submount
17350 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17352 skip_env "Fileset feature is not supported"
17354 local submount=${MOUNT}_$tdir
17357 mkdir -p $submount || error "mkdir $submount failed"
17358 FILESET="$FILESET/$tdir" mount_client $submount ||
17359 error "mount $submount failed"
17360 trap "cleanup_247 $submount" EXIT
17361 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
17362 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
17363 error "read $MOUNT/$tdir/$tfile failed"
17364 cleanup_247 $submount
17366 run_test 247a "mount subdir as fileset"
17369 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17370 skip_env "Fileset feature is not supported"
17372 local submount=${MOUNT}_$tdir
17374 rm -rf $MOUNT/$tdir
17375 mkdir -p $submount || error "mkdir $submount failed"
17377 FILESET="$FILESET/$tdir" mount_client $submount &&
17378 error "mount $submount should fail"
17381 run_test 247b "mount subdir that dose not exist"
17384 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17385 skip_env "Fileset feature is not supported"
17387 local submount=${MOUNT}_$tdir
17389 mkdir -p $MOUNT/$tdir/dir1
17390 mkdir -p $submount || error "mkdir $submount failed"
17391 trap "cleanup_247 $submount" EXIT
17392 FILESET="$FILESET/$tdir" mount_client $submount ||
17393 error "mount $submount failed"
17394 local fid=$($LFS path2fid $MOUNT/)
17395 $LFS fid2path $submount $fid && error "fid2path should fail"
17396 cleanup_247 $submount
17398 run_test 247c "running fid2path outside root"
17401 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17402 skip "Fileset feature is not supported"
17404 local submount=${MOUNT}_$tdir
17406 mkdir -p $MOUNT/$tdir/dir1
17407 mkdir -p $submount || error "mkdir $submount failed"
17408 FILESET="$FILESET/$tdir" mount_client $submount ||
17409 error "mount $submount failed"
17410 trap "cleanup_247 $submount" EXIT
17411 local fid=$($LFS path2fid $submount/dir1)
17412 $LFS fid2path $submount $fid || error "fid2path should succeed"
17413 cleanup_247 $submount
17415 run_test 247d "running fid2path inside root"
17419 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17421 skip "Fileset feature is not supported"
17423 local submount=${MOUNT}_$tdir
17426 mkdir -p $submount || error "mkdir $submount failed"
17427 FILESET="$FILESET/.." mount_client $submount &&
17428 error "mount $submount should fail"
17431 run_test 247e "mount .. as fileset"
17434 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17435 [ $MDS1_VERSION -lt $(version_code 2.12.6) ] &&
17436 skip "Need at least version 2.12.6"
17437 [ $CLIENT_VERSION -lt $(version_code 2.12.6) ] &&
17438 skip "Need at least version 2.12.6"
17439 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17441 skip "Fileset feature is not supported"
17443 mkdir $DIR/$tdir || error "mkdir $tdir failed"
17444 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
17445 error "mkdir remote failed"
17446 mkdir $DIR/$tdir/remote/subdir || error "mkdir remote/subdir failed"
17447 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
17448 error "mkdir striped failed"
17449 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
17451 local submount=${MOUNT}_$tdir
17453 mkdir -p $submount || error "mkdir $submount failed"
17454 stack_trap "rmdir $submount"
17458 local fileset=$FILESET
17459 local mdts=$(comma_list $(mdts_nodes))
17461 stat=$(do_facet mds1 $LCTL get_param -n \
17462 mdt.*MDT0000.enable_remote_subdir_mount)
17463 stack_trap "do_nodes $mdts $LCTL set_param \
17464 mdt.*.enable_remote_subdir_mount=$stat"
17466 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
17467 stack_trap "umount_client $submount"
17468 FILESET="$fileset/$tdir/remote" mount_client $submount &&
17469 error "mount remote dir $dir should fail"
17471 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
17472 $tdir/striped/. ; do
17473 FILESET="$fileset/$dir" mount_client $submount ||
17474 error "mount $dir failed"
17475 umount_client $submount
17478 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
17479 FILESET="$fileset/$tdir/remote" mount_client $submount ||
17480 error "mount $tdir/remote failed"
17482 run_test 247f "mount striped or remote directory as fileset"
17485 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
17486 [ $CLIENT_VERSION -lt $(version_code 2.12.6) ] &&
17487 skip "Need at least version 2.12.6"
17489 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
17490 error "mkdir $tdir failed"
17491 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
17493 local submount=${MOUNT}_$tdir
17495 mkdir -p $submount || error "mkdir $submount failed"
17496 stack_trap "rmdir $submount"
17498 FILESET="$fileset/$tdir" mount_client $submount ||
17499 error "mount $dir failed"
17500 stack_trap "umount $submount"
17502 local mdts=$(comma_list $(mdts_nodes))
17506 stat $submount > /dev/null
17507 cancel_lru_locks $MDC
17508 stat $submount > /dev/null
17509 stat $submount/$tfile > /dev/null
17510 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
17511 stat $submount/$tfile > /dev/null
17512 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
17513 awk '/getattr/ {sum += $2} END {print sum}')
17515 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
17517 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
17520 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
17521 [ -z "$fast_read_sav" ] && skip "no fast read support"
17523 # create a large file for fast read verification
17524 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
17526 # make sure the file is created correctly
17527 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
17528 { rm -f $DIR/$tfile; skip "file creation error"; }
17530 echo "Test 1: verify that fast read is 4 times faster on cache read"
17532 # small read with fast read enabled
17533 $LCTL set_param -n llite.*.fast_read=1
17534 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17535 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17536 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17537 # small read with fast read disabled
17538 $LCTL set_param -n llite.*.fast_read=0
17539 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17540 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17541 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17543 # verify that fast read is 4 times faster for cache read
17544 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
17545 error_not_in_vm "fast read was not 4 times faster: " \
17546 "$t_fast vs $t_slow"
17548 echo "Test 2: verify the performance between big and small read"
17549 $LCTL set_param -n llite.*.fast_read=1
17551 # 1k non-cache read
17552 cancel_lru_locks osc
17553 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17554 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17555 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17557 # 1M non-cache read
17558 cancel_lru_locks osc
17559 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17560 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17561 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17563 # verify that big IO is not 4 times faster than small IO
17564 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
17565 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
17567 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
17570 run_test 248 "fast read verification"
17572 test_249() { # LU-7890
17573 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
17574 skip "Need at least version 2.8.54"
17577 $SETSTRIPE -c 1 $DIR/$tfile
17578 # Offset 2T == 4k * 512M
17579 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
17580 error "dd to 2T offset failed"
17582 run_test 249 "Write above 2T file size"
17585 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
17586 && skip "no 16TB file size limit on ZFS"
17588 $SETSTRIPE -c 1 $DIR/$tfile
17589 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
17590 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
17591 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
17592 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
17593 conv=notrunc,fsync && error "append succeeded"
17596 run_test 250 "Write above 16T limit"
17599 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
17601 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
17602 #Skip once - writing the first stripe will succeed
17603 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17604 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
17605 error "short write happened"
17607 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17608 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
17609 error "short read happened"
17613 run_test 251 "Handling short read and write correctly"
17616 remote_mds_nodsh && skip "remote MDS with nodsh"
17617 remote_ost_nodsh && skip "remote OST with nodsh"
17618 if [ "$ost1_FSTYPE" != "ldiskfs" -o "$mds1_FSTYPE" != "ldiskfs" ]; then
17619 skip_env "ldiskfs only test"
17629 # check lr_reader on OST0000
17631 dev=$(facet_device $tgt)
17632 out=$(do_facet $tgt $LR_READER $dev)
17633 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17635 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
17636 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
17637 error "Invalid uuid returned by $LR_READER on target $tgt"
17638 echo -e "uuid returned by $LR_READER is '$uuid'\n"
17640 # check lr_reader -c on MDT0000
17642 dev=$(facet_device $tgt)
17643 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
17644 skip "$LR_READER does not support additional options"
17646 out=$(do_facet $tgt $LR_READER -c $dev)
17647 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17649 num=$(echo "$out" | grep -c "mdtlov")
17650 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
17651 error "Invalid number of mdtlov clients returned by $LR_READER"
17652 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
17654 # check lr_reader -cr on MDT0000
17655 out=$(do_facet $tgt $LR_READER -cr $dev)
17656 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17658 echo "$out" | grep -q "^reply_data:$" ||
17659 error "$LR_READER should have returned 'reply_data' section"
17660 num=$(echo "$out" | grep -c "client_generation")
17661 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
17663 run_test 252 "check lr_reader tool"
17665 test_253_fill_ost() {
17666 local size_mb #how many MB should we write to pass watermark
17667 local lwm=$3 #low watermark
17668 local free_10mb #10% of free space
17670 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
17671 size_mb=$((free_kb / 1024 - lwm))
17672 free_10mb=$((free_kb / 10240))
17673 #If 10% of free space cross low watermark use it
17674 if (( free_10mb > size_mb )); then
17677 #At least we need to store 1.1 of difference between
17678 #free space and low watermark
17679 size_mb=$((size_mb + size_mb / 10))
17681 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
17682 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
17683 oflag=append conv=notrunc
17688 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
17689 echo "OST still has $((free_kb / 1024)) mbytes free"
17693 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17694 remote_mds_nodsh && skip "remote MDS with nodsh"
17695 remote_mgs_nodsh && skip "remote MGS with nodsh"
17700 local ost_name=$($LFS osts |
17701 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
17703 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
17704 do_facet $SINGLEMDS $LCTL get_param -n \
17705 osp.$mdtosc_proc1.reserved_mb_high ||
17706 skip "remote MDS does not support reserved_mb_high"
17710 wait_delete_completed
17713 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
17714 osp.$mdtosc_proc1.reserved_mb_high)
17715 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
17716 osp.$mdtosc_proc1.reserved_mb_low)
17717 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
17719 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
17720 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
17721 error "Adding $ost_name to pool failed"
17723 # Wait for client to see a OST at pool
17724 wait_update $HOSTNAME "$LCTL get_param -n
17725 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
17726 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
17727 error "Client can not see the pool"
17728 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
17729 error "Setstripe failed"
17731 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
17732 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
17733 echo "OST still has $((blocks/1024)) mbytes free"
17735 local new_lwm=$((blocks/1024-10))
17736 do_facet $SINGLEMDS $LCTL set_param \
17737 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
17738 do_facet $SINGLEMDS $LCTL set_param \
17739 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
17741 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
17743 #First enospc could execute orphan deletion so repeat.
17744 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
17746 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17747 osp.$mdtosc_proc1.prealloc_status)
17748 echo "prealloc_status $oa_status"
17750 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
17751 error "File creation should fail"
17752 #object allocation was stopped, but we still able to append files
17753 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
17754 error "Append failed"
17755 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
17757 wait_delete_completed
17761 for i in $(seq 10 12); do
17762 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
17763 error "File creation failed after rm";
17766 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17767 osp.$mdtosc_proc1.prealloc_status)
17768 echo "prealloc_status $oa_status"
17770 if (( oa_status != 0 )); then
17771 error "Object allocation still disable after rm"
17773 do_facet $SINGLEMDS $LCTL set_param \
17774 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
17775 do_facet $SINGLEMDS $LCTL set_param \
17776 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
17779 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
17780 error "Remove $ost_name from pool failed"
17781 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
17782 error "Pool destroy fialed"
17784 run_test 253 "Check object allocation limit"
17787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17788 remote_mds_nodsh && skip "remote MDS with nodsh"
17789 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
17790 skip "MDS does not support changelog_size"
17793 local MDT0=$(facet_svc $SINGLEMDS)
17795 changelog_register || error "changelog_register failed"
17797 changelog_clear 0 || error "changelog_clear failed"
17799 local size1=$(do_facet $SINGLEMDS \
17800 $LCTL get_param -n mdd.$MDT0.changelog_size)
17801 echo "Changelog size $size1"
17804 $LFS mkdir -i 0 $DIR/$tdir
17806 mkdir -p $DIR/$tdir/pics/2008/zachy
17807 touch $DIR/$tdir/pics/2008/zachy/timestamp
17808 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
17809 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
17810 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
17811 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
17812 rm $DIR/$tdir/pics/desktop.jpg
17814 local size2=$(do_facet $SINGLEMDS \
17815 $LCTL get_param -n mdd.$MDT0.changelog_size)
17816 echo "Changelog size after work $size2"
17818 (( $size2 > $size1 )) ||
17819 error "new Changelog size=$size2 less than old size=$size1"
17821 run_test 254 "Check changelog size"
17828 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
17829 awk -F: '{print $2}' | grep $type > /dev/null
17830 if [ $? -ne 0 ]; then
17840 lfs ladvise -a willread $file > /dev/null 2>&1
17841 if [ $? -eq 0 ]; then
17845 lfs ladvise -a willread $file 2>&1 |
17846 grep "Inappropriate ioctl for device" > /dev/null
17847 if [ $? -eq 0 ]; then
17854 bc <<<"scale=2; ($1 - $2) * 100 / $2"
17857 # run a random read IO workload
17858 # usage: random_read_iops <filename> <filesize> <iosize>
17859 random_read_iops() {
17862 local iosize=${3:-4096}
17864 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
17865 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
17868 drop_file_oss_cache() {
17872 $LFS ladvise -a dontneed $file 2>/dev/null ||
17873 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
17876 ladvise_willread_performance()
17879 local average_origin=0
17880 local average_cache=0
17881 local average_ladvise=0
17883 for ((i = 1; i <= $repeat; i++)); do
17884 echo "Iter $i/$repeat: reading without willread hint"
17885 cancel_lru_locks osc
17886 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17887 local speed_origin=$(random_read_iops $DIR/$tfile $size)
17888 echo "Iter $i/$repeat: uncached speed: $speed_origin"
17889 average_origin=$(bc <<<"$average_origin + $speed_origin")
17891 cancel_lru_locks osc
17892 local speed_cache=$(random_read_iops $DIR/$tfile $size)
17893 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
17894 average_cache=$(bc <<<"$average_cache + $speed_cache")
17896 cancel_lru_locks osc
17897 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17898 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
17899 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
17900 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
17901 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
17903 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
17904 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
17905 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
17907 speedup_cache=$(percent $average_cache $average_origin)
17908 speedup_ladvise=$(percent $average_ladvise $average_origin)
17910 echo "Average uncached read: $average_origin"
17911 echo "Average speedup with OSS cached read: " \
17912 "$average_cache = +$speedup_cache%"
17913 echo "Average speedup with ladvise willread: " \
17914 "$average_ladvise = +$speedup_ladvise%"
17916 local lowest_speedup=20
17917 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
17918 echo "Speedup with OSS cached read less than $lowest_speedup%," \
17919 "got $average_cache%. Skipping ladvise willread check."
17923 # the test won't work on ZFS until it supports 'ladvise dontneed', but
17924 # it is still good to run until then to exercise 'ladvise willread'
17925 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17926 [ "$ost1_FSTYPE" = "zfs" ] &&
17927 echo "osd-zfs does not support dontneed or drop_caches" &&
17930 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
17931 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
17932 error_not_in_vm "Speedup with willread is less than " \
17933 "$lowest_speedup%, got $average_ladvise%"
17937 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17938 skip "lustre < 2.8.54 does not support ladvise "
17939 remote_ost_nodsh && skip "remote OST with nodsh"
17941 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
17943 ladvise_no_type willread $DIR/$tfile &&
17944 skip "willread ladvise is not supported"
17946 ladvise_no_ioctl $DIR/$tfile &&
17947 skip "ladvise ioctl is not supported"
17950 local size=$((size_mb * 1048576))
17951 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17952 error "dd to $DIR/$tfile failed"
17954 lfs ladvise -a willread $DIR/$tfile ||
17955 error "Ladvise failed with no range argument"
17957 lfs ladvise -a willread -s 0 $DIR/$tfile ||
17958 error "Ladvise failed with no -l or -e argument"
17960 lfs ladvise -a willread -e 1 $DIR/$tfile ||
17961 error "Ladvise failed with only -e argument"
17963 lfs ladvise -a willread -l 1 $DIR/$tfile ||
17964 error "Ladvise failed with only -l argument"
17966 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
17967 error "End offset should not be smaller than start offset"
17969 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
17970 error "End offset should not be equal to start offset"
17972 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
17973 error "Ladvise failed with overflowing -s argument"
17975 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
17976 error "Ladvise failed with overflowing -e argument"
17978 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
17979 error "Ladvise failed with overflowing -l argument"
17981 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
17982 error "Ladvise succeeded with conflicting -l and -e arguments"
17984 echo "Synchronous ladvise should wait"
17986 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
17987 do_nodes $(comma_list $(osts_nodes)) \
17988 $LCTL set_param fail_val=$delay fail_loc=0x237
17990 local start_ts=$SECONDS
17991 lfs ladvise -a willread $DIR/$tfile ||
17992 error "Ladvise failed with no range argument"
17993 local end_ts=$SECONDS
17994 local inteval_ts=$((end_ts - start_ts))
17996 if [ $inteval_ts -lt $(($delay - 1)) ]; then
17997 error "Synchronous advice didn't wait reply"
18000 echo "Asynchronous ladvise shouldn't wait"
18001 local start_ts=$SECONDS
18002 lfs ladvise -a willread -b $DIR/$tfile ||
18003 error "Ladvise failed with no range argument"
18004 local end_ts=$SECONDS
18005 local inteval_ts=$((end_ts - start_ts))
18007 if [ $inteval_ts -gt $(($delay / 2)) ]; then
18008 error "Asynchronous advice blocked"
18011 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
18012 ladvise_willread_performance
18014 run_test 255a "check 'lfs ladvise -a willread'"
18020 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
18024 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
18025 skip "lustre < 2.8.54 does not support ladvise "
18026 remote_ost_nodsh && skip "remote OST with nodsh"
18028 lfs setstripe -c 1 -i 0 $DIR/$tfile
18030 ladvise_no_type dontneed $DIR/$tfile &&
18031 skip "dontneed ladvise is not supported"
18033 ladvise_no_ioctl $DIR/$tfile &&
18034 skip "ladvise ioctl is not supported"
18036 ! $LFS ladvise -a dontneed $DIR/$tfile &&
18037 [ "$ost1_FSTYPE" = "zfs" ] &&
18038 skip "zfs-osd does not support 'ladvise dontneed'"
18041 local size=$((size_mb * 1048576))
18042 # In order to prevent disturbance of other processes, only check 3/4
18043 # of the memory usage
18044 local kibibytes=$((size_mb * 1024 * 3 / 4))
18046 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
18047 error "dd to $DIR/$tfile failed"
18049 #force write to complete before dropping OST cache & checking memory
18052 local total=$(facet_meminfo ost1 MemTotal)
18053 echo "Total memory: $total KiB"
18055 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
18056 local before_read=$(facet_meminfo ost1 Cached)
18057 echo "Cache used before read: $before_read KiB"
18059 lfs ladvise -a willread $DIR/$tfile ||
18060 error "Ladvise willread failed"
18061 local after_read=$(facet_meminfo ost1 Cached)
18062 echo "Cache used after read: $after_read KiB"
18064 lfs ladvise -a dontneed $DIR/$tfile ||
18065 error "Ladvise dontneed again failed"
18066 local no_read=$(facet_meminfo ost1 Cached)
18067 echo "Cache used after dontneed ladvise: $no_read KiB"
18069 if [ $total -lt $((before_read + kibibytes)) ]; then
18070 echo "Memory is too small, abort checking"
18074 if [ $((before_read + kibibytes)) -gt $after_read ]; then
18075 error "Ladvise willread should use more memory" \
18076 "than $kibibytes KiB"
18079 if [ $((no_read + kibibytes)) -gt $after_read ]; then
18080 error "Ladvise dontneed should release more memory" \
18081 "than $kibibytes KiB"
18084 run_test 255b "check 'lfs ladvise -a dontneed'"
18087 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
18088 skip "lustre < 2.10.50 does not support lockahead"
18090 local ost1_imp=$(get_osc_import_name client ost1)
18091 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
18099 test_mkdir -p $DIR/$tdir
18100 $SETSTRIPE -i 0 $DIR/$tdir
18102 #test 10 returns only success/failure
18104 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18106 if [ $rc -eq 255 ]; then
18107 error "Ladvise test${i} failed, ${rc}"
18110 #test 11 counts lock enqueue requests, all others count new locks
18112 count=$(do_facet ost1 \
18113 $LCTL get_param -n ost.OSS.ost.stats)
18114 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
18116 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18118 if [ $rc -eq 255 ]; then
18119 error "Ladvise test${i} failed, ${rc}"
18122 new_count=$(do_facet ost1 \
18123 $LCTL get_param -n ost.OSS.ost.stats)
18124 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
18125 awk '{ print $2 }')
18127 difference="$((new_count - count))"
18128 if [ $difference -ne $rc ]; then
18129 error "Ladvise test${i}, bad enqueue count, returned " \
18130 "${rc}, actual ${difference}"
18133 for i in $(seq 12 21); do
18134 # If we do not do this, we run the risk of having too many
18135 # locks and starting lock cancellation while we are checking
18137 cancel_lru_locks osc
18139 count=$($LCTL get_param -n \
18140 ldlm.namespaces.$imp_name.lock_unused_count)
18142 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18144 if [ $rc -eq 255 ]; then
18145 error "Ladvise test ${i} failed, ${rc}"
18148 new_count=$($LCTL get_param -n \
18149 ldlm.namespaces.$imp_name.lock_unused_count)
18150 difference="$((new_count - count))"
18152 # Test 15 output is divided by 100 to map down to valid return
18153 if [ $i -eq 15 ]; then
18157 if [ $difference -ne $rc ]; then
18158 error "Ladvise test ${i}, bad lock count, returned " \
18159 "${rc}, actual ${difference}"
18163 #test 22 returns only success/failure
18165 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18167 if [ $rc -eq 255 ]; then
18168 error "Ladvise test${i} failed, ${rc}"
18171 run_test 255c "suite of ladvise lockahead tests"
18174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18175 remote_mds_nodsh && skip "remote MDS with nodsh"
18176 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18177 changelog_users $SINGLEMDS | grep "^cl" &&
18178 skip "active changelog user"
18184 mdt_dev=$(mdsdevname 1)
18187 changelog_register || error "changelog_register failed"
18190 mkdir -p $DIR/$tdir
18192 changelog_clear 0 || error "changelog_clear failed"
18195 touch $DIR/$tdir/{1..10}
18198 stop $SINGLEMDS || error "Fail to stop MDT"
18202 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
18204 #after mount new plainllog is used
18205 touch $DIR/$tdir/{11..19}
18206 local tmpfile=$(mktemp -u $tfile.XXXXXX)
18207 cat_sl=$(do_facet $SINGLEMDS "sync; \
18208 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18209 llog_reader $tmpfile | grep -c type=1064553b")
18210 do_facet $SINGLEMDS llog_reader $tmpfile
18212 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
18214 changelog_clear 0 || error "changelog_clear failed"
18216 cat_sl=$(do_facet $SINGLEMDS "sync; \
18217 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18218 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
18220 if (( cat_sl == 2 )); then
18221 error "Empty plain llog was not deleted from changelog catalog"
18222 elif (( cat_sl != 1 )); then
18223 error "Active plain llog shouldn't be deleted from catalog"
18226 run_test 256 "Check llog delete for empty and not full state"
18229 remote_mds_nodsh && skip "remote MDS with nodsh"
18230 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
18231 skip "Need MDS version at least 2.8.55"
18233 test_mkdir $DIR/$tdir
18235 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
18236 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
18239 #define OBD_FAIL_MDS_XATTR_REP 0x161
18240 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18241 local facet=mds$((mdtidx + 1))
18242 set_nodes_failloc $(facet_active_host $facet) 0x80000161
18243 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
18245 stop $facet || error "stop MDS failed"
18246 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
18247 error "start MDS fail"
18249 run_test 257 "xattr locks are not lost"
18251 # Verify we take the i_mutex when security requires it
18253 #define OBD_FAIL_IMUTEX_SEC 0x141c
18254 $LCTL set_param fail_loc=0x141c
18256 chmod u+s $DIR/$tfile
18257 chmod a+rwx $DIR/$tfile
18258 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18260 if [ $RC -ne 0 ]; then
18261 error "error, failed to take i_mutex, rc=$?"
18265 run_test 258a "verify i_mutex security behavior when suid attributes is set"
18267 # Verify we do NOT take the i_mutex in the normal case
18269 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
18270 $LCTL set_param fail_loc=0x141d
18273 chmod a+rw $DIR/$tfile
18274 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18276 if [ $RC -ne 0 ]; then
18277 error "error, took i_mutex unnecessarily, rc=$?"
18282 run_test 258b "verify i_mutex security behavior"
18285 local file=$DIR/$tfile
18289 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18291 stack_trap "rm -f $file" EXIT
18293 wait_delete_completed
18294 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18295 echo "before: $before"
18297 $LFS setstripe -i 0 -c 1 $file
18298 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
18300 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18301 echo "after write: $after"
18303 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
18304 do_facet ost1 $LCTL set_param fail_loc=0x2301
18306 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18307 echo "after truncate: $after"
18310 do_facet ost1 $LCTL set_param fail_loc=0
18311 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18313 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18314 echo "after restart: $after"
18315 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
18316 error "missing truncate?"
18320 run_test 259 "crash at delayed truncate"
18323 #define OBD_FAIL_MDC_CLOSE 0x806
18324 $LCTL set_param fail_loc=0x80000806
18328 run_test 260 "Check mdc_close fail"
18330 ### Data-on-MDT sanity tests ###
18332 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18333 skip "Need MDS version at least 2.10.55 for DoM"
18336 local dom=$DIR/$tdir/dom_file
18337 local tmp=$DIR/$tdir/tmp_file
18339 mkdir -p $DIR/$tdir
18341 # basic checks for DoM component creation
18342 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
18343 error "Can set MDT layout to non-first entry"
18345 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
18346 error "Can define multiple entries as MDT layout"
18348 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
18350 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
18351 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
18352 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
18354 local mdtidx=$($LFS getstripe -m $dom)
18355 local mdtname=MDT$(printf %04x $mdtidx)
18356 local facet=mds$((mdtidx + 1))
18357 local space_check=1
18359 # Skip free space checks with ZFS
18360 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
18364 local size_tmp=$((65536 * 3))
18365 local mdtfree1=$(do_facet $facet \
18366 lctl get_param -n osd*.*$mdtname.kbytesfree)
18368 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18369 # check also direct IO along write
18370 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
18371 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18373 cmp $tmp $dom || error "file data is different"
18374 [ $(stat -c%s $dom) == $size_tmp ] ||
18375 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18376 if [ $space_check == 1 ]; then
18377 local mdtfree2=$(do_facet $facet \
18378 lctl get_param -n osd*.*$mdtname.kbytesfree)
18380 # increase in usage from by $size_tmp
18381 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18382 error "MDT free space wrong after write: " \
18383 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18387 local size_dom=10000
18389 $TRUNCATE $dom $size_dom
18390 [ $(stat -c%s $dom) == $size_dom ] ||
18391 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
18392 if [ $space_check == 1 ]; then
18393 mdtfree1=$(do_facet $facet \
18394 lctl get_param -n osd*.*$mdtname.kbytesfree)
18395 # decrease in usage from $size_tmp to new $size_dom
18396 [ $(($mdtfree1 - $mdtfree2)) -ge \
18397 $(((size_tmp - size_dom) / 1024)) ] ||
18398 error "MDT free space is wrong after truncate: " \
18399 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
18405 size_dom=$((size_dom + size_tmp))
18406 [ $(stat -c%s $dom) == $size_dom ] ||
18407 error "bad size after append: $(stat -c%s $dom) != $size_dom"
18408 if [ $space_check == 1 ]; then
18409 mdtfree2=$(do_facet $facet \
18410 lctl get_param -n osd*.*$mdtname.kbytesfree)
18411 # increase in usage by $size_tmp from previous
18412 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18413 error "MDT free space is wrong after append: " \
18414 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18419 if [ $space_check == 1 ]; then
18420 mdtfree1=$(do_facet $facet \
18421 lctl get_param -n osd*.*$mdtname.kbytesfree)
18422 # decrease in usage by $size_dom from previous
18423 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
18424 error "MDT free space is wrong after removal: " \
18425 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
18428 # combined striping
18429 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
18430 error "Can't create DoM + OST striping"
18432 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
18433 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18434 # check also direct IO along write
18435 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18437 cmp $tmp $dom || error "file data is different"
18438 [ $(stat -c%s $dom) == $size_tmp ] ||
18439 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18444 run_test 270a "DoM: basic functionality tests"
18447 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18448 skip "Need MDS version at least 2.10.55"
18450 local dom=$DIR/$tdir/dom_file
18451 local max_size=1048576
18453 mkdir -p $DIR/$tdir
18454 $LFS setstripe -E $max_size -L mdt $dom
18456 # truncate over the limit
18457 $TRUNCATE $dom $(($max_size + 1)) &&
18458 error "successful truncate over the maximum size"
18459 # write over the limit
18460 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
18461 error "successful write over the maximum size"
18462 # append over the limit
18463 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
18464 echo "12345" >> $dom && error "successful append over the maximum size"
18469 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
18472 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18473 skip "Need MDS version at least 2.10.55"
18475 mkdir -p $DIR/$tdir
18476 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18478 # check files inherit DoM EA
18479 touch $DIR/$tdir/first
18480 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
18481 error "bad pattern"
18482 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
18483 error "bad stripe count"
18484 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
18485 error "bad stripe size"
18487 # check directory inherits DoM EA and uses it as default
18488 mkdir $DIR/$tdir/subdir
18489 touch $DIR/$tdir/subdir/second
18490 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
18491 error "bad pattern in sub-directory"
18492 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
18493 error "bad stripe count in sub-directory"
18494 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
18495 error "bad stripe size in sub-directory"
18498 run_test 270c "DoM: DoM EA inheritance tests"
18501 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18502 skip "Need MDS version at least 2.10.55"
18504 mkdir -p $DIR/$tdir
18505 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18507 # inherit default DoM striping
18508 mkdir $DIR/$tdir/subdir
18509 touch $DIR/$tdir/subdir/f1
18511 # change default directory striping
18512 $LFS setstripe -c 1 $DIR/$tdir/subdir
18513 touch $DIR/$tdir/subdir/f2
18514 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
18515 error "wrong default striping in file 2"
18516 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
18517 error "bad pattern in file 2"
18520 run_test 270d "DoM: change striping from DoM to RAID0"
18523 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18524 skip "Need MDS version at least 2.10.55"
18526 mkdir -p $DIR/$tdir/dom
18527 mkdir -p $DIR/$tdir/norm
18530 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
18531 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
18533 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
18534 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
18536 # find DoM files by layout
18537 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
18538 [ $NUM -eq $DOMFILES ] ||
18539 error "lfs find -L: found $NUM, expected $DOMFILES"
18540 echo "Test 1: lfs find 20 DOM files by layout: OK"
18542 # there should be 1 dir with default DOM striping
18543 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
18545 error "lfs find -L: found $NUM, expected 1 dir"
18546 echo "Test 2: lfs find 1 DOM dir by layout: OK"
18548 # find DoM files by stripe size
18549 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
18550 [ $NUM -eq $DOMFILES ] ||
18551 error "lfs find -S: found $NUM, expected $DOMFILES"
18552 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
18554 # find files by stripe offset except DoM files
18555 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
18556 [ $NUM -eq $NORMFILES ] ||
18557 error "lfs find -i: found $NUM, expected $NORMFILES"
18558 echo "Test 5: lfs find no DOM files by stripe index: OK"
18561 run_test 270e "DoM: lfs find with DoM files test"
18564 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18565 skip "Need MDS version at least 2.10.55"
18567 local mdtname=${FSNAME}-MDT0000-mdtlov
18568 local dom=$DIR/$tdir/dom_file
18569 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
18570 lod.$mdtname.dom_stripesize)
18571 local dom_limit=131072
18573 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
18574 local dom_current=$(do_facet mds1 $LCTL get_param -n \
18575 lod.$mdtname.dom_stripesize)
18576 [ ${dom_limit} -eq ${dom_current} ] ||
18577 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
18579 $LFS mkdir -i 0 -c 1 $DIR/$tdir
18580 $LFS setstripe -d $DIR/$tdir
18581 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
18582 error "Can't set directory default striping"
18584 # exceed maximum stripe size
18585 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18586 error "Can't create file with $((dom_limit * 2)) DoM stripe"
18587 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
18588 error "Able to create DoM component size more than LOD limit"
18590 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
18591 dom_current=$(do_facet mds1 $LCTL get_param -n \
18592 lod.$mdtname.dom_stripesize)
18593 [ 0 -eq ${dom_current} ] ||
18594 error "Can't set zero DoM stripe limit"
18597 # attempt to create DoM file on server with disabled DoM should
18598 # remove DoM entry from layout and be succeed
18599 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
18600 error "Can't create DoM file (DoM is disabled)"
18601 [ $($LFS getstripe -L $dom) == "mdt" ] &&
18602 error "File has DoM component while DoM is disabled"
18605 # attempt to create DoM file with only DoM stripe should return error
18606 $LFS setstripe -E $dom_limit -L mdt $dom &&
18607 error "Able to create DoM-only file while DoM is disabled"
18609 # too low values to be aligned with smallest stripe size 64K
18610 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
18611 dom_current=$(do_facet mds1 $LCTL get_param -n \
18612 lod.$mdtname.dom_stripesize)
18613 [ 30000 -eq ${dom_current} ] &&
18614 error "Can set too small DoM stripe limit"
18616 # 64K is a minimal stripe size in Lustre, expect limit of that size
18617 [ 65536 -eq ${dom_current} ] ||
18618 error "Limit is not set to 64K but ${dom_current}"
18620 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
18621 dom_current=$(do_facet mds1 $LCTL get_param -n \
18622 lod.$mdtname.dom_stripesize)
18624 [ 2147483648 -eq ${dom_current} ] &&
18625 error "Can set too large DoM stripe limit"
18627 do_facet mds1 $LCTL set_param -n \
18628 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
18629 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18630 error "Can't create DoM component size after limit change"
18631 do_facet mds1 $LCTL set_param -n \
18632 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
18633 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
18634 error "Can't create DoM file after limit decrease"
18635 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
18636 error "Can create big DoM component after limit decrease"
18637 touch ${dom}_def ||
18638 error "Can't create file with old default layout"
18640 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
18643 run_test 270f "DoM: maximum DoM stripe size checks"
18646 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18647 skip "Need MDS version at least 2.10.55"
18649 local dom=$DIR/$tdir/dom
18651 mkdir -p $DIR/$tdir
18653 $LFS setstripe -E 1024K -L mdt $dom
18655 lctl set_param -n mdc.*.stats=clear
18656 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18657 cat $dom > /dev/null
18658 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
18659 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
18663 run_test 271a "DoM: data is cached for read after write"
18666 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18667 skip "Need MDS version at least 2.10.55"
18669 local dom=$DIR/$tdir/dom
18671 mkdir -p $DIR/$tdir
18673 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18675 lctl set_param -n mdc.*.stats=clear
18676 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18677 cancel_lru_locks mdc
18678 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
18679 # second stat to check size is cached on client
18680 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
18681 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18682 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
18685 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
18688 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18689 skip "Need MDS version at least 2.10.55"
18691 local dom=$DIR/$tdir/dom
18693 mkdir -p $DIR/$tdir
18695 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18697 lctl set_param -n mdc.*.stats=clear
18698 lctl set_param -n osc.*.stats=clear
18699 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
18700 cancel_lru_locks mdc
18701 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18702 # second stat to check size is cached on client
18703 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18704 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18705 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
18706 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
18707 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
18710 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
18716 local mdt=MDT$(printf %04x $mdtidx)
18718 if [ -z $param ]; then
18719 lctl get_param -n mdc.*$mdt*.stats
18721 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
18726 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18727 skip "Need MDS version at least 2.10.55"
18729 local dom=$DIR/$tdir/dom
18731 mkdir -p $DIR/$tdir
18733 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18735 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18736 local facet=mds$((mdtidx + 1))
18738 cancel_lru_locks mdc
18739 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
18740 createmany -o $dom 1000
18741 lctl set_param -n mdc.*.stats=clear
18742 smalliomany -w $dom 1000 200
18743 get_mdc_stats $mdtidx
18744 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18745 # Each file has 1 open, 1 IO enqueues, total 2000
18746 # but now we have also +1 getxattr for security.capability, total 3000
18747 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
18748 unlinkmany $dom 1000
18750 cancel_lru_locks mdc
18751 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
18752 createmany -o $dom 1000
18753 lctl set_param -n mdc.*.stats=clear
18754 smalliomany -w $dom 1000 200
18755 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18756 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
18757 # for OPEN and IO lock.
18758 [ $((enq - enq_2)) -ge 1000 ] ||
18759 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
18760 unlinkmany $dom 1000
18763 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
18765 cleanup_271def_tests() {
18771 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18772 skip "Need MDS version at least 2.10.57"
18774 local dom=$DIR/$tdir/dom
18775 local tmp=$TMP/$tfile
18776 trap "cleanup_271def_tests $tmp" EXIT
18778 mkdir -p $DIR/$tdir
18780 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18782 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18784 cancel_lru_locks mdc
18785 dd if=/dev/urandom of=$tmp bs=1000 count=1
18786 dd if=$tmp of=$dom bs=1000 count=1
18787 cancel_lru_locks mdc
18789 cat /etc/hosts >> $tmp
18790 lctl set_param -n mdc.*.stats=clear
18792 # append data to the same file it should update local page
18793 echo "Append to the same page"
18794 cat /etc/hosts >> $dom
18795 local num=$(get_mdc_stats $mdtidx ost_read)
18796 local ra=$(get_mdc_stats $mdtidx req_active)
18797 local rw=$(get_mdc_stats $mdtidx req_waittime)
18799 [ -z $num ] || error "$num READ RPC occured"
18800 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18804 cmp $tmp $dom || error "file miscompare"
18806 cancel_lru_locks mdc
18807 lctl set_param -n mdc.*.stats=clear
18809 echo "Open and read file"
18810 cat $dom > /dev/null
18811 local num=$(get_mdc_stats $mdtidx ost_read)
18812 local ra=$(get_mdc_stats $mdtidx req_active)
18813 local rw=$(get_mdc_stats $mdtidx req_waittime)
18815 [ -z $num ] || error "$num READ RPC occured"
18816 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18820 cmp $tmp $dom || error "file miscompare"
18824 run_test 271d "DoM: read on open (1K file in reply buffer)"
18827 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18828 skip "Need MDS version at least 2.10.57"
18830 local dom=$DIR/$tdir/dom
18831 local tmp=$TMP/$tfile
18832 trap "cleanup_271def_tests $tmp" EXIT
18834 mkdir -p $DIR/$tdir
18836 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18838 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18840 cancel_lru_locks mdc
18841 dd if=/dev/urandom of=$tmp bs=200000 count=1
18842 dd if=$tmp of=$dom bs=200000 count=1
18843 cancel_lru_locks mdc
18844 cat /etc/hosts >> $tmp
18845 lctl set_param -n mdc.*.stats=clear
18847 echo "Append to the same page"
18848 cat /etc/hosts >> $dom
18849 local num=$(get_mdc_stats $mdtidx ost_read)
18850 local ra=$(get_mdc_stats $mdtidx req_active)
18851 local rw=$(get_mdc_stats $mdtidx req_waittime)
18853 [ -z $num ] || error "$num READ RPC occured"
18854 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18858 cmp $tmp $dom || error "file miscompare"
18860 cancel_lru_locks mdc
18861 lctl set_param -n mdc.*.stats=clear
18863 echo "Open and read file"
18864 cat $dom > /dev/null
18865 local num=$(get_mdc_stats $mdtidx ost_read)
18866 local ra=$(get_mdc_stats $mdtidx req_active)
18867 local rw=$(get_mdc_stats $mdtidx req_waittime)
18869 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
18870 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18874 cmp $tmp $dom || error "file miscompare"
18878 run_test 271f "DoM: read on open (200K file and read tail)"
18881 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
18882 skip "Skipping due to old client or server version"
18884 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
18886 $CHECKSTAT -t file $DIR1/$tfile
18888 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
18891 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
18892 $LCTL set_param fail_loc=0x80000314
18893 rm $DIR1/$tfile || error "Unlink fails"
18895 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
18896 [ $RC -eq 0 ] || error "Failed write to stale object"
18898 run_test 271g "Discard DoM data vs client flush race"
18901 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18902 skip "Need MDS version at least 2.11.50"
18904 local dom=$DIR/$tdir/dom
18905 mkdir -p $DIR/$tdir
18907 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
18908 dd if=/dev/urandom of=$dom bs=512K count=1 ||
18909 error "failed to write data into $dom"
18910 local old_md5=$(md5sum $dom)
18912 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
18913 error "failed to migrate to the same DoM component"
18915 [ $($LFS getstripe -c $dom) -eq 2 ] ||
18916 error "layout was not changed silently"
18918 local new_md5=$(md5sum $dom)
18920 [ "$old_md5" != "$new_md5" ] &&
18921 error "md5sum differ: $old_md5, $new_md5"
18924 run_test 272a "DoM migration: new layout with the same DOM component"
18927 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18928 skip "Need MDS version at least 2.11.50"
18930 local dom=$DIR/$tdir/dom
18931 mkdir -p $DIR/$tdir
18932 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18934 local mdtidx=$($LFS getstripe -m $dom)
18935 local mdtname=MDT$(printf %04x $mdtidx)
18936 local facet=mds$((mdtidx + 1))
18938 local mdtfree1=$(do_facet $facet \
18939 lctl get_param -n osd*.*$mdtname.kbytesfree)
18940 dd if=/dev/urandom of=$dom bs=2M count=1 ||
18941 error "failed to write data into $dom"
18942 local old_md5=$(md5sum $dom)
18943 cancel_lru_locks mdc
18944 local mdtfree1=$(do_facet $facet \
18945 lctl get_param -n osd*.*$mdtname.kbytesfree)
18947 $LFS migrate -c2 $dom ||
18948 error "failed to migrate to the new composite layout"
18949 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18950 error "MDT stripe was not removed"
18952 cancel_lru_locks mdc
18953 local new_md5=$(md5sum $dom)
18954 [ "$old_md5" != "$new_md5" ] &&
18955 error "$old_md5 != $new_md5"
18957 # Skip free space checks with ZFS
18958 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18959 local mdtfree2=$(do_facet $facet \
18960 lctl get_param -n osd*.*$mdtname.kbytesfree)
18961 [ $mdtfree2 -gt $mdtfree1 ] ||
18962 error "MDT space is not freed after migration"
18966 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
18969 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18970 skip "Need MDS version at least 2.11.50"
18972 local dom=$DIR/$tdir/$tfile
18973 mkdir -p $DIR/$tdir
18974 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18976 local mdtidx=$($LFS getstripe -m $dom)
18977 local mdtname=MDT$(printf %04x $mdtidx)
18978 local facet=mds$((mdtidx + 1))
18980 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
18981 error "failed to write data into $dom"
18982 local old_md5=$(md5sum $dom)
18983 cancel_lru_locks mdc
18984 local mdtfree1=$(do_facet $facet \
18985 lctl get_param -n osd*.*$mdtname.kbytesfree)
18987 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
18988 error "failed to migrate to the new composite layout"
18989 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18990 error "MDT stripe was not removed"
18992 cancel_lru_locks mdc
18993 local new_md5=$(md5sum $dom)
18994 [ "$old_md5" != "$new_md5" ] &&
18995 error "$old_md5 != $new_md5"
18997 # Skip free space checks with ZFS
18998 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18999 local mdtfree2=$(do_facet $facet \
19000 lctl get_param -n osd*.*$mdtname.kbytesfree)
19001 [ $mdtfree2 -gt $mdtfree1 ] ||
19002 error "MDS space is not freed after migration"
19006 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
19009 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19010 skip "Need MDS version at least 2.11.50"
19012 # Layout swap cannot be done if either file has DOM component,
19013 # this will never be supported, migration should be used instead
19015 local dom=$DIR/$tdir/$tfile
19016 mkdir -p $DIR/$tdir
19018 $LFS setstripe -c2 ${dom}_plain
19019 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
19020 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
19021 error "can swap layout with DoM component"
19022 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
19023 error "can swap layout with DoM component"
19025 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
19026 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
19027 error "can swap layout with DoM component"
19028 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
19029 error "can swap layout with DoM component"
19032 run_test 273a "DoM: layout swapping should fail with DOM"
19035 remote_ost_nodsh && skip "remote OST with nodsh"
19036 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
19037 skip "Need OST version >= 2.10.57"
19039 local file=$DIR/$tfile
19042 oss=$(comma_list $(osts_nodes))
19044 dd if=/dev/urandom of=$file bs=1M count=2 ||
19045 error "failed to create a file"
19046 cancel_lru_locks osc
19049 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
19050 error "failed to read a file"
19052 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
19053 $LCTL set_param fail_loc=0x8000031f
19055 cancel_lru_locks osc &
19058 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
19059 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
19060 #IO takes another lock, but matches the PENDING one
19061 #and places it to the IO RPC
19062 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
19063 error "failed to read a file with PENDING lock"
19065 run_test 275 "Read on a canceled duplicate lock"
19068 remote_ost_nodsh && skip "remote OST with nodsh"
19071 do_facet ost1 "(while true; do \
19072 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
19073 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
19076 for LOOP in $(seq 20); do
19078 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
19081 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
19082 rm $TMP/sanity_276_pid"
19084 run_test 276 "Race between mount and obd_statfs"
19086 cleanup_test_300() {
19090 test_striped_dir() {
19095 mkdir -p $DIR/$tdir
19097 SAVE_UMASK=$(umask)
19098 trap cleanup_test_300 RETURN EXIT
19100 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
19101 $DIR/$tdir/striped_dir ||
19102 error "set striped dir error"
19104 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
19105 [ "$mode" = "755" ] || error "expect 755 got $mode"
19107 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
19108 error "getdirstripe failed"
19109 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
19110 if [ "$stripe_count" != "2" ]; then
19111 error "1:stripe_count is $stripe_count, expect 2"
19113 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
19114 if [ "$stripe_count" != "2" ]; then
19115 error "2:stripe_count is $stripe_count, expect 2"
19118 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
19119 if [ "$stripe_index" != "$mdt_index" ]; then
19120 error "stripe_index is $stripe_index, expect $mdt_index"
19123 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
19124 error "nlink error after create striped dir"
19126 mkdir $DIR/$tdir/striped_dir/a
19127 mkdir $DIR/$tdir/striped_dir/b
19129 stat $DIR/$tdir/striped_dir/a ||
19130 error "create dir under striped dir failed"
19131 stat $DIR/$tdir/striped_dir/b ||
19132 error "create dir under striped dir failed"
19134 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
19135 error "nlink error after mkdir"
19137 rmdir $DIR/$tdir/striped_dir/a
19138 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
19139 error "nlink error after rmdir"
19141 rmdir $DIR/$tdir/striped_dir/b
19142 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
19143 error "nlink error after rmdir"
19145 chattr +i $DIR/$tdir/striped_dir
19146 createmany -o $DIR/$tdir/striped_dir/f 10 &&
19147 error "immutable flags not working under striped dir!"
19148 chattr -i $DIR/$tdir/striped_dir
19150 rmdir $DIR/$tdir/striped_dir ||
19151 error "rmdir striped dir error"
19159 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19160 skip "skipped for lustre < 2.7.0"
19161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19162 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19164 test_striped_dir 0 || error "failed on striped dir on MDT0"
19165 test_striped_dir 1 || error "failed on striped dir on MDT0"
19167 run_test 300a "basic striped dir sanity test"
19170 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19171 skip "skipped for lustre < 2.7.0"
19172 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19173 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19180 test_mkdir $DIR/$tdir || error "mkdir fail"
19181 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19182 error "set striped dir error"
19183 for i in {0..9}; do
19184 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
19186 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
19187 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
19188 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
19190 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
19191 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
19192 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
19196 run_test 300b "check ctime/mtime for striped dir"
19199 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19200 skip "skipped for lustre < 2.7.0"
19201 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19202 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19206 mkdir -p $DIR/$tdir
19207 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
19208 error "set striped dir error"
19210 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
19211 error "chown striped dir failed"
19213 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
19214 error "create 5k files failed"
19216 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
19218 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
19222 run_test 300c "chown && check ls under striped directory"
19225 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19226 skip "skipped for lustre < 2.7.0"
19227 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19228 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19233 mkdir -p $DIR/$tdir
19234 $SETSTRIPE -c 2 $DIR/$tdir
19236 #local striped directory
19237 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19238 error "set striped dir error"
19239 #look at the directories for debug purposes
19241 $LFS getdirstripe $DIR/$tdir
19242 ls -l $DIR/$tdir/striped_dir
19243 $LFS getdirstripe $DIR/$tdir/striped_dir
19244 createmany -o $DIR/$tdir/striped_dir/f 10 ||
19245 error "create 10 files failed"
19247 #remote striped directory
19248 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
19249 error "set striped dir error"
19250 #look at the directories for debug purposes
19252 $LFS getdirstripe $DIR/$tdir
19253 ls -l $DIR/$tdir/remote_striped_dir
19254 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
19255 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
19256 error "create 10 files failed"
19258 for file in $(find $DIR/$tdir); do
19259 stripe_count=$($LFS getstripe -c $file)
19260 [ $stripe_count -eq 2 ] ||
19261 error "wrong stripe $stripe_count for $file"
19266 run_test 300d "check default stripe under striped directory"
19269 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19270 skip "Need MDS version at least 2.7.55"
19271 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19272 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19277 mkdir -p $DIR/$tdir
19279 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19280 error "set striped dir error"
19282 touch $DIR/$tdir/striped_dir/a
19283 touch $DIR/$tdir/striped_dir/b
19284 touch $DIR/$tdir/striped_dir/c
19286 mkdir $DIR/$tdir/striped_dir/dir_a
19287 mkdir $DIR/$tdir/striped_dir/dir_b
19288 mkdir $DIR/$tdir/striped_dir/dir_c
19290 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
19291 error "set striped adir under striped dir error"
19293 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
19294 error "set striped bdir under striped dir error"
19296 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
19297 error "set striped cdir under striped dir error"
19299 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
19300 error "rename dir under striped dir fails"
19302 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
19303 error "rename dir under different stripes fails"
19305 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
19306 error "rename file under striped dir should succeed"
19308 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
19309 error "rename dir under striped dir should succeed"
19313 run_test 300e "check rename under striped directory"
19316 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19317 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19318 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19319 skip "Need MDS version at least 2.7.55"
19325 mkdir -p $DIR/$tdir
19327 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19328 error "set striped dir error"
19330 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
19331 error "set striped dir error"
19333 touch $DIR/$tdir/striped_dir/a
19334 mkdir $DIR/$tdir/striped_dir/dir_a
19335 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
19336 error "create striped dir under striped dir fails"
19338 touch $DIR/$tdir/striped_dir1/b
19339 mkdir $DIR/$tdir/striped_dir1/dir_b
19340 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
19341 error "create striped dir under striped dir fails"
19343 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
19344 error "rename dir under different striped dir should fail"
19346 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
19347 error "rename striped dir under diff striped dir should fail"
19349 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
19350 error "rename file under diff striped dirs fails"
19354 run_test 300f "check rename cross striped directory"
19356 test_300_check_default_striped_dir()
19359 local default_count=$2
19360 local default_index=$3
19363 local dir_stripe_index
19366 echo "checking $dirname $default_count $default_index"
19367 $LFS setdirstripe -D -c $default_count -i $default_index \
19368 -t all_char $DIR/$tdir/$dirname ||
19369 error "set default stripe on striped dir error"
19370 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
19371 [ $stripe_count -eq $default_count ] ||
19372 error "expect $default_count get $stripe_count for $dirname"
19374 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
19375 [ $stripe_index -eq $default_index ] ||
19376 error "expect $default_index get $stripe_index for $dirname"
19378 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
19379 error "create dirs failed"
19381 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
19382 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
19383 for dir in $(find $DIR/$tdir/$dirname/*); do
19384 stripe_count=$($LFS getdirstripe -c $dir)
19385 [ $stripe_count -eq $default_count ] ||
19386 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
19387 error "stripe count $default_count != $stripe_count for $dir"
19389 stripe_index=$($LFS getdirstripe -i $dir)
19390 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
19391 error "$stripe_index != $default_index for $dir"
19393 #check default stripe
19394 stripe_count=$($LFS getdirstripe -D -c $dir)
19395 [ $stripe_count -eq $default_count ] ||
19396 error "default count $default_count != $stripe_count for $dir"
19398 stripe_index=$($LFS getdirstripe -D -i $dir)
19399 [ $stripe_index -eq $default_index ] ||
19400 error "default index $default_index != $stripe_index for $dir"
19402 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
19406 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19407 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19408 skip "Need MDS version at least 2.7.55"
19415 mkdir $DIR/$tdir/normal_dir
19417 #Checking when client cache stripe index
19418 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
19419 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
19420 error "create striped_dir failed"
19422 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
19423 error "create dir0 fails"
19424 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
19425 [ $stripe_index -eq 0 ] ||
19426 error "dir0 expect index 0 got $stripe_index"
19428 mkdir $DIR/$tdir/striped_dir/dir1 ||
19429 error "create dir1 fails"
19430 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
19431 [ $stripe_index -eq 1 ] ||
19432 error "dir1 expect index 1 got $stripe_index"
19434 #check default stripe count/stripe index
19435 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
19436 test_300_check_default_striped_dir normal_dir 1 0
19437 test_300_check_default_striped_dir normal_dir 2 1
19438 test_300_check_default_striped_dir normal_dir 2 -1
19440 #delete default stripe information
19441 echo "delete default stripeEA"
19442 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
19443 error "set default stripe on striped dir error"
19445 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
19446 for dir in $(find $DIR/$tdir/normal_dir/*); do
19447 stripe_count=$($LFS getdirstripe -c $dir)
19448 [ $stripe_count -eq 0 ] ||
19449 error "expect 1 get $stripe_count for $dir"
19450 stripe_index=$($LFS getdirstripe -i $dir)
19451 [ $stripe_index -eq 0 ] ||
19452 error "expect 0 get $stripe_index for $dir"
19455 run_test 300g "check default striped directory for normal directory"
19458 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19459 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19460 skip "Need MDS version at least 2.7.55"
19466 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19467 error "set striped dir error"
19469 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
19470 test_300_check_default_striped_dir striped_dir 1 0
19471 test_300_check_default_striped_dir striped_dir 2 1
19472 test_300_check_default_striped_dir striped_dir 2 -1
19474 #delete default stripe information
19475 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
19476 error "set default stripe on striped dir error"
19478 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
19479 for dir in $(find $DIR/$tdir/striped_dir/*); do
19480 stripe_count=$($LFS getdirstripe -c $dir)
19481 [ $stripe_count -eq 0 ] ||
19482 error "expect 1 get $stripe_count for $dir"
19485 run_test 300h "check default striped directory for striped directory"
19488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19489 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19490 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19491 skip "Need MDS version at least 2.7.55"
19498 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19499 error "set striped dir error"
19501 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19502 error "create files under striped dir failed"
19504 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
19505 error "set striped hashdir error"
19507 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
19508 error "create dir0 under hash dir failed"
19509 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
19510 error "create dir1 under hash dir failed"
19512 # unfortunately, we need to umount to clear dir layout cache for now
19513 # once we fully implement dir layout, we can drop this
19514 umount_client $MOUNT || error "umount failed"
19515 mount_client $MOUNT || error "mount failed"
19517 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
19518 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
19519 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
19521 #set the stripe to be unknown hash type
19522 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
19523 $LCTL set_param fail_loc=0x1901
19524 for ((i = 0; i < 10; i++)); do
19525 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
19526 error "stat f-$i failed"
19527 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
19530 touch $DIR/$tdir/striped_dir/f0 &&
19531 error "create under striped dir with unknown hash should fail"
19533 $LCTL set_param fail_loc=0
19535 umount_client $MOUNT || error "umount failed"
19536 mount_client $MOUNT || error "mount failed"
19540 run_test 300i "client handle unknown hash type striped directory"
19543 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19545 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19546 skip "Need MDS version at least 2.7.55"
19553 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
19554 $LCTL set_param fail_loc=0x1702
19555 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19556 error "set striped dir error"
19558 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19559 error "create files under striped dir failed"
19561 $LCTL set_param fail_loc=0
19563 rm -rf $DIR/$tdir || error "unlink striped dir fails"
19567 run_test 300j "test large update record"
19570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19571 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19572 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19573 skip "Need MDS version at least 2.7.55"
19580 #define OBD_FAIL_LARGE_STRIPE 0x1703
19581 $LCTL set_param fail_loc=0x1703
19582 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
19583 error "set striped dir error"
19584 $LCTL set_param fail_loc=0
19586 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19587 error "getstripeddir fails"
19588 rm -rf $DIR/$tdir/striped_dir ||
19589 error "unlink striped dir fails"
19593 run_test 300k "test large striped directory"
19596 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19597 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19598 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19599 skip "Need MDS version at least 2.7.55"
19603 test_mkdir -p $DIR/$tdir/striped_dir
19604 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
19605 error "chown $RUNAS_ID failed"
19606 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
19607 error "set default striped dir failed"
19609 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
19610 $LCTL set_param fail_loc=0x80000158
19611 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
19613 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
19614 [ $stripe_index -eq 1 ] ||
19615 error "expect 1 get $stripe_index for $dir"
19617 run_test 300l "non-root user to create dir under striped dir with stale layout"
19620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19621 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
19622 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19623 skip "Need MDS version at least 2.7.55"
19625 mkdir -p $DIR/$tdir/striped_dir
19626 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
19627 error "set default stripes dir error"
19629 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
19631 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
19632 [ $stripe_count -eq 0 ] ||
19633 error "expect 0 get $stripe_count for a"
19635 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
19636 error "set default stripes dir error"
19638 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
19640 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
19641 [ $stripe_count -eq 0 ] ||
19642 error "expect 0 get $stripe_count for b"
19644 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
19645 error "set default stripes dir error"
19647 mkdir $DIR/$tdir/striped_dir/c &&
19648 error "default stripe_index is invalid, mkdir c should fails"
19650 rm -rf $DIR/$tdir || error "rmdir fails"
19652 run_test 300m "setstriped directory on single MDT FS"
19655 local list=$(comma_list $(mdts_nodes))
19658 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19662 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19663 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19664 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19665 skip "Need MDS version at least 2.7.55"
19666 remote_mds_nodsh && skip "remote MDS with nodsh"
19669 local list=$(comma_list $(mdts_nodes))
19671 trap cleanup_300n RETURN EXIT
19672 mkdir -p $DIR/$tdir
19673 chmod 777 $DIR/$tdir
19674 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
19675 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19676 error "create striped dir succeeds with gid=0"
19678 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19679 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
19680 error "create striped dir fails with gid=-1"
19682 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19683 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
19684 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19685 error "set default striped dir succeeds with gid=0"
19688 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19689 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
19690 error "set default striped dir fails with gid=-1"
19693 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19694 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
19695 error "create test_dir fails"
19696 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
19697 error "create test_dir1 fails"
19698 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
19699 error "create test_dir2 fails"
19702 run_test 300n "non-root user to create dir under striped dir with default EA"
19705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19706 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19707 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19708 skip "Need MDS version at least 2.7.55"
19713 mkdir -p $DIR/$tdir
19715 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
19716 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
19717 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
19718 skip "not enough free inodes $numfree1 $numfree2"
19721 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
19722 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
19723 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
19724 skip "not enough free space $numfree1 $numfree2"
19727 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
19728 error "setdirstripe fails"
19730 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
19731 error "create dirs fails"
19733 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
19734 ls $DIR/$tdir/striped_dir > /dev/null ||
19735 error "ls striped dir fails"
19736 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
19737 error "unlink big striped dir fails"
19739 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
19742 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19743 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19744 remote_mds_nodsh && skip "remote MDS with nodsh"
19746 mkdir -p $DIR/$tdir
19748 #define OBD_FAIL_OUT_ENOSPC 0x1704
19749 do_facet mds2 lctl set_param fail_loc=0x80001704
19750 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
19751 && error "create striped directory should fail"
19753 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
19755 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
19758 run_test 300p "create striped directory without space"
19761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19762 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19764 local fd=$(free_fd)
19765 local cmd="exec $fd<$tdir"
19767 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
19770 trap "eval $cmd" EXIT
19771 cd $tdir || error "cd $tdir fails"
19772 rmdir ../$tdir || error "rmdir $tdir fails"
19773 mkdir local_dir && error "create dir succeeds"
19774 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
19778 run_test 300q "create remote directory under orphan directory"
19781 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
19782 skip "Need MDS version at least 2.7.55" && return
19783 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19787 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
19788 error "set striped dir error"
19790 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19791 error "getstripeddir fails"
19794 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
19795 awk '/lmv_stripe_count:/ { print $2 }')
19797 [ $MDSCOUNT -ne $stripe_count ] &&
19798 error "wrong stripe count $stripe_count expected $MDSCOUNT"
19800 rm -rf $DIR/$tdir/striped_dir ||
19801 error "unlink striped dir fails"
19803 run_test 300r "test -1 striped directory"
19805 test_300s_helper() {
19808 local stripe_dir=$DIR/$tdir/striped_dir.$count
19810 $LFS mkdir -c $count $stripe_dir ||
19811 error "lfs mkdir -c error"
19813 $LFS getdirstripe $stripe_dir ||
19814 error "lfs getdirstripe fails"
19817 stripe_count=$($LFS getdirstripe $stripe_dir |
19818 awk '/lmv_stripe_count:/ { print $2 }')
19820 [ $count -ne $stripe_count ] &&
19821 error_noexit "bad stripe count $stripe_count expected $count"
19824 dupe_stripes=$($LFS getdirstripe $stripe_dir |
19825 awk '/0x/ {count[$1] += 1}; END {
19826 for (idx in count) {
19827 if (count[idx]>1) {
19828 print "index " idx " count " count[idx]
19833 if [[ -n "$dupe_stripes" ]] ; then
19834 lfs getdirstripe $stripe_dir
19835 error_noexit "Dupe MDT above: $dupe_stripes "
19838 rm -rf $stripe_dir ||
19839 error_noexit "unlink $stripe_dir fails"
19843 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19844 skip "Need MDS version at least 2.7.55" && return
19845 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19848 for count in $(seq 2 $MDSCOUNT); do
19849 test_300s_helper $count
19852 run_test 300s "test lfs mkdir -c without -i"
19855 prepare_remote_file() {
19856 mkdir $DIR/$tdir/src_dir ||
19857 error "create remote source failed"
19859 cp /etc/hosts $DIR/$tdir/src_dir/a ||
19860 error "cp to remote source failed"
19861 touch $DIR/$tdir/src_dir/a
19863 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
19864 error "create remote target dir failed"
19866 touch $DIR/$tdir/tgt_dir/b
19868 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
19869 error "rename dir cross MDT failed!"
19871 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
19872 error "src_child still exists after rename"
19874 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
19875 error "missing file(a) after rename"
19877 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
19878 error "diff after rename"
19882 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19883 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19885 local remote_file=$DIR/$tdir/tgt_dir/b
19887 mkdir -p $DIR/$tdir
19889 prepare_remote_file || error "prepare remote file failed"
19892 $OPENUNLINK $remote_file $remote_file ||
19893 error "openunlink $remote_file failed"
19894 $CHECKSTAT -a $remote_file || error "$remote_file exists"
19896 run_test 310a "open unlink remote file"
19899 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19900 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19902 local remote_file=$DIR/$tdir/tgt_dir/b
19904 mkdir -p $DIR/$tdir
19906 prepare_remote_file || error "prepare remote file failed"
19908 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19909 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
19910 $CHECKSTAT -t file $remote_file || error "check file failed"
19912 run_test 310b "unlink remote file with multiple links while open"
19915 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19916 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
19918 local remote_file=$DIR/$tdir/tgt_dir/b
19920 mkdir -p $DIR/$tdir
19922 prepare_remote_file || error "prepare remote file failed"
19924 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19925 multiop_bg_pause $remote_file O_uc ||
19926 error "mulitop failed for remote file"
19928 $MULTIOP $DIR/$tfile Ouc
19929 kill -USR1 $MULTIPID
19932 run_test 310c "open-unlink remote file with multiple links"
19936 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19937 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19938 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
19939 skip "lustre < 2.8.54 does not contain LU-4825 fix"
19940 remote_mds_nodsh && skip "remote MDS with nodsh"
19942 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19943 local mdts=$(comma_list $(mdts_nodes))
19945 mkdir -p $DIR/$tdir
19946 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
19947 createmany -o $DIR/$tdir/$tfile. 1000
19949 # statfs data is not real time, let's just calculate it
19950 old_iused=$((old_iused + 1000))
19952 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19953 osp.*OST0000*MDT0000.create_count")
19954 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19955 osp.*OST0000*MDT0000.max_create_count")
19956 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
19958 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
19959 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
19960 [ $index -ne 0 ] || error "$tfile stripe index is 0"
19962 unlinkmany $DIR/$tdir/$tfile. 1000
19964 do_nodes $mdts "$LCTL set_param -n \
19965 osp.*OST0000*.max_create_count=$max_count"
19966 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
19967 do_nodes $mdts "$LCTL set_param -n \
19968 osp.*OST0000*.create_count=$count"
19969 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
19970 grep "=0" && error "create_count is zero"
19973 for i in $(seq 120); do
19974 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19975 # system may be too busy to destroy all objs in time, use
19976 # a somewhat small value to not fail autotest
19977 [ $((old_iused - new_iused)) -gt 400 ] && break
19981 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
19982 [ $((old_iused - new_iused)) -gt 400 ] ||
19983 error "objs not destroyed after unlink"
19985 run_test 311 "disable OSP precreate, and unlink should destroy objs"
19992 local vdevdir=$(dirname $(facet_vdevice $ost))
19993 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
19994 local zfs_zapid=$(do_facet $ost $cmd |
19995 grep -w "/O/0/d$((objid%32))" -C 5 |
19996 awk '/Object/{getline; print $1}')
19997 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
19998 awk "/$objid = /"'{printf $3}')
20003 zfs_object_blksz() {
20007 local vdevdir=$(dirname $(facet_vdevice $ost))
20008 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
20009 local blksz=$(do_facet $ost $cmd $objid |
20010 awk '/dblk/{getline; printf $4}')
20012 case "${blksz: -1}" in
20013 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
20014 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
20021 test_312() { # LU-4856
20022 remote_ost_nodsh && skip "remote OST with nodsh"
20023 [ "$ost1_FSTYPE" = "zfs" ] ||
20024 skip_env "the test only applies to zfs"
20026 local max_blksz=$(do_facet ost1 \
20027 $ZFS get -p recordsize $(facet_device ost1) |
20028 awk '!/VALUE/{print $3}')
20030 # to make life a little bit easier
20031 $LFS mkdir -c 1 -i 0 $DIR/$tdir
20032 $LFS setstripe -c 1 -i 0 $DIR/$tdir
20034 local tf=$DIR/$tdir/$tfile
20036 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
20038 # Get ZFS object id
20039 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
20040 # block size change by sequential overwrite
20043 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
20044 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
20046 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
20047 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
20051 # block size change by sequential append write
20052 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
20053 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
20054 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
20057 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
20058 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
20059 oflag=sync conv=notrunc
20061 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20062 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
20063 error "blksz error, actual $blksz, " \
20064 "expected: 2 * $count * $PAGE_SIZE"
20070 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
20071 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
20073 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
20074 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20075 [ $blksz -eq $PAGE_SIZE ] ||
20076 error "blksz error: $blksz, expected: $PAGE_SIZE"
20078 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
20079 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20080 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
20082 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
20083 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20084 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
20086 run_test 312 "make sure ZFS adjusts its block size by write pattern"
20089 remote_ost_nodsh && skip "remote OST with nodsh"
20091 local file=$DIR/$tfile
20094 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
20096 # define OBD_FAIL_TGT_RCVD_EIO 0x720
20097 do_facet ost1 "$LCTL set_param fail_loc=0x720"
20098 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
20099 error "write should failed"
20100 do_facet ost1 "$LCTL set_param fail_loc=0"
20103 run_test 313 "io should fail after last_rcvd update fail"
20106 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
20108 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
20109 do_facet ost1 "$LCTL set_param fail_loc=0x720"
20111 wait_delete_completed
20112 do_facet ost1 "$LCTL set_param fail_loc=0"
20114 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
20116 test_315() { # LU-618
20117 local file=$DIR/$tfile
20120 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
20121 error "multiop file write failed"
20122 $MULTIOP $file oO_RDONLY:r4063232_c &
20127 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
20130 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
20133 run_test 315 "read should be accounted"
20136 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20137 large_xattr_enabled || skip_env "ea_inode feature disabled"
20139 rm -rf $DIR/$tdir/d
20140 mkdir -p $DIR/$tdir/d
20141 chown nobody $DIR/$tdir/d
20142 touch $DIR/$tdir/d/file
20144 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
20146 run_test 316 "lfs mv"
20149 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
20150 skip "Need MDS version at least 2.11.53"
20151 if [ "$ost1_FSTYPE" == "zfs" ]; then
20152 skip "LU-10370: no implementation for ZFS"
20156 local grant_blk_size
20158 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
20159 awk '/grant_block_size:/ { print $2; exit; }')
20161 # Create File of size 5M. Truncate it to below size's and verify
20164 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
20165 error "Create file $DIR/$tfile failed"
20166 stack_trap "rm -f $DIR/$tfile" EXIT
20168 for trunc_sz in 2097152 4097 4000 509 0; do
20169 $TRUNCATE $DIR/$tfile $trunc_sz ||
20170 error "truncate $tfile to $trunc_sz failed"
20171 local sz=$(stat --format=%s $DIR/$tfile)
20172 local blk=$(stat --format=%b $DIR/$tfile)
20173 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
20174 grant_blk_size) * 8))
20176 if [[ $blk -ne $trunc_blk ]]; then
20177 $(which stat) $DIR/$tfile
20178 error "Expected Block $trunc_blk got $blk for $tfile"
20181 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20182 error "Expected Size $trunc_sz got $sz for $tfile"
20187 # Create file with a hole and write actual two blocks. Block count
20190 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
20191 conv=fsync || error "Create file : $DIR/$tfile"
20193 # Calculate the final truncate size.
20194 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
20197 # truncate to size $trunc_sz bytes. Strip the last block
20198 # The block count must drop to 8
20200 $TRUNCATE $DIR/$tfile $trunc_sz ||
20201 error "truncate $tfile to $trunc_sz failed"
20203 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
20204 sz=$(stat --format=%s $DIR/$tfile)
20205 blk=$(stat --format=%b $DIR/$tfile)
20207 if [[ $blk -ne $trunc_bsz ]]; then
20208 $(which stat) $DIR/$tfile
20209 error "Expected Block $trunc_bsz got $blk for $tfile"
20212 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20213 error "Expected Size $trunc_sz got $sz for $tfile"
20215 run_test 317 "Verify blocks get correctly update after truncate"
20218 local read_write=$1
20219 if [ "$read_write" = "write" ]; then
20220 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
20221 elif [ "$read_write" = "read" ]; then
20222 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
20224 error "argument error"
20227 # turn off debug for performance testing
20228 local saved_debug=$($LCTL get_param -n debug)
20229 $LCTL set_param debug=0
20231 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
20233 # get ost1 size - lustre-OST0000
20234 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
20235 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
20236 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
20238 if [ "$read_write" = "read" ]; then
20239 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
20242 local start_time=$(date +%s.%N)
20243 $dd_cmd bs=1M count=$blocks oflag=sync ||
20244 error "real dd $read_write error"
20245 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
20247 if [ "$read_write" = "write" ]; then
20251 # define OBD_FAIL_OST_FAKE_RW 0x238
20252 do_facet ost1 $LCTL set_param fail_loc=0x238
20254 local start_time=$(date +%s.%N)
20255 $dd_cmd bs=1M count=$blocks oflag=sync ||
20256 error "fake dd $read_write error"
20257 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
20259 if [ "$read_write" = "write" ]; then
20261 cancel_lru_locks osc
20262 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
20263 error "$tfile size not $blocks MB"
20265 do_facet ost1 $LCTL set_param fail_loc=0
20267 echo "fake $read_write $duration_fake vs. normal $read_write" \
20268 "$duration in seconds"
20269 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
20270 error_not_in_vm "fake write is slower"
20272 $LCTL set_param -n debug="$saved_debug"
20275 test_399a() { # LU-7655 for OST fake write
20276 remote_ost_nodsh && skip "remote OST with nodsh"
20280 run_test 399a "fake write should not be slower than normal write"
20282 test_399b() { # LU-8726 for OST fake read
20283 remote_ost_nodsh && skip "remote OST with nodsh"
20284 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
20285 skip_env "ldiskfs only test"
20290 run_test 399b "fake read should not be slower than normal read"
20292 test_400a() { # LU-1606, was conf-sanity test_74
20293 if ! which $CC > /dev/null 2>&1; then
20294 skip_env "$CC is not installed"
20297 local extra_flags=''
20298 local out=$TMP/$tfile
20299 local prefix=/usr/include/lustre
20302 # Oleg removes c files in his test rig so test if any c files exist
20303 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
20304 skip_env "Needed c test files are missing"
20306 if ! [[ -d $prefix ]]; then
20307 # Assume we're running in tree and fixup the include path.
20308 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
20309 extra_flags+=" -L$LUSTRE/utils/.lib"
20312 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
20313 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
20314 error "client api broken"
20318 run_test 400a "Lustre client api program can compile and link"
20320 test_400b() { # LU-1606, LU-5011
20322 local out=$TMP/$tfile
20323 local prefix=/usr/include/linux/lustre
20325 # We use a hard coded prefix so that this test will not fail
20326 # when run in tree. There are headers in lustre/include/lustre/
20327 # that are not packaged (like lustre_idl.h) and have more
20328 # complicated include dependencies (like config.h and lnet/types.h).
20329 # Since this test about correct packaging we just skip them when
20330 # they don't exist (see below) rather than try to fixup cppflags.
20332 if ! which $CC > /dev/null 2>&1; then
20333 skip_env "$CC is not installed"
20336 for header in $prefix/*.h; do
20337 if ! [[ -f "$header" ]]; then
20341 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
20342 continue # lustre_ioctl.h is internal header
20345 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
20346 error "cannot compile '$header'"
20350 run_test 400b "packaged headers can be compiled"
20352 test_401a() { #LU-7437
20353 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
20354 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
20356 #count the number of parameters by "list_param -R"
20357 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
20358 #count the number of parameters by listing proc files
20359 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
20360 echo "proc_dirs='$proc_dirs'"
20361 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
20362 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
20365 [ $params -eq $procs ] ||
20366 error "found $params parameters vs. $procs proc files"
20368 # test the list_param -D option only returns directories
20369 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
20370 #count the number of parameters by listing proc directories
20371 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
20374 [ $params -eq $procs ] ||
20375 error "found $params parameters vs. $procs proc files"
20377 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
20380 local save=$($LCTL get_param -n jobid_var)
20383 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
20384 error "no error returned when setting bad parameters"
20386 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
20387 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
20389 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
20390 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
20391 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
20393 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
20396 local jobid_var_old=$($LCTL get_param -n jobid_var)
20397 local jobid_var_new
20399 $LCTL set_param jobid_var= &&
20400 error "no error returned for 'set_param a='"
20402 jobid_var_new=$($LCTL get_param -n jobid_var)
20403 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20404 error "jobid_var was changed by setting without value"
20406 $LCTL set_param jobid_var &&
20407 error "no error returned for 'set_param a'"
20409 jobid_var_new=$($LCTL get_param -n jobid_var)
20410 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20411 error "jobid_var was changed by setting without value"
20413 run_test 401c "Verify 'lctl set_param' without value fails in either format."
20416 local jobid_var_old=$($LCTL get_param -n jobid_var)
20417 local jobid_var_new
20418 local new_value="foo=bar"
20420 $LCTL set_param jobid_var=$new_value ||
20421 error "'set_param a=b' did not accept a value containing '='"
20423 jobid_var_new=$($LCTL get_param -n jobid_var)
20424 [[ "$jobid_var_new" == "$new_value" ]] ||
20425 error "'set_param a=b' failed on a value containing '='"
20427 # Reset the jobid_var to test the other format
20428 $LCTL set_param jobid_var=$jobid_var_old
20429 jobid_var_new=$($LCTL get_param -n jobid_var)
20430 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20431 error "failed to reset jobid_var"
20433 $LCTL set_param jobid_var $new_value ||
20434 error "'set_param a b' did not accept a value containing '='"
20436 jobid_var_new=$($LCTL get_param -n jobid_var)
20437 [[ "$jobid_var_new" == "$new_value" ]] ||
20438 error "'set_param a b' failed on a value containing '='"
20440 $LCTL set_param jobid_var $jobid_var_old
20441 jobid_var_new=$($LCTL get_param -n jobid_var)
20442 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20443 error "failed to reset jobid_var"
20445 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
20448 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
20449 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
20450 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
20451 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
20452 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
20453 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
20454 remote_mds_nodsh && skip "remote MDS with nodsh"
20456 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
20457 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
20458 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
20459 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
20460 echo "Touch failed - OK"
20462 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
20465 local file1=$DIR/$tfile.1
20466 local file2=$DIR/$tfile.2
20467 local tfile=$TMP/$tfile
20469 rm -f $file1 $file2 $tfile
20474 # 30 sec OBD_TIMEOUT in ll_getattr()
20475 # right before populating st_nlink
20476 $LCTL set_param fail_loc=0x80001409
20477 stat -c %h $file1 > $tfile &
20479 # create an alias, drop all locks and reclaim the dentry
20481 cancel_lru_locks mdc
20482 cancel_lru_locks osc
20483 sysctl -w vm.drop_caches=2
20487 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
20489 rm -f $tfile $file1 $file2
20491 run_test 403 "i_nlink should not drop to zero due to aliasing"
20493 test_404() { # LU-6601
20494 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
20495 skip "Need server version newer than 2.8.52"
20496 remote_mds_nodsh && skip "remote MDS with nodsh"
20498 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
20499 awk '/osp .*-osc-MDT/ { print $4}')
20502 for osp in $mosps; do
20503 echo "Deactivate: " $osp
20504 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
20505 local stat=$(do_facet $SINGLEMDS $LCTL dl |
20506 awk -vp=$osp '$4 == p { print $2 }')
20507 [ $stat = IN ] || {
20508 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
20509 error "deactivate error"
20511 echo "Activate: " $osp
20512 do_facet $SINGLEMDS $LCTL --device %$osp activate
20513 local stat=$(do_facet $SINGLEMDS $LCTL dl |
20514 awk -vp=$osp '$4 == p { print $2 }')
20515 [ $stat = UP ] || {
20516 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
20517 error "activate error"
20521 run_test 404 "validate manual {de}activated works properly for OSPs"
20524 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
20525 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
20526 skip "Layout swap lock is not supported"
20528 check_swap_layouts_support
20530 test_mkdir $DIR/$tdir
20531 swap_lock_test -d $DIR/$tdir ||
20532 error "One layout swap locked test failed"
20534 run_test 405 "Various layout swap lock tests"
20537 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20538 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
20539 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
20540 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20541 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
20542 skip "Need MDS version at least 2.8.50"
20544 local def_stripe_size=$($LFS getstripe -S $MOUNT)
20545 local test_pool=$TESTNAME
20547 pool_add $test_pool || error "pool_add failed"
20548 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
20549 error "pool_add_targets failed"
20551 save_layout_restore_at_exit $MOUNT
20553 # parent set default stripe count only, child will stripe from both
20554 # parent and fs default
20555 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
20556 error "setstripe $MOUNT failed"
20557 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
20558 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
20559 for i in $(seq 10); do
20560 local f=$DIR/$tdir/$tfile.$i
20561 touch $f || error "touch failed"
20562 local count=$($LFS getstripe -c $f)
20563 [ $count -eq $OSTCOUNT ] ||
20564 error "$f stripe count $count != $OSTCOUNT"
20565 local offset=$($LFS getstripe -i $f)
20566 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
20567 local size=$($LFS getstripe -S $f)
20568 [ $size -eq $((def_stripe_size * 2)) ] ||
20569 error "$f stripe size $size != $((def_stripe_size * 2))"
20570 local pool=$($LFS getstripe -p $f)
20571 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
20574 # change fs default striping, delete parent default striping, now child
20575 # will stripe from new fs default striping only
20576 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
20577 error "change $MOUNT default stripe failed"
20578 $LFS setstripe -c 0 $DIR/$tdir ||
20579 error "delete $tdir default stripe failed"
20580 for i in $(seq 11 20); do
20581 local f=$DIR/$tdir/$tfile.$i
20582 touch $f || error "touch $f failed"
20583 local count=$($LFS getstripe -c $f)
20584 [ $count -eq 1 ] || error "$f stripe count $count != 1"
20585 local offset=$($LFS getstripe -i $f)
20586 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
20587 local size=$($LFS getstripe -S $f)
20588 [ $size -eq $def_stripe_size ] ||
20589 error "$f stripe size $size != $def_stripe_size"
20590 local pool=$($LFS getstripe -p $f)
20591 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
20594 unlinkmany $DIR/$tdir/$tfile. 1 20
20596 local f=$DIR/$tdir/$tfile
20597 pool_remove_all_targets $test_pool $f
20598 pool_remove $test_pool $f
20600 run_test 406 "DNE support fs default striping"
20603 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20604 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
20605 skip "Need MDS version at least 2.8.55"
20606 remote_mds_nodsh && skip "remote MDS with nodsh"
20608 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
20609 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
20610 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
20611 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
20612 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
20614 #define OBD_FAIL_DT_TXN_STOP 0x2019
20615 for idx in $(seq $MDSCOUNT); do
20616 do_facet mds$idx "lctl set_param fail_loc=0x2019"
20618 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
20619 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
20620 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
20623 run_test 407 "transaction fail should cause operation fail"
20626 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
20628 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
20629 lctl set_param fail_loc=0x8000040a
20630 # let ll_prepare_partial_page() fail
20631 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
20635 # create at least 100 unused inodes so that
20636 # shrink_icache_memory(0) should not return 0
20637 touch $DIR/$tfile-{0..100}
20638 rm -f $DIR/$tfile-{0..100}
20641 echo 2 > /proc/sys/vm/drop_caches
20643 run_test 408 "drop_caches should not hang due to page leaks"
20647 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20648 check_mount_and_prep
20650 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
20651 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
20652 touch $DIR/$tdir/guard || error "(2) Fail to create"
20654 local PREFIX=$(str_repeat 'A' 128)
20655 echo "Create 1K hard links start at $(date)"
20656 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20657 error "(3) Fail to hard link"
20659 echo "Links count should be right although linkEA overflow"
20660 stat $DIR/$tdir/guard || error "(4) Fail to stat"
20661 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
20662 [ $linkcount -eq 1001 ] ||
20663 error "(5) Unexpected hard links count: $linkcount"
20665 echo "List all links start at $(date)"
20666 ls -l $DIR/$tdir/foo > /dev/null ||
20667 error "(6) Fail to list $DIR/$tdir/foo"
20669 echo "Unlink hard links start at $(date)"
20670 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20671 error "(7) Fail to unlink"
20673 run_test 409 "Large amount of cross-MDTs hard links on the same file"
20677 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
20678 skip "Need client version at least 2.9.59"
20680 # Create a file, and stat it from the kernel
20681 local testfile=$DIR/$tfile
20684 local run_id=$RANDOM
20685 local my_ino=$(stat --format "%i" $testfile)
20687 # Try to insert the module. This will always fail as the
20688 # module is designed to not be inserted.
20689 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
20692 # Anything but success is a test failure
20694 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
20695 error "no inode match"
20697 run_test 410 "Test inode number returned from kernel thread"
20699 cleanup_test411_cgroup() {
20705 local cg_basedir=/sys/fs/cgroup/memory
20707 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
20708 skip "no setup for cgroup"
20710 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
20711 error "test file creation failed"
20712 cancel_lru_locks osc
20714 # Create a very small memory cgroup to force a slab allocation error
20715 local cgdir=$cg_basedir/osc_slab_alloc
20716 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
20717 trap "cleanup_test411_cgroup $cgdir" EXIT
20718 echo 2M > $cgdir/memory.kmem.limit_in_bytes
20719 echo 1M > $cgdir/memory.limit_in_bytes
20721 # Should not LBUG, just be killed by oom-killer
20722 # dd will return 0 even allocation failure in some environment.
20723 # So don't check return value
20724 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
20725 cleanup_test411_cgroup $cgdir
20729 run_test 411 "Slab allocation error with cgroup does not LBUG"
20732 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20733 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20734 skip "Need server version at least 2.10.55"
20737 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
20738 error "mkdir failed"
20739 $LFS getdirstripe $DIR/$tdir
20740 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20741 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
20742 error "expect $((MDSCOUT - 1)) get $stripe_index"
20743 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
20744 [ $stripe_count -eq 2 ] ||
20745 error "expect 2 get $stripe_count"
20747 run_test 412 "mkdir on specific MDTs"
20750 [ $MDSCOUNT -lt 2 ] &&
20751 skip "We need at least 2 MDTs for this test"
20753 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20754 skip "Need server version at least 2.10.55"
20757 mkdir $DIR/$tdir || error "mkdir failed"
20759 # find MDT that is the most full
20760 local max=$($LFS df | grep MDT |
20769 END { split(b, c, ":")
20774 for i in $(seq $((MDSCOUNT - 1))); do
20775 $LFS mkdir -c $i $DIR/$tdir/d$i ||
20776 error "mkdir d$i failed"
20777 $LFS getdirstripe $DIR/$tdir/d$i
20778 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
20779 [ $stripe_index -ne $max ] ||
20780 error "don't expect $max"
20783 run_test 413 "mkdir on less full MDTs"
20786 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
20787 $LCTL set_param fail_loc=0x80000521
20788 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
20791 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
20794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20795 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
20796 skip "Need server version at least 2.11.52"
20806 # this test may be slow on ZFS
20807 [ "$mds1_FSTYPE" == "zfs" ] && total=100
20809 # though this test is designed for striped directory, let's test normal
20810 # directory too since lock is always saved as CoS lock.
20811 test_mkdir $DIR/$tdir || error "mkdir $tdir"
20812 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
20821 start_time=$(date +%s)
20822 for i in $(seq $total); do
20823 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
20826 end_time=$(date +%s)
20827 duration=$((end_time - start_time))
20829 kill -9 $setattr_pid
20831 echo "rename $total files took $duration sec"
20832 [ $duration -lt 100 ] || error "rename took $duration sec"
20834 run_test 415 "lock revoke is not missing"
20837 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
20838 skip "Need server version at least 2.11.55"
20840 # define OBD_FAIL_OSD_TXN_START 0x19a
20841 do_facet mds1 lctl set_param fail_loc=0x19a
20843 lfs mkdir -c $MDSCOUNT $DIR/$tdir
20847 run_test 416 "transaction start failure won't cause system hung"
20851 do_nodes $(comma_list $(mdts_nodes)) \
20852 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
20853 do_nodes $(comma_list $(mdts_nodes)) \
20854 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
20855 do_nodes $(comma_list $(mdts_nodes)) \
20856 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
20860 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20861 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
20862 skip "Need MDS version at least 2.11.56"
20864 trap cleanup_417 RETURN EXIT
20866 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
20867 do_nodes $(comma_list $(mdts_nodes)) \
20868 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
20869 $LFS migrate -m 0 $DIR/$tdir.1 &&
20870 error "migrate dir $tdir.1 should fail"
20872 do_nodes $(comma_list $(mdts_nodes)) \
20873 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
20874 $LFS mkdir -i 1 $DIR/$tdir.2 &&
20875 error "create remote dir $tdir.2 should fail"
20877 do_nodes $(comma_list $(mdts_nodes)) \
20878 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
20879 $LFS mkdir -c 2 $DIR/$tdir.3 &&
20880 error "create striped dir $tdir.3 should fail"
20883 run_test 417 "disable remote dir, striped dir and dir migration"
20885 # Checks that the outputs of df [-i] and lfs df [-i] match
20887 # usage: check_lfs_df <blocks | inodes> <mountpoint>
20897 [ "$1" == "blocks" ] && inodes= || inodes="-i"
20899 for count in {1..100}; do
20903 # read the lines of interest
20904 df_out=($(df -P $inodes $dir | tail -n +2)) ||
20905 error "df $inodes $dir | tail -n +2 failed"
20906 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
20907 error "lfs df $inodes $dir | grep summary: failed"
20909 # skip first substrings of each output as they are different
20910 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
20911 # compare the remaining fields of the two outputs
20913 for i in {1..5}; do
20914 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
20922 lfs df $inodes $dir
20923 error "df and lfs df $1 output mismatch: " \
20924 "df ${inodes}: ${df_out[*]}, " \
20925 "lfs df ${inodes}: ${lfs_df_out[*]}"
20930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20932 local dir=$DIR/$tdir
20933 local numfiles=$((RANDOM % 4096 + 2))
20934 local numblocks=$((RANDOM % 256 + 1))
20936 wait_delete_completed
20939 # check block output
20940 check_lfs_df blocks $dir
20941 # check inode output
20942 check_lfs_df inodes $dir
20944 # create a single file and retest
20945 echo "Creating a single file and testing"
20946 createmany -o $dir/$tfile- 1 &>/dev/null ||
20947 error "creating 1 file in $dir failed"
20948 check_lfs_df blocks $dir
20949 check_lfs_df inodes $dir
20951 # create a random number of files
20952 echo "Creating $((numfiles - 1)) files and testing"
20953 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
20954 error "creating $((numfiles - 1)) files in $dir failed"
20956 # write a random number of blocks to the first test file
20957 echo "Writing $numblocks 4K blocks and testing"
20958 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
20959 count=$numblocks &>/dev/null ||
20960 error "dd to $dir/${tfile}-0 failed"
20963 check_lfs_df blocks $dir
20964 check_lfs_df inodes $dir
20966 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
20967 error "unlinking $numfiles files in $dir failed"
20969 run_test 418 "df and lfs df outputs match"
20973 local dir=$DIR/$tdir
20978 cancel_lru_locks mdc
20980 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
20981 $LCTL set_param fail_loc=0x1410
20983 $LCTL set_param fail_loc=0
20986 run_test 419 "Verify open file by name doesn't crash kernel"
20990 [[ $MDS1_VERSION -ge $(version_code 2.12.1) ]] ||
20991 skip "Need MDS version at least 2.12.1"
20993 local SAVE_UMASK=$(umask)
20994 local dir=$DIR/$tdir
20995 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
20999 mkdir -m03777 $dir/testdir
21000 ls -dn $dir/testdir
21001 # Need to remove trailing '.' when SELinux is enabled
21002 local dirperms=$(ls -dn $dir/testdir |
21003 awk '{ sub(/\.$/, "", $1); print $1}')
21004 [ $dirperms == "drwxrwsrwt" ] ||
21005 error "incorrect perms on $dir/testdir"
21007 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
21008 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
21009 ls -n $dir/testdir/testfile
21010 local fileperms=$(ls -n $dir/testdir/testfile |
21011 awk '{ sub(/\.$/, "", $1); print $1}')
21012 [ $fileperms == "-rwxr-xr-x" ] ||
21013 error "incorrect perms on $dir/testdir/testfile"
21017 run_test 420 "clear SGID bit on non-directories for non-members"
21024 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21025 skip "Need MDS version at least 2.12.2"
21027 test_mkdir $DIR/$tdir
21028 createmany -o $DIR/$tdir/f 3
21029 cnt=$(ls -1 $DIR/$tdir | wc -l)
21030 [ $cnt != 3 ] && error "unexpected #files: $cnt"
21032 fid1=$(lfs path2fid $DIR/$tdir/f1)
21033 fid2=$(lfs path2fid $DIR/$tdir/f2)
21034 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
21036 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
21037 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
21039 cnt=$(ls -1 $DIR/$tdir | wc -l)
21040 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
21042 rm -f $DIR/$tdir/f3 || error "can't remove f3"
21043 createmany -o $DIR/$tdir/f 3
21044 cnt=$(ls -1 $DIR/$tdir | wc -l)
21045 [ $cnt != 3 ] && error "unexpected #files: $cnt"
21047 fid1=$(lfs path2fid $DIR/$tdir/f1)
21048 fid2=$(lfs path2fid $DIR/$tdir/f2)
21049 echo "remove using fsname $FSNAME"
21050 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
21052 cnt=$(ls -1 $DIR/$tdir | wc -l)
21053 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
21055 run_test 421a "simple rm by fid"
21062 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21063 skip "Need MDS version at least 2.12.2"
21065 test_mkdir $DIR/$tdir
21066 createmany -o $DIR/$tdir/f 3
21067 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
21070 FID1=$(lfs path2fid $DIR/$tdir/f1)
21071 FID2=$(lfs path2fid $DIR/$tdir/f2)
21072 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
21074 kill -USR1 $MULTIPID
21077 cnt=$(ls $DIR/$tdir | wc -l)
21078 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
21080 run_test 421b "rm by fid on open file"
21086 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21087 skip "Need MDS version at least 2.12.2"
21089 test_mkdir $DIR/$tdir
21090 createmany -o $DIR/$tdir/f 3
21091 touch $DIR/$tdir/$tfile
21092 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
21093 cnt=$(ls -1 $DIR/$tdir | wc -l)
21094 [ $cnt != 184 ] && error "unexpected #files: $cnt"
21096 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
21097 $LFS rmfid $DIR $FID1 || error "rmfid failed"
21099 cnt=$(ls $DIR/$tdir | wc -l)
21100 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
21102 run_test 421c "rm by fid against hardlinked files"
21108 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21109 skip "Need MDS version at least 2.12.2"
21111 test_mkdir $DIR/$tdir
21112 createmany -o $DIR/$tdir/f 4097
21113 cnt=$(ls -1 $DIR/$tdir | wc -l)
21114 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
21116 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
21117 $LFS rmfid $DIR $FIDS || error "rmfid failed"
21119 cnt=$(ls $DIR/$tdir | wc -l)
21121 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21123 run_test 421d "rmfid en masse"
21129 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21130 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21131 skip "Need MDS version at least 2.12.2"
21133 mkdir -p $DIR/$tdir
21134 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
21135 createmany -o $DIR/$tdir/striped_dir/f 512
21136 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21137 [ $cnt != 512 ] && error "unexpected #files: $cnt"
21139 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
21140 sed "s/[/][^:]*://g")
21141 $LFS rmfid $DIR $FIDS || error "rmfid failed"
21143 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21145 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21147 run_test 421e "rmfid in DNE"
21153 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21154 skip "Need MDS version at least 2.12.2"
21156 test_mkdir $DIR/$tdir
21158 cnt=$(ls -1 $DIR/$tdir | wc -l)
21159 [ $cnt != 1 ] && error "unexpected #files: $cnt"
21161 FID=$(lfs path2fid $DIR/$tdir/f)
21162 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
21163 # rmfid should fail
21164 cnt=$(ls -1 $DIR/$tdir | wc -l)
21165 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
21167 chmod a+rw $DIR/$tdir
21169 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
21170 # rmfid should fail
21171 cnt=$(ls -1 $DIR/$tdir | wc -l)
21172 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
21175 $RUNAS touch $DIR/$tdir/f
21176 FID=$(lfs path2fid $DIR/$tdir/f)
21177 echo "rmfid as root"
21178 $LFS rmfid $DIR $FID || error "rmfid as root failed"
21179 cnt=$(ls -1 $DIR/$tdir | wc -l)
21180 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
21183 $RUNAS touch $DIR/$tdir/f
21184 cnt=$(ls -1 $DIR/$tdir | wc -l)
21185 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
21186 FID=$(lfs path2fid $DIR/$tdir/f)
21187 # rmfid w/o user_fid2path mount option should fail
21188 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
21189 cnt=$(ls -1 $DIR/$tdir | wc -l)
21190 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
21192 umount_client $MOUNT || error "failed to umount client"
21193 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
21194 error "failed to mount client'"
21196 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
21197 # rmfid should succeed
21198 cnt=$(ls -1 $DIR/$tdir | wc -l)
21199 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
21201 # rmfid shouldn't allow to remove files due to dir's permission
21202 chmod a+rwx $DIR/$tdir
21205 FID=$(lfs path2fid $DIR/$tdir/f)
21206 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
21208 umount_client $MOUNT || error "failed to umount client"
21209 mount_client $MOUNT "$MOUNT_OPTS" ||
21210 error "failed to mount client'"
21213 run_test 421f "rmfid checks permissions"
21219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21220 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21221 skip "Need MDS version at least 2.12.2"
21223 mkdir -p $DIR/$tdir
21224 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
21225 createmany -o $DIR/$tdir/striped_dir/f 512
21226 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21227 [ $cnt != 512 ] && error "unexpected #files: $cnt"
21229 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
21230 sed "s/[/][^:]*://g")
21232 rm -f $DIR/$tdir/striped_dir/f1*
21233 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21234 removed=$((512 - cnt))
21236 # few files have been just removed, so we expect
21237 # rmfid to fail on their fids
21238 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
21239 [ $removed != $errors ] && error "$errors != $removed"
21241 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21243 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21245 run_test 421g "rmfid to return errors properly"
21258 # ensure statfs cache is expired
21261 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
21262 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
21266 run_test 423 "statfs should return a right data"
21269 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21270 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
21271 skip "Need server version at least 2.9.55"
21273 start_full_debug_logging
21277 stop_full_debug_logging
21281 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
21282 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
21283 awk '/The barrier for/ { print $7 }')
21286 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
21291 barrier_expired() {
21294 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
21295 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
21296 awk '/will be expired/ { print $7 }')
21298 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
21307 echo "Start barrier_freeze at: $(date)"
21308 #define OBD_FAIL_BARRIER_DELAY 0x2202
21309 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
21310 # Do not reduce barrier time - See LU-11873
21311 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
21314 local b_status=$(barrier_stat)
21315 echo "Got barrier status at: $(date)"
21316 [ "$b_status" = "'freezing_p1'" ] ||
21317 error "(1) unexpected barrier status $b_status"
21319 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
21321 b_status=$(barrier_stat)
21322 [ "$b_status" = "'frozen'" ] ||
21323 error "(2) unexpected barrier status $b_status"
21325 local expired=$(barrier_expired)
21326 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
21327 sleep $((expired + 3))
21329 b_status=$(barrier_stat)
21330 [ "$b_status" = "'expired'" ] ||
21331 error "(3) unexpected barrier status $b_status"
21333 # Do not reduce barrier time - See LU-11873
21334 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
21335 error "(4) fail to freeze barrier"
21337 b_status=$(barrier_stat)
21338 [ "$b_status" = "'frozen'" ] ||
21339 error "(5) unexpected barrier status $b_status"
21341 echo "Start barrier_thaw at: $(date)"
21342 #define OBD_FAIL_BARRIER_DELAY 0x2202
21343 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
21344 do_facet mgs $LCTL barrier_thaw $FSNAME &
21347 b_status=$(barrier_stat)
21348 echo "Got barrier status at: $(date)"
21349 [ "$b_status" = "'thawing'" ] ||
21350 error "(6) unexpected barrier status $b_status"
21352 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
21354 b_status=$(barrier_stat)
21355 [ "$b_status" = "'thawed'" ] ||
21356 error "(7) unexpected barrier status $b_status"
21358 #define OBD_FAIL_BARRIER_FAILURE 0x2203
21359 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
21360 do_facet mgs $LCTL barrier_freeze $FSNAME
21362 b_status=$(barrier_stat)
21363 [ "$b_status" = "'failed'" ] ||
21364 error "(8) unexpected barrier status $b_status"
21366 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21367 do_facet mgs $LCTL barrier_thaw $FSNAME
21371 run_test 801a "write barrier user interfaces and stat machine"
21376 mkdir $DIR/$tdir || error "(1) fail to mkdir"
21377 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
21378 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
21379 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
21380 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
21382 cancel_lru_locks mdc
21384 # 180 seconds should be long enough
21385 do_facet mgs $LCTL barrier_freeze $FSNAME 180
21387 local b_status=$(barrier_stat)
21388 [ "$b_status" = "'frozen'" ] ||
21389 error "(6) unexpected barrier status $b_status"
21391 mkdir $DIR/$tdir/d0/d10 &
21394 touch $DIR/$tdir/d1/f13 &
21397 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
21400 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
21403 rm -f $DIR/$tdir/d4/f12 &
21406 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
21408 # To guarantee taht the 'stat' is not blocked
21409 b_status=$(barrier_stat)
21410 [ "$b_status" = "'frozen'" ] ||
21411 error "(8) unexpected barrier status $b_status"
21413 # let above commands to run at background
21416 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
21417 ps -p $touch_pid || error "(10) touch should be blocked"
21418 ps -p $ln_pid || error "(11) link should be blocked"
21419 ps -p $mv_pid || error "(12) rename should be blocked"
21420 ps -p $rm_pid || error "(13) unlink should be blocked"
21422 b_status=$(barrier_stat)
21423 [ "$b_status" = "'frozen'" ] ||
21424 error "(14) unexpected barrier status $b_status"
21426 do_facet mgs $LCTL barrier_thaw $FSNAME
21427 b_status=$(barrier_stat)
21428 [ "$b_status" = "'thawed'" ] ||
21429 error "(15) unexpected barrier status $b_status"
21431 wait $mkdir_pid || error "(16) mkdir should succeed"
21432 wait $touch_pid || error "(17) touch should succeed"
21433 wait $ln_pid || error "(18) link should succeed"
21434 wait $mv_pid || error "(19) rename should succeed"
21435 wait $rm_pid || error "(20) unlink should succeed"
21439 run_test 801b "modification will be blocked by write barrier"
21442 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21446 stop mds2 || error "(1) Fail to stop mds2"
21448 do_facet mgs $LCTL barrier_freeze $FSNAME 30
21450 local b_status=$(barrier_stat)
21451 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
21452 do_facet mgs $LCTL barrier_thaw $FSNAME
21453 error "(2) unexpected barrier status $b_status"
21456 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21457 error "(3) Fail to rescan barrier bitmap"
21459 # Do not reduce barrier time - See LU-11873
21460 do_facet mgs $LCTL barrier_freeze $FSNAME 20
21462 b_status=$(barrier_stat)
21463 [ "$b_status" = "'frozen'" ] ||
21464 error "(4) unexpected barrier status $b_status"
21466 do_facet mgs $LCTL barrier_thaw $FSNAME
21467 b_status=$(barrier_stat)
21468 [ "$b_status" = "'thawed'" ] ||
21469 error "(5) unexpected barrier status $b_status"
21471 local devname=$(mdsdevname 2)
21473 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
21475 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21476 error "(7) Fail to rescan barrier bitmap"
21480 run_test 801c "rescan barrier bitmap"
21482 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
21483 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
21484 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
21485 saved_MOUNT_OPTS=$MOUNT_OPTS
21491 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
21492 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
21493 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
21494 MOUNT_OPTS=$saved_MOUNT_OPTS
21499 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
21500 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21501 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
21502 skip "Need server version at least 2.9.55"
21504 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
21506 mkdir $DIR/$tdir || error "(1) fail to mkdir"
21508 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
21509 error "(2) Fail to copy"
21511 trap cleanup_802 EXIT
21513 # sync by force before remount as readonly
21514 sync; sync_all_data; sleep 3; sync_all_data
21518 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
21519 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
21520 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
21522 echo "Mount the server as read only"
21523 setupall server_only || error "(3) Fail to start servers"
21525 echo "Mount client without ro should fail"
21526 mount_client $MOUNT &&
21527 error "(4) Mount client without 'ro' should fail"
21529 echo "Mount client with ro should succeed"
21530 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
21531 mount_client $MOUNT ||
21532 error "(5) Mount client with 'ro' should succeed"
21534 echo "Modify should be refused"
21535 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
21537 echo "Read should be allowed"
21538 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
21539 error "(7) Read should succeed under ro mode"
21543 run_test 802 "simulate readonly device"
21546 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21547 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21548 skip "MDS needs to be newer than 2.10.54"
21550 mkdir -p $DIR/$tdir
21551 # Create some objects on all MDTs to trigger related logs objects
21552 for idx in $(seq $MDSCOUNT); do
21553 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
21554 $DIR/$tdir/dir${idx} ||
21555 error "Fail to create $DIR/$tdir/dir${idx}"
21559 wait_delete_completed # ensure old test cleanups are finished
21560 echo "before create:"
21562 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21564 for i in {1..10}; do
21565 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
21566 error "Fail to create $DIR/$tdir/foo$i"
21570 echo "after create:"
21572 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21574 # allow for an llog to be cleaned up during the test
21575 [ $after_used -ge $((before_used + 10 - 1)) ] ||
21576 error "before ($before_used) + 10 > after ($after_used)"
21578 for i in {1..10}; do
21579 rm -rf $DIR/$tdir/foo$i ||
21580 error "Fail to remove $DIR/$tdir/foo$i"
21583 sleep 3 # avoid MDT return cached statfs
21584 wait_delete_completed
21585 echo "after unlink:"
21587 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21589 # allow for an llog to be created during the test
21590 [ $after_used -le $((before_used + 1)) ] ||
21591 error "after ($after_used) > before ($before_used) + 1"
21593 run_test 803a "verify agent object for remote object"
21596 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21597 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
21598 skip "MDS needs to be newer than 2.13.56"
21599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21601 for i in $(seq 0 $((MDSCOUNT - 1))); do
21602 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
21610 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
21611 for i in $(seq 0 $((MDSCOUNT - 1))); do
21612 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
21613 awk '/getattr/ { print $2 }')
21614 before=$((before + tmp))
21616 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
21617 for i in $(seq 0 $((MDSCOUNT - 1))); do
21618 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
21619 awk '/getattr/ { print $2 }')
21620 after=$((after + tmp))
21623 [ $before -eq $after ] || error "getattr count $before != $after"
21625 run_test 803b "remote object can getattr from cache"
21628 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21629 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21630 skip "MDS needs to be newer than 2.10.54"
21631 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21633 mkdir -p $DIR/$tdir
21634 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
21635 error "Fail to create $DIR/$tdir/dir0"
21637 local fid=$($LFS path2fid $DIR/$tdir/dir0)
21638 local dev=$(mdsdevname 2)
21640 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21641 grep ${fid} || error "NOT found agent entry for dir0"
21643 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
21644 error "Fail to create $DIR/$tdir/dir1"
21646 touch $DIR/$tdir/dir1/foo0 ||
21647 error "Fail to create $DIR/$tdir/dir1/foo0"
21648 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
21651 for idx in $(seq $MDSCOUNT); do
21652 dev=$(mdsdevname $idx)
21653 do_facet mds${idx} \
21654 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21655 grep ${fid} && rc=$idx
21658 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
21659 error "Fail to rename foo0 to foo1"
21660 if [ $rc -eq 0 ]; then
21661 for idx in $(seq $MDSCOUNT); do
21662 dev=$(mdsdevname $idx)
21663 do_facet mds${idx} \
21664 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21665 grep ${fid} && rc=$idx
21669 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
21670 error "Fail to rename foo1 to foo2"
21671 if [ $rc -eq 0 ]; then
21672 for idx in $(seq $MDSCOUNT); do
21673 dev=$(mdsdevname $idx)
21674 do_facet mds${idx} \
21675 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21676 grep ${fid} && rc=$idx
21680 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
21682 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
21683 error "Fail to link to $DIR/$tdir/dir1/foo2"
21684 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
21685 error "Fail to rename foo2 to foo0"
21686 unlink $DIR/$tdir/dir1/foo0 ||
21687 error "Fail to unlink $DIR/$tdir/dir1/foo0"
21688 rm -rf $DIR/$tdir/dir0 ||
21689 error "Fail to rm $DIR/$tdir/dir0"
21691 for idx in $(seq $MDSCOUNT); do
21692 dev=$(mdsdevname $idx)
21696 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
21698 start mds${idx} $dev $MDS_MOUNT_OPTS ||
21699 error "mount mds$idx failed"
21700 df $MOUNT > /dev/null 2>&1
21702 # e2fsck should not return error
21704 error "e2fsck detected error on MDT${idx}: rc=$rc"
21707 run_test 804 "verify agent entry for remote entry"
21710 do_facet $SINGLEMDS zfs set quota=$old $fsset
21711 unlinkmany $DIR/$tdir/f- 1000000
21716 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
21717 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
21718 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
21719 skip "netfree not implemented before 0.7"
21720 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
21721 skip "Need MDS version at least 2.10.57"
21728 local pref="osd-zfs.lustre-MDT0000."
21730 # limit available space on MDS dataset to meet nospace issue
21731 # quickly. then ZFS 0.7.2 can use reserved space if asked
21732 # properly (using netfree flag in osd_declare_destroy()
21733 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
21734 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
21736 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
21737 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
21738 let "usedkb=usedkb-freekb"
21739 let "freekb=freekb/2"
21740 if let "freekb > 5000"; then
21743 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
21744 trap cleanup_805 EXIT
21746 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
21747 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
21748 rm -rf $DIR/$tdir || error "not able to remove"
21749 do_facet $SINGLEMDS zfs set quota=$old $fsset
21752 run_test 805 "ZFS can remove from full fs"
21758 local size=$($LFS getsom -s $file)
21759 local expect=$(stat -c %s $file)
21761 [[ $size == $expect ]] ||
21762 error "$file expected size: $expect, got: $size"
21764 local blocks=$($LFS getsom -b $file)
21765 expect=$(stat -c %b $file)
21766 [[ $blocks == $expect ]] ||
21767 error "$file expected blocks: $expect, got: $blocks"
21772 local size=$($LFS getsom -s $1)
21775 [[ $size == $expect ]] ||
21776 error "$file expected size: $expect, got: $size"
21780 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21781 skip "Need MDS version at least 2.11.52"
21785 touch $DIR/$tfile || error "touch $tfile failed"
21787 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21788 save_lustre_params client "llite.*.xattr_cache" > $save
21789 lctl set_param llite.*.xattr_cache=0
21790 stack_trap "restore_lustre_params < $save" EXIT
21792 # single-threaded write
21793 echo "Test SOM for single-threaded write"
21794 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
21795 error "write $tfile failed"
21796 check_lsom_size $DIR/$tfile $bs
21799 local size=$(($num * $bs))
21803 echo "Test SOM for single client multi-threaded($num) write"
21804 $TRUNCATE $DIR/$tfile 0
21805 for ((i = 0; i < $num; i++)); do
21806 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21808 offset=$((offset + $bs))
21810 for (( i=0; i < $num; i++ )); do
21813 check_lsom_size $DIR/$tfile $size
21815 $TRUNCATE $DIR/$tfile 0
21816 for ((i = 0; i < $num; i++)); do
21817 offset=$((offset - $bs))
21818 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21821 for (( i=0; i < $num; i++ )); do
21824 check_lsom_size $DIR/$tfile $size
21826 # multi-client writes
21827 num=$(get_node_count ${CLIENTS//,/ })
21828 size=$(($num * $bs))
21832 echo "Test SOM for multi-client ($num) writes"
21833 $TRUNCATE $DIR/$tfile 0
21834 for client in ${CLIENTS//,/ }; do
21835 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21838 offset=$((offset + $bs))
21840 for (( i=0; i < $num; i++ )); do
21843 check_lsom_size $DIR/$tfile $offset
21846 $TRUNCATE $DIR/$tfile 0
21847 for client in ${CLIENTS//,/ }; do
21848 offset=$((offset - $bs))
21849 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21853 for (( i=0; i < $num; i++ )); do
21856 check_lsom_size $DIR/$tfile $size
21859 echo "Test SOM for truncate"
21860 $TRUNCATE $DIR/$tfile 1048576
21861 check_lsom_size $DIR/$tfile 1048576
21862 $TRUNCATE $DIR/$tfile 1234
21863 check_lsom_size $DIR/$tfile 1234
21865 # verify SOM blocks count
21866 echo "Verify SOM block count"
21867 $TRUNCATE $DIR/$tfile 0
21868 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
21869 error "failed to write file $tfile"
21870 check_lsom_data $DIR/$tfile
21872 run_test 806 "Verify Lazy Size on MDS"
21875 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21876 skip "Need MDS version at least 2.11.52"
21878 # Registration step
21879 changelog_register || error "changelog_register failed"
21880 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
21881 changelog_users $SINGLEMDS | grep -q $cl_user ||
21882 error "User $cl_user not found in changelog_users"
21884 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21885 save_lustre_params client "llite.*.xattr_cache" > $save
21886 lctl set_param llite.*.xattr_cache=0
21887 stack_trap "restore_lustre_params < $save" EXIT
21889 rm -rf $DIR/$tdir || error "rm $tdir failed"
21890 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
21891 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
21892 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
21893 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
21894 error "truncate $tdir/trunc failed"
21897 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
21898 error "write $tfile failed"
21900 # multi-client wirtes
21901 local num=$(get_node_count ${CLIENTS//,/ })
21905 echo "Test SOM for multi-client ($num) writes"
21906 touch $DIR/$tfile || error "touch $tfile failed"
21907 $TRUNCATE $DIR/$tfile 0
21908 for client in ${CLIENTS//,/ }; do
21909 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21912 offset=$((offset + $bs))
21914 for (( i=0; i < $num; i++ )); do
21919 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
21920 check_lsom_data $DIR/$tdir/trunc
21921 check_lsom_data $DIR/$tdir/single_dd
21922 check_lsom_data $DIR/$tfile
21925 # Deregistration step
21926 changelog_deregister || error "changelog_deregister failed"
21928 run_test 807 "verify LSOM syncing tool"
21930 check_som_nologged()
21932 local lines=$($LFS changelog $FSNAME-MDT0000 |
21933 grep 'x=trusted.som' | wc -l)
21934 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
21938 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
21939 skip "Need MDS version at least 2.11.55"
21941 # Registration step
21942 changelog_register || error "changelog_register failed"
21944 touch $DIR/$tfile || error "touch $tfile failed"
21947 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
21948 error "write $tfile failed"
21951 $TRUNCATE $DIR/$tfile 1234
21954 $TRUNCATE $DIR/$tfile 1048576
21957 # Deregistration step
21958 changelog_deregister || error "changelog_deregister failed"
21960 run_test 808 "Check trusted.som xattr not logged in Changelogs"
21965 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
21969 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
21970 skip "Need MDS version at least 2.11.56"
21972 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
21973 error "failed to create DoM-only file $DIR/$tfile"
21974 touch $DIR/$tfile || error "touch $tfile failed"
21975 check_som_nodata $DIR/$tfile
21977 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
21978 error "write $tfile failed"
21979 check_som_nodata $DIR/$tfile
21981 $TRUNCATE $DIR/$tfile 1234
21982 check_som_nodata $DIR/$tfile
21984 $TRUNCATE $DIR/$tfile 4097
21985 check_som_nodata $DIR/$file
21987 run_test 809 "Verify no SOM xattr store for DoM-only files"
21990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21991 $GSS && skip_env "could not run with gss"
21994 stack_trap "set_checksums $ORIG_CSUM" EXIT
21995 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
22000 for csum in $CKSUM_TYPES; do
22001 #define OBD_FAIL_OSC_NO_GRANT 0x411
22002 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
22003 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
22005 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
22006 before=$(md5sum $DIR/$tfile)
22007 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
22008 after=$(md5sum $DIR/$tfile)
22009 [ "$before" == "$after" ] ||
22010 error "$csum: $before != $after bs=$1 seek=$2"
22014 run_test 810 "partial page writes on ZFS (LU-11663)"
22017 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
22018 skip "OST < 2.12.51 doesn't support this fail_loc"
22019 [ "$SHARED_KEY" = true ] &&
22020 skip "OSC connections never go IDLE with Shared-Keys enabled"
22022 $LFS setstripe -c 1 -i 0 $DIR/$tfile
22023 # ensure ost1 is connected
22024 stat $DIR/$tfile >/dev/null || error "can't stat"
22025 wait_osc_import_state client ost1 FULL
22026 # no locks, no reqs to let the connection idle
22027 cancel_lru_locks osc
22029 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
22030 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
22031 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
22032 wait_osc_import_state client ost1 CONNECTING
22033 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
22035 stat $DIR/$tfile >/dev/null || error "can't stat file"
22037 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
22041 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
22042 echo -n y >> $DIR/$tfile
22043 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
22044 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
22046 run_test 814 "sparse cp works as expected (LU-12361)"
22050 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
22051 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
22053 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
22056 local ost1_imp=$(get_osc_import_name client ost1)
22057 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
22060 [ "$SHARED_KEY" = true ] &&
22061 skip "OSC connections never go IDLE with Shared-Keys enabled"
22063 $LFS setstripe -c 1 -i 0 $DIR/$tfile
22064 # ensure ost1 is connected
22065 stat $DIR/$tfile >/dev/null || error "can't stat"
22066 wait_osc_import_state client ost1 FULL
22067 # no locks, no reqs to let the connection idle
22068 cancel_lru_locks osc
22069 lru_resize_disable osc
22072 before=$($LCTL get_param -n \
22073 ldlm.namespaces.$imp_name.lru_size)
22075 wait_osc_import_state client ost1 IDLE
22076 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
22077 now=$($LCTL get_param -n \
22078 ldlm.namespaces.$imp_name.lru_size)
22079 [ $before == $now ] || error "lru_size changed $before != $now"
22081 run_test 816 "do not reset lru_resize on idle reconnect"
22085 exportfs -u localhost:$DIR/nfsexp
22090 systemctl restart nfs-server.service || skip "failed to restart nfsd"
22092 mkdir -p $DIR/nfsexp
22093 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
22094 error "failed to export nfs"
22096 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
22097 stack_trap cleanup_817 EXIT
22099 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
22100 error "failed to mount nfs to $tmpdir"
22102 cp /bin/true $tmpdir
22103 $DIR/nfsexp/true || error "failed to execute 'true' command"
22105 run_test 817 "nfsd won't cache write lock for exec file"
22108 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
22109 cancel_lru_locks osc
22110 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
22111 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
22112 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
22115 run_test 819a "too big niobuf in read"
22118 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
22119 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
22120 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
22121 cancel_lru_locks osc
22125 run_test 819b "too big niobuf in write"
22129 $LFS setstripe -c1 -i0 $DIR/$tfile
22130 $LFS setstripe -c1 -i1 $DIR/$tfile
22132 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
22133 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
22134 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
22135 error "start $SINGLEMDS failed"
22138 run_test 818 "unlink with failed llog"
22141 # tests that do cleanup/setup should be run at the end
22145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22148 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
22149 $LCTL set_param fail_loc=0x903
22151 cancel_lru_locks MGC
22153 FAIL_ON_ERROR=true cleanup
22154 FAIL_ON_ERROR=true setup
22156 run_test 900 "umount should not race with any mgc requeue thread"
22160 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
22161 skip "client does not have LU-13377 fix"
22162 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
22163 $LCTL set_param fail_loc=0x1415
22164 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
22165 cancel_lru_locks osc
22168 run_test 902 "test short write doesn't hang lustre"
22171 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
22172 check_and_cleanup_lustre
22173 if [ "$I_MOUNTED" != "yes" ]; then
22174 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true