3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
31 export PARALLEL=${PARALLEL:-"no"}
34 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
35 LUSTRE=${LUSTRE:-$(dirname $0)/..}
36 . $LUSTRE/tests/test-framework.sh
41 ALWAYS_EXCEPT="$SANITY_EXCEPT "
42 # bug number for skipped test: LU-9693 LU-6493 LU-9693
43 ALWAYS_EXCEPT+=" 42a 42b 42c "
44 # bug number: LU-8411 LU-9054
45 ALWAYS_EXCEPT+=" 407 312 "
48 # bug number: LU-9795 LU-9795 LU-9795 LU-9795
49 ALWAYS_EXCEPT+=" 17n 60a 133g 300f "
52 # skip the grant tests for ARM until they are fixed
53 if [[ $(uname -m) = aarch64 ]]; then
54 # bug number: LU-11596
55 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
56 # bug number: LU-11671 LU-11667 LU-4398
57 ALWAYS_EXCEPT+=" 45 317 817"
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
63 if [ "$mds1_FSTYPE" = "zfs" ]; then
64 # bug number for skipped test:
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
67 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
70 # Get the SLES distro version
72 # Returns a version string that should only be used in comparing
73 # strings returned by version_code()
76 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
78 # All SuSE Linux versions have one decimal. version_code expects two
79 local sles_version=$version.0
80 version_code $sles_version
83 # Check if we are running on Ubuntu or SLES so we can make decisions on
85 if [ -r /etc/SuSE-release ]; then
86 sles_version=$(sles_version_code)
87 [ $sles_version -lt $(version_code 11.4.0) ] &&
88 # bug number for skipped test: LU-4341
89 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
90 [ $sles_version -lt $(version_code 12.0.0) ] &&
91 # bug number for skipped test: LU-3703
92 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
93 elif [ -r /etc/os-release ]; then
94 if grep -qi ubuntu /etc/os-release; then
95 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
100 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
101 # bug number for skipped test:
103 ALWAYS_EXCEPT+=" 103a 410"
113 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
114 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
123 check_swap_layouts_support()
125 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
126 skip "Does not support layout lock."
129 check_and_setup_lustre
133 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
135 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
136 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
137 rm -rf $DIR/[Rdfs][0-9]*
139 # $RUNAS_ID may get set incorrectly somewhere else
140 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
141 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
143 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
145 if [ "${ONLY}" = "MOUNT" ] ; then
146 echo "Lustre is up, please go on"
150 echo "preparing for tests involving mounts"
151 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
153 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
154 echo # add a newline after mke2fs.
158 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
159 lctl set_param debug=-1 2> /dev/null || true
162 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
164 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
166 run_test 0a "touch; rm ====================="
169 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
170 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
172 run_test 0b "chmod 0755 $DIR ============================="
175 $LCTL get_param mdc.*.import | grep "state: FULL" ||
176 error "import not FULL"
177 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
180 run_test 0c "check import proc"
182 test_0d() { # LU-3397
183 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
184 skip "proc exports not supported before 2.10.57"
186 local mgs_exp="mgs.MGS.exports"
187 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
189 local exp_client_version
192 local temp_imp=$DIR/$tfile.import
193 local temp_exp=$DIR/$tfile.export
195 # save mgc import file to $temp_imp
196 $LCTL get_param mgc.*.import | tee $temp_imp
197 # Check if client uuid is found in MGS export
198 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
199 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
203 # save mgs export file to $temp_exp
204 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
206 # Compare the value of field "connect_flags"
207 imp_val=$(grep "connect_flags" $temp_imp)
208 exp_val=$(grep "connect_flags" $temp_exp)
209 [ "$exp_val" == "$imp_val" ] ||
210 error "export flags '$exp_val' != import flags '$imp_val'"
212 # Compare the value of client version
213 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
214 exp_val=$(version_code $exp_client_version)
215 imp_val=$CLIENT_VERSION
216 [ "$exp_val" == "$imp_val" ] ||
217 error "export client version '$exp_val' != '$imp_val'"
219 run_test 0d "check export proc ============================="
222 test_mkdir $DIR/$tdir
223 test_mkdir $DIR/$tdir/d2
224 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
225 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
228 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
230 run_test 1 "mkdir; remkdir; rmdir"
233 test_mkdir $DIR/$tdir
234 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
235 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
237 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
239 run_test 2 "mkdir; touch; rmdir; check file"
242 test_mkdir $DIR/$tdir
243 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
244 touch $DIR/$tdir/$tfile
245 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
247 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
249 run_test 3 "mkdir; touch; rmdir; check dir"
251 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
253 test_mkdir -i 1 $DIR/$tdir
255 touch $DIR/$tdir/$tfile ||
256 error "Create file under remote directory failed"
259 error "Expect error removing in-use dir $DIR/$tdir"
261 test -d $DIR/$tdir || error "Remote directory disappeared"
263 rm -rf $DIR/$tdir || error "remove remote dir error"
265 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
268 test_mkdir $DIR/$tdir
269 test_mkdir $DIR/$tdir/d2
270 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
271 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
272 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
274 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
277 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
278 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
279 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
280 error "$tfile does not have perm 0666 or UID $UID"
281 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
282 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
283 error "$tfile should be 0666 and owned by UID $UID"
285 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
288 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
291 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
292 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
293 error "$tfile should be owned by UID $RUNAS_ID"
294 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
295 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
296 error "$tfile should be owned by UID $RUNAS_ID"
298 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
301 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
304 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
305 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
306 error "$tfile should be owned by GID $UID"
307 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
308 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
309 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
311 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
314 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
316 test_mkdir $DIR/$tdir
317 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
318 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
319 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
320 test_mkdir $DIR/$tdir/d/subdir
321 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
322 error "$tdir/d/subdir should be GID $RUNAS_GID"
323 if [[ $MDSCOUNT -gt 1 ]]; then
324 # check remote dir sgid inherite
325 $LFS mkdir -i 0 $DIR/$tdir.local ||
326 error "mkdir $tdir.local failed"
327 chmod g+s $DIR/$tdir.local ||
328 error "chmod $tdir.local failed"
329 chgrp $RUNAS_GID $DIR/$tdir.local ||
330 error "chgrp $tdir.local failed"
331 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
332 error "mkdir $tdir.remote failed"
333 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
334 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
335 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
336 error "$tdir.remote should be mode 02755"
339 run_test 6g "verify new dir in sgid dir inherits group"
341 test_6h() { # bug 7331
342 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
344 touch $DIR/$tfile || error "touch failed"
345 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
346 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
347 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
348 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
349 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
351 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
354 test_mkdir $DIR/$tdir
355 $MCREATE $DIR/$tdir/$tfile
356 chmod 0666 $DIR/$tdir/$tfile
357 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
358 error "$tdir/$tfile should be mode 0666"
360 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
363 if [ ! -d $DIR/$tdir ]; then
364 test_mkdir $DIR/$tdir
366 $MCREATE $DIR/$tdir/$tfile
367 echo -n foo > $DIR/$tdir/$tfile
368 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
369 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
371 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
376 chmod 0666 $DIR/$tdir/$tfile
377 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
378 error "$tfile mode not 0666"
380 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
383 test_mkdir $DIR/$tdir
384 test_mkdir $DIR/$tdir/d2
385 test_mkdir $DIR/$tdir/d2/d3
386 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
388 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
391 test_mkdir $DIR/$tdir
392 test_mkdir $DIR/$tdir/d2
393 touch $DIR/$tdir/d2/$tfile
394 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
395 error "$tdir/d2/$tfile not a file"
397 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
400 test_mkdir $DIR/$tdir
401 test_mkdir $DIR/$tdir/d2
402 chmod 0666 $DIR/$tdir/d2
403 chmod 0705 $DIR/$tdir/d2
404 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
405 error "$tdir/d2 mode not 0705"
407 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
410 test_mkdir $DIR/$tdir
411 touch $DIR/$tdir/$tfile
412 chmod 0666 $DIR/$tdir/$tfile
413 chmod 0654 $DIR/$tdir/$tfile
414 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
415 error "$tdir/d2 mode not 0654"
417 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
420 test_mkdir $DIR/$tdir
421 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
423 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
424 error "$tdir/$tfile size not 0 after truncate"
426 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
429 test_mkdir $DIR/$tdir
430 touch $DIR/$tdir/$tfile
432 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
434 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
437 test_mkdir $DIR/$tdir
438 touch $DIR/$tdir/$tfile
439 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
440 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
441 error "$tdir/${tfile_2} not a file after rename"
442 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
444 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
447 test_mkdir $DIR/$tdir
448 touch $DIR/$tdir/$tfile
449 rm -rf $DIR/$tdir/$tfile
450 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
452 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
455 test_mkdir $DIR/$tdir
456 touch $DIR/$tdir/$tfile
457 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
459 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
460 error "$tdir/l-exist not a symlink"
461 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
462 error "$tdir/l-exist not referencing a file"
463 rm -f $DIR/$tdir/l-exist
464 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
466 run_test 17a "symlinks: create, remove (real)"
469 test_mkdir $DIR/$tdir
470 ln -s no-such-file $DIR/$tdir/l-dangle
472 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
473 error "$tdir/l-dangle not referencing no-such-file"
474 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
475 error "$tdir/l-dangle not referencing non-existent file"
476 rm -f $DIR/$tdir/l-dangle
477 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
479 run_test 17b "symlinks: create, remove (dangling)"
481 test_17c() { # bug 3440 - don't save failed open RPC for replay
482 test_mkdir $DIR/$tdir
483 ln -s foo $DIR/$tdir/$tfile
484 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
486 run_test 17c "symlinks: open dangling (should return error)"
489 test_mkdir $DIR/$tdir
490 ln -s foo $DIR/$tdir/$tfile
491 touch $DIR/$tdir/$tfile || error "creating to new symlink"
493 run_test 17d "symlinks: create dangling"
496 test_mkdir $DIR/$tdir
497 local foo=$DIR/$tdir/$tfile
498 ln -s $foo $foo || error "create symlink failed"
499 ls -l $foo || error "ls -l failed"
500 ls $foo && error "ls not failed" || true
502 run_test 17e "symlinks: create recursive symlink (should return error)"
505 test_mkdir $DIR/$tdir
506 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
507 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
508 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
509 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
510 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
511 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
514 run_test 17f "symlinks: long and very long symlink name"
516 # str_repeat(S, N) generate a string that is string S repeated N times
521 while [ $((n -= 1)) -ge 0 ]; do
527 # Long symlinks and LU-2241
529 test_mkdir $DIR/$tdir
530 local TESTS="59 60 61 4094 4095"
532 # Fix for inode size boundary in 2.1.4
533 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
536 # Patch not applied to 2.2 or 2.3 branches
537 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
538 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
541 # skip long symlink name for rhel6.5.
542 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
543 grep -q '6.5' /etc/redhat-release &>/dev/null &&
544 TESTS="59 60 61 4062 4063"
547 local SYMNAME=$(str_repeat 'x' $i)
548 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
549 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
552 run_test 17g "symlinks: really long symlink name and inode boundaries"
554 test_17h() { #bug 17378
555 [ $PARALLEL == "yes" ] && skip "skip parallel run"
556 remote_mds_nodsh && skip "remote MDS with nodsh"
560 test_mkdir $DIR/$tdir
561 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
562 $LFS setstripe -c -1 $DIR/$tdir
563 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
564 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
565 touch $DIR/$tdir/$tfile || true
567 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
569 test_17i() { #bug 20018
570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
571 remote_mds_nodsh && skip "remote MDS with nodsh"
573 local foo=$DIR/$tdir/$tfile
576 test_mkdir -c1 $DIR/$tdir
577 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
578 ln -s $foo $foo || error "create symlink failed"
579 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
580 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
581 ls -l $foo && error "error not detected"
584 run_test 17i "don't panic on short symlink (should return error)"
586 test_17k() { #bug 22301
587 [ $PARALLEL == "yes" ] && skip "skip parallel run"
588 [[ -z "$(which rsync 2>/dev/null)" ]] &&
589 skip "no rsync command"
590 rsync --help | grep -q xattr ||
591 skip_env "$(rsync --version | head -n1) does not support xattrs"
592 test_mkdir $DIR/$tdir
593 test_mkdir $DIR/$tdir.new
594 touch $DIR/$tdir/$tfile
595 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
596 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
597 error "rsync failed with xattrs enabled"
599 run_test 17k "symlinks: rsync with xattrs enabled"
601 test_17l() { # LU-279
602 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
603 skip "no getfattr command"
605 test_mkdir $DIR/$tdir
606 touch $DIR/$tdir/$tfile
607 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
608 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
609 # -h to not follow symlinks. -m '' to list all the xattrs.
610 # grep to remove first line: '# file: $path'.
611 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
613 lgetxattr_size_check $path $xattr ||
614 error "lgetxattr_size_check $path $xattr failed"
618 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
623 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
624 remote_mds_nodsh && skip "remote MDS with nodsh"
625 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
626 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
627 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
629 local short_sym="0123456789"
630 local wdir=$DIR/$tdir
635 # create a long symlink file
636 for ((i = 0; i < 4; ++i)); do
637 long_sym=${long_sym}${long_sym}
640 echo "create 512 short and long symlink files under $wdir"
641 for ((i = 0; i < 256; ++i)); do
642 ln -sf ${long_sym}"a5a5" $wdir/long-$i
643 ln -sf ${short_sym}"a5a5" $wdir/short-$i
649 wait_delete_completed
651 echo "recreate the 512 symlink files with a shorter string"
652 for ((i = 0; i < 512; ++i)); do
653 # rewrite the symlink file with a shorter string
654 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
655 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
658 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
659 local devname=$(mdsdevname $mds_index)
661 echo "stop and checking mds${mds_index}:"
662 # e2fsck should not return error
664 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
667 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
668 error "start mds${mds_index} failed"
669 df $MOUNT > /dev/null 2>&1
671 error "e2fsck detected error for short/long symlink: rc=$rc"
674 run_test 17m "run e2fsck against MDT which contains short/long symlink"
676 check_fs_consistency_17n() {
680 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
681 # so it only check MDT1/MDT2 instead of all of MDTs.
682 for mdt_index in 1 2; do
683 local devname=$(mdsdevname $mdt_index)
684 # e2fsck should not return error
686 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
689 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
690 error "mount mds$mdt_index failed"
691 df $MOUNT > /dev/null 2>&1
697 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
699 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
700 remote_mds_nodsh && skip "remote MDS with nodsh"
701 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
702 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
703 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
707 test_mkdir $DIR/$tdir
708 for ((i=0; i<10; i++)); do
709 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
710 error "create remote dir error $i"
711 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
712 error "create files under remote dir failed $i"
715 check_fs_consistency_17n ||
716 error "e2fsck report error after create files under remote dir"
718 for ((i = 0; i < 10; i++)); do
719 rm -rf $DIR/$tdir/remote_dir_${i} ||
720 error "destroy remote dir error $i"
723 check_fs_consistency_17n ||
724 error "e2fsck report error after unlink files under remote dir"
726 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
727 skip "lustre < 2.4.50 does not support migrate mv"
729 for ((i = 0; i < 10; i++)); do
730 mkdir -p $DIR/$tdir/remote_dir_${i}
731 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
732 error "create files under remote dir failed $i"
733 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
734 error "migrate remote dir error $i"
736 check_fs_consistency_17n || error "e2fsck report error after migration"
738 for ((i = 0; i < 10; i++)); do
739 rm -rf $DIR/$tdir/remote_dir_${i} ||
740 error "destroy remote dir error $i"
743 check_fs_consistency_17n || error "e2fsck report error after unlink"
745 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
748 remote_mds_nodsh && skip "remote MDS with nodsh"
749 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
750 skip "Need MDS version at least 2.3.64"
752 local wdir=$DIR/${tdir}o
758 mdt_index=$($LFS getstripe -m $wdir/$tfile)
759 mdt_index=$((mdt_index + 1))
762 #fail mds will wait the failover finish then set
763 #following fail_loc to avoid interfer the recovery process.
766 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
767 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
768 ls -l $wdir/$tfile && rc=1
769 do_facet mds${mdt_index} lctl set_param fail_loc=0
770 [[ $rc -eq 0 ]] || error "stat file should fail"
772 run_test 17o "stat file with incompat LMA feature"
775 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
776 ls $DIR || error "Failed to ls $DIR: $?"
778 run_test 18 "touch .../f ; ls ... =============================="
784 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
786 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
789 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
791 run_test 19b "ls -l .../f19 (should return error) =============="
794 [ $RUNAS_ID -eq $UID ] &&
795 skip_env "RUNAS_ID = UID = $UID -- skipping"
797 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
799 run_test 19c "$RUNAS touch .../f19 (should return error) =="
802 cat $DIR/f19 && error || true
804 run_test 19d "cat .../f19 (should return error) =============="
813 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
815 run_test 20 "touch .../f ; ls -l ..."
818 test_mkdir $DIR/$tdir
819 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
820 ln -s dangle $DIR/$tdir/link
821 echo foo >> $DIR/$tdir/link
822 cat $DIR/$tdir/dangle
823 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
824 $CHECKSTAT -f -t file $DIR/$tdir/link ||
825 error "$tdir/link not linked to a file"
827 run_test 21 "write to dangling link"
830 local wdir=$DIR/$tdir
832 chown $RUNAS_ID:$RUNAS_GID $wdir
833 (cd $wdir || error "cd $wdir failed";
834 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
836 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
837 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
838 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
839 error "checkstat -u failed"
841 run_test 22 "unpack tar archive as non-root user"
845 test_mkdir $DIR/$tdir
846 local file=$DIR/$tdir/$tfile
848 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
849 openfile -f O_CREAT:O_EXCL $file &&
850 error "$file recreate succeeded" || true
852 run_test 23a "O_CREAT|O_EXCL in subdir"
854 test_23b() { # bug 18988
855 test_mkdir $DIR/$tdir
856 local file=$DIR/$tdir/$tfile
859 echo foo > $file || error "write filed"
860 echo bar >> $file || error "append filed"
861 $CHECKSTAT -s 8 $file || error "wrong size"
864 run_test 23b "O_APPEND check"
866 # LU-9409, size with O_APPEND and tiny writes
868 local file=$DIR/$tfile
871 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
872 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
876 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
877 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
879 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
882 #racing tiny & normal writes
883 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
884 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
886 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
889 #racing tiny & normal writes 2, ugly numbers
890 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
891 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
893 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
896 run_test 23c "O_APPEND size checks for tiny writes"
898 # LU-11069 file offset is correct after appending writes
900 local file=$DIR/$tfile
903 echo CentaurHauls > $file
904 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
905 if ((offset != 26)); then
906 error "wrong offset, expected 26, got '$offset'"
909 run_test 23d "file offset is correct after appending writes"
913 echo '-- same directory rename'
914 test_mkdir $DIR/$tdir
915 touch $DIR/$tdir/$tfile.1
916 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
917 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
919 run_test 24a "rename file to non-existent target"
922 test_mkdir $DIR/$tdir
923 touch $DIR/$tdir/$tfile.{1,2}
924 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
925 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
926 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
928 run_test 24b "rename file to existing target"
931 test_mkdir $DIR/$tdir
932 test_mkdir $DIR/$tdir/d$testnum.1
933 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
934 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
935 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
937 run_test 24c "rename directory to non-existent target"
940 test_mkdir -c1 $DIR/$tdir
941 test_mkdir -c1 $DIR/$tdir/d$testnum.1
942 test_mkdir -c1 $DIR/$tdir/d$testnum.2
943 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
944 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
945 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
947 run_test 24d "rename directory to existing target"
950 echo '-- cross directory renames --'
954 mv $DIR/R5a/f $DIR/R5b/g
955 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
956 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
958 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
963 touch $DIR/R6a/f $DIR/R6b/g
964 mv $DIR/R6a/f $DIR/R6b/g
965 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
966 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
968 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
973 test_mkdir $DIR/R7a/d
974 mv $DIR/R7a/d $DIR/R7b/e
975 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
976 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
978 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
981 test_mkdir -c1 $DIR/R8a
982 test_mkdir -c1 $DIR/R8b
983 test_mkdir -c1 $DIR/R8a/d
984 test_mkdir -c1 $DIR/R8b/e
985 mrename $DIR/R8a/d $DIR/R8b/e
986 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
987 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
989 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
992 echo "-- rename error cases"
996 mrename $DIR/R9/f $DIR/R9/a
997 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
998 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
999 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1001 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1005 mrename $DIR/R10/f $DIR/R10/g
1006 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1007 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1008 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1010 run_test 24j "source does not exist ============================"
1013 test_mkdir $DIR/R11a
1014 test_mkdir $DIR/R11a/d
1016 mv $DIR/R11a/f $DIR/R11a/d
1017 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1018 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1020 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1022 # bug 2429 - rename foo foo foo creates invalid file
1025 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1027 run_test 24l "Renaming a file to itself ========================"
1031 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1032 # on ext3 this does not remove either the source or target files
1033 # though the "expected" operation would be to remove the source
1034 $CHECKSTAT -t file ${f} || error "${f} missing"
1035 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1037 run_test 24m "Renaming a file to a hard link to itself ========="
1041 # this stats the old file after it was renamed, so it should fail
1043 $CHECKSTAT ${f} || error "${f} missing"
1045 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1046 $CHECKSTAT -a ${f} || error "${f} exists"
1048 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1051 test_mkdir $DIR/$tdir
1052 rename_many -s random -v -n 10 $DIR/$tdir
1054 run_test 24o "rename of files during htree split"
1057 test_mkdir $DIR/R12a
1058 test_mkdir $DIR/R12b
1059 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1060 mrename $DIR/R12a $DIR/R12b
1061 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1062 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1063 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1064 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1066 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1068 cleanup_multiop_pause() {
1070 kill -USR1 $MULTIPID
1074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1076 test_mkdir $DIR/R13a
1077 test_mkdir $DIR/R13b
1078 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1079 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1082 trap cleanup_multiop_pause EXIT
1083 mrename $DIR/R13a $DIR/R13b
1084 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1085 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1086 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1087 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1088 cleanup_multiop_pause
1089 wait $MULTIPID || error "multiop close failed"
1091 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1093 test_24r() { #bug 3789
1094 test_mkdir $DIR/R14a
1095 test_mkdir $DIR/R14a/b
1096 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1097 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1098 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1100 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1103 test_mkdir $DIR/R15a
1104 test_mkdir $DIR/R15a/b
1105 test_mkdir $DIR/R15a/b/c
1106 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1107 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1108 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1110 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1112 test_mkdir $DIR/R16a
1113 test_mkdir $DIR/R16a/b
1114 test_mkdir $DIR/R16a/b/c
1115 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1116 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1117 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1119 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1121 test_24u() { # bug12192
1122 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1123 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1125 run_test 24u "create stripe file"
1127 simple_cleanup_common() {
1130 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1132 local start=$SECONDS
1135 wait_delete_completed
1136 echo "cleanup time $((SECONDS - start))"
1140 max_pages_per_rpc() {
1141 local mdtname="$(printf "MDT%04x" ${1:-0})"
1142 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1148 local nrfiles=${COUNT:-100000}
1149 local fname="$DIR/$tdir/$tfile"
1151 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1152 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1154 test_mkdir "$(dirname $fname)"
1155 # assume MDT0000 has the fewest inodes
1156 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1157 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1158 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1160 trap simple_cleanup_common EXIT
1162 createmany -m "$fname" $nrfiles
1164 cancel_lru_locks mdc
1165 lctl set_param mdc.*.stats clear
1167 # was previously test_24D: LU-6101
1168 # readdir() returns correct number of entries after cursor reload
1169 local num_ls=$(ls $DIR/$tdir | wc -l)
1170 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1171 local num_all=$(ls -a $DIR/$tdir | wc -l)
1172 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1173 [ $num_all -ne $((nrfiles + 2)) ]; then
1174 error "Expected $nrfiles files, got $num_ls " \
1175 "($num_uniq unique $num_all .&..)"
1177 # LU-5 large readdir
1178 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1179 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1180 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1181 # take into account of overhead in lu_dirpage header and end mark in
1182 # each page, plus one in rpc_num calculation.
1183 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1184 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1185 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1186 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1187 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1188 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1189 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1190 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1191 error "large readdir doesn't take effect: " \
1192 "$mds_readpage should be about $rpc_max"
1194 simple_cleanup_common
1196 run_test 24v "list large directory (test hash collision, b=17560)"
1198 test_24w() { # bug21506
1200 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1201 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1202 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1203 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1204 [[ "$SZ1" -eq "$SZ2" ]] ||
1205 error "Error reading at the end of the file $tfile"
1207 run_test 24w "Reading a file larger than 4Gb"
1210 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1211 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1212 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1213 skip "Need MDS version at least 2.7.56"
1216 local remote_dir=$DIR/$tdir/remote_dir
1218 test_mkdir $DIR/$tdir
1219 $LFS mkdir -i $MDTIDX $remote_dir ||
1220 error "create remote directory failed"
1222 test_mkdir $DIR/$tdir/src_dir
1223 touch $DIR/$tdir/src_file
1224 test_mkdir $remote_dir/tgt_dir
1225 touch $remote_dir/tgt_file
1227 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1228 error "rename dir cross MDT failed!"
1230 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1231 error "rename file cross MDT failed!"
1233 touch $DIR/$tdir/ln_file
1234 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1235 error "ln file cross MDT failed"
1237 rm -rf $DIR/$tdir || error "Can not delete directories"
1239 run_test 24x "cross MDT rename/link"
1242 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1243 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1245 local remote_dir=$DIR/$tdir/remote_dir
1248 test_mkdir $DIR/$tdir
1249 $LFS mkdir -i $mdtidx $remote_dir ||
1250 error "create remote directory failed"
1252 test_mkdir $remote_dir/src_dir
1253 touch $remote_dir/src_file
1254 test_mkdir $remote_dir/tgt_dir
1255 touch $remote_dir/tgt_file
1257 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1258 error "rename subdir in the same remote dir failed!"
1260 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1261 error "rename files in the same remote dir failed!"
1263 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1264 error "link files in the same remote dir failed!"
1266 rm -rf $DIR/$tdir || error "Can not delete directories"
1268 run_test 24y "rename/link on the same dir should succeed"
1271 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1272 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1273 skip "Need MDS version at least 2.12.51"
1277 for index in 0 1; do
1278 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1279 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1282 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1284 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1285 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1287 local mdts=$(comma_list $(mdts_nodes))
1289 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1290 stack_trap "do_nodes $mdts $LCTL \
1291 set_param mdt.*.enable_remote_rename=1" EXIT
1293 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1295 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1296 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1298 run_test 24z "cross-MDT rename is done as cp"
1300 test_24A() { # LU-3182
1304 test_mkdir $DIR/$tdir
1305 trap simple_cleanup_common EXIT
1306 createmany -m $DIR/$tdir/$tfile $NFILES
1307 local t=$(ls $DIR/$tdir | wc -l)
1308 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1309 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1310 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1311 [ $v -ne $((NFILES + 2)) ] ; then
1312 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1315 simple_cleanup_common || error "Can not delete directories"
1317 run_test 24A "readdir() returns correct number of entries."
1319 test_24B() { # LU-4805
1320 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1324 test_mkdir $DIR/$tdir
1325 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1326 error "create striped dir failed"
1328 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1329 [ $count -eq 2 ] || error "Expected 2, got $count"
1331 touch $DIR/$tdir/striped_dir/a
1333 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1334 [ $count -eq 3 ] || error "Expected 3, got $count"
1336 touch $DIR/$tdir/striped_dir/.f
1338 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1339 [ $count -eq 4 ] || error "Expected 4, got $count"
1341 rm -rf $DIR/$tdir || error "Can not delete directories"
1343 run_test 24B "readdir for striped dir return correct number of entries"
1346 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1352 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1353 error "create striped dir failed"
1355 cd $DIR/$tdir/d0/striped_dir
1357 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1358 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1359 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1361 [ "$d0_ino" = "$parent_ino" ] ||
1362 error ".. wrong, expect $d0_ino, get $parent_ino"
1364 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1365 error "mv striped dir failed"
1367 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1369 [ "$d1_ino" = "$parent_ino" ] ||
1370 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1372 run_test 24C "check .. in striped dir"
1375 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1376 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1379 mkdir $DIR/$tdir/src_dir
1380 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1381 error "create remote source failed"
1383 touch $DIR/$tdir/src_dir/src_child/a
1385 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1386 error "create remote target dir failed"
1388 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1389 error "create remote target child failed"
1391 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1392 error "rename dir cross MDT failed!"
1396 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1397 error "src_child still exists after rename"
1399 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1400 error "missing file(a) after rename"
1402 rm -rf $DIR/$tdir || error "Can not delete directories"
1404 run_test 24E "cross MDT rename/link"
1407 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1410 [ "$SLOW" = "no" ] && repeats=100
1414 echo "$repeats repeats"
1415 for ((i = 0; i < repeats; i++)); do
1416 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1417 touch $DIR/$tdir/test/a || error "touch fails"
1418 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1419 rm -rf $DIR/$tdir/test || error "rmdir fails"
1424 run_test 24F "hash order vs readdir (LU-11330)"
1427 echo '== symlink sanity ============================================='
1431 touch $DIR/s25/foo ||
1432 error "File creation in symlinked directory failed"
1434 run_test 25a "create file in symlinked directory ==============="
1437 [ ! -d $DIR/d25 ] && test_25a
1438 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1440 run_test 25b "lookup file in symlinked directory ==============="
1444 test_mkdir $DIR/d26/d26-2
1445 ln -s d26/d26-2 $DIR/s26
1446 touch $DIR/s26/foo || error "File creation failed"
1448 run_test 26a "multiple component symlink ======================="
1451 test_mkdir -p $DIR/$tdir/d26-2
1452 ln -s $tdir/d26-2/foo $DIR/s26-2
1453 touch $DIR/s26-2 || error "File creation failed"
1455 run_test 26b "multiple component symlink at end of lookup ======"
1458 test_mkdir $DIR/d26.2
1459 touch $DIR/d26.2/foo
1460 ln -s d26.2 $DIR/s26.2-1
1461 ln -s s26.2-1 $DIR/s26.2-2
1462 ln -s s26.2-2 $DIR/s26.2-3
1463 chmod 0666 $DIR/s26.2-3/foo
1465 run_test 26c "chain of symlinks"
1467 # recursive symlinks (bug 439)
1469 ln -s d26-3/foo $DIR/d26-3
1471 run_test 26d "create multiple component recursive symlink"
1474 [ ! -h $DIR/d26-3 ] && test_26d
1477 run_test 26e "unlink multiple component recursive symlink"
1479 # recursive symlinks (bug 7022)
1481 test_mkdir $DIR/$tdir
1482 test_mkdir $DIR/$tdir/$tfile
1483 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1484 test_mkdir -p lndir/bar1
1485 test_mkdir $DIR/$tdir/$tfile/$tfile
1486 cd $tfile || error "cd $tfile failed"
1487 ln -s .. dotdot || error "ln dotdot failed"
1488 ln -s dotdot/lndir lndir || error "ln lndir failed"
1489 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1490 output=`ls $tfile/$tfile/lndir/bar1`
1491 [ "$output" = bar1 ] && error "unexpected output"
1492 rm -r $tfile || error "rm $tfile failed"
1493 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1495 run_test 26f "rm -r of a directory which has recursive symlink"
1498 test_mkdir $DIR/$tdir
1499 $LFS getstripe $DIR/$tdir
1500 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1501 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1502 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1504 run_test 27a "one stripe file"
1507 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1509 test_mkdir $DIR/$tdir
1510 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1511 $LFS getstripe -c $DIR/$tdir/$tfile
1512 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1513 error "two-stripe file doesn't have two stripes"
1515 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1517 run_test 27b "create and write to two stripe file"
1519 # 27c family tests specific striping, setstripe -o
1521 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1522 test_mkdir -p $DIR/$tdir
1525 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1526 $LFS getstripe -i $DIR/$tdir/$tfile
1527 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1528 error "stripe not on specified OST"
1530 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1532 run_test 27ca "one stripe on specified OST"
1535 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1536 test_mkdir -p $DIR/$tdir
1538 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1539 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1542 # Strip getstripe output to a space separated list of OSTs
1543 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1544 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1545 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1546 error "stripes not on specified OSTs"
1548 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1550 run_test 27cb "two stripes on specified OSTs"
1553 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1554 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1555 skip "server does not support overstriping"
1557 test_mkdir -p $DIR/$tdir
1559 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1560 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1563 # Strip getstripe output to a space separated list of OSTs
1564 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1565 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1566 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1567 error "stripes not on specified OSTs"
1569 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1571 run_test 27cc "two stripes on the same OST"
1574 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1575 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1576 skip "server does not support overstriping"
1577 test_mkdir -p $DIR/$tdir
1578 local osts="0,1,1,0"
1579 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1580 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1583 # Strip getstripe output to a space separated list of OSTs
1584 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1585 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1586 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1587 error "stripes not on specified OSTs"
1589 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1591 run_test 27cd "four stripes on two OSTs"
1594 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1595 skip_env "too many osts, skipping"
1596 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1597 skip "server does not support overstriping"
1598 # We do one more stripe than we have OSTs
1599 [ $OSTCOUNT -ge 159 ] || large_xattr_enabled ||
1600 skip_env "ea_inode feature disabled"
1602 test_mkdir -p $DIR/$tdir
1604 for i in $(seq 0 $OSTCOUNT);
1607 if [ $i -ne $OSTCOUNT ]; then
1611 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1612 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1615 # Strip getstripe output to a space separated list of OSTs
1616 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1617 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1618 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1619 error "stripes not on specified OSTs"
1621 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1623 run_test 27ce "more stripes than OSTs with -o"
1626 test_mkdir $DIR/$tdir
1627 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1628 error "setstripe failed"
1629 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1630 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1632 run_test 27d "create file with default settings"
1635 # LU-5839 adds check for existed layout before setting it
1636 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1637 skip "Need MDS version at least 2.7.56"
1639 test_mkdir $DIR/$tdir
1640 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1641 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1642 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1644 run_test 27e "setstripe existing file (should return error)"
1647 test_mkdir $DIR/$tdir
1648 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1649 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1650 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1651 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1652 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1653 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1655 run_test 27f "setstripe with bad stripe size (should return error)"
1658 test_mkdir $DIR/$tdir
1659 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1660 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1661 error "$DIR/$tdir/$tfile has object"
1663 run_test 27g "$LFS getstripe with no objects"
1666 test_mkdir $DIR/$tdir
1667 touch $DIR/$tdir/$tfile || error "touch failed"
1668 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1669 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1671 (( rc == 2 )) || error "getstripe did not return ENOENT"
1673 run_test 27ga "$LFS getstripe with missing file (should return error)"
1676 test_mkdir $DIR/$tdir
1677 touch $DIR/$tdir/$tfile || error "touch failed"
1678 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1679 error "missing objects"
1681 run_test 27i "$LFS getstripe with some objects"
1684 test_mkdir $DIR/$tdir
1685 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1686 error "setstripe failed" || true
1688 run_test 27j "setstripe with bad stripe offset (should return error)"
1690 test_27k() { # bug 2844
1691 test_mkdir $DIR/$tdir
1692 local file=$DIR/$tdir/$tfile
1693 local ll_max_blksize=$((4 * 1024 * 1024))
1694 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1695 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1696 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1697 dd if=/dev/zero of=$file bs=4k count=1
1698 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1699 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1701 run_test 27k "limit i_blksize for broken user apps"
1704 mcreate $DIR/$tfile || error "creating file"
1705 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1706 error "setstripe should have failed" || true
1708 run_test 27l "check setstripe permissions (should return error)"
1711 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1713 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1714 skip_env "multiple clients -- skipping"
1716 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1718 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1719 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1721 trap simple_cleanup_common EXIT
1722 test_mkdir $DIR/$tdir
1723 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1724 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1725 error "dd should fill OST0"
1727 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1729 [ $i -gt 256 ] && break
1732 touch $DIR/$tdir/$tfile.$i
1733 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1734 awk '{print $1}'| grep -w "0") ] &&
1735 error "OST0 was full but new created file still use it"
1737 touch $DIR/$tdir/$tfile.$i
1738 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1739 awk '{print $1}'| grep -w "0") ] &&
1740 error "OST0 was full but new created file still use it"
1741 simple_cleanup_common
1743 run_test 27m "create file while OST0 was full"
1745 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1746 # if the OST isn't full anymore.
1748 local OSTIDX=${1:-""}
1750 local list=$(comma_list $(osts_nodes))
1751 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1753 do_nodes $list lctl set_param fail_loc=0
1754 sync # initiate all OST_DESTROYs from MDS to OST
1758 exhaust_precreations() {
1761 local FAILIDX=${3:-$OSTIDX}
1762 local ofacet=ost$((OSTIDX + 1))
1764 test_mkdir -p -c1 $DIR/$tdir
1765 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1766 local mfacet=mds$((mdtidx + 1))
1767 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1769 local OST=$(ostname_from_index $OSTIDX)
1772 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1773 local last_id=$(do_facet $mfacet lctl get_param -n \
1774 osp.$mdtosc_proc1.prealloc_last_id)
1775 local next_id=$(do_facet $mfacet lctl get_param -n \
1776 osp.$mdtosc_proc1.prealloc_next_id)
1778 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1779 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1781 test_mkdir -p $DIR/$tdir/${OST}
1782 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1783 #define OBD_FAIL_OST_ENOSPC 0x215
1784 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1785 echo "Creating to objid $last_id on ost $OST..."
1786 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1787 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1788 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1792 exhaust_all_precreations() {
1794 for (( i=0; i < OSTCOUNT; i++ )) ; do
1795 exhaust_precreations $i $1 -1
1800 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1801 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1802 remote_mds_nodsh && skip "remote MDS with nodsh"
1803 remote_ost_nodsh && skip "remote OST with nodsh"
1806 rm -f $DIR/$tdir/$tfile
1807 exhaust_precreations 0 0x80000215
1808 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1809 touch $DIR/$tdir/$tfile || error "touch failed"
1810 $LFS getstripe $DIR/$tdir/$tfile
1813 run_test 27n "create 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
1823 exhaust_all_precreations 0x215
1825 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1830 run_test 27o "create file with all full OSTs (should error)"
1833 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1835 remote_mds_nodsh && skip "remote MDS with nodsh"
1836 remote_ost_nodsh && skip "remote OST with nodsh"
1839 rm -f $DIR/$tdir/$tfile
1840 test_mkdir $DIR/$tdir
1842 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1843 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1844 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1846 exhaust_precreations 0 0x80000215
1847 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1848 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1849 $LFS getstripe $DIR/$tdir/$tfile
1853 run_test 27p "append to a truncated file with some full OSTs"
1856 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1858 remote_mds_nodsh && skip "remote MDS with nodsh"
1859 remote_ost_nodsh && skip "remote OST with nodsh"
1862 rm -f $DIR/$tdir/$tfile
1864 test_mkdir $DIR/$tdir
1865 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1866 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1867 error "truncate $DIR/$tdir/$tfile failed"
1868 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1870 exhaust_all_precreations 0x215
1872 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1873 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1877 run_test 27q "append to truncated file with all OSTs full (should error)"
1880 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1882 remote_mds_nodsh && skip "remote MDS with nodsh"
1883 remote_ost_nodsh && skip "remote OST with nodsh"
1886 rm -f $DIR/$tdir/$tfile
1887 exhaust_precreations 0 0x80000215
1889 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1893 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1895 test_27s() { # bug 10725
1896 test_mkdir $DIR/$tdir
1897 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1898 local stripe_count=0
1899 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1900 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1901 error "stripe width >= 2^32 succeeded" || true
1904 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1906 test_27t() { # bug 10864
1911 $WLFS getstripe $tfile
1914 run_test 27t "check that utils parse path correctly"
1916 test_27u() { # bug 4900
1917 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1918 remote_mds_nodsh && skip "remote MDS with nodsh"
1921 local list=$(comma_list $(mdts_nodes))
1923 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1924 do_nodes $list $LCTL set_param fail_loc=0x139
1925 test_mkdir -p $DIR/$tdir
1926 trap simple_cleanup_common EXIT
1927 createmany -o $DIR/$tdir/t- 1000
1928 do_nodes $list $LCTL set_param fail_loc=0
1930 TLOG=$TMP/$tfile.getstripe
1931 $LFS getstripe $DIR/$tdir > $TLOG
1932 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1933 unlinkmany $DIR/$tdir/t- 1000
1935 [[ $OBJS -gt 0 ]] &&
1936 error "$OBJS objects created on OST-0. See $TLOG" ||
1939 run_test 27u "skip object creation on OSC w/o objects"
1941 test_27v() { # bug 4900
1942 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1944 remote_mds_nodsh && skip "remote MDS with nodsh"
1945 remote_ost_nodsh && skip "remote OST with nodsh"
1947 exhaust_all_precreations 0x215
1950 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1952 touch $DIR/$tdir/$tfile
1953 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1955 for (( i=1; i < OSTCOUNT; i++ )); do
1956 do_facet ost$i lctl set_param fail_loc=0x705
1958 local START=`date +%s`
1959 createmany -o $DIR/$tdir/$tfile 32
1961 local FINISH=`date +%s`
1962 local TIMEOUT=`lctl get_param -n timeout`
1963 local PROCESS=$((FINISH - START))
1964 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1965 error "$FINISH - $START >= $TIMEOUT / 2"
1966 sleep $((TIMEOUT / 2 - PROCESS))
1969 run_test 27v "skip object creation on slow OST"
1971 test_27w() { # bug 10997
1972 test_mkdir $DIR/$tdir
1973 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1974 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1975 error "stripe size $size != 65536" || true
1976 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1977 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1979 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1982 [[ $OSTCOUNT -lt 2 ]] &&
1983 skip_env "skipping multiple stripe count/offset test"
1985 test_mkdir $DIR/$tdir
1986 for i in $(seq 1 $OSTCOUNT); do
1988 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1989 error "setstripe -c $i -i $offset failed"
1990 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1991 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1992 [ $count -ne $i ] && error "stripe count $count != $i" || true
1993 [ $index -ne $offset ] &&
1994 error "stripe offset $index != $offset" || true
1997 run_test 27wa "check $LFS setstripe -c -i options"
2000 remote_ost_nodsh && skip "remote OST with nodsh"
2001 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2002 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2004 OFFSET=$(($OSTCOUNT - 1))
2006 local OST=$(ostname_from_index $OSTIDX)
2008 test_mkdir $DIR/$tdir
2009 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2010 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2012 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2013 for i in $(seq 0 $OFFSET); do
2014 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2015 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2016 error "OST0 was degraded but new created file still use it"
2018 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2020 run_test 27x "create files while OST0 is degraded"
2023 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2024 remote_mds_nodsh && skip "remote MDS with nodsh"
2025 remote_ost_nodsh && skip "remote OST with nodsh"
2026 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2028 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2029 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2030 osp.$mdtosc.prealloc_last_id)
2031 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2032 osp.$mdtosc.prealloc_next_id)
2033 local fcount=$((last_id - next_id))
2034 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2035 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2037 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2038 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2039 local OST_DEACTIVE_IDX=-1
2044 for OSC in $MDS_OSCS; do
2045 OST=$(osc_to_ost $OSC)
2046 OSTIDX=$(index_from_ostuuid $OST)
2047 if [ $OST_DEACTIVE_IDX == -1 ]; then
2048 OST_DEACTIVE_IDX=$OSTIDX
2050 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2051 echo $OSC "is Deactivated:"
2052 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2056 OSTIDX=$(index_from_ostuuid $OST)
2057 test_mkdir $DIR/$tdir
2058 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2060 for OSC in $MDS_OSCS; do
2061 OST=$(osc_to_ost $OSC)
2062 OSTIDX=$(index_from_ostuuid $OST)
2063 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2064 echo $OST "is degraded:"
2065 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2066 obdfilter.$OST.degraded=1
2071 createmany -o $DIR/$tdir/$tfile $fcount
2073 for OSC in $MDS_OSCS; do
2074 OST=$(osc_to_ost $OSC)
2075 OSTIDX=$(index_from_ostuuid $OST)
2076 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2077 echo $OST "is recovered from degraded:"
2078 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2079 obdfilter.$OST.degraded=0
2081 do_facet $SINGLEMDS lctl --device %$OSC activate
2085 # all osp devices get activated, hence -1 stripe count restored
2086 local stripe_count=0
2088 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2089 # devices get activated.
2091 $LFS setstripe -c -1 $DIR/$tfile
2092 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2094 [ $stripe_count -ne $OSTCOUNT ] &&
2095 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2098 run_test 27y "create files while OST0 is degraded and the rest inactive"
2104 lmm_count=$($LFS getstripe -c $1)
2105 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2106 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2108 local old_ifs="$IFS"
2110 fid=($($LFS path2fid $1))
2113 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2114 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2116 # compare lmm_seq and lu_fid->f_seq
2117 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2118 # compare lmm_object_id and lu_fid->oid
2119 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2121 # check the trusted.fid attribute of the OST objects of the file
2122 local have_obdidx=false
2124 $LFS getstripe $1 | while read obdidx oid hex seq; do
2125 # skip lines up to and including "obdidx"
2126 [ -z "$obdidx" ] && break
2127 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2128 $have_obdidx || continue
2130 local ost=$((obdidx + 1))
2131 local dev=$(ostdevname $ost)
2134 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2136 seq=$(echo $seq | sed -e "s/^0x//g")
2137 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2138 oid_hex=$(echo $oid)
2140 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2142 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2146 # Don't unmount/remount the OSTs if we don't need to do that.
2147 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2148 # update too, until that use mount/ll_decode_filter_fid/mount.
2149 # Re-enable when debugfs will understand new filter_fid.
2151 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2152 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2153 $dev 2>/dev/null" | grep "parent=")
2155 if [ -z "$ff" ]; then
2157 mount_fstype ost$ost
2158 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2159 $(facet_mntpt ost$ost)/$obj_file)
2160 unmount_fstype ost$ost
2161 start ost$ost $dev $OST_MOUNT_OPTS
2165 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2167 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2169 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2170 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2172 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2173 # stripe_size=1048576 component_id=1 component_start=0 \
2174 # component_end=33554432
2175 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2176 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2177 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2179 if grep -q 'stripe=' <<<$ff; then
2180 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2182 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2183 # into f_ver in this case. See comment on ff_parent.
2184 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2187 # compare lmm_seq and filter_fid->ff_parent.f_seq
2188 [ $ff_pseq = $lmm_seq ] ||
2189 error "FF parent SEQ $ff_pseq != $lmm_seq"
2190 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2191 [ $ff_poid = $lmm_oid ] ||
2192 error "FF parent OID $ff_poid != $lmm_oid"
2193 (($ff_pstripe == $stripe_nr)) ||
2194 error "FF stripe $ff_pstripe != $stripe_nr"
2196 stripe_nr=$((stripe_nr + 1))
2197 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2199 if grep -q 'stripe_count=' <<<$ff; then
2200 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2201 -e 's/ .*//' <<<$ff)
2202 [ $lmm_count = $ff_scnt ] ||
2203 error "FF stripe count $lmm_count != $ff_scnt"
2209 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2210 remote_ost_nodsh && skip "remote OST with nodsh"
2212 test_mkdir $DIR/$tdir
2213 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2214 { error "setstripe -c -1 failed"; return 1; }
2215 # We need to send a write to every object to get parent FID info set.
2216 # This _should_ also work for setattr, but does not currently.
2217 # touch $DIR/$tdir/$tfile-1 ||
2218 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2219 { error "dd $tfile-1 failed"; return 2; }
2220 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2221 { error "setstripe -c -1 failed"; return 3; }
2222 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2223 { error "dd $tfile-2 failed"; return 4; }
2225 # make sure write RPCs have been sent to OSTs
2228 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2229 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2231 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2233 test_27A() { # b=19102
2234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2236 save_layout_restore_at_exit $MOUNT
2237 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2238 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2239 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2240 local default_size=$($LFS getstripe -S $MOUNT)
2241 local default_offset=$($LFS getstripe -i $MOUNT)
2242 local dsize=$(do_facet $SINGLEMDS \
2243 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2244 [ $default_size -eq $dsize ] ||
2245 error "stripe size $default_size != $dsize"
2246 [ $default_offset -eq -1 ] ||
2247 error "stripe offset $default_offset != -1"
2249 run_test 27A "check filesystem-wide default LOV EA values"
2251 test_27B() { # LU-2523
2252 test_mkdir $DIR/$tdir
2253 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2255 # open f1 with O_LOV_DELAY_CREATE
2257 # call setstripe ioctl on open file descriptor for f1
2259 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2263 # open f1 with O_LOV_DELAY_CREATE
2265 # call setstripe ioctl on open file descriptor for f1
2267 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2269 # Allow multiop to fail in imitation of NFS's busted semantics.
2272 run_test 27B "call setstripe on open unlinked file/rename victim"
2274 # 27C family tests full striping and overstriping
2275 test_27Ca() { #LU-2871
2276 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2284 test_mkdir $DIR/$tdir
2286 for i in $(seq 0 $((OSTCOUNT - 1))); do
2287 # set stripe across all OSTs starting from OST$i
2288 $LFS setstripe -i $i -c -1 $tfile$i
2289 # get striping information
2290 ost_idx=($($LFS getstripe $tfile$i |
2291 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2295 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2296 error "${#ost_idx[@]} != $OSTCOUNT"
2298 for index in $(seq 0 $((OSTCOUNT - 1))); do
2300 for j in $(echo ${ost_idx[@]}); do
2301 if [ $index -eq $j ]; then
2307 error "Can not find $index in ${ost_idx[@]}"
2311 run_test 27Ca "check full striping across all OSTs"
2314 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2315 skip "server does not support overstriping"
2316 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2317 skip_env "too many osts, skipping"
2319 test_mkdir -p $DIR/$tdir
2320 local setcount=$(($OSTCOUNT * 2))
2321 [ $setcount -ge 160 ] || large_xattr_enabled ||
2322 skip_env "ea_inode feature disabled"
2324 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2325 error "setstripe failed"
2327 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2328 [ $count -eq $setcount ] ||
2329 error "stripe count $count, should be $setcount"
2331 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2332 error "overstriped should be set in pattern"
2334 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2337 run_test 27Cb "more stripes than OSTs with -C"
2340 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2341 skip "server does not support overstriping"
2342 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2344 test_mkdir -p $DIR/$tdir
2345 local setcount=$(($OSTCOUNT - 1))
2347 [ $setcount -ge 160 ] || large_xattr_enabled ||
2348 skip_env "ea_inode feature disabled"
2350 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2351 error "setstripe failed"
2353 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2354 [ $count -eq $setcount ] ||
2355 error "stripe count $count, should be $setcount"
2357 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2358 error "overstriped should not be set in pattern"
2360 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2363 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2366 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2367 skip "server does not support overstriping"
2368 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2369 large_xattr_enabled || skip_env "ea_inode feature disabled"
2371 test_mkdir -p $DIR/$tdir
2372 local setcount=$LOV_MAX_STRIPE_COUNT
2374 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2375 error "setstripe failed"
2377 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2378 [ $count -eq $setcount ] ||
2379 error "stripe count $count, should be $setcount"
2381 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2382 error "overstriped should be set in pattern"
2384 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2387 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2389 run_test 27Cd "test maximum stripe count"
2392 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2393 skip "server does not support overstriping"
2394 test_mkdir -p $DIR/$tdir
2396 pool_add $TESTNAME || error "Pool creation failed"
2397 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2401 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2402 error "setstripe failed"
2404 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2405 [ $count -eq $setcount ] ||
2406 error "stripe count $count, should be $setcount"
2408 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2409 error "overstriped should be set in pattern"
2411 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2414 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2416 run_test 27Ce "test pool with overstriping"
2419 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2420 skip "server does not support overstriping"
2421 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2422 skip_env "too many osts, skipping"
2424 test_mkdir -p $DIR/$tdir
2426 local setcount=$(($OSTCOUNT * 2))
2427 [ $setcount -ge 160 ] || large_xattr_enabled ||
2428 skip_env "ea_inode feature disabled"
2430 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2431 error "setstripe failed"
2433 echo 1 > $DIR/$tdir/$tfile
2435 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2436 [ $count -eq $setcount ] ||
2437 error "stripe count $count, should be $setcount"
2439 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2440 error "overstriped should be set in pattern"
2442 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2445 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2447 run_test 27Cf "test default inheritance with overstriping"
2450 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2451 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2452 remote_mds_nodsh && skip "remote MDS with nodsh"
2454 local POOL=${POOL:-testpool}
2456 local last_ost=$(($OSTCOUNT - 1))
2458 local ost_list=$(seq $first_ost $ost_step $last_ost)
2459 local ost_range="$first_ost $last_ost $ost_step"
2461 test_mkdir $DIR/$tdir
2462 pool_add $POOL || error "pool_add failed"
2463 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2466 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2468 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2469 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2470 skip27D+=" -s 30,31"
2471 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2472 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2473 skip27D+=" -s 32,33"
2474 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2476 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2477 error "llapi_layout_test failed"
2479 destroy_test_pools || error "destroy test pools failed"
2481 run_test 27D "validate llapi_layout API"
2483 # Verify that default_easize is increased from its initial value after
2484 # accessing a widely striped file.
2486 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2487 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2488 skip "client does not have LU-3338 fix"
2490 # 72 bytes is the minimum space required to store striping
2491 # information for a file striped across one OST:
2492 # (sizeof(struct lov_user_md_v3) +
2493 # sizeof(struct lov_user_ost_data_v1))
2495 $LCTL set_param -n llite.*.default_easize $min_easize ||
2496 error "lctl set_param failed"
2497 local easize=$($LCTL get_param -n llite.*.default_easize)
2499 [ $easize -eq $min_easize ] ||
2500 error "failed to set default_easize"
2502 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2503 error "setstripe failed"
2504 # In order to ensure stat() call actually talks to MDS we need to
2505 # do something drastic to this file to shake off all lock, e.g.
2506 # rename it (kills lookup lock forcing cache cleaning)
2507 mv $DIR/$tfile $DIR/${tfile}-1
2508 ls -l $DIR/${tfile}-1
2511 easize=$($LCTL get_param -n llite.*.default_easize)
2513 [ $easize -gt $min_easize ] ||
2514 error "default_easize not updated"
2516 run_test 27E "check that default extended attribute size properly increases"
2518 test_27F() { # LU-5346/LU-7975
2519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2520 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2521 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2522 skip "Need MDS version at least 2.8.51"
2523 remote_ost_nodsh && skip "remote OST with nodsh"
2525 test_mkdir $DIR/$tdir
2527 $LFS setstripe -c 2 $DIR/$tdir
2529 # stop all OSTs to reproduce situation for LU-7975 ticket
2530 for num in $(seq $OSTCOUNT); do
2534 # open/create f0 with O_LOV_DELAY_CREATE
2535 # truncate f0 to a non-0 size
2537 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2539 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2540 # open/write it again to force delayed layout creation
2541 cat /etc/hosts > $DIR/$tdir/f0 &
2545 for num in $(seq $OSTCOUNT); do
2546 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2547 error "ost$num failed to start"
2550 wait $catpid || error "cat failed"
2552 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2553 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2554 error "wrong stripecount"
2557 run_test 27F "Client resend delayed layout creation with non-zero size"
2559 test_27G() { #LU-10629
2560 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2561 skip "Need MDS version at least 2.11.51"
2562 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2563 remote_mds_nodsh && skip "remote MDS with nodsh"
2564 local POOL=${POOL:-testpool}
2565 local ostrange="0 0 1"
2567 test_mkdir $DIR/$tdir
2568 pool_add $POOL || error "pool_add failed"
2569 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2570 $LFS setstripe -p $POOL $DIR/$tdir
2572 local pool=$($LFS getstripe -p $DIR/$tdir)
2574 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2576 $LFS setstripe -d $DIR/$tdir
2578 pool=$($LFS getstripe -p $DIR/$tdir)
2582 [ -z "$pool" ] || error "'$pool' is not empty"
2584 run_test 27G "Clear OST pool from stripe"
2587 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2588 skip "Need MDS version newer than 2.11.54"
2589 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2590 test_mkdir $DIR/$tdir
2591 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2592 touch $DIR/$tdir/$tfile
2593 $LFS getstripe -c $DIR/$tdir/$tfile
2594 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2595 error "two-stripe file doesn't have two stripes"
2597 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2598 $LFS getstripe -y $DIR/$tdir/$tfile
2599 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2600 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2601 error "expected l_ost_idx: [02]$ not matched"
2603 # make sure ost list has been cleared
2604 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2605 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2606 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2608 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2610 run_test 27H "Set specific OSTs stripe"
2613 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2614 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2615 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2616 skip "Need MDS version newer than 2.12.52"
2617 local pool=$TESTNAME
2618 local ostrange="1 1 1"
2620 save_layout_restore_at_exit $MOUNT
2621 $LFS setstripe -c 2 -i 0 $MOUNT
2622 pool_add $pool || error "pool_add failed"
2623 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2624 test_mkdir $DIR/$tdir
2625 $LFS setstripe -p $pool $DIR/$tdir
2626 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2627 $LFS getstripe $DIR/$tdir/$tfile
2629 run_test 27I "check that root dir striping does not break parent dir one"
2632 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
2633 skip "Need MDS version newer than 2.12.51"
2635 test_mkdir $DIR/$tdir
2636 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2637 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2639 # create foreign file (raw way)
2640 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2641 -t 1 -F 0xda08 || error "create_foreign_file failed"
2643 # verify foreign file (raw way)
2644 parse_foreign_file -f $DIR/$tdir/$tfile |
2645 grep "lov_foreign_magic: 0x0BD70BD0" ||
2646 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2647 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2648 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2649 parse_foreign_file -f $DIR/$tdir/$tfile |
2650 grep "lov_foreign_size: 73" ||
2651 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2652 parse_foreign_file -f $DIR/$tdir/$tfile |
2653 grep "lov_foreign_type: 1" ||
2654 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2655 parse_foreign_file -f $DIR/$tdir/$tfile |
2656 grep "lov_foreign_flags: 0x0000DA08" ||
2657 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2658 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2659 grep "lov_foreign_value: 0x" |
2660 sed -e 's/lov_foreign_value: 0x//')
2661 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2662 [[ $lov = ${lov2// /} ]] ||
2663 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2665 # create foreign file (lfs + API)
2666 $LFS setstripe --foreign=daos --flags 0xda08 \
2667 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2668 error "$DIR/$tdir/${tfile}2: create failed"
2670 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2671 grep "lfm_magic:.*0x0BD70BD0" ||
2672 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2673 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2674 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2675 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2676 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2677 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2678 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2679 grep "lfm_flags:.*0x0000DA08" ||
2680 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2681 $LFS getstripe $DIR/$tdir/${tfile}2 |
2682 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2683 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2685 # modify striping should fail
2686 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2687 error "$DIR/$tdir/$tfile: setstripe should fail"
2688 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2689 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2692 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2693 cat $DIR/$tdir/${tfile}2 &&
2694 error "$DIR/$tdir/${tfile}2: read should fail"
2695 cat /etc/passwd > $DIR/$tdir/$tfile &&
2696 error "$DIR/$tdir/$tfile: write should fail"
2697 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2698 error "$DIR/$tdir/${tfile}2: write should fail"
2701 chmod 222 $DIR/$tdir/$tfile ||
2702 error "$DIR/$tdir/$tfile: chmod failed"
2703 chmod 222 $DIR/$tdir/${tfile}2 ||
2704 error "$DIR/$tdir/${tfile}2: chmod failed"
2707 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2708 error "$DIR/$tdir/$tfile: chown failed"
2709 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2710 error "$DIR/$tdir/${tfile}2: chown failed"
2712 # rename should work
2713 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2714 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2715 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2716 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2718 #remove foreign file
2719 rm $DIR/$tdir/${tfile}.new ||
2720 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2721 rm $DIR/$tdir/${tfile}2.new ||
2722 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2724 run_test 27J "basic ops on file with foreign LOV"
2727 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
2728 skip "Need MDS version newer than 2.12.49"
2730 test_mkdir $DIR/$tdir
2731 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2732 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2734 # create foreign dir (raw way)
2735 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2736 error "create_foreign_dir FAILED"
2738 # verify foreign dir (raw way)
2739 parse_foreign_dir -d $DIR/$tdir/$tdir |
2740 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2741 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2742 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2743 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2744 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2745 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2746 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2747 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2748 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2749 grep "lmv_foreign_value: 0x" |
2750 sed 's/lmv_foreign_value: 0x//')
2751 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2753 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2755 # create foreign dir (lfs + API)
2756 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2757 $DIR/$tdir/${tdir}2 ||
2758 error "$DIR/$tdir/${tdir}2: create failed"
2760 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2761 grep "lfm_magic:.*0x0CD50CD0" ||
2762 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2763 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2764 # - sizeof(lfm_type) - sizeof(lfm_flags)
2765 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2766 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2767 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2768 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2769 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2770 grep "lfm_flags:.*0x0000DA05" ||
2771 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2772 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2773 grep "lfm_value.*${uuid1}@${uuid2}" ||
2774 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2776 # file create in dir should fail
2777 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2778 touch $DIR/$tdir/${tdir}2/$tfile &&
2779 "$DIR/${tdir}2: file create should fail"
2782 chmod 777 $DIR/$tdir/$tdir ||
2783 error "$DIR/$tdir: chmod failed"
2784 chmod 777 $DIR/$tdir/${tdir}2 ||
2785 error "$DIR/${tdir}2: chmod failed"
2788 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2789 error "$DIR/$tdir: chown failed"
2790 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2791 error "$DIR/${tdir}2: chown failed"
2793 # rename should work
2794 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2795 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2796 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2797 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2800 rmdir $DIR/$tdir/${tdir}.new ||
2801 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2802 rmdir $DIR/$tdir/${tdir}2.new ||
2803 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2805 run_test 27K "basic ops on dir with foreign LMV"
2808 remote_mds_nodsh && skip "remote MDS with nodsh"
2810 local POOL=${POOL:-$TESTNAME}
2812 pool_add $POOL || error "pool_add failed"
2814 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2815 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2816 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2818 run_test 27L "lfs pool_list gives correct pool name"
2821 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2822 skip "Need MDS version >= than 2.12.57"
2823 remote_mds_nodsh && skip "remote MDS with nodsh"
2824 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2826 test_mkdir $DIR/$tdir
2828 # Set default striping on directory
2829 $LFS setstripe -C 4 $DIR/$tdir
2831 echo 1 > $DIR/$tdir/${tfile}.1
2832 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2834 [ $count -eq $setcount ] ||
2835 error "(1) stripe count $count, should be $setcount"
2837 # Capture existing append_stripe_count setting for restore
2838 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2839 local mdts=$(comma_list $(mdts_nodes))
2840 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2842 local appendcount=$orig_count
2843 echo 1 >> $DIR/$tdir/${tfile}.2_append
2844 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2845 [ $count -eq $appendcount ] ||
2846 error "(2)stripe count $count, should be $appendcount for append"
2848 # Disable O_APPEND striping, verify it works
2849 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2851 # Should now get the default striping, which is 4
2853 echo 1 >> $DIR/$tdir/${tfile}.3_append
2854 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2855 [ $count -eq $setcount ] ||
2856 error "(3) stripe count $count, should be $setcount"
2858 # Try changing the stripe count for append files
2859 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2861 # Append striping is now 2 (directory default is still 4)
2863 echo 1 >> $DIR/$tdir/${tfile}.4_append
2864 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2865 [ $count -eq $appendcount ] ||
2866 error "(4) stripe count $count, should be $appendcount for append"
2868 # Test append stripe count of -1
2869 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2870 appendcount=$OSTCOUNT
2871 echo 1 >> $DIR/$tdir/${tfile}.5
2872 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2873 [ $count -eq $appendcount ] ||
2874 error "(5) stripe count $count, should be $appendcount for append"
2876 # Set append striping back to default of 1
2877 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2879 # Try a new default striping, PFL + DOM
2880 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2882 # Create normal DOM file, DOM returns stripe count == 0
2884 touch $DIR/$tdir/${tfile}.6
2885 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2886 [ $count -eq $setcount ] ||
2887 error "(6) stripe count $count, should be $setcount"
2891 echo 1 >> $DIR/$tdir/${tfile}.7_append
2892 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2893 [ $count -eq $appendcount ] ||
2894 error "(7) stripe count $count, should be $appendcount for append"
2896 # Clean up DOM layout
2897 $LFS setstripe -d $DIR/$tdir
2899 # Now test that append striping works when layout is from root
2900 $LFS setstripe -c 2 $MOUNT
2901 # Make a special directory for this
2902 mkdir $DIR/${tdir}/${tdir}.2
2903 stack_trap "$LFS setstripe -d $MOUNT" EXIT
2905 # Verify for normal file
2907 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2908 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2909 [ $count -eq $setcount ] ||
2910 error "(8) stripe count $count, should be $setcount"
2913 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2914 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2915 [ $count -eq $appendcount ] ||
2916 error "(9) stripe count $count, should be $appendcount for append"
2918 # Now test O_APPEND striping with pools
2919 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2920 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2923 pool_add $TESTNAME || error "pool creation failed"
2924 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2926 echo 1 >> $DIR/$tdir/${tfile}.10_append
2928 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2929 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2931 # Check that count is still correct
2933 echo 1 >> $DIR/$tdir/${tfile}.11_append
2934 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2935 [ $count -eq $appendcount ] ||
2936 error "(11) stripe count $count, should be $appendcount for append"
2938 # Disable O_APPEND stripe count, verify pool works separately
2939 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2941 echo 1 >> $DIR/$tdir/${tfile}.12_append
2943 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2944 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2946 # Remove pool setting, verify it's not applied
2947 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
2949 echo 1 >> $DIR/$tdir/${tfile}.13_append
2951 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
2952 [ "$pool" = "" ] || error "(13) pool found: $pool"
2954 run_test 27M "test O_APPEND striping"
2957 combined_mgs_mds && skip "needs separate MGS/MDT"
2959 pool_add $TESTNAME || error "pool_add failed"
2960 do_facet mgs "$LCTL pool_list $FSNAME" |
2961 grep -Fx "${FSNAME}.${TESTNAME}" ||
2962 error "lctl pool_list on MGS failed"
2964 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
2966 # createtest also checks that device nodes are created and
2967 # then visible correctly (#2091)
2968 test_28() { # bug 2091
2970 $CREATETEST $DIR/d28/ct || error "createtest failed"
2972 run_test 28 "create/mknod/mkdir with bad file types ============"
2975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2977 sync; sleep 1; sync # flush out any dirty pages from previous tests
2984 declare -i LOCKCOUNTORIG=0
2985 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2986 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2988 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2990 declare -i LOCKUNUSEDCOUNTORIG=0
2991 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2992 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2999 declare -i LOCKCOUNTCURRENT=0
3000 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3001 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3004 declare -i LOCKUNUSEDCOUNTCURRENT=0
3005 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3006 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3009 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3010 $LCTL set_param -n ldlm.dump_namespaces ""
3011 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3012 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3013 log "dumped log to $TMP/test_29.dk (bug 5793)"
3016 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3017 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3018 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3019 log "dumped log to $TMP/test_29.dk (bug 5793)"
3023 run_test 29 "IT_GETATTR regression ============================"
3025 test_30a() { # was test_30
3026 cp $(which ls) $DIR || cp /bin/ls $DIR
3027 $DIR/ls / || error "Can't execute binary from lustre"
3030 run_test 30a "execute binary from Lustre (execve) =============="
3033 cp `which ls` $DIR || cp /bin/ls $DIR
3035 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3038 run_test 30b "execute binary from Lustre as non-root ==========="
3040 test_30c() { # b=22376
3041 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3043 cp `which ls` $DIR || cp /bin/ls $DIR
3045 cancel_lru_locks mdc
3046 cancel_lru_locks osc
3047 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3050 run_test 30c "execute binary from Lustre without read perms ===="
3053 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3054 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3056 run_test 31a "open-unlink file =================================="
3059 touch $DIR/f31 || error "touch $DIR/f31 failed"
3060 ln $DIR/f31 $DIR/f31b || error "ln failed"
3061 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3062 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3064 run_test 31b "unlink file with multiple links while open ======="
3067 touch $DIR/f31 || error "touch $DIR/f31 failed"
3068 ln $DIR/f31 $DIR/f31c || error "ln failed"
3069 multiop_bg_pause $DIR/f31 O_uc ||
3070 error "multiop_bg_pause for $DIR/f31 failed"
3072 $MULTIOP $DIR/f31c Ouc
3073 kill -USR1 $MULTIPID
3076 run_test 31c "open-unlink file with multiple links ============="
3079 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3080 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3082 run_test 31d "remove of open directory ========================="
3084 test_31e() { # bug 2904
3085 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3087 run_test 31e "remove of open non-empty directory ==============="
3089 test_31f() { # bug 4554
3090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3093 test_mkdir $DIR/d31f
3094 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3095 cp /etc/hosts $DIR/d31f
3097 $LFS getstripe $DIR/d31f/hosts
3098 multiop_bg_pause $DIR/d31f D_c || return 1
3101 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3102 test_mkdir $DIR/d31f
3103 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3104 cp /etc/hosts $DIR/d31f
3106 $LFS getstripe $DIR/d31f/hosts
3107 multiop_bg_pause $DIR/d31f D_c || return 1
3110 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3111 wait $MULTIPID || error "first opendir $MULTIPID failed"
3115 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3116 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3119 run_test 31f "remove of open directory with open-unlink file ==="
3122 echo "-- cross directory link --"
3123 test_mkdir -c1 $DIR/${tdir}ga
3124 test_mkdir -c1 $DIR/${tdir}gb
3125 touch $DIR/${tdir}ga/f
3126 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3127 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3128 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3129 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3130 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3132 run_test 31g "cross directory link==============="
3135 echo "-- cross directory link --"
3136 test_mkdir -c1 $DIR/${tdir}
3137 test_mkdir -c1 $DIR/${tdir}/dir
3138 touch $DIR/${tdir}/f
3139 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3140 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3141 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3142 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3143 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3145 run_test 31h "cross directory link under child==============="
3148 echo "-- cross directory link --"
3149 test_mkdir -c1 $DIR/$tdir
3150 test_mkdir -c1 $DIR/$tdir/dir
3151 touch $DIR/$tdir/dir/f
3152 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3153 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3154 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3155 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3156 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3158 run_test 31i "cross directory link under parent==============="
3161 test_mkdir -c1 -p $DIR/$tdir
3162 test_mkdir -c1 -p $DIR/$tdir/dir1
3163 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3164 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3165 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3166 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3169 run_test 31j "link for directory==============="
3172 test_mkdir -c1 -p $DIR/$tdir
3174 touch $DIR/$tdir/exist
3175 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3176 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3177 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3178 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3179 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3180 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3181 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3184 run_test 31k "link to file: the same, non-existing, dir==============="
3190 touch $DIR/d31m2/exist
3191 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3192 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3193 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3194 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3195 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3196 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3199 run_test 31m "link to file: the same, non-existing, dir==============="
3202 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3203 nlink=$(stat --format=%h $DIR/$tfile)
3204 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3206 local cmd="exec $fd<$DIR/$tfile"
3209 trap "eval $cmd" EXIT
3210 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3211 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3212 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3213 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3214 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3217 run_test 31n "check link count of unlinked file"
3220 local tempfile=$(mktemp $1_XXXXXX)
3221 mlink $tempfile $1 2> /dev/null &&
3222 echo "$BASHPID: link $tempfile to $1 succeeded"
3226 test_31o() { # LU-2901
3227 test_mkdir $DIR/$tdir
3228 for LOOP in $(seq 100); do
3229 rm -f $DIR/$tdir/$tfile*
3230 for THREAD in $(seq 8); do
3231 link_one $DIR/$tdir/$tfile.$LOOP &
3234 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3235 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3236 error "$LINKS duplicate links to $tfile.$LOOP" &&
3240 run_test 31o "duplicate hard links with same filename"
3243 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3245 test_mkdir $DIR/$tdir
3246 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3247 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3249 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3250 error "open unlink test1 failed"
3251 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3252 error "open unlink test2 failed"
3254 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3255 error "test1 still exists"
3256 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3257 error "test2 still exists"
3259 run_test 31p "remove of open striped directory"
3261 cleanup_test32_mount() {
3264 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3265 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3266 losetup -d $loopdev || true
3272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3274 echo "== more mountpoints and symlinks ================="
3275 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3276 trap cleanup_test32_mount EXIT
3277 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3278 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3279 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3280 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3281 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3282 cleanup_test32_mount
3284 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3287 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3289 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3290 trap cleanup_test32_mount EXIT
3291 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3292 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3293 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3294 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3295 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3296 cleanup_test32_mount
3298 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3303 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3304 trap cleanup_test32_mount EXIT
3305 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3306 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3307 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3308 test_mkdir -p $DIR/$tdir/d2/test_dir
3309 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3310 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3311 cleanup_test32_mount
3313 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3316 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3318 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3319 trap cleanup_test32_mount EXIT
3320 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3321 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3322 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3323 test_mkdir -p $DIR/$tdir/d2/test_dir
3324 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3325 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3326 cleanup_test32_mount
3328 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3332 test_mkdir -p $DIR/$tdir/tmp
3333 local tmp_dir=$DIR/$tdir/tmp
3334 ln -s $DIR/$tdir $tmp_dir/symlink11
3335 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3336 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3337 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3339 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3343 test_mkdir -p $DIR/$tdir/tmp
3344 local tmp_dir=$DIR/$tdir/tmp
3345 ln -s $DIR/$tdir $tmp_dir/symlink11
3346 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3347 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3348 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3350 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3353 local tmp_dir=$DIR/$tdir/tmp
3354 test_mkdir -p $tmp_dir
3355 test_mkdir $DIR/${tdir}2
3356 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3357 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3358 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3359 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3360 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3361 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3363 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3366 rm -fr $DIR/$tdir $DIR/${tdir}2
3367 tmp_dir=$DIR/$tdir/tmp
3368 test_mkdir -p $tmp_dir
3369 test_mkdir $DIR/${tdir}2
3370 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3371 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3372 ls $tmp_dir/symlink12 || error "listing symlink12"
3373 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3375 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3380 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3381 trap cleanup_test32_mount EXIT
3382 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3383 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3384 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3385 touch $DIR/$tdir/test_file
3386 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3387 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3388 cleanup_test32_mount
3390 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3395 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3396 trap cleanup_test32_mount EXIT
3397 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3398 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3399 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3400 touch $DIR/$tdir/test_file
3401 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3402 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3403 cleanup_test32_mount
3405 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3408 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3411 trap cleanup_test32_mount EXIT
3412 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3413 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3414 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3415 test_mkdir -p $DIR/$tdir/d2
3416 touch $DIR/$tdir/d2/test_file || error "touch failed"
3417 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3418 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3419 cleanup_test32_mount
3421 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3424 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3427 trap cleanup_test32_mount EXIT
3428 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3429 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3430 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3431 test_mkdir -p $DIR/$tdir/d2
3432 touch $DIR/$tdir/d2/test_file || error "touch failed"
3433 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3434 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3435 cleanup_test32_mount
3437 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3441 test_mkdir -p $DIR/d32m/tmp
3442 TMP_DIR=$DIR/d32m/tmp
3443 ln -s $DIR $TMP_DIR/symlink11
3444 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3445 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3446 error "symlink11 not a link"
3447 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3448 error "symlink01 not a link"
3450 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3454 test_mkdir -p $DIR/d32n/tmp
3455 TMP_DIR=$DIR/d32n/tmp
3456 ln -s $DIR $TMP_DIR/symlink11
3457 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3458 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3459 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3461 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3465 test_mkdir -p $DIR/d32o/tmp
3466 TMP_DIR=$DIR/d32o/tmp
3467 ln -s $DIR/$tfile $TMP_DIR/symlink12
3468 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3469 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3470 error "symlink12 not a link"
3471 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3472 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3473 error "$DIR/d32o/tmp/symlink12 not file type"
3474 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3475 error "$DIR/d32o/symlink02 not file type"
3477 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3487 test_mkdir -p $DIR/d32p/tmp
3489 TMP_DIR=$DIR/d32p/tmp
3491 ln -s $DIR/$tfile $TMP_DIR/symlink12
3493 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3495 cat $DIR/d32p/tmp/symlink12 ||
3496 error "Can't open $DIR/d32p/tmp/symlink12"
3498 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3501 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3504 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3506 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3507 trap cleanup_test32_mount EXIT
3508 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3509 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3510 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3511 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3512 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3513 cleanup_test32_mount
3515 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3520 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3521 trap cleanup_test32_mount EXIT
3522 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3523 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3524 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3525 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3526 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3527 cleanup_test32_mount
3529 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3534 chmod 444 $DIR/$tfile
3535 chown $RUNAS_ID $DIR/$tfile
3537 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3540 run_test 33aa "write file with mode 444 (should return error)"
3544 test_mkdir $DIR/$tdir
3545 chown $RUNAS_ID $DIR/$tdir
3546 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3547 error "$RUNAS create $tdir/$tfile failed"
3548 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3549 error "open RDWR" || true
3551 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3555 test_mkdir $DIR/$tdir
3556 chown $RUNAS_ID $DIR/$tdir
3557 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3559 run_test 33b "test open file with malformed flags (No panic)"
3562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3563 remote_ost_nodsh && skip "remote OST with nodsh"
3572 test_mkdir $DIR/$tdir
3573 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3576 for ostnum in $(seq $OSTCOUNT); do
3577 # test-framework's OST numbering is one-based, while Lustre's
3579 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3580 # Parsing llobdstat's output sucks; we could grep the /proc
3581 # path, but that's likely to not be as portable as using the
3582 # llobdstat utility. So we parse lctl output instead.
3583 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3584 obdfilter/$ostname/stats |
3585 awk '/^write_bytes/ {print $7}' )
3586 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3587 if (( ${write_bytes:-0} > 0 ))
3594 $all_zeros || return 0
3597 echo foo > $DIR/$tdir/bar
3601 # Total up write_bytes after writing. We'd better find non-zeros.
3602 for ostnum in $(seq $OSTCOUNT); do
3603 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3604 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3605 obdfilter/$ostname/stats |
3606 awk '/^write_bytes/ {print $7}' )
3607 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3608 if (( ${write_bytes:-0} > 0 ))
3617 for ostnum in $(seq $OSTCOUNT); do
3618 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3619 echo "Check that write_bytes is present in obdfilter/*/stats:"
3620 do_facet ost$ostnum lctl get_param -n \
3621 obdfilter/$ostname/stats
3623 error "OST not keeping write_bytes stats (b22312)"
3626 run_test 33c "test llobdstat and write_bytes"
3629 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3630 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3633 local remote_dir=$DIR/$tdir/remote_dir
3635 test_mkdir $DIR/$tdir
3636 $LFS mkdir -i $MDTIDX $remote_dir ||
3637 error "create remote directory failed"
3639 touch $remote_dir/$tfile
3640 chmod 444 $remote_dir/$tfile
3641 chown $RUNAS_ID $remote_dir/$tfile
3643 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3645 chown $RUNAS_ID $remote_dir
3646 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3647 error "create" || true
3648 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3649 error "open RDWR" || true
3650 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3652 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3655 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3659 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3660 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3661 mkdir $DIR/$tdir/local_dir
3663 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3664 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3665 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3667 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3668 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3670 rmdir $DIR/$tdir/* || error "rmdir failed"
3673 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3674 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3675 mkdir $DIR/$tdir/local_dir
3677 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3678 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3679 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3681 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3682 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3684 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3687 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3688 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3689 mkdir $DIR/$tdir/local_dir
3691 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3692 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3693 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3695 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3696 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3698 run_test 33e "mkdir and striped directory should have same mode"
3702 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3706 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3707 remote_mds_nodsh && skip "remote MDS with nodsh"
3710 chmod go+rwx $DIR/$tdir
3711 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3712 trap cleanup_33f EXIT
3714 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3715 error "cannot create striped directory"
3717 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3718 error "cannot create files in striped directory"
3720 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3721 error "cannot remove files in striped directory"
3723 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3724 error "cannot remove striped directory"
3728 run_test 33f "nonroot user can create, access, and remove a striped directory"
3731 mkdir -p $DIR/$tdir/dir2
3733 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3735 [[ $err =~ "exists" ]] || error "Not exists error"
3737 run_test 33g "nonroot user create already existing root created file"
3739 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3742 $MCREATE $DIR/f34 || error "mcreate failed"
3743 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3744 error "getstripe failed"
3745 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3746 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3747 error "getstripe failed"
3748 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3749 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3751 run_test 34a "truncate file that has not been opened ==========="
3754 [ ! -f $DIR/f34 ] && test_34a
3755 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3756 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3757 $OPENFILE -f O_RDONLY $DIR/f34
3758 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3759 error "getstripe failed"
3760 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3761 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3763 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3766 [ ! -f $DIR/f34 ] && test_34a
3767 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3768 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3769 $OPENFILE -f O_RDWR $DIR/f34
3770 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3771 error "$LFS getstripe failed"
3772 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3773 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3775 run_test 34c "O_RDWR opening file-with-size works =============="
3778 [ ! -f $DIR/f34 ] && test_34a
3779 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3781 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3782 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3785 run_test 34d "write to sparse file ============================="
3789 $MCREATE $DIR/f34e || error "mcreate failed"
3790 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3791 $CHECKSTAT -s 1000 $DIR/f34e ||
3792 error "Size of $DIR/f34e not equal to 1000 bytes"
3793 $OPENFILE -f O_RDWR $DIR/f34e
3794 $CHECKSTAT -s 1000 $DIR/f34e ||
3795 error "Size of $DIR/f34e not equal to 1000 bytes"
3797 run_test 34e "create objects, some with size and some without =="
3799 test_34f() { # bug 6242, 6243
3800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3804 $MCREATE $DIR/f34f || error "mcreate failed"
3805 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3806 dd if=$DIR/f34f of=$TMP/f34f
3807 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3808 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3809 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3810 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3811 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3813 run_test 34f "read from a file with no objects until EOF ======="
3816 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3818 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3820 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3821 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3822 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3823 cancel_lru_locks osc
3824 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3825 error "wrong size after lock cancel"
3827 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3828 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3829 error "expanding truncate failed"
3830 cancel_lru_locks osc
3831 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3832 error "wrong expanded size after lock cancel"
3834 run_test 34g "truncate long file ==============================="
3837 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3842 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3843 sync # Flush the cache so that multiop below does not block on cache
3844 # flush when getting the group lock
3845 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3848 # Since just timed wait is not good enough, let's do a sync write
3849 # that way we are sure enough time for a roundtrip + processing
3850 # passed + 2 seconds of extra margin.
3851 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3855 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3856 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3860 local nsz=`stat -c %s $DIR/$tfile`
3861 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3863 run_test 34h "ftruncate file under grouplock should not block"
3866 cp /bin/sh $DIR/f35a
3868 chown $RUNAS_ID $DIR/f35a
3869 $RUNAS $DIR/f35a && error || true
3872 run_test 35a "exec file with mode 444 (should return and not leak)"
3876 utime $DIR/f36 || error "utime failed for MDS"
3878 run_test 36a "MDS utime check (mknod, utime)"
3882 utime $DIR/f36 || error "utime failed for OST"
3884 run_test 36b "OST utime check (open, utime)"
3889 chown $RUNAS_ID $DIR/d36
3890 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3892 run_test 36c "non-root MDS utime check (mknod, utime)"
3895 [ ! -d $DIR/d36 ] && test_36c
3896 echo "" > $DIR/d36/f36
3897 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3899 run_test 36d "non-root OST utime check (open, utime)"
3902 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3904 test_mkdir $DIR/$tdir
3905 touch $DIR/$tdir/$tfile
3906 $RUNAS utime $DIR/$tdir/$tfile &&
3907 error "utime worked, expected failure" || true
3909 run_test 36e "utime on non-owned file (should return error)"
3913 local LANG_SAVE=$LANG
3914 local LC_LANG_SAVE=$LC_LANG
3915 export LANG=C LC_LANG=C # for date language
3917 DATESTR="Dec 20 2000"
3918 test_mkdir $DIR/$tdir
3919 lctl set_param fail_loc=$fl
3921 cp /etc/hosts $DIR/$tdir/$tfile
3922 sync & # write RPC generated with "current" inode timestamp, but delayed
3924 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3925 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3926 cancel_lru_locks $OSC
3927 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3929 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3930 echo "BEFORE: $LS_BEFORE" && \
3931 echo "AFTER : $LS_AFTER" && \
3932 echo "WANT : $DATESTR" && \
3933 error "$DIR/$tdir/$tfile timestamps changed" || true
3935 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3939 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3941 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3942 subr_36fh "0x80000214"
3944 run_test 36f "utime on file racing with OST BRW write =========="
3947 remote_ost_nodsh && skip "remote OST with nodsh"
3948 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3949 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3950 skip "Need MDS version at least 2.12.51"
3955 local tgt="obdfilter"
3957 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3959 test_mkdir $DIR/$tdir
3960 fmd_max_age=$(do_facet $facet \
3961 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3964 echo "FMD max age: ${fmd_max_age}s"
3965 touch $DIR/$tdir/$tfile
3966 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3967 gawk '{cnt=cnt+$1} END{print cnt}')
3968 echo "FMD before: $fmd"
3970 error "FMD wasn't create by touch"
3971 sleep $((fmd_max_age + 12))
3972 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3973 gawk '{cnt=cnt+$1} END{print cnt}')
3974 echo "FMD after: $fmd"
3976 error "FMD wasn't expired by ping"
3978 run_test 36g "FMD cache expiry ====================="
3981 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3983 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3984 subr_36fh "0x80000227"
3986 run_test 36h "utime on file racing with OST BRW write =========="
3989 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3991 test_mkdir $DIR/$tdir
3992 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3994 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3995 local new_mtime=$((mtime + 200))
3997 #change Modify time of striped dir
3998 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3999 error "change mtime failed"
4001 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4003 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4005 run_test 36i "change mtime on striped directory"
4007 # test_37 - duplicate with tests 32q 32r
4010 local file=$DIR/$tfile
4012 openfile -f O_DIRECTORY $file
4015 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4016 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4018 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4020 test_39a() { # was test_39
4022 touch $DIR/${tfile}2
4023 # ls -l $DIR/$tfile $DIR/${tfile}2
4024 # ls -lu $DIR/$tfile $DIR/${tfile}2
4025 # ls -lc $DIR/$tfile $DIR/${tfile}2
4027 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4028 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4030 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4032 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4034 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4035 error "O_TRUNC didn't change timestamps"
4038 run_test 39a "mtime changed on create"
4041 test_mkdir -c1 $DIR/$tdir
4042 cp -p /etc/passwd $DIR/$tdir/fopen
4043 cp -p /etc/passwd $DIR/$tdir/flink
4044 cp -p /etc/passwd $DIR/$tdir/funlink
4045 cp -p /etc/passwd $DIR/$tdir/frename
4046 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4049 echo "aaaaaa" >> $DIR/$tdir/fopen
4050 echo "aaaaaa" >> $DIR/$tdir/flink
4051 echo "aaaaaa" >> $DIR/$tdir/funlink
4052 echo "aaaaaa" >> $DIR/$tdir/frename
4054 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4055 local link_new=`stat -c %Y $DIR/$tdir/flink`
4056 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4057 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4059 cat $DIR/$tdir/fopen > /dev/null
4060 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4061 rm -f $DIR/$tdir/funlink2
4062 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4064 for (( i=0; i < 2; i++ )) ; do
4065 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4066 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4067 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4068 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4070 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4071 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4072 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4073 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4075 cancel_lru_locks $OSC
4076 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4079 run_test 39b "mtime change on open, link, unlink, rename ======"
4081 # this should be set to past
4082 TEST_39_MTIME=`date -d "1 year ago" +%s`
4088 local mtime0=`stat -c %Y $DIR1/$tfile`
4090 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4091 local mtime1=`stat -c %Y $DIR1/$tfile`
4092 [ "$mtime1" = $TEST_39_MTIME ] || \
4093 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4096 echo hello >> $DIR1/$tfile
4098 local mtime2=`stat -c %Y $DIR1/$tfile`
4099 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4100 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4102 mv $DIR1/$tfile $DIR1/$tfile-1
4104 for (( i=0; i < 2; i++ )) ; do
4105 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4106 [ "$mtime2" = "$mtime3" ] || \
4107 error "mtime ($mtime2) changed (to $mtime3) on rename"
4109 cancel_lru_locks $OSC
4110 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4113 run_test 39c "mtime change on rename ==========================="
4117 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4120 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4122 for (( i=0; i < 2; i++ )) ; do
4123 local mtime=`stat -c %Y $DIR1/$tfile`
4124 [ $mtime = $TEST_39_MTIME ] || \
4125 error "mtime($mtime) is not set to $TEST_39_MTIME"
4127 cancel_lru_locks $OSC
4128 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4131 run_test 39d "create, utime, stat =============================="
4135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4138 local mtime1=`stat -c %Y $DIR1/$tfile`
4140 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4142 for (( i=0; i < 2; i++ )) ; do
4143 local mtime2=`stat -c %Y $DIR1/$tfile`
4144 [ $mtime2 = $TEST_39_MTIME ] || \
4145 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4147 cancel_lru_locks $OSC
4148 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4151 run_test 39e "create, stat, utime, stat ========================"
4155 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4158 mtime1=`stat -c %Y $DIR1/$tfile`
4161 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4163 for (( i=0; i < 2; i++ )) ; do
4164 local mtime2=`stat -c %Y $DIR1/$tfile`
4165 [ $mtime2 = $TEST_39_MTIME ] || \
4166 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4168 cancel_lru_locks $OSC
4169 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4172 run_test 39f "create, stat, sleep, utime, stat ================="
4176 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4178 echo hello >> $DIR1/$tfile
4179 local mtime1=`stat -c %Y $DIR1/$tfile`
4182 chmod o+r $DIR1/$tfile
4184 for (( i=0; i < 2; i++ )) ; do
4185 local mtime2=`stat -c %Y $DIR1/$tfile`
4186 [ "$mtime1" = "$mtime2" ] || \
4187 error "lost mtime: $mtime2, should be $mtime1"
4189 cancel_lru_locks $OSC
4190 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4193 run_test 39g "write, chmod, stat ==============================="
4197 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4203 echo hello >> $DIR1/$tfile
4204 local mtime1=`stat -c %Y $DIR1/$tfile`
4206 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4208 if [ "$d1" != "$d2" ]; then
4209 echo "write and touch not within one second"
4211 for (( i=0; i < 2; i++ )) ; do
4212 local mtime2=`stat -c %Y $DIR1/$tfile`
4213 [ "$mtime2" = $TEST_39_MTIME ] || \
4214 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4216 cancel_lru_locks $OSC
4217 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4221 run_test 39h "write, utime within one second, stat ============="
4224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4229 echo hello >> $DIR1/$tfile
4230 local mtime1=`stat -c %Y $DIR1/$tfile`
4232 mv $DIR1/$tfile $DIR1/$tfile-1
4234 for (( i=0; i < 2; i++ )) ; do
4235 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4237 [ "$mtime1" = "$mtime2" ] || \
4238 error "lost mtime: $mtime2, should be $mtime1"
4240 cancel_lru_locks $OSC
4241 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4244 run_test 39i "write, rename, stat =============================="
4247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4249 start_full_debug_logging
4253 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4254 lctl set_param fail_loc=0x80000412
4255 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4256 error "multiop failed"
4258 local mtime1=`stat -c %Y $DIR1/$tfile`
4260 mv $DIR1/$tfile $DIR1/$tfile-1
4262 kill -USR1 $multipid
4263 wait $multipid || error "multiop close failed"
4265 for (( i=0; i < 2; i++ )) ; do
4266 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4267 [ "$mtime1" = "$mtime2" ] ||
4268 error "mtime is lost on close: $mtime2, " \
4272 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4274 lctl set_param fail_loc=0
4275 stop_full_debug_logging
4277 run_test 39j "write, rename, close, stat ======================="
4280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4285 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4287 local mtime1=`stat -c %Y $DIR1/$tfile`
4289 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4291 kill -USR1 $multipid
4292 wait $multipid || error "multiop close failed"
4294 for (( i=0; i < 2; i++ )) ; do
4295 local mtime2=`stat -c %Y $DIR1/$tfile`
4297 [ "$mtime2" = $TEST_39_MTIME ] || \
4298 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4301 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4304 run_test 39k "write, utime, close, stat ========================"
4306 # this should be set to future
4307 TEST_39_ATIME=`date -d "1 year" +%s`
4310 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4311 remote_mds_nodsh && skip "remote MDS with nodsh"
4313 local atime_diff=$(do_facet $SINGLEMDS \
4314 lctl get_param -n mdd.*MDT0000*.atime_diff)
4318 # test setting directory atime to future
4319 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4320 local atime=$(stat -c %X $DIR/$tdir)
4321 [ "$atime" = $TEST_39_ATIME ] ||
4322 error "atime is not set to future: $atime, $TEST_39_ATIME"
4324 # test setting directory atime from future to now
4325 local now=$(date +%s)
4326 touch -a -d @$now $DIR/$tdir
4328 atime=$(stat -c %X $DIR/$tdir)
4329 [ "$atime" -eq "$now" ] ||
4330 error "atime is not updated from future: $atime, $now"
4332 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4335 # test setting directory atime when now > dir atime + atime_diff
4336 local d1=$(date +%s)
4338 local d2=$(date +%s)
4339 cancel_lru_locks mdc
4340 atime=$(stat -c %X $DIR/$tdir)
4341 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4342 error "atime is not updated : $atime, should be $d2"
4344 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4347 # test not setting directory atime when now < dir atime + atime_diff
4349 cancel_lru_locks mdc
4350 atime=$(stat -c %X $DIR/$tdir)
4351 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4352 error "atime is updated to $atime, should remain $d1<atime<$d2"
4354 do_facet $SINGLEMDS \
4355 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4357 run_test 39l "directory atime update ==========================="
4360 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4364 local far_past_mtime=$(date -d "May 29 1953" +%s)
4365 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4367 touch -m -d @$far_past_mtime $DIR1/$tfile
4368 touch -a -d @$far_past_atime $DIR1/$tfile
4370 for (( i=0; i < 2; i++ )) ; do
4371 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4372 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4373 error "atime or mtime set incorrectly"
4375 cancel_lru_locks $OSC
4376 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4379 run_test 39m "test atime and mtime before 1970"
4381 test_39n() { # LU-3832
4382 remote_mds_nodsh && skip "remote MDS with nodsh"
4384 local atime_diff=$(do_facet $SINGLEMDS \
4385 lctl get_param -n mdd.*MDT0000*.atime_diff)
4390 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4393 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4394 atime0=$(stat -c %X $DIR/$tfile)
4397 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4398 atime1=$(stat -c %X $DIR/$tfile)
4401 cancel_lru_locks mdc
4402 cancel_lru_locks osc
4403 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4404 atime2=$(stat -c %X $DIR/$tfile)
4406 do_facet $SINGLEMDS \
4407 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4409 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4410 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4412 run_test 39n "check that O_NOATIME is honored"
4415 TESTDIR=$DIR/$tdir/$tfile
4416 [ -e $TESTDIR ] && rm -rf $TESTDIR
4423 links2=$(stat -c %h .)
4424 [ $(($links1 + 2)) != $links2 ] &&
4425 error "wrong links count $(($links1 + 2)) != $links2"
4427 links3=$(stat -c %h .)
4428 [ $(($links1 + 1)) != $links3 ] &&
4429 error "wrong links count $links1 != $links3"
4432 run_test 39o "directory cached attributes updated after create"
4435 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4438 TESTDIR=$DIR/$tdir/$tdir
4439 [ -e $TESTDIR ] && rm -rf $TESTDIR
4440 test_mkdir -p $TESTDIR
4444 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4445 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4447 links2=$(stat -c %h .)
4448 [ $(($links1 + 2)) != $links2 ] &&
4449 error "wrong links count $(($links1 + 2)) != $links2"
4451 links3=$(stat -c %h .)
4452 [ $(($links1 + 1)) != $links3 ] &&
4453 error "wrong links count $links1 != $links3"
4456 run_test 39p "remote directory cached attributes updated after create ========"
4459 test_39q() { # LU-8041
4460 local testdir=$DIR/$tdir
4462 multiop_bg_pause $testdir D_c || error "multiop failed"
4464 cancel_lru_locks mdc
4465 kill -USR1 $multipid
4466 local atime=$(stat -c %X $testdir)
4467 [ "$atime" -ne 0 ] || error "atime is zero"
4469 run_test 39q "close won't zero out atime"
4472 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4473 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4474 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4475 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4476 error "$tfile is not 4096 bytes in size"
4478 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4482 small_write $DIR/f41 18
4484 run_test 41 "test small file write + fstat ====================="
4486 count_ost_writes() {
4487 lctl get_param -n ${OSC}.*.stats |
4488 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4489 END { printf("%0.0f", writes) }'
4496 BG_DIRTY_RATIO_SAVE=10
4497 MAX_BG_DIRTY_RATIO=25
4501 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4502 # dirty_ratio, dirty_background_ratio
4503 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4504 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4505 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4506 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4508 # if file not here, we are a 2.4 kernel
4509 kill -CONT `pidof kupdated`
4514 # setup the trap first, so someone cannot exit the test at the
4515 # exact wrong time and mess up a machine
4516 trap start_writeback EXIT
4517 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4518 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4519 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4520 sysctl -w vm.dirty_writeback_centisecs=0
4521 sysctl -w vm.dirty_writeback_centisecs=0
4522 # save and increase /proc/sys/vm/dirty_ratio
4523 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4524 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4525 # save and increase /proc/sys/vm/dirty_background_ratio
4526 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4527 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4529 # if file not here, we are a 2.4 kernel
4530 kill -STOP `pidof kupdated`
4534 # ensure that all stripes have some grant before we test client-side cache
4536 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4537 dd if=/dev/zero of=$i bs=4k count=1
4542 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4543 # file truncation, and file removal.
4545 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4548 cancel_lru_locks $OSC
4550 sync; sleep 1; sync # just to be safe
4551 BEFOREWRITES=`count_ost_writes`
4552 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4553 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4554 AFTERWRITES=`count_ost_writes`
4555 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4556 error "$BEFOREWRITES < $AFTERWRITES"
4559 run_test 42a "ensure that we don't flush on close"
4562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4565 cancel_lru_locks $OSC
4568 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4569 BEFOREWRITES=$(count_ost_writes)
4570 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4571 AFTERWRITES=$(count_ost_writes)
4572 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4573 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4575 BEFOREWRITES=$(count_ost_writes)
4576 sync || error "sync: $?"
4577 AFTERWRITES=$(count_ost_writes)
4578 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4579 error "$BEFOREWRITES < $AFTERWRITES on sync"
4581 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4585 run_test 42b "test destroy of file with cached dirty data ======"
4587 # if these tests just want to test the effect of truncation,
4588 # they have to be very careful. consider:
4589 # - the first open gets a {0,EOF}PR lock
4590 # - the first write conflicts and gets a {0, count-1}PW
4591 # - the rest of the writes are under {count,EOF}PW
4592 # - the open for truncate tries to match a {0,EOF}PR
4593 # for the filesize and cancels the PWs.
4594 # any number of fixes (don't get {0,EOF} on open, match
4595 # composite locks, do smarter file size management) fix
4596 # this, but for now we want these tests to verify that
4597 # the cancellation with truncate intent works, so we
4598 # start the file with a full-file pw lock to match against
4599 # until the truncate.
4604 cancel_lru_locks $OSC
4606 # prime the file with 0,EOF PW to match
4610 # now the real test..
4611 dd if=/dev/zero of=$file bs=1024 count=100
4612 BEFOREWRITES=`count_ost_writes`
4613 $TRUNCATE $file $offset
4614 cancel_lru_locks $OSC
4615 AFTERWRITES=`count_ost_writes`
4620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4623 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4624 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4627 run_test 42c "test partial truncate of file with cached dirty data"
4630 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4633 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4634 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4637 run_test 42d "test complete truncate of file with cached dirty data"
4639 test_42e() { # bug22074
4640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4642 local TDIR=$DIR/${tdir}e
4643 local pages=16 # hardcoded 16 pages, don't change it.
4644 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4645 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4649 test_mkdir $DIR/${tdir}e
4650 $LFS setstripe -c 1 $TDIR
4651 createmany -o $TDIR/f $files
4653 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4655 # we assume that with $OSTCOUNT files, at least one of them will
4656 # be allocated on OST0.
4657 warmup_files=$((OSTCOUNT * max_dirty_mb))
4658 createmany -o $TDIR/w $warmup_files
4660 # write a large amount of data into one file and sync, to get good
4661 # avail_grant number from OST.
4662 for ((i=0; i<$warmup_files; i++)); do
4663 idx=$($LFS getstripe -i $TDIR/w$i)
4664 [ $idx -ne 0 ] && continue
4665 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4668 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4670 $LCTL get_param $proc_osc0/cur_dirty_bytes
4671 $LCTL get_param $proc_osc0/cur_grant_bytes
4673 # create as much dirty pages as we can while not to trigger the actual
4674 # RPCs directly. but depends on the env, VFS may trigger flush during this
4675 # period, hopefully we are good.
4676 for ((i=0; i<$warmup_files; i++)); do
4677 idx=$($LFS getstripe -i $TDIR/w$i)
4678 [ $idx -ne 0 ] && continue
4679 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4681 $LCTL get_param $proc_osc0/cur_dirty_bytes
4682 $LCTL get_param $proc_osc0/cur_grant_bytes
4684 # perform the real test
4685 $LCTL set_param $proc_osc0/rpc_stats 0
4686 for ((;i<$files; i++)); do
4687 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
4688 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4691 $LCTL get_param $proc_osc0/rpc_stats
4694 local have_ppr=false
4695 $LCTL get_param $proc_osc0/rpc_stats |
4696 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4697 # skip lines until we are at the RPC histogram data
4698 [ "$PPR" == "pages" ] && have_ppr=true && continue
4699 $have_ppr || continue
4701 # we only want the percent stat for < 16 pages
4702 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4704 percent=$((percent + WPCT))
4705 if [[ $percent -gt 15 ]]; then
4706 error "less than 16-pages write RPCs" \
4713 run_test 42e "verify sub-RPC writes are not done synchronously"
4715 test_43A() { # was test_43
4716 test_mkdir $DIR/$tdir
4717 cp -p /bin/ls $DIR/$tdir/$tfile
4718 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4720 # give multiop a chance to open
4723 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4726 run_test 43A "execution of file opened for write should return -ETXTBSY"
4729 test_mkdir $DIR/$tdir
4730 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4731 $DIR/$tdir/sleep 60 &
4733 # Make sure exec of $tdir/sleep wins race with truncate
4735 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4738 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4741 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4743 test_mkdir $DIR/$tdir
4744 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4745 $DIR/$tdir/sleep 60 &
4747 # Make sure exec of $tdir/sleep wins race with truncate
4749 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4752 run_test 43b "truncate of file being executed should return -ETXTBSY"
4755 local testdir="$DIR/$tdir"
4758 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4759 ( cd $testdir && md5sum -c )
4761 run_test 43c "md5sum of copy into lustre"
4763 test_44A() { # was test_44
4764 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4766 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4767 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4769 run_test 44A "zero length read from a sparse stripe"
4772 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4774 [ -z "$nstripe" ] && skip "can't get stripe info"
4775 [[ $nstripe -gt $OSTCOUNT ]] &&
4776 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4778 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4780 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4781 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4785 OFFSETS="0 $((stride/2)) $((stride-1))"
4786 for offset in $OFFSETS; do
4787 for i in $(seq 0 $((nstripe-1))); do
4788 local GLOBALOFFSETS=""
4790 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4791 local myfn=$DIR/d44a-$size
4792 echo "--------writing $myfn at $size"
4793 ll_sparseness_write $myfn $size ||
4794 error "ll_sparseness_write"
4795 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4796 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4797 error "ll_sparseness_verify $GLOBALOFFSETS"
4799 for j in $(seq 0 $((nstripe-1))); do
4801 size=$((((j + $nstripe )*$stride + $offset)))
4802 ll_sparseness_write $myfn $size ||
4803 error "ll_sparseness_write"
4804 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4806 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4807 error "ll_sparseness_verify $GLOBALOFFSETS"
4812 run_test 44a "test sparse pwrite ==============================="
4816 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4822 before=`dirty_osc_total`
4823 echo executing "\"$*\""
4825 after=`dirty_osc_total`
4826 echo before $before, after $after
4829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4832 # Obtain grants from OST if it supports it
4833 echo blah > ${f}_grant
4836 do_dirty_record "echo blah > $f"
4837 [[ $before -eq $after ]] && error "write wasn't cached"
4838 do_dirty_record "> $f"
4839 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4840 do_dirty_record "echo blah > $f"
4841 [[ $before -eq $after ]] && error "write wasn't cached"
4842 do_dirty_record "sync"
4843 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4844 do_dirty_record "echo blah > $f"
4845 [[ $before -eq $after ]] && error "write wasn't cached"
4846 do_dirty_record "cancel_lru_locks osc"
4847 [[ $before -gt $after ]] ||
4848 error "lock cancellation didn't lower dirty count"
4851 run_test 45 "osc io page accounting ============================"
4853 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4854 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4855 # objects offset and an assert hit when an rpc was built with 1023's mapped
4856 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4863 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4865 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4866 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4870 run_test 46 "dirtying a previously written page ================"
4872 # test_47 is removed "Device nodes check" is moved to test_28
4874 test_48a() { # bug 2399
4875 [ "$mds1_FSTYPE" = "zfs" ] &&
4876 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4877 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4879 test_mkdir $DIR/$tdir
4881 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4882 test_mkdir $DIR/$tdir
4883 touch foo || error "'touch foo' failed after recreating cwd"
4885 touch .foo || error "'touch .foo' failed after recreating cwd"
4887 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4888 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4889 cd . || error "'cd .' failed after recreating cwd"
4890 mkdir . && error "'mkdir .' worked after recreating cwd"
4891 rmdir . && error "'rmdir .' worked after recreating cwd"
4892 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4893 cd .. || error "'cd ..' failed after recreating cwd"
4895 run_test 48a "Access renamed working dir (should return errors)="
4897 test_48b() { # bug 2399
4899 test_mkdir $DIR/$tdir
4901 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4902 touch foo && error "'touch foo' worked after removing cwd"
4903 mkdir foo && error "'mkdir foo' worked after removing cwd"
4904 touch .foo && error "'touch .foo' worked after removing cwd"
4905 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4906 ls . > /dev/null && error "'ls .' worked after removing cwd"
4907 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4908 mkdir . && error "'mkdir .' worked after removing cwd"
4909 rmdir . && error "'rmdir .' worked after removing cwd"
4910 ln -s . foo && error "'ln -s .' worked after removing cwd"
4911 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4913 run_test 48b "Access removed working dir (should return errors)="
4915 test_48c() { # bug 2350
4916 #lctl set_param debug=-1
4919 test_mkdir -p $DIR/$tdir/dir
4921 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4922 $TRACE touch foo && error "touch foo worked after removing cwd"
4923 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4924 touch .foo && error "touch .foo worked after removing cwd"
4925 mkdir .foo && error "mkdir .foo worked after removing cwd"
4926 $TRACE ls . && error "'ls .' worked after removing cwd"
4927 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4928 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4929 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4930 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4931 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4933 run_test 48c "Access removed working subdir (should return errors)"
4935 test_48d() { # bug 2350
4936 #lctl set_param debug=-1
4939 test_mkdir -p $DIR/$tdir/dir
4941 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4942 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4943 $TRACE touch foo && error "'touch foo' worked after removing parent"
4944 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4945 touch .foo && error "'touch .foo' worked after removing parent"
4946 mkdir .foo && error "mkdir .foo worked after removing parent"
4947 $TRACE ls . && error "'ls .' worked after removing parent"
4948 $TRACE ls .. && error "'ls ..' worked after removing parent"
4949 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4950 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4951 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4954 run_test 48d "Access removed parent subdir (should return errors)"
4956 test_48e() { # bug 4134
4957 #lctl set_param debug=-1
4960 test_mkdir -p $DIR/$tdir/dir
4962 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4963 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4964 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4965 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4966 # On a buggy kernel addition of "touch foo" after cd .. will
4967 # produce kernel oops in lookup_hash_it
4968 touch ../foo && error "'cd ..' worked after recreate parent"
4970 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4972 run_test 48e "Access to recreated parent subdir (should return errors)"
4974 test_49() { # LU-1030
4975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4976 remote_ost_nodsh && skip "remote OST with nodsh"
4978 # get ost1 size - lustre-OST0000
4979 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4981 # write 800M at maximum
4982 [[ $ost1_size -lt 2 ]] && ost1_size=2
4983 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4985 $LFS setstripe -c 1 -i 0 $DIR/$tfile
4986 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4989 # change max_pages_per_rpc while writing the file
4990 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4991 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4992 # loop until dd process exits
4993 while ps ax -opid | grep -wq $dd_pid; do
4994 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4995 sleep $((RANDOM % 5 + 1))
4997 # restore original max_pages_per_rpc
4998 $LCTL set_param $osc1_mppc=$orig_mppc
4999 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5001 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5005 test_mkdir $DIR/$tdir
5007 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5009 run_test 50 "special situations: /proc symlinks ==============="
5011 test_51a() { # was test_51
5012 # bug 1516 - create an empty entry right after ".." then split dir
5013 test_mkdir -c1 $DIR/$tdir
5014 touch $DIR/$tdir/foo
5015 $MCREATE $DIR/$tdir/bar
5017 createmany -m $DIR/$tdir/longfile 201
5019 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5020 $MCREATE $DIR/$tdir/longfile$FNUM
5025 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5027 run_test 51a "special situations: split htree with empty entry =="
5029 cleanup_print_lfs_df () {
5036 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5038 local dir=$DIR/$tdir
5039 local nrdirs=$((65536 + 100))
5041 # cleanup the directory
5048 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5049 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5050 [[ $numfree -lt $nrdirs ]] &&
5051 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5053 # need to check free space for the directories as well
5054 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5055 numfree=$(( blkfree / $(fs_inode_ksize) ))
5056 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5058 trap cleanup_print_lfs_df EXIT
5061 createmany -d $dir/d $nrdirs || {
5062 unlinkmany $dir/d $nrdirs
5063 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5067 nrdirs=$(ls -U $dir | wc -l)
5069 # unlink all but 100 subdirectories, then check it still works
5071 local delete=$((nrdirs - left))
5076 # for ldiskfs the nlink count should be 1, but this is OSD specific
5077 # and so this is listed for informational purposes only
5078 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5079 unlinkmany -d $dir/d $delete ||
5080 error "unlink of first $delete subdirs failed"
5082 echo "nlink between: $(stat -c %h $dir)"
5083 local found=$(ls -U $dir | wc -l)
5084 [ $found -ne $left ] &&
5085 error "can't find subdirs: found only $found, expected $left"
5087 unlinkmany -d $dir/d $delete $left ||
5088 error "unlink of second $left subdirs failed"
5089 # regardless of whether the backing filesystem tracks nlink accurately
5090 # or not, the nlink count shouldn't be more than "." and ".." here
5091 local after=$(stat -c %h $dir)
5092 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5093 echo "nlink after: $after"
5095 cleanup_print_lfs_df
5097 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5100 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5101 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5103 test_mkdir $DIR/$tdir
5104 createmany -o $DIR/$tdir/t- 1000
5105 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5106 for N in $(seq 0 $((OSTCOUNT - 1))); do
5107 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
5108 END { printf("%0.0f", objs) }' $TMP/$tfile)
5109 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5110 '($1 == '$N') { objs += 1 } \
5111 END { printf("%0.0f", objs) }')
5112 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
5114 unlinkmany $DIR/$tdir/t- 1000
5117 for N in $(seq 1 $((OSTCOUNT - 1))); do
5118 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
5119 error "OST $N has less objects vs OST $NLAST" \
5120 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5121 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
5122 error "OST $N has less objects vs OST $NLAST" \
5123 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5125 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
5126 error "OST $N has less #0 objects vs OST $NLAST" \
5127 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5128 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
5129 error "OST $N has less #0 objects vs OST $NLAST" \
5130 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5135 run_test 51d "check object distribution"
5138 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5139 skip_env "ldiskfs only test"
5142 test_mkdir -c1 $DIR/$tdir
5143 test_mkdir -c1 $DIR/$tdir/d0
5145 touch $DIR/$tdir/d0/foo
5146 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5147 error "file exceed 65000 nlink limit!"
5148 unlinkmany $DIR/$tdir/d0/f- 65001
5151 run_test 51e "check file nlink limit"
5154 test_mkdir $DIR/$tdir
5157 local ulimit_old=$(ulimit -n)
5158 local spare=20 # number of spare fd's for scripts/libraries, etc.
5159 local mdt=$($LFS getstripe -m $DIR/$tdir)
5160 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5162 echo "MDT$mdt numfree=$numfree, max=$max"
5163 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5164 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5165 while ! ulimit -n $((numfree + spare)); do
5166 numfree=$((numfree * 3 / 4))
5168 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5170 echo "left ulimit at $ulimit_old"
5173 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5174 unlinkmany $DIR/$tdir/f $numfree
5175 error "create+open $numfree files in $DIR/$tdir failed"
5177 ulimit -n $ulimit_old
5179 # if createmany exits at 120s there will be fewer than $numfree files
5180 unlinkmany $DIR/$tdir/f $numfree || true
5182 run_test 51f "check many open files limit"
5185 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5186 test_mkdir $DIR/$tdir
5187 touch $DIR/$tdir/foo
5188 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5189 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5190 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5191 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5192 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5194 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5195 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5196 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5198 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5199 cp -r $DIR/$tdir $TMP/
5200 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5202 run_test 52a "append-only flag test (should return errors)"
5205 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5206 test_mkdir $DIR/$tdir
5207 touch $DIR/$tdir/foo
5208 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5209 cat test > $DIR/$tdir/foo && error "cat test worked"
5210 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5211 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5212 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5214 echo foo >> $DIR/$tdir/foo && error "echo worked"
5215 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5216 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5217 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5218 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5220 chattr -i $DIR/$tdir/foo || error "chattr failed"
5222 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5224 run_test 52b "immutable flag test (should return errors) ======="
5227 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5228 remote_mds_nodsh && skip "remote MDS with nodsh"
5229 remote_ost_nodsh && skip "remote OST with nodsh"
5242 local support_last_seq=true
5244 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5245 support_last_seq=false
5248 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5250 for value in $(do_facet $SINGLEMDS \
5251 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5252 param=$(echo ${value[0]} | cut -d "=" -f1)
5253 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5255 if $support_last_seq; then
5256 param_seq=$(echo $param |
5257 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5258 mds_last_seq=$(do_facet $SINGLEMDS \
5259 $LCTL get_param -n $param_seq)
5261 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5263 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5264 node=$(facet_active_host ost$((ostnum+1)))
5265 param="obdfilter.$ostname.last_id"
5266 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5267 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5268 ost_last_id=$ost_last
5270 if $support_last_seq; then
5271 ost_last_id=$(echo $ost_last |
5272 awk -F':' '{print $2}' |
5274 ost_last_seq=$(echo $ost_last |
5275 awk -F':' '{print $1}')
5276 [[ $ost_last_seq = $mds_last_seq ]] || continue
5279 if [[ $ost_last_id != $mds_last ]]; then
5280 error "$ost_last_id != $mds_last"
5287 $found || error "can not match last_seq/last_id for $mdtosc"
5290 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5293 perl -MSocket -e ';' || skip "no Socket perl module installed"
5295 $SOCKETSERVER $DIR/socket ||
5296 error "$SOCKETSERVER $DIR/socket failed: $?"
5297 $SOCKETCLIENT $DIR/socket ||
5298 error "$SOCKETCLIENT $DIR/socket failed: $?"
5299 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5301 run_test 54a "unix domain socket test =========================="
5307 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5309 run_test 54b "char device works in lustre ======================"
5312 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5313 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5314 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5316 for i in $(seq 3 7); do
5317 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5326 loopdev="$DIR/loop54c"
5329 $UMOUNT $DIR/$tdir || rc=$?
5330 losetup -d $loopdev || true
5331 losetup -d $LOOPDEV || true
5332 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5337 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5339 loopdev="$DIR/loop54c"
5342 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5343 trap cleanup_54c EXIT
5344 mknod $loopdev b 7 $LOOPNUM
5345 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5346 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5347 losetup $loopdev $DIR/$tfile ||
5348 error "can't set up $loopdev for $DIR/$tfile"
5349 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5350 test_mkdir $DIR/$tdir
5351 mount -t ext2 $loopdev $DIR/$tdir ||
5352 error "error mounting $loopdev on $DIR/$tdir"
5353 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5356 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5360 run_test 54c "block device works in lustre ====================="
5366 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5368 run_test 54d "fifo device works in lustre ======================"
5373 cp -aL /dev/console $f
5374 echo $string > $f || error "echo $string to $f failed"
5376 run_test 54e "console/tty device works in lustre ======================"
5380 local dir=$DIR/$tdir
5383 test_mkdir -p $dir/dir
5384 for i in $(seq $numfiles); do
5386 touch $dir/dir/file$i
5389 local numcomp=$($LFS getstripe --component-count $dir)
5391 [[ $numcomp == 0 ]] && numcomp=1
5393 # test lfs getstripe with --recursive
5394 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5396 [[ $filenum -eq $((numfiles * 2)) ]] ||
5397 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5398 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5399 [[ $filenum -eq $numfiles ]] ||
5400 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5401 echo "$LFS getstripe showed obdidx or l_ost_idx"
5403 # test lfs getstripe with file instead of dir
5404 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5405 [[ $filenum -eq 1 ]] ||
5406 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5407 echo "$LFS getstripe file1 passed"
5409 #test lfs getstripe with --verbose
5410 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5411 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5412 error "$LFS getstripe --verbose $dir: "\
5413 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5414 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5415 error "$LFS getstripe $dir: showed lmm_magic"
5417 #test lfs getstripe with -v prints lmm_fid
5418 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5419 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5420 error "$LFS getstripe -v $dir: "\
5421 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5422 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5423 error "$LFS getstripe $dir: showed lmm_fid by default"
5424 echo "$LFS getstripe --verbose passed"
5426 #check for FID information
5427 local fid1=$($LFS getstripe --fid $dir/file1)
5428 local fid2=$($LFS getstripe --verbose $dir/file1 |
5429 awk '/lmm_fid: / { print $2; exit; }')
5430 local fid3=$($LFS path2fid $dir/file1)
5432 [ "$fid1" != "$fid2" ] &&
5433 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5434 [ "$fid1" != "$fid3" ] &&
5435 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5436 echo "$LFS getstripe --fid passed"
5438 #test lfs getstripe with --obd
5439 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5440 error "$LFS getstripe --obd wrong_uuid: should return error"
5442 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5445 local obduuid=$(ostuuid_from_index $ostidx)
5446 local found=$($LFS getstripe -r --obd $obduuid $dir |
5447 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5449 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5450 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5452 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5455 [[ $found -eq $filenum ]] ||
5456 error "$LFS getstripe --obd: found $found expect $filenum"
5457 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5458 sed '/^[ ]*'${ostidx}'[ ]/d' |
5459 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5460 error "$LFS getstripe --obd: should not show file on other obd"
5461 echo "$LFS getstripe --obd passed"
5463 run_test 56a "check $LFS getstripe"
5466 local dir=$DIR/$tdir
5470 for i in $(seq $numdirs); do
5471 test_mkdir $dir/dir$i
5474 # test lfs getdirstripe default mode is non-recursion, which is
5475 # different from lfs getstripe
5476 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5478 [[ $dircnt -eq 1 ]] ||
5479 error "$LFS getdirstripe: found $dircnt, not 1"
5480 dircnt=$($LFS getdirstripe --recursive $dir |
5481 grep -c lmv_stripe_count)
5482 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5483 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5485 run_test 56b "check $LFS getdirstripe"
5488 remote_ost_nodsh && skip "remote OST with nodsh"
5491 local ost_name=$(ostname_from_index $ost_idx)
5492 local old_status=$(ost_dev_status $ost_idx)
5494 [[ -z "$old_status" ]] ||
5495 skip_env "OST $ost_name is in $old_status status"
5497 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5500 local new_status=$(ost_dev_status $ost_idx)
5502 [[ "$new_status" = "D" ]] ||
5503 error "OST $ost_name is in status of '$new_status', not 'D'"
5505 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5508 new_status=$(ost_dev_status $ost_idx)
5509 [[ -z "$new_status" ]] ||
5510 error "OST $ost_name is in status of '$new_status', not ''"
5512 run_test 56c "check 'lfs df' showing device status"
5517 local local_tdir="$1"
5518 local local_numfiles="$2"
5519 local local_numdirs="$3"
5520 local dir_params="$4"
5521 local dir_stripe_params="$5"
5523 if [ ! -d "$local_tdir" ] ; then
5524 test_mkdir -p $dir_stripe_params $local_tdir
5525 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5526 for i in $(seq $local_numfiles) ; do
5527 touch $local_tdir/file$i
5529 for i in $(seq $local_numdirs) ; do
5530 test_mkdir $dir_stripe_params $local_tdir/dir$i
5531 for j in $(seq $local_numfiles) ; do
5532 touch $local_tdir/dir$i/file$j
5538 setup_56_special() {
5540 local local_numfiles=$2
5541 local local_numdirs=$3
5543 setup_56 $local_tdir $local_numfiles $local_numdirs
5545 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5546 for i in $(seq $local_numfiles) ; do
5547 mknod $local_tdir/loop${i}b b 7 $i
5548 mknod $local_tdir/null${i}c c 1 3
5549 ln -s $local_tdir/file1 $local_tdir/link${i}
5551 for i in $(seq $local_numdirs) ; do
5552 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5553 mknod $local_tdir/dir$i/null${i}c c 1 3
5554 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5560 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5561 local expected=$(($NUMDIRS + 2))
5563 setup_56 $dir $NUMFILES $NUMDIRS
5565 # test lfs find with -name
5566 for i in $(seq $NUMFILES) ; do
5567 local nums=$($LFS find -name "*$i" $dir | wc -l)
5569 [ $nums -eq $expected ] ||
5570 error "lfs find -name '*$i' $dir wrong: "\
5571 "found $nums, expected $expected"
5574 run_test 56g "check lfs find -name"
5577 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5578 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5580 setup_56 $dir $NUMFILES $NUMDIRS
5582 # test lfs find with ! -name
5583 for i in $(seq $NUMFILES) ; do
5584 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5586 [ $nums -eq $expected ] ||
5587 error "lfs find ! -name '*$i' $dir wrong: "\
5588 "found $nums, expected $expected"
5591 run_test 56h "check lfs find ! -name"
5594 local dir=$DIR/$tdir
5598 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5601 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5603 run_test 56i "check 'lfs find -ost UUID' skips directories"
5606 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5608 setup_56_special $dir $NUMFILES $NUMDIRS
5610 local expected=$((NUMDIRS + 1))
5611 local cmd="$LFS find -type d $dir"
5612 local nums=$($cmd | wc -l)
5614 [ $nums -eq $expected ] ||
5615 error "'$cmd' wrong: found $nums, expected $expected"
5617 run_test 56j "check lfs find -type d"
5620 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5622 setup_56_special $dir $NUMFILES $NUMDIRS
5624 local expected=$(((NUMDIRS + 1) * NUMFILES))
5625 local cmd="$LFS find -type f $dir"
5626 local nums=$($cmd | wc -l)
5628 [ $nums -eq $expected ] ||
5629 error "'$cmd' wrong: found $nums, expected $expected"
5631 run_test 56k "check lfs find -type f"
5634 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5636 setup_56_special $dir $NUMFILES $NUMDIRS
5638 local expected=$((NUMDIRS + NUMFILES))
5639 local cmd="$LFS find -type b $dir"
5640 local nums=$($cmd | wc -l)
5642 [ $nums -eq $expected ] ||
5643 error "'$cmd' wrong: found $nums, expected $expected"
5645 run_test 56l "check lfs find -type b"
5648 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5650 setup_56_special $dir $NUMFILES $NUMDIRS
5652 local expected=$((NUMDIRS + NUMFILES))
5653 local cmd="$LFS find -type c $dir"
5654 local nums=$($cmd | wc -l)
5655 [ $nums -eq $expected ] ||
5656 error "'$cmd' wrong: found $nums, expected $expected"
5658 run_test 56m "check lfs find -type c"
5661 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5662 setup_56_special $dir $NUMFILES $NUMDIRS
5664 local expected=$((NUMDIRS + NUMFILES))
5665 local cmd="$LFS find -type l $dir"
5666 local nums=$($cmd | wc -l)
5668 [ $nums -eq $expected ] ||
5669 error "'$cmd' wrong: found $nums, expected $expected"
5671 run_test 56n "check lfs find -type l"
5674 local dir=$DIR/$tdir
5676 setup_56 $dir $NUMFILES $NUMDIRS
5677 utime $dir/file1 > /dev/null || error "utime (1)"
5678 utime $dir/file2 > /dev/null || error "utime (2)"
5679 utime $dir/dir1 > /dev/null || error "utime (3)"
5680 utime $dir/dir2 > /dev/null || error "utime (4)"
5681 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5682 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5685 local nums=$($LFS find -mtime +0 $dir | wc -l)
5687 [ $nums -eq $expected ] ||
5688 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5691 cmd="$LFS find -mtime 0 $dir"
5692 nums=$($cmd | wc -l)
5693 [ $nums -eq $expected ] ||
5694 error "'$cmd' wrong: found $nums, expected $expected"
5696 run_test 56o "check lfs find -mtime for old files"
5699 local dir=$DIR/$tdir
5703 # just to make sure there is something that won't be found
5705 touch $dir/$tfile.now
5707 for age in year week day hour min; do
5708 count=$((count + 1))
5710 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
5711 touch --date="$count $age ago" -a $dir/$tfile-a.$age
5712 touch --date="$count $age ago" -m $dir/$tfile-m.$age
5714 local cmd="$LFS find $dir -mtime $count${age:0:1}"
5715 local nums=$($cmd | wc -l)
5716 [ $nums -eq $expected ] ||
5717 error "'$cmd' wrong: found $nums, expected $expected"
5719 cmd="$LFS find $dir -atime $count${age:0:1}"
5720 nums=$($cmd | wc -l)
5721 [ $nums -eq $expected ] ||
5722 error "'$cmd' wrong: found $nums, expected $expected"
5726 cmd="$LFS find $dir -ctime +1s -type f"
5727 nums=$($cmd | wc -l)
5728 (( $nums == $count * 2 + 1)) ||
5729 error "'$cmd' wrong: found $nums, expected $((expected*2+1))"
5731 run_test 56ob "check lfs find -atime -mtime -ctime with units"
5734 [ $RUNAS_ID -eq $UID ] &&
5735 skip_env "RUNAS_ID = UID = $UID -- skipping"
5737 local dir=$DIR/$tdir
5739 setup_56 $dir $NUMFILES $NUMDIRS
5740 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5742 local expected=$NUMFILES
5743 local cmd="$LFS find -uid $RUNAS_ID $dir"
5744 local nums=$($cmd | wc -l)
5746 [ $nums -eq $expected ] ||
5747 error "'$cmd' wrong: found $nums, expected $expected"
5749 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5750 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5751 nums=$($cmd | wc -l)
5752 [ $nums -eq $expected ] ||
5753 error "'$cmd' wrong: found $nums, expected $expected"
5755 run_test 56p "check lfs find -uid and ! -uid"
5758 [ $RUNAS_ID -eq $UID ] &&
5759 skip_env "RUNAS_ID = UID = $UID -- skipping"
5761 local dir=$DIR/$tdir
5763 setup_56 $dir $NUMFILES $NUMDIRS
5764 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5766 local expected=$NUMFILES
5767 local cmd="$LFS find -gid $RUNAS_GID $dir"
5768 local nums=$($cmd | wc -l)
5770 [ $nums -eq $expected ] ||
5771 error "'$cmd' wrong: found $nums, expected $expected"
5773 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5774 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5775 nums=$($cmd | wc -l)
5776 [ $nums -eq $expected ] ||
5777 error "'$cmd' wrong: found $nums, expected $expected"
5779 run_test 56q "check lfs find -gid and ! -gid"
5782 local dir=$DIR/$tdir
5784 setup_56 $dir $NUMFILES $NUMDIRS
5787 local cmd="$LFS find -size 0 -type f -lazy $dir"
5788 local nums=$($cmd | wc -l)
5790 [ $nums -eq $expected ] ||
5791 error "'$cmd' wrong: found $nums, expected $expected"
5792 cmd="$LFS find -size 0 -type f $dir"
5793 nums=$($cmd | wc -l)
5794 [ $nums -eq $expected ] ||
5795 error "'$cmd' wrong: found $nums, expected $expected"
5798 cmd="$LFS find ! -size 0 -type f -lazy $dir"
5799 nums=$($cmd | wc -l)
5800 [ $nums -eq $expected ] ||
5801 error "'$cmd' wrong: found $nums, expected $expected"
5802 cmd="$LFS find ! -size 0 -type f $dir"
5803 nums=$($cmd | wc -l)
5804 [ $nums -eq $expected ] ||
5805 error "'$cmd' wrong: found $nums, expected $expected"
5807 echo "test" > $dir/$tfile
5808 echo "test2" > $dir/$tfile.2 && sync
5810 cmd="$LFS find -size 5 -type f -lazy $dir"
5811 nums=$($cmd | wc -l)
5812 [ $nums -eq $expected ] ||
5813 error "'$cmd' wrong: found $nums, expected $expected"
5814 cmd="$LFS find -size 5 -type f $dir"
5815 nums=$($cmd | wc -l)
5816 [ $nums -eq $expected ] ||
5817 error "'$cmd' wrong: found $nums, expected $expected"
5820 cmd="$LFS find -size +5 -type f -lazy $dir"
5821 nums=$($cmd | wc -l)
5822 [ $nums -eq $expected ] ||
5823 error "'$cmd' wrong: found $nums, expected $expected"
5824 cmd="$LFS find -size +5 -type f $dir"
5825 nums=$($cmd | wc -l)
5826 [ $nums -eq $expected ] ||
5827 error "'$cmd' wrong: found $nums, expected $expected"
5830 cmd="$LFS find -size +0 -type f -lazy $dir"
5831 nums=$($cmd | wc -l)
5832 [ $nums -eq $expected ] ||
5833 error "'$cmd' wrong: found $nums, expected $expected"
5834 cmd="$LFS find -size +0 -type f $dir"
5835 nums=$($cmd | wc -l)
5836 [ $nums -eq $expected ] ||
5837 error "'$cmd' wrong: found $nums, expected $expected"
5840 cmd="$LFS find ! -size -5 -type f -lazy $dir"
5841 nums=$($cmd | wc -l)
5842 [ $nums -eq $expected ] ||
5843 error "'$cmd' wrong: found $nums, expected $expected"
5844 cmd="$LFS find ! -size -5 -type f $dir"
5845 nums=$($cmd | wc -l)
5846 [ $nums -eq $expected ] ||
5847 error "'$cmd' wrong: found $nums, expected $expected"
5850 cmd="$LFS find -size -5 -type f -lazy $dir"
5851 nums=$($cmd | wc -l)
5852 [ $nums -eq $expected ] ||
5853 error "'$cmd' wrong: found $nums, expected $expected"
5854 cmd="$LFS find -size -5 -type f $dir"
5855 nums=$($cmd | wc -l)
5856 [ $nums -eq $expected ] ||
5857 error "'$cmd' wrong: found $nums, expected $expected"
5859 run_test 56r "check lfs find -size works"
5862 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
5863 skip "MDS < 2.12.58 doesn't return LSOM data"
5864 local dir=$DIR/$tdir
5866 [[ $OSC == "mdc" ]] && skip "DoM files" && return
5868 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5870 cancel_lru_locks $OSC
5872 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5874 local cmd="$LFS find -size 0 -type f -lazy $dir"
5875 local nums=$($cmd | wc -l)
5877 [ $nums -eq $expected ] ||
5878 error "'$cmd' wrong: found $nums, expected $expected"
5880 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5881 [ $rpcs_before -eq $rpcs_after ] ||
5882 error "'$cmd' should not send glimpse RPCs to OST"
5883 cmd="$LFS find -size 0 -type f $dir"
5884 nums=$($cmd | wc -l)
5885 [ $nums -eq $expected ] ||
5886 error "'$cmd' wrong: found $nums, expected $expected"
5887 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5888 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5889 $LCTL get_param osc.*.stats
5890 [ $rpcs_after -eq $((rpcs_before + 12)) ] ||
5891 error "'$cmd' should send 12 glimpse RPCs to OST"
5893 cancel_lru_locks $OSC
5894 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5896 cmd="$LFS find ! -size 0 -type f -lazy $dir"
5897 nums=$($cmd | wc -l)
5898 [ $nums -eq $expected ] ||
5899 error "'$cmd' wrong: found $nums, expected $expected"
5900 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5901 $LCTL get_param mdc.*.stats
5902 [ $rpcs_before -eq $rpcs_after ] ||
5903 error "'$cmd' should not send glimpse RPCs to OST"
5904 cmd="$LFS find ! -size 0 -type f $dir"
5905 nums=$($cmd | wc -l)
5906 [ $nums -eq $expected ] ||
5907 error "'$cmd' wrong: found $nums, expected $expected"
5908 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5909 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5910 [ $rpcs_after -eq $((rpcs_before + 12)) ] ||
5911 error "'$cmd' should send 12 glimpse RPCs to OST"
5913 echo "test" > $dir/$tfile
5914 echo "test2" > $dir/$tfile.2 && sync
5915 cancel_lru_locks $OSC
5916 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5918 cmd="$LFS find -size 5 -type f -lazy $dir"
5919 nums=$($cmd | wc -l)
5920 [ $nums -eq $expected ] ||
5921 error "'$cmd' wrong: found $nums, expected $expected"
5922 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5923 [ $rpcs_before -eq $rpcs_after ] ||
5924 error "'$cmd' should not send glimpse RPCs to OST"
5925 cmd="$LFS find -size 5 -type f $dir"
5926 nums=$($cmd | wc -l)
5927 [ $nums -eq $expected ] ||
5928 error "'$cmd' wrong: found $nums, expected $expected"
5929 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5930 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5931 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
5932 error "'$cmd' should send 14 glimpse RPCs to OST"
5934 cancel_lru_locks $OSC
5935 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5937 cmd="$LFS find -size +5 -type f -lazy $dir"
5938 nums=$($cmd | wc -l)
5939 [ $nums -eq $expected ] ||
5940 error "'$cmd' wrong: found $nums, expected $expected"
5941 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5942 [ $rpcs_before -eq $rpcs_after ] ||
5943 error "'$cmd' should not send glimpse RPCs to OST"
5944 cmd="$LFS find -size +5 -type f $dir"
5945 nums=$($cmd | wc -l)
5946 [ $nums -eq $expected ] ||
5947 error "'$cmd' wrong: found $nums, expected $expected"
5948 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5949 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5950 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
5951 error "'$cmd' should send 14 glimpse RPCs to OST"
5953 cancel_lru_locks $OSC
5954 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5956 cmd="$LFS find -size +0 -type f -lazy $dir"
5957 nums=$($cmd | wc -l)
5958 [ $nums -eq $expected ] ||
5959 error "'$cmd' wrong: found $nums, expected $expected"
5960 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5961 [ $rpcs_before -eq $rpcs_after ] ||
5962 error "'$cmd' should not send glimpse RPCs to OST"
5963 cmd="$LFS find -size +0 -type f $dir"
5964 nums=$($cmd | wc -l)
5965 [ $nums -eq $expected ] ||
5966 error "'$cmd' wrong: found $nums, expected $expected"
5967 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5968 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5969 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
5970 error "'$cmd' should send 14 glimpse RPCs to OST"
5972 cancel_lru_locks $OSC
5973 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5975 cmd="$LFS find ! -size -5 -type f -lazy $dir"
5976 nums=$($cmd | wc -l)
5977 [ $nums -eq $expected ] ||
5978 error "'$cmd' wrong: found $nums, expected $expected"
5979 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5980 [ $rpcs_before -eq $rpcs_after ] ||
5981 error "'$cmd' should not send glimpse RPCs to OST"
5982 cmd="$LFS find ! -size -5 -type f $dir"
5983 nums=$($cmd | wc -l)
5984 [ $nums -eq $expected ] ||
5985 error "'$cmd' wrong: found $nums, expected $expected"
5986 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5987 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5988 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
5989 error "'$cmd' should send 14 glimpse RPCs to OST"
5991 cancel_lru_locks $OSC
5992 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5994 cmd="$LFS find -size -5 -type f -lazy $dir"
5995 nums=$($cmd | wc -l)
5996 [ $nums -eq $expected ] ||
5997 error "'$cmd' wrong: found $nums, expected $expected"
5998 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5999 [ $rpcs_before -eq $rpcs_after ] ||
6000 error "'$cmd' should not send glimpse RPCs to OST"
6001 cmd="$LFS find -size -5 -type f $dir"
6002 nums=$($cmd | wc -l)
6003 [ $nums -eq $expected ] ||
6004 error "'$cmd' wrong: found $nums, expected $expected"
6005 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6006 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6007 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6008 error "'$cmd' should send 14 glimpse RPCs to OST"
6010 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6012 test_56s() { # LU-611 #LU-9369
6013 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6015 local dir=$DIR/$tdir
6016 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6018 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6019 for i in $(seq $NUMDIRS); do
6020 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6023 local expected=$NUMDIRS
6024 local cmd="$LFS find -c $OSTCOUNT $dir"
6025 local nums=$($cmd | wc -l)
6027 [ $nums -eq $expected ] || {
6028 $LFS getstripe -R $dir
6029 error "'$cmd' wrong: found $nums, expected $expected"
6032 expected=$((NUMDIRS + onestripe))
6033 cmd="$LFS find -stripe-count +0 -type f $dir"
6034 nums=$($cmd | wc -l)
6035 [ $nums -eq $expected ] || {
6036 $LFS getstripe -R $dir
6037 error "'$cmd' wrong: found $nums, expected $expected"
6041 cmd="$LFS find -stripe-count 1 -type f $dir"
6042 nums=$($cmd | wc -l)
6043 [ $nums -eq $expected ] || {
6044 $LFS getstripe -R $dir
6045 error "'$cmd' wrong: found $nums, expected $expected"
6048 cmd="$LFS find -stripe-count -2 -type f $dir"
6049 nums=$($cmd | wc -l)
6050 [ $nums -eq $expected ] || {
6051 $LFS getstripe -R $dir
6052 error "'$cmd' wrong: found $nums, expected $expected"
6056 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6057 nums=$($cmd | wc -l)
6058 [ $nums -eq $expected ] || {
6059 $LFS getstripe -R $dir
6060 error "'$cmd' wrong: found $nums, expected $expected"
6063 run_test 56s "check lfs find -stripe-count works"
6065 test_56t() { # LU-611 #LU-9369
6066 local dir=$DIR/$tdir
6068 setup_56 $dir 0 $NUMDIRS
6069 for i in $(seq $NUMDIRS); do
6070 $LFS setstripe -S 8M $dir/dir$i/$tfile
6073 local expected=$NUMDIRS
6074 local cmd="$LFS find -S 8M $dir"
6075 local nums=$($cmd | wc -l)
6077 [ $nums -eq $expected ] || {
6078 $LFS getstripe -R $dir
6079 error "'$cmd' wrong: found $nums, expected $expected"
6083 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6085 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6087 expected=$(((NUMDIRS + 1) * NUMFILES))
6088 cmd="$LFS find -stripe-size 512k -type f $dir"
6089 nums=$($cmd | wc -l)
6090 [ $nums -eq $expected ] ||
6091 error "'$cmd' wrong: found $nums, expected $expected"
6093 cmd="$LFS find -stripe-size +320k -type f $dir"
6094 nums=$($cmd | wc -l)
6095 [ $nums -eq $expected ] ||
6096 error "'$cmd' wrong: found $nums, expected $expected"
6098 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6099 cmd="$LFS find -stripe-size +200k -type f $dir"
6100 nums=$($cmd | wc -l)
6101 [ $nums -eq $expected ] ||
6102 error "'$cmd' wrong: found $nums, expected $expected"
6104 cmd="$LFS find -stripe-size -640k -type f $dir"
6105 nums=$($cmd | wc -l)
6106 [ $nums -eq $expected ] ||
6107 error "'$cmd' wrong: found $nums, expected $expected"
6110 cmd="$LFS find -stripe-size 256k -type f $dir"
6111 nums=$($cmd | wc -l)
6112 [ $nums -eq $expected ] ||
6113 error "'$cmd' wrong: found $nums, expected $expected"
6115 cmd="$LFS find -stripe-size -320k -type f $dir"
6116 nums=$($cmd | wc -l)
6117 [ $nums -eq $expected ] ||
6118 error "'$cmd' wrong: found $nums, expected $expected"
6121 cmd="$LFS find -stripe-size 1024k -type f $dir"
6122 nums=$($cmd | wc -l)
6123 [ $nums -eq $expected ] ||
6124 error "'$cmd' wrong: found $nums, expected $expected"
6126 run_test 56t "check lfs find -stripe-size works"
6128 test_56u() { # LU-611
6129 local dir=$DIR/$tdir
6131 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6133 if [[ $OSTCOUNT -gt 1 ]]; then
6134 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6140 local expected=$(((NUMDIRS + 1) * NUMFILES))
6141 local cmd="$LFS find -stripe-index 0 -type f $dir"
6142 local nums=$($cmd | wc -l)
6144 [ $nums -eq $expected ] ||
6145 error "'$cmd' wrong: found $nums, expected $expected"
6148 cmd="$LFS find -stripe-index 1 -type f $dir"
6149 nums=$($cmd | wc -l)
6150 [ $nums -eq $expected ] ||
6151 error "'$cmd' wrong: found $nums, expected $expected"
6153 cmd="$LFS find ! -stripe-index 0 -type f $dir"
6154 nums=$($cmd | wc -l)
6155 [ $nums -eq $expected ] ||
6156 error "'$cmd' wrong: found $nums, expected $expected"
6159 # This should produce an error and not return any files
6160 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
6161 nums=$($cmd 2>/dev/null | wc -l)
6162 [ $nums -eq $expected ] ||
6163 error "'$cmd' wrong: found $nums, expected $expected"
6165 if [[ $OSTCOUNT -gt 1 ]]; then
6166 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
6167 cmd="$LFS find -stripe-index 0,1 -type f $dir"
6168 nums=$($cmd | wc -l)
6169 [ $nums -eq $expected ] ||
6170 error "'$cmd' wrong: found $nums, expected $expected"
6173 run_test 56u "check lfs find -stripe-index works"
6177 local dir=$DIR/$tdir
6179 setup_56 $dir $NUMFILES $NUMDIRS
6181 UUID=$(mdtuuid_from_index $mdt_idx $dir)
6182 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
6184 for file in $($LFS find -m $UUID $dir); do
6185 file_midx=$($LFS getstripe -m $file)
6186 [ $file_midx -eq $mdt_idx ] ||
6187 error "lfs find -m $UUID != getstripe -m $file_midx"
6190 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
6193 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6196 local dir=$DIR/$tdir
6198 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
6200 local stripe_size=$($LFS getstripe -S -d $dir) ||
6201 error "$LFS getstripe -S -d $dir failed"
6202 stripe_size=${stripe_size%% *}
6204 local file_size=$((stripe_size * OSTCOUNT))
6205 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
6206 local required_space=$((file_num * file_size))
6207 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
6209 [[ $free_space -le $((required_space / 1024)) ]] &&
6210 skip_env "need $required_space, have $free_space kbytes"
6213 local dd_count=$((file_size / dd_bs))
6215 # write data into the files
6220 for i in $(seq $NUMFILES); do
6222 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6223 error "write data into $file failed"
6225 for i in $(seq $NUMDIRS); do
6226 for j in $(seq $NUMFILES); do
6227 file=$dir/dir$i/file$j
6228 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6229 error "write data into $file failed"
6233 # $LFS_MIGRATE will fail if hard link migration is unsupported
6234 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
6235 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
6236 error "creating links to $dir/dir1/file1 failed"
6241 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
6244 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
6247 eval $cmd || error "$cmd failed"
6249 check_stripe_count $dir/file1 $expected
6251 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
6253 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
6254 # OST 1 if it is on OST 0. This file is small enough to
6255 # be on only one stripe.
6256 file=$dir/migr_1_ost
6257 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
6258 error "write data into $file failed"
6259 local obdidx=$($LFS getstripe -i $file)
6260 local oldmd5=$(md5sum $file)
6263 [[ $obdidx -eq 0 ]] && newobdidx=1
6264 cmd="$LFS migrate -i $newobdidx $file"
6266 eval $cmd || error "$cmd failed"
6268 local realobdix=$($LFS getstripe -i $file)
6269 local newmd5=$(md5sum $file)
6271 [[ $newobdidx -ne $realobdix ]] &&
6272 error "new OST is different (was=$obdidx, "\
6273 "wanted=$newobdidx, got=$realobdix)"
6274 [[ "$oldmd5" != "$newmd5" ]] &&
6275 error "md5sum differ: $oldmd5, $newmd5"
6279 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
6281 eval $cmd || error "$cmd failed"
6283 for j in $(seq $NUMFILES); do
6284 check_stripe_count $dir/dir1/file$j $expected
6287 # lfs_migrate works with lfs find
6288 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
6289 $LFS_MIGRATE -y -c $expected"
6291 eval $cmd || error "$cmd failed"
6293 for i in $(seq 2 $NUMFILES); do
6294 check_stripe_count $dir/file$i $expected
6296 for i in $(seq 2 $NUMDIRS); do
6297 for j in $(seq $NUMFILES); do
6298 check_stripe_count $dir/dir$i/file$j $expected
6302 run_test 56w "check lfs_migrate -c stripe_count works"
6305 local file1=$DIR/$tdir/file1
6306 local create_pool=false
6307 local initial_pool=$($LFS getstripe -p $DIR)
6311 echo -n "Creating test dir..."
6312 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6315 echo -n "Creating test file..."
6316 touch $file1 || error "cannot create file"
6319 echo -n "Detecting existing pools..."
6320 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
6322 if [ ${#pool_list[@]} -gt 0 ]; then
6323 echo "${pool_list[@]}"
6324 for thispool in "${pool_list[@]}"; do
6325 if [[ -z "$initial_pool" ||
6326 "$initial_pool" != "$thispool" ]]; then
6328 echo "Using existing pool '$pool'"
6333 echo "none detected."
6335 if [ -z "$pool" ]; then
6336 pool=${POOL:-testpool}
6337 [ "$initial_pool" = "$pool" ] && pool="testpool2"
6338 echo -n "Creating pool '$pool'..."
6340 pool_add $pool &> /dev/null ||
6341 error "pool_add failed"
6344 echo -n "Adding target to pool..."
6345 pool_add_targets $pool 0 0 1 &> /dev/null ||
6346 error "pool_add_targets failed"
6350 echo -n "Setting pool using -p option..."
6351 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
6352 error "migrate failed rc = $?"
6355 echo -n "Verifying test file is in pool after migrating..."
6356 [ "$($LFS getstripe -p $file1)" = $pool ] ||
6357 error "file was not migrated to pool $pool"
6360 echo -n "Removing test file from pool '$pool'..."
6361 $LFS migrate $file1 &> /dev/null ||
6362 error "cannot remove from pool"
6363 [ "$($LFS getstripe -p $file1)" ] &&
6364 error "pool still set"
6367 echo -n "Setting pool using --pool option..."
6368 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
6369 error "migrate failed rc = $?"
6374 if $create_pool; then
6375 destroy_test_pools 2> /dev/null ||
6376 error "destroy test pools failed"
6379 run_test 56wb "check lfs_migrate pool support"
6382 local file1="$DIR/$tdir/file1"
6384 echo -n "Creating test dir..."
6385 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6386 local def_stripe_size=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
6387 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
6388 error "cannot set stripe"
6391 echo -n "Setting initial stripe for test file..."
6392 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
6393 error "cannot set stripe"
6394 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
6395 error "stripe size not set"
6398 # File currently set to -S 512K -c 1
6400 # Ensure -c and -S options are rejected when -R is set
6401 echo -n "Verifying incompatible options are detected..."
6402 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
6403 error "incompatible -c and -R options not detected"
6404 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
6405 error "incompatible -S and -R options not detected"
6408 # Ensure unrecognized options are passed through to 'lfs migrate'
6409 echo -n "Verifying -S option is passed through to lfs migrate..."
6410 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
6411 error "migration failed"
6412 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
6413 error "file was not restriped"
6416 # File currently set to -S 1M -c 1
6418 # Ensure long options are supported
6419 echo -n "Verifying long options supported..."
6420 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
6421 error "long option without argument not supported"
6422 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
6423 error "long option with argument not supported"
6424 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
6425 error "file not restriped with --stripe-size option"
6428 # File currently set to -S 512K -c 1
6430 if [ "$OSTCOUNT" -gt 1 ]; then
6431 echo -n "Verifying explicit stripe count can be set..."
6432 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
6433 error "migrate failed"
6434 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
6435 error "file not restriped to explicit count"
6439 # File currently set to -S 512K -c 1 or -S 512K -c 2
6441 # Ensure parent striping is used if -R is set, and no stripe
6442 # count or size is specified
6443 echo -n "Setting stripe for parent directory..."
6444 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
6445 error "cannot set stripe"
6448 echo -n "Verifying restripe option uses parent stripe settings..."
6449 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
6450 error "migrate failed"
6451 [ $($LFS getstripe -S "$file1") -eq $def_stripe_size ] ||
6452 error "file not restriped to parent settings"
6453 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
6454 error "file not restriped to parent settings"
6457 # File currently set to -S 1M -c 1
6459 # Ensure striping is preserved if -R is not set, and no stripe
6460 # count or size is specified
6461 echo -n "Verifying striping size preserved when not specified..."
6462 local orig_stripe_size=$($LFS getstripe -S "$file1" 2>/dev/null)
6463 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6464 error "cannot set stripe on parent directory"
6465 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6466 error "migrate failed"
6467 [ $($LFS getstripe -S "$file1") -eq $orig_stripe_size ] ||
6468 error "file was restriped"
6471 # Ensure file name properly detected when final option has no argument
6472 echo -n "Verifying file name properly detected..."
6473 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6474 error "file name interpreted as option argument"
6480 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
6483 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6485 local file1=$DIR/$tdir/file1
6487 echo -n "Creating test dir..."
6488 test_mkdir $DIR/$tdir || error "cannot create dir"
6491 echo -n "Creating test file..."
6495 # Ensure 'lfs migrate' will fail by using a non-existent option,
6496 # and make sure rsync is not called to recover
6497 echo -n "Make sure --no-rsync option works..."
6498 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
6499 grep -q 'refusing to fall back to rsync' ||
6500 error "rsync was called with --no-rsync set"
6503 # Ensure rsync is called without trying 'lfs migrate' first
6504 echo -n "Make sure --rsync option works..."
6505 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
6506 grep -q 'falling back to rsync' &&
6507 error "lfs migrate was called with --rsync set"
6510 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6511 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6512 grep -q 'at the same time' ||
6513 error "--rsync and --no-rsync accepted concurrently"
6519 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6522 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6523 check_swap_layouts_support
6525 local dir=$DIR/$tdir
6526 local ref1=/etc/passwd
6527 local file1=$dir/file1
6529 test_mkdir $dir || error "creating dir $dir"
6530 $LFS setstripe -c 2 $file1
6532 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6533 stripe=$($LFS getstripe -c $file1)
6534 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6535 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6540 run_test 56x "lfs migration support"
6543 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6544 check_swap_layouts_support
6546 local dir=$DIR/$tdir/$testnum
6550 local ref1=/etc/passwd
6551 local file1=$dir/file1
6553 $LFS setstripe -c 2 $file1
6555 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6557 local stripe=$($LFS getstripe -c $file1)
6559 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6560 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6565 run_test 56xa "lfs migration --block support"
6567 check_migrate_links() {
6569 local file1="$dir/file1"
6572 local total_count=$(($begin + $count - 1))
6573 local symlink_count=10
6576 if [ ! -f "$file1" ]; then
6577 echo -n "creating initial file..."
6578 $LFS setstripe -c 1 -S "512k" "$file1" ||
6579 error "cannot setstripe initial file"
6582 echo -n "creating symlinks..."
6583 for s in $(seq 1 $symlink_count); do
6584 ln -s "$file1" "$dir/slink$s" ||
6585 error "cannot create symlinks"
6589 echo -n "creating nonlinked files..."
6590 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6591 error "cannot create nonlinked files"
6596 if [ ! -f "$dir/file$total_count" ]; then
6597 echo -n "creating hard links $begin:$total_count..."
6598 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6599 /dev/null || error "cannot create hard links"
6603 echo -n "checking number of hard links listed in xattrs..."
6604 local fid=$($LFS getstripe -F "$file1")
6605 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6608 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6609 skip "hard link list has unexpected size, skipping test"
6611 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6612 error "link names should exceed xattrs size"
6615 echo -n "migrating files..."
6616 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
6618 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6621 # make sure all links have been properly migrated
6622 echo -n "verifying files..."
6623 fid=$($LFS getstripe -F "$file1") ||
6624 error "cannot get fid for file $file1"
6625 for i in $(seq 2 $total_count); do
6626 local fid2=$($LFS getstripe -F $dir/file$i)
6628 [ "$fid2" == "$fid" ] ||
6629 error "migrated hard link has mismatched FID"
6632 # make sure hard links were properly detected, and migration was
6633 # performed only once for the entire link set; nonlinked files should
6635 local actual=$(grep -c 'done' <<< "$migrate_out")
6636 local expected=$(($uniq_count + 1))
6638 [ "$actual" -eq "$expected" ] ||
6639 error "hard links individually migrated ($actual != $expected)"
6641 # make sure the correct number of hard links are present
6642 local hardlinks=$(stat -c '%h' "$file1")
6644 [ $hardlinks -eq $total_count ] ||
6645 error "num hard links $hardlinks != $total_count"
6652 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6653 skip "Need MDS version at least 2.10.55"
6655 local dir="$DIR/$tdir"
6657 test_mkdir "$dir" || error "cannot create dir $dir"
6659 echo "testing lfs migrate mode when all links fit within xattrs"
6660 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6662 echo "testing rsync mode when all links fit within xattrs"
6663 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6665 echo "testing lfs migrate mode when all links do not fit within xattrs"
6666 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6668 echo "testing rsync mode when all links do not fit within xattrs"
6669 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6675 run_test 56xb "lfs migration hard link support"
6678 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6680 local dir="$DIR/$tdir"
6682 test_mkdir "$dir" || error "cannot create dir $dir"
6684 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6685 echo -n "Setting initial stripe for 20MB test file..."
6686 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6687 error "cannot setstripe 20MB file"
6689 echo -n "Sizing 20MB test file..."
6690 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6692 echo -n "Verifying small file autostripe count is 1..."
6693 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6694 error "cannot migrate 20MB file"
6695 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6696 error "cannot get stripe for $dir/20mb"
6697 [ $stripe_count -eq 1 ] ||
6698 error "unexpected stripe count $stripe_count for 20MB file"
6702 # Test 2: File is small enough to fit within the available space on
6703 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6704 # have at least an additional 1KB for each desired stripe for test 3
6705 echo -n "Setting stripe for 1GB test file..."
6706 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
6708 echo -n "Sizing 1GB test file..."
6709 # File size is 1GB + 3KB
6710 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
6713 # need at least 512MB per OST for 1GB file to fit in 2 stripes
6714 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
6715 if (( avail > 524288 * OSTCOUNT )); then
6716 echo -n "Migrating 1GB file..."
6717 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
6718 error "cannot migrate 1GB file"
6720 echo -n "Verifying autostripe count is sqrt(n) + 1..."
6721 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
6722 error "cannot getstripe for 1GB file"
6723 [ $stripe_count -eq 2 ] ||
6724 error "unexpected stripe count $stripe_count != 2"
6728 # Test 3: File is too large to fit within the available space on
6729 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
6730 if [ $OSTCOUNT -ge 3 ]; then
6731 # The required available space is calculated as
6732 # file size (1GB + 3KB) / OST count (3).
6733 local kb_per_ost=349526
6735 echo -n "Migrating 1GB file with limit..."
6736 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
6737 error "cannot migrate 1GB file with limit"
6740 stripe_count=$($LFS getstripe -c "$dir/1gb")
6741 echo -n "Verifying 1GB autostripe count with limited space..."
6742 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
6743 error "unexpected stripe count $stripe_count (min 3)"
6750 run_test 56xc "lfs migration autostripe"
6753 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
6754 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
6757 local dir=$DIR/$tdir
6761 test_mkdir -p $dir || error "creating dir $dir"
6762 touch $f1 || error "creating std file $f1"
6763 $MULTIOP $f2 H2c || error "creating released file $f2"
6765 # a directory can be raid0, so ask only for files
6766 res=$($LFS find $dir -L raid0 -type f | wc -l)
6767 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
6769 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
6770 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
6772 # only files can be released, so no need to force file search
6773 res=$($LFS find $dir -L released)
6774 [[ $res == $f2 ]] || error "search released: found $res != $f2"
6776 res=$($LFS find $dir -type f \! -L released)
6777 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
6779 run_test 56y "lfs find -L raid0|released"
6781 test_56z() { # LU-4824
6782 # This checks to make sure 'lfs find' continues after errors
6783 # There are two classes of errors that should be caught:
6784 # - If multiple paths are provided, all should be searched even if one
6786 # - If errors are encountered during the search, it should not terminate
6788 local dir=$DIR/$tdir
6792 for i in d{0..9}; do
6794 touch $dir/$i/$tfile
6796 $LFS find $DIR/non_existent_dir $dir &&
6797 error "$LFS find did not return an error"
6798 # Make a directory unsearchable. This should NOT be the last entry in
6799 # directory order. Arbitrarily pick the 6th entry
6800 chmod 700 $($LFS find $dir -type d | sed '6!d')
6802 $RUNAS $LFS find $DIR/non_existent $dir
6803 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
6805 # The user should be able to see 10 directories and 9 files
6806 (( count == 19 )) ||
6807 error "$LFS find found $count != 19 entries after error"
6809 run_test 56z "lfs find should continue after an error"
6811 test_56aa() { # LU-5937
6812 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
6814 local dir=$DIR/$tdir
6817 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
6819 createmany -o $dir/striped_dir/${tfile}- 1024
6820 local dirs=$($LFS find --size +8k $dir/)
6822 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
6824 run_test 56aa "lfs find --size under striped dir"
6826 test_56ab() { # LU-10705
6827 test_mkdir $DIR/$tdir
6828 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
6829 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
6830 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
6831 # Flush writes to ensure valid blocks. Need to be more thorough for
6832 # ZFS, since blocks are not allocated/returned to client immediately.
6834 wait_zfs_commit ost1 2
6835 cancel_lru_locks osc
6838 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
6840 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
6842 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
6843 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
6845 rm -f $DIR/$tdir/$tfile.[123]
6847 run_test 56ab "lfs find --blocks"
6850 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
6851 skip "Need MDS version at least 2.10.50"
6853 # Create composite files with one component
6854 local dir=$DIR/$tdir
6856 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
6857 # Create composite files with three components
6858 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
6859 # Create non-composite files
6860 createmany -o $dir/${tfile}- 10
6862 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
6864 [[ $nfiles == 10 ]] ||
6865 error "lfs find -E 1M found $nfiles != 10 files"
6867 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
6868 [[ $nfiles == 25 ]] ||
6869 error "lfs find ! -E 1M found $nfiles != 25 files"
6871 # All files have a component that starts at 0
6872 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
6873 [[ $nfiles == 35 ]] ||
6874 error "lfs find --component-start 0 - $nfiles != 35 files"
6876 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
6877 [[ $nfiles == 15 ]] ||
6878 error "lfs find --component-start 2M - $nfiles != 15 files"
6880 # All files created here have a componenet that does not starts at 2M
6881 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
6882 [[ $nfiles == 35 ]] ||
6883 error "lfs find ! --component-start 2M - $nfiles != 35 files"
6885 # Find files with a specified number of components
6886 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
6887 [[ $nfiles == 15 ]] ||
6888 error "lfs find --component-count 3 - $nfiles != 15 files"
6890 # Remember non-composite files have a component count of zero
6891 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
6892 [[ $nfiles == 10 ]] ||
6893 error "lfs find --component-count 0 - $nfiles != 10 files"
6895 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
6896 [[ $nfiles == 20 ]] ||
6897 error "lfs find ! --component-count 3 - $nfiles != 20 files"
6899 # All files have a flag called "init"
6900 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
6901 [[ $nfiles == 35 ]] ||
6902 error "lfs find --component-flags init - $nfiles != 35 files"
6904 # Multi-component files will have a component not initialized
6905 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
6906 [[ $nfiles == 15 ]] ||
6907 error "lfs find !--component-flags init - $nfiles != 15 files"
6912 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
6915 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
6916 skip "Need MDS version at least 2.10.57"
6926 # create mirrored directories and mirrored files
6927 mkdir $td || error "mkdir $td failed"
6928 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
6929 createmany -o $tf- 10 || error "create $tf- failed"
6931 for i in $(seq 2); do
6933 mkdir $dir || error "mkdir $dir failed"
6934 $LFS mirror create -N$((3 + i)) $dir ||
6935 error "create mirrored dir $dir failed"
6936 createmany -o $dir/$tfile- 10 ||
6937 error "create $dir/$tfile- failed"
6940 # change the states of some mirrored files
6942 for i in $(seq 2); do
6944 for j in $(seq 4 9); do
6945 echo foo > $dir/$tfile-$j
6949 # find mirrored files with specific mirror count
6950 cmd="$LFS find --mirror-count 3 --type f $td"
6951 nfiles=$($cmd | wc -l)
6952 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
6954 cmd="$LFS find ! --mirror-count 3 --type f $td"
6955 nfiles=$($cmd | wc -l)
6956 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
6958 cmd="$LFS find --mirror-count +2 --type f $td"
6959 nfiles=$($cmd | wc -l)
6960 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6962 cmd="$LFS find --mirror-count -6 --type f $td"
6963 nfiles=$($cmd | wc -l)
6964 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6966 # find mirrored files with specific file state
6967 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
6968 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
6970 cmd="$LFS find --mirror-state=ro --type f $td"
6971 nfiles=$($cmd | wc -l)
6972 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6974 cmd="$LFS find ! --mirror-state=ro --type f $td"
6975 nfiles=$($cmd | wc -l)
6976 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6978 cmd="$LFS find --mirror-state=wp --type f $td"
6979 nfiles=$($cmd | wc -l)
6980 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6982 cmd="$LFS find ! --mirror-state=sp --type f $td"
6983 nfiles=$($cmd | wc -l)
6984 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6986 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6990 # note test will not do anything if MDS is not local
6991 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6992 skip_env "ldiskfs only test"
6994 remote_mds_nodsh && skip "remote MDS with nodsh"
6996 local MNTDEV="osd*.*MDT*.mntdev"
6997 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6998 [ -z "$DEV" ] && error "can't access $MNTDEV"
6999 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
7000 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
7001 error "can't access $DEV"
7002 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
7003 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
7007 run_test 57a "verify MDS filesystem created with large inodes =="
7010 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7011 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7012 skip_env "ldiskfs only test"
7014 remote_mds_nodsh && skip "remote MDS with nodsh"
7016 local dir=$DIR/$tdir
7019 local fileN=$dir/f$filecount
7021 rm -rf $dir || error "removing $dir"
7023 local mdtidx=$($LFS getstripe -m $dir)
7024 local mdtname=MDT$(printf %04x $mdtidx)
7025 local facet=mds$((mdtidx + 1))
7027 echo "mcreating $filecount files"
7028 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
7030 # verify that files do not have EAs yet
7031 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
7032 error "$file1 has an EA"
7033 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
7034 error "$fileN has an EA"
7038 df $dir #make sure we get new statfs data
7039 local mdsfree=$(do_facet $facet \
7040 lctl get_param -n osd*.*$mdtname.kbytesfree)
7041 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7044 echo "opening files to create objects/EAs"
7045 for file in $(seq -f $dir/f%g 1 $filecount); do
7046 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
7047 error "opening $file"
7050 # verify that files have EAs now
7051 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
7052 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
7054 sleep 1 #make sure we get new statfs data
7056 local mdsfree2=$(do_facet $facet \
7057 lctl get_param -n osd*.*$mdtname.kbytesfree)
7058 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7060 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
7061 if [ "$mdsfree" != "$mdsfree2" ]; then
7062 error "MDC before $mdcfree != after $mdcfree2"
7064 echo "MDC before $mdcfree != after $mdcfree2"
7065 echo "unable to confirm if MDS has large inodes"
7070 run_test 57b "default LOV EAs are stored inside large inodes ==="
7073 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7074 [ -z "$(which wiretest 2>/dev/null)" ] &&
7075 skip_env "could not find wiretest"
7079 run_test 58 "verify cross-platform wire constants =============="
7082 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7084 echo "touch 130 files"
7085 createmany -o $DIR/f59- 130
7087 unlinkmany $DIR/f59- 130
7089 # wait for commitment of removal
7090 wait_delete_completed
7092 run_test 59 "verify cancellation of llog records async ========="
7094 TEST60_HEAD="test_60 run $RANDOM"
7096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7097 remote_mgs_nodsh && skip "remote MGS with nodsh"
7098 do_facet mgs "! which run-llog.sh &> /dev/null" &&
7099 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
7100 skip_env "missing subtest run-llog.sh"
7102 log "$TEST60_HEAD - from kernel mode"
7103 do_facet mgs "$LCTL dk > /dev/null"
7104 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
7105 do_facet mgs $LCTL dk > $TMP/$tfile
7107 # LU-6388: test llog_reader
7108 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
7109 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
7110 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
7111 skip_env "missing llog_reader"
7112 local fstype=$(facet_fstype mgs)
7113 [ $fstype != ldiskfs -a $fstype != zfs ] &&
7114 skip_env "Only for ldiskfs or zfs type mgs"
7116 local mntpt=$(facet_mntpt mgs)
7117 local mgsdev=$(mgsdevname 1)
7129 #get fid and record list
7130 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
7132 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
7134 #remount mgs as ldiskfs or zfs type
7135 stop mgs || error "stop mgs failed"
7136 mount_fstype mgs || error "remount mgs failed"
7137 for ((i = 0; i < ${#fid_list[@]}; i++)); do
7140 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
7141 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
7146 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
7148 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
7150 echo "obj_file is $obj_file"
7151 do_facet mgs $llog_reader $obj_file
7153 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
7154 awk '{ print $3 }' | sed -e "s/^type=//g")
7155 if [ $rec_type != $rec ]; then
7156 echo "FAILED test_60a wrong record type $rec_type," \
7162 #check obj path if record type is LLOG_LOGID_MAGIC
7163 if [ "$rec" == "1064553b" ]; then
7164 path=$(do_facet mgs $llog_reader $obj_file |
7165 grep "path=" | awk '{ print $NF }' |
7166 sed -e "s/^path=//g")
7167 if [ $obj_file != $mntpt/$path ]; then
7168 echo "FAILED test_60a wrong obj path" \
7169 "$montpt/$path, should be $obj_file"
7176 #restart mgs before "error", otherwise it will block the next test
7177 stop mgs || error "stop mgs failed"
7178 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
7179 $pass || error "test failed, see FAILED test_60a messages for specifics"
7181 run_test 60a "llog_test run from kernel module and test llog_reader"
7183 test_60b() { # bug 6411
7184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7187 LLOG_COUNT=$(do_facet mgs dmesg |
7188 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
7189 /llog_[a-z]*.c:[0-9]/ {
7201 [[ $LLOG_COUNT -gt 120 ]] &&
7202 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
7204 run_test 60b "limit repeated messages from CERROR/CWARN"
7207 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7209 echo "create 5000 files"
7210 createmany -o $DIR/f60c- 5000
7211 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
7212 lctl set_param fail_loc=0x80000137
7213 unlinkmany $DIR/f60c- 5000
7214 lctl set_param fail_loc=0
7216 run_test 60c "unlink file when mds full"
7219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7221 SAVEPRINTK=$(lctl get_param -n printk)
7222 # verify "lctl mark" is even working"
7223 MESSAGE="test message ID $RANDOM $$"
7224 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7225 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
7227 lctl set_param printk=0 || error "set lnet.printk failed"
7228 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
7229 MESSAGE="new test message ID $RANDOM $$"
7230 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
7231 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7232 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
7234 lctl set_param -n printk="$SAVEPRINTK"
7236 run_test 60d "test printk console message masking"
7239 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7240 remote_mds_nodsh && skip "remote MDS with nodsh"
7243 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
7244 do_facet mds1 lctl set_param fail_loc=0x15b
7247 run_test 60e "no space while new llog is being created"
7253 test_mkdir -c $MDSCOUNT $DIR/$tdir
7258 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
7259 -c $MDSCOUNT $DIR/$tdir/subdir$index \
7261 mkdir $DIR/$tdir/subdir$index 2>/dev/null
7262 rmdir $DIR/$tdir/subdir$index 2>/dev/null
7263 index=$((index + 1))
7269 for i in {0..100}; do
7270 # define OBD_FAIL_OSD_TXN_START 0x19a
7271 local index=$((i % MDSCOUNT + 1))
7273 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
7280 for i in $(seq $MDSCOUNT); do
7281 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
7284 mkdir $DIR/$tdir/new || error "mkdir failed"
7285 rmdir $DIR/$tdir/new || error "rmdir failed"
7287 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
7289 for i in $(seq $MDSCOUNT); do
7290 wait_update_facet mds$i "$LCTL get_param -n \
7291 mdd.$(facet_svc mds$i).lfsck_namespace |
7292 awk '/^status/ { print \\\$2 }'" "completed"
7295 ls -R $DIR/$tdir || error "ls failed"
7296 rm -rf $DIR/$tdir || error "rmdir failed"
7298 run_test 60g "transaction abort won't cause MDT hung"
7301 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
7302 skip "Need MDS version at least 2.12.52"
7303 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
7307 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
7308 #define OBD_FAIL_MDS_STRIPE_FID 0x189
7309 for fail_loc in 0x80000188 0x80000189; do
7310 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
7311 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
7312 error "mkdir $dir-$fail_loc failed"
7313 for i in {0..10}; do
7314 # create may fail on missing stripe
7315 echo $i > $DIR/$tdir-$fail_loc/$i
7317 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7318 error "getdirstripe $tdir-$fail_loc failed"
7319 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
7320 error "migrate $tdir-$fail_loc failed"
7321 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7322 error "getdirstripe $tdir-$fail_loc failed"
7323 pushd $DIR/$tdir-$fail_loc
7325 echo $f | cmp $f - || error "$f data mismatch"
7328 rm -rf $DIR/$tdir-$fail_loc
7331 run_test 60h "striped directory with missing stripes can be accessed"
7334 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7337 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
7338 cancel_lru_locks osc
7339 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
7342 run_test 61a "mmap() writes don't make sync hang ================"
7345 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
7347 run_test 61b "mmap() of unstriped file is successful"
7349 # bug 2330 - insufficient obd_match error checking causes LBUG
7351 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7355 cancel_lru_locks osc
7356 lctl set_param fail_loc=0x405
7357 cat $f && error "cat succeeded, expect -EIO"
7358 lctl set_param fail_loc=0
7360 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
7361 # match every page all of the time.
7362 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
7364 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
7365 # Though this test is irrelevant anymore, it helped to reveal some
7366 # other grant bugs (LU-4482), let's keep it.
7367 test_63a() { # was test_63
7368 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7370 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
7372 for i in `seq 10` ; do
7373 dd if=/dev/zero of=$DIR/f63 bs=8k &
7379 rm -f $DIR/f63 || true
7381 run_test 63a "Verify oig_wait interruption does not crash ======="
7383 # bug 2248 - async write errors didn't return to application on sync
7384 # bug 3677 - async write errors left page locked
7386 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7389 lctl set_param debug=-1
7391 # ensure we have a grant to do async writes
7392 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
7395 sync # sync lest earlier test intercept the fail_loc
7397 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7398 lctl set_param fail_loc=0x80000406
7399 $MULTIOP $DIR/$tfile Owy && \
7400 error "sync didn't return ENOMEM"
7401 sync; sleep 2; sync # do a real sync this time to flush page
7402 lctl get_param -n llite.*.dump_page_cache | grep locked && \
7403 error "locked page left in cache after async error" || true
7406 run_test 63b "async write errors should be returned to fsync ==="
7409 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7412 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
7414 run_test 64a "verify filter grant calculations (in kernel) ====="
7417 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7419 sh oos.sh $MOUNT || error "oos.sh failed: $?"
7421 run_test 64b "check out-of-space detection on client"
7424 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
7426 run_test 64c "verify grant shrink"
7428 # this does exactly what osc_request.c:osc_announce_cached() does in
7429 # order to calculate max amount of grants to ask from server
7433 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
7434 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
7436 ((rpc_in_flight ++));
7437 nrpages=$((nrpages * rpc_in_flight))
7439 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
7441 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
7443 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
7444 local undirty=$((nrpages * PAGE_SIZE))
7446 local max_extent_pages
7447 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
7448 grep grant_max_extent_size | awk '{print $2}')
7449 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
7450 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
7451 local grant_extent_tax
7452 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7453 grep grant_extent_tax | awk '{print $2}')
7455 undirty=$((undirty + nrextents * grant_extent_tax))
7460 # this is size of unit for grant allocation. It should be equal to
7461 # what tgt_grant.c:tgt_grant_chunk() calculates
7465 local grant_extent_tax
7467 max_brw_size=$($LCTL get_param osc.${tgt}.import |
7468 grep max_brw_size | awk '{print $2}')
7470 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7471 grep grant_extent_tax | awk '{print $2}')
7473 echo $(((max_brw_size + grant_extent_tax) * 2))
7477 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
7478 skip "OST < 2.10.55 doesn't limit grants enough"
7480 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
7481 local file=$DIR/$tfile
7483 [[ $($LCTL get_param osc.${tgt}.import |
7484 grep "connect_flags:.*grant_param") ]] ||
7485 skip "no grant_param connect flag"
7487 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
7489 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
7491 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7492 stack_trap "rm -f $file" EXIT
7494 $LFS setstripe $file -i 0 -c 1
7495 dd if=/dev/zero of=$file bs=1M count=1000 &
7500 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
7501 if [[ $cur_grant -gt $max_cur_granted ]]
7504 error "cur_grant $cur_grant > $max_cur_granted"
7507 [[ $? -ne 0 ]] && break;
7512 wait_delete_completed
7513 $LCTL set_param debug="$olddebug" 2> /dev/null || true
7515 run_test 64d "check grant limit exceed"
7517 # bug 1414 - set/get directories' stripe info
7519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7521 test_mkdir $DIR/$tdir
7523 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7525 run_test 65a "directory with no stripe info"
7528 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7530 test_mkdir $DIR/$tdir
7531 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7533 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7536 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7538 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7541 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7542 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7544 test_mkdir $DIR/$tdir
7545 local stripesize=$($LFS getstripe -S $DIR/$tdir)
7547 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7548 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7550 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7552 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7555 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7557 test_mkdir $DIR/$tdir
7558 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
7559 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7561 if [[ $STRIPECOUNT -le 0 ]]; then
7563 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
7564 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
7565 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
7567 sc=$(($STRIPECOUNT - 1))
7569 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7570 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7571 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7572 error "lverify failed"
7574 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7579 test_mkdir $DIR/$tdir
7581 $LFS setstripe $DIR/$tdir || error "setstripe"
7582 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7583 error "no stripe info failed"
7585 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
7587 run_test 65e "directory setstripe defaults"
7590 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7592 test_mkdir $DIR/${tdir}f
7593 $RUNAS $LFS setstripe $DIR/${tdir}f &&
7594 error "setstripe succeeded" || true
7596 run_test 65f "dir setstripe permission (should return error) ==="
7599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7601 test_mkdir $DIR/$tdir
7602 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7604 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7605 error "setstripe -S failed"
7606 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7607 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7608 error "delete default stripe failed"
7610 run_test 65g "directory setstripe -d"
7613 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7615 test_mkdir $DIR/$tdir
7616 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7618 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7619 error "setstripe -S failed"
7620 test_mkdir $DIR/$tdir/dd1
7621 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
7622 error "stripe info inherit failed"
7624 run_test 65h "directory stripe info inherit ===================="
7627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7629 save_layout_restore_at_exit $MOUNT
7631 # bug6367: set non-default striping on root directory
7632 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7634 # bug12836: getstripe on -1 default directory striping
7635 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7637 # bug12836: getstripe -v on -1 default directory striping
7638 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7640 # bug12836: new find on -1 default directory striping
7641 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7643 run_test 65i "various tests to set root directory striping"
7645 test_65j() { # bug6367
7646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7650 # if we aren't already remounting for each test, do so for this test
7651 if [ "$I_MOUNTED" = "yes" ]; then
7652 cleanup || error "failed to unmount"
7656 save_layout_restore_at_exit $MOUNT
7658 $LFS setstripe -d $MOUNT || error "setstripe failed"
7660 run_test 65j "set default striping on root directory (bug 6367)="
7664 wait_delete_completed
7665 do_facet $SINGLEMDS "lctl set_param -n \
7666 osp.$ost*MDT0000.max_create_count=$max_count"
7667 do_facet $SINGLEMDS "lctl set_param -n \
7668 osp.$ost*MDT0000.create_count=$count"
7669 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7670 echo $INACTIVE_OSC "is Activate"
7672 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7675 test_65k() { # bug11679
7676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7677 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7678 remote_mds_nodsh && skip "remote MDS with nodsh"
7680 local disable_precreate=true
7681 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7682 disable_precreate=false
7684 echo "Check OST status: "
7685 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7686 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7688 for OSC in $MDS_OSCS; do
7689 echo $OSC "is active"
7690 do_facet $SINGLEMDS lctl --device %$OSC activate
7693 for INACTIVE_OSC in $MDS_OSCS; do
7694 local ost=$(osc_to_ost $INACTIVE_OSC)
7695 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7696 lov.*md*.target_obd |
7697 awk -F: /$ost/'{ print $1 }' | head -n 1)
7700 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
7701 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7703 echo "Deactivate: " $INACTIVE_OSC
7704 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7706 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7707 osp.$ost*MDT0000.create_count")
7708 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7709 osp.$ost*MDT0000.max_create_count")
7710 $disable_precreate &&
7711 do_facet $SINGLEMDS "lctl set_param -n \
7712 osp.$ost*MDT0000.max_create_count=0"
7714 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7715 [ -f $DIR/$tdir/$idx ] && continue
7716 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
7717 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
7719 error "setstripe $idx should succeed"; }
7720 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7722 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7725 do_facet $SINGLEMDS "lctl set_param -n \
7726 osp.$ost*MDT0000.max_create_count=$max_count"
7727 do_facet $SINGLEMDS "lctl set_param -n \
7728 osp.$ost*MDT0000.create_count=$count"
7729 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7730 echo $INACTIVE_OSC "is Activate"
7732 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7735 run_test 65k "validate manual striping works properly with deactivated OSCs"
7737 test_65l() { # bug 12836
7738 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7740 test_mkdir -p $DIR/$tdir/test_dir
7741 $LFS setstripe -c -1 $DIR/$tdir/test_dir
7742 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7744 run_test 65l "lfs find on -1 stripe dir ========================"
7747 local layout=$(save_layout $MOUNT)
7748 $RUNAS $LFS setstripe -c 2 $MOUNT && {
7749 restore_layout $MOUNT $layout
7750 error "setstripe should fail by non-root users"
7754 run_test 65m "normal user can't set filesystem default stripe"
7757 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
7758 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.50) ]] ||
7759 skip "Need MDS version at least 2.12.50"
7760 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7762 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7763 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7764 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7766 local root_layout=$(save_layout $MOUNT)
7767 stack_trap "restore_layout $MOUNT $root_layout" EXIT
7769 # new subdirectory under root directory should not inherit
7770 # the default layout from root
7771 local dir1=$MOUNT/$tdir-1
7772 mkdir $dir1 || error "mkdir $dir1 failed"
7773 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7774 error "$dir1 shouldn't have LOV EA"
7776 # delete the default layout on root directory
7777 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7779 local dir2=$MOUNT/$tdir-2
7780 mkdir $dir2 || error "mkdir $dir2 failed"
7781 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7782 error "$dir2 shouldn't have LOV EA"
7784 # set a new striping pattern on root directory
7785 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7786 local new_def_stripe_size=$((def_stripe_size * 2))
7787 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7788 error "set stripe size on $MOUNT failed"
7790 # new file created in $dir2 should inherit the new stripe size from
7791 # the filesystem default
7792 local file2=$dir2/$tfile-2
7793 touch $file2 || error "touch $file2 failed"
7795 local file2_stripe_size=$($LFS getstripe -S $file2)
7796 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
7797 error "$file2 didn't inherit stripe size $new_def_stripe_size"
7799 local dir3=$MOUNT/$tdir-3
7800 mkdir $dir3 || error "mkdir $dir3 failed"
7801 ! getfattr -n trusted.lov $dir3 &> /dev/null ||
7802 error "$dir3 shouldn't have LOV EA"
7804 # set OST pool on root directory
7805 local pool=$TESTNAME
7806 pool_add $pool || error "add $pool failed"
7807 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
7808 error "add targets to $pool failed"
7810 $LFS setstripe -p $pool $MOUNT ||
7811 error "set OST pool on $MOUNT failed"
7813 # new file created in $dir3 should inherit the pool from
7814 # the filesystem default
7815 local file3=$dir3/$tfile-3
7816 touch $file3 || error "touch $file3 failed"
7818 local file3_pool=$($LFS getstripe -p $file3)
7819 [[ "$file3_pool" = "$pool" ]] ||
7820 error "$file3 didn't inherit OST pool $pool"
7822 local dir4=$MOUNT/$tdir-4
7823 mkdir $dir4 || error "mkdir $dir4 failed"
7824 ! getfattr -n trusted.lov $dir4 &> /dev/null ||
7825 error "$dir4 shouldn't have LOV EA"
7827 # new file created in $dir4 should inherit the pool from
7828 # the filesystem default
7829 local file4=$dir4/$tfile-4
7830 touch $file4 || error "touch $file4 failed"
7832 local file4_pool=$($LFS getstripe -p $file4)
7833 [[ "$file4_pool" = "$pool" ]] ||
7834 error "$file4 didn't inherit OST pool $pool"
7836 # new subdirectory under non-root directory should inherit
7837 # the default layout from its parent directory
7838 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
7839 error "set directory layout on $dir4 failed"
7841 local dir5=$dir4/$tdir-5
7842 mkdir $dir5 || error "mkdir $dir5 failed"
7844 local dir4_layout=$(get_layout_param $dir4)
7845 local dir5_layout=$(get_layout_param $dir5)
7846 [[ "$dir4_layout" = "$dir5_layout" ]] ||
7847 error "$dir5 should inherit the default layout from $dir4"
7849 # though subdir under ROOT doesn't inherit default layout, but
7850 # its sub dir/file should be created with default layout.
7851 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
7852 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
7853 skip "Need MDS version at least 2.12.59"
7855 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
7856 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
7857 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
7859 if [ $default_lmv_hash == "none" ]; then
7860 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
7862 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
7863 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
7866 $LFS setdirstripe -D -c 2 $MOUNT ||
7867 error "setdirstripe -D -c 2 failed"
7868 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
7869 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
7870 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
7872 run_test 65n "don't inherit default layout from root for new subdirectories"
7874 # bug 2543 - update blocks count on client
7876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7879 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
7880 sync; sync_all_data; sync; sync_all_data
7881 cancel_lru_locks osc
7882 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
7883 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
7885 run_test 66 "update inode blocks count on client ==============="
7888 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
7892 swapon -s | awk '($1 == "'$1'") { print $4 }'
7895 # bug5265, obdfilter oa2dentry return -ENOENT
7896 # #define OBD_FAIL_SRV_ENOENT 0x217
7898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7899 remote_ost_nodsh && skip "remote OST with nodsh"
7902 $LFS setstripe -c 1 -i 0 $f
7904 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
7906 do_facet ost1 lctl set_param fail_loc=0x217
7907 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
7908 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
7910 do_facet ost1 lctl set_param fail_loc=0
7911 $DIRECTIO write $f 0 2 || error "write error"
7913 cancel_lru_locks osc
7914 $DIRECTIO read $f 0 1 || error "read error"
7916 do_facet ost1 lctl set_param fail_loc=0x217
7917 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
7919 do_facet ost1 lctl set_param fail_loc=0
7922 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
7925 test_mkdir $DIR/$tdir
7926 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
7927 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
7929 run_test 71 "Running dbench on lustre (don't segment fault) ===="
7931 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
7932 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7933 [ "$RUNAS_ID" = "$UID" ] &&
7934 skip_env "RUNAS_ID = UID = $UID -- skipping"
7935 # Check that testing environment is properly set up. Skip if not
7936 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
7937 skip_env "User $RUNAS_ID does not exist - skipping"
7940 chmod 777 $DIR/$tfile
7941 chmod ug+s $DIR/$tfile
7942 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
7943 error "$RUNAS dd $DIR/$tfile failed"
7944 # See if we are still setuid/sgid
7945 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
7946 error "S/gid is not dropped on write"
7947 # Now test that MDS is updated too
7948 cancel_lru_locks mdc
7949 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
7950 error "S/gid is not dropped on MDS"
7953 run_test 72a "Test that remove suid works properly (bug5695) ===="
7955 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7958 [ "$RUNAS_ID" = "$UID" ] &&
7959 skip_env "RUNAS_ID = UID = $UID -- skipping"
7960 [ "$RUNAS_ID" -eq 0 ] &&
7961 skip_env "RUNAS_ID = 0 -- skipping"
7962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7963 # Check that testing environment is properly set up. Skip if not
7964 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7965 skip_env "User $RUNAS_ID does not exist - skipping"
7967 touch $DIR/${tfile}-f{g,u}
7968 test_mkdir $DIR/${tfile}-dg
7969 test_mkdir $DIR/${tfile}-du
7970 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7971 chmod g+s $DIR/${tfile}-{f,d}g
7972 chmod u+s $DIR/${tfile}-{f,d}u
7973 for perm in 777 2777 4777; do
7974 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7975 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7976 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7977 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7981 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7983 # bug 3462 - multiple simultaneous MDC requests
7985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7987 test_mkdir $DIR/d73-1
7988 test_mkdir $DIR/d73-2
7989 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7992 lctl set_param fail_loc=0x80000129
7993 $MULTIOP $DIR/d73-1/f73-2 Oc &
7995 lctl set_param fail_loc=0
7997 $MULTIOP $DIR/d73-2/f73-3 Oc &
8001 wait $pid1 || return 1
8005 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
8006 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
8007 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
8011 run_test 73 "multiple MDC requests (should not deadlock)"
8013 test_74a() { # bug 6149, 6184
8014 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8017 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8019 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8020 # will spin in a tight reconnection loop
8021 $LCTL set_param fail_loc=0x8000030e
8022 # get any lock that won't be difficult - lookup works.
8024 $LCTL set_param fail_loc=0
8028 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
8030 test_74b() { # bug 13310
8031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8033 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8035 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8036 # will spin in a tight reconnection loop
8037 $LCTL set_param fail_loc=0x8000030e
8038 # get a "difficult" lock
8040 $LCTL set_param fail_loc=0
8044 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
8047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8049 #define OBD_FAIL_LDLM_NEW_LOCK
8050 $LCTL set_param fail_loc=0x319
8051 touch $DIR/$tfile && error "touch successful"
8052 $LCTL set_param fail_loc=0
8055 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
8058 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
8061 test_76() { # Now for bug 20433, added originally in bug 1443
8062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8064 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
8066 cancel_lru_locks osc
8067 BEFORE_INODES=$(num_inodes)
8068 echo "before inodes: $BEFORE_INODES"
8070 [ "$SLOW" = "no" ] && COUNT=100
8071 for i in $(seq $COUNT); do
8075 cancel_lru_locks osc
8076 AFTER_INODES=$(num_inodes)
8077 echo "after inodes: $AFTER_INODES"
8079 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
8081 AFTER_INODES=$(num_inodes)
8083 echo "wait $wait seconds inodes: $AFTER_INODES"
8084 if [ $wait -gt 30 ]; then
8085 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
8089 run_test 76 "confirm clients recycle inodes properly ===="
8095 # Note: in sptlrpc modes which enable its own bulk checksum, the
8096 # original crc32_le bulk checksum will be automatically disabled,
8097 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
8098 # will be checked by sptlrpc code against sptlrpc bulk checksum.
8099 # In this case set_checksums() will not be no-op, because sptlrpc
8100 # bulk checksum will be enabled all through the test.
8102 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
8103 lctl set_param -n osc.*.checksums $1
8107 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8108 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
8109 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8110 tr -d [] | head -n1)}
8113 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
8115 log "set checksum type to $1, rc = $rc"
8119 get_osc_checksum_type()
8121 # arugment 1: OST name, like OST0000
8123 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
8124 sed 's/.*\[\(.*\)\].*/\1/g')
8126 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
8130 F77_TMP=$TMP/f77-temp
8133 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
8134 error "error writing to $F77_TMP"
8137 test_77a() { # bug 10889
8138 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8139 $GSS && skip_env "could not run with gss"
8141 [ ! -f $F77_TMP ] && setup_f77
8143 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
8147 run_test 77a "normal checksum read/write operation"
8149 test_77b() { # bug 10889
8150 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8151 $GSS && skip_env "could not run with gss"
8153 [ ! -f $F77_TMP ] && setup_f77
8154 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8155 $LCTL set_param fail_loc=0x80000409
8158 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8159 error "dd error: $?"
8160 $LCTL set_param fail_loc=0
8162 for algo in $CKSUM_TYPES; do
8163 cancel_lru_locks osc
8164 set_checksum_type $algo
8165 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8166 $LCTL set_param fail_loc=0x80000408
8167 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
8168 $LCTL set_param fail_loc=0
8171 set_checksum_type $ORIG_CSUM_TYPE
8174 run_test 77b "checksum error on client write, read"
8179 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
8181 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
8182 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
8183 $check_ost && [ -n "$ost_file_prefix" ] &&
8184 do_facet ost1 rm -f ${ost_file_prefix}\*
8188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8189 $GSS && skip_env "could not run with gss"
8190 remote_ost_nodsh && skip "remote OST with nodsh"
8193 local osc_file_prefix
8195 local check_ost=false
8196 local ost_file_prefix
8202 # ensure corruption will occur on first OSS/OST
8203 $LFS setstripe -i 0 $DIR/$tfile
8205 [ ! -f $F77_TMP ] && setup_f77
8206 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8207 error "dd write error: $?"
8208 fid=$($LFS path2fid $DIR/$tfile)
8210 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
8213 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
8214 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
8216 echo "OSS do not support bulk pages dump upon error"
8219 osc_file_prefix=$($LCTL get_param -n debug_path)
8220 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
8222 trap cleanup_77c EXIT
8225 # enable bulk pages dump upon error on Client
8226 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
8227 # enable bulk pages dump upon error on OSS
8229 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
8231 # flush Client cache to allow next read to reach OSS
8232 cancel_lru_locks osc
8234 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8235 $LCTL set_param fail_loc=0x80000408
8236 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
8237 $LCTL set_param fail_loc=0
8241 # check cksum dump on Client
8242 osc_file=$(ls ${osc_file_prefix}*)
8243 [ -n "$osc_file" ] || error "no checksum dump file on Client"
8244 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
8245 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
8246 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
8247 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
8249 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
8250 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8251 error "dump content does not match on Client"
8253 $check_ost || skip "No need to check cksum dump on OSS"
8255 # check cksum dump on OSS
8256 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
8257 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
8258 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
8259 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
8260 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8261 error "dump content does not match on OSS"
8265 run_test 77c "checksum error on client read with debug"
8267 test_77d() { # bug 10889
8268 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8269 $GSS && skip_env "could not run with gss"
8271 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8272 $LCTL set_param fail_loc=0x80000409
8274 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8275 error "direct write: rc=$?"
8276 $LCTL set_param fail_loc=0
8279 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8280 $LCTL set_param fail_loc=0x80000408
8282 cancel_lru_locks osc
8283 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8284 error "direct read: rc=$?"
8285 $LCTL set_param fail_loc=0
8288 run_test 77d "checksum error on OST direct write, read"
8290 test_77f() { # bug 10889
8291 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8292 $GSS && skip_env "could not run with gss"
8295 for algo in $CKSUM_TYPES; do
8296 cancel_lru_locks osc
8297 set_checksum_type $algo
8298 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8299 $LCTL set_param fail_loc=0x409
8300 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
8301 error "direct write succeeded"
8302 $LCTL set_param fail_loc=0
8304 set_checksum_type $ORIG_CSUM_TYPE
8307 run_test 77f "repeat checksum error on write (expect error)"
8309 test_77g() { # bug 10889
8310 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8311 $GSS && skip_env "could not run with gss"
8312 remote_ost_nodsh && skip "remote OST with nodsh"
8314 [ ! -f $F77_TMP ] && setup_f77
8316 local file=$DIR/$tfile
8317 stack_trap "rm -f $file" EXIT
8319 $LFS setstripe -c 1 -i 0 $file
8320 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
8321 do_facet ost1 lctl set_param fail_loc=0x8000021a
8323 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
8324 error "write error: rc=$?"
8325 do_facet ost1 lctl set_param fail_loc=0
8328 cancel_lru_locks osc
8329 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
8330 do_facet ost1 lctl set_param fail_loc=0x8000021b
8332 cmp $F77_TMP $file || error "file compare failed"
8333 do_facet ost1 lctl set_param fail_loc=0
8336 run_test 77g "checksum error on OST write, read"
8338 test_77k() { # LU-10906
8339 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8340 $GSS && skip_env "could not run with gss"
8342 local cksum_param="osc.$FSNAME*.checksums"
8343 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
8347 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
8348 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
8349 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
8353 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
8354 error "failed to set checksum=$i on MGS"
8355 wait_update $HOSTNAME "$get_checksum" $i
8357 echo "remount client, checksum should be $i"
8358 remount_client $MOUNT || error "failed to remount client"
8359 checksum=$(eval $get_checksum)
8360 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8362 # remove persistent param to avoid races with checksum mountopt below
8363 do_facet mgs $LCTL set_param -P -d $cksum_param ||
8364 error "failed to delete checksum on MGS"
8366 for opt in "checksum" "nochecksum"; do
8367 #remount with mount option
8368 echo "remount client with option $opt, checksum should be $i"
8369 umount_client $MOUNT || error "failed to umount client"
8370 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8371 error "failed to mount client with option '$opt'"
8372 checksum=$(eval $get_checksum)
8373 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8377 remount_client $MOUNT || error "failed to remount client"
8379 run_test 77k "enable/disable checksum correctly"
8382 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8383 $GSS && skip_env "could not run with gss"
8386 stack_trap "set_checksums $ORIG_CSUM" EXIT
8387 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
8389 set_checksum_type invalid && error "unexpected success of invalid checksum type"
8391 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8392 for algo in $CKSUM_TYPES; do
8393 set_checksum_type $algo || error "fail to set checksum type $algo"
8394 osc_algo=$(get_osc_checksum_type OST0000)
8395 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
8397 # no locks, no reqs to let the connection idle
8398 cancel_lru_locks osc
8399 lru_resize_disable osc
8400 wait_osc_import_state client ost1 IDLE
8402 # ensure ost1 is connected
8403 stat $DIR/$tfile >/dev/null || error "can't stat"
8404 wait_osc_import_state client ost1 FULL
8406 osc_algo=$(get_osc_checksum_type OST0000)
8407 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
8411 run_test 77l "preferred checksum type is remembered after reconnected"
8413 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8422 test_78() { # bug 10901
8423 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8424 remote_ost || skip_env "local OST"
8427 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8428 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8429 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8430 echo "MemTotal: $MEMTOTAL"
8432 # reserve 256MB of memory for the kernel and other running processes,
8433 # and then take 1/2 of the remaining memory for the read/write buffers.
8434 if [ $MEMTOTAL -gt 512 ] ;then
8435 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8437 # for those poor memory-starved high-end clusters...
8438 MEMTOTAL=$((MEMTOTAL / 2))
8440 echo "Mem to use for directio: $MEMTOTAL"
8442 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8443 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8444 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8445 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8447 echo "Smallest OST: $SMALLESTOST"
8448 [[ $SMALLESTOST -lt 10240 ]] &&
8449 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8451 trap cleanup_test_78 EXIT
8453 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8454 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8456 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8457 echo "File size: $F78SIZE"
8458 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8459 for i in $(seq 1 $NSEQ); do
8460 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8461 echo directIO rdwr round $i of $NSEQ
8462 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8467 run_test 78 "handle large O_DIRECT writes correctly ============"
8469 test_79() { # bug 12743
8470 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8472 wait_delete_completed
8474 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8475 BKFREE=$(calc_osc_kbytes kbytesfree)
8476 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8478 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8479 DFTOTAL=`echo $STRING | cut -d, -f1`
8480 DFUSED=`echo $STRING | cut -d, -f2`
8481 DFAVAIL=`echo $STRING | cut -d, -f3`
8482 DFFREE=$(($DFTOTAL - $DFUSED))
8484 ALLOWANCE=$((64 * $OSTCOUNT))
8486 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8487 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8488 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8490 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8491 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8492 error "df free($DFFREE) mismatch OST free($BKFREE)"
8494 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8495 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8496 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8499 run_test 79 "df report consistency check ======================="
8501 test_80() { # bug 10718
8502 remote_ost_nodsh && skip "remote OST with nodsh"
8503 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8505 # relax strong synchronous semantics for slow backends like ZFS
8506 local soc="obdfilter.*.sync_on_lock_cancel"
8507 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
8509 if [ "$soc_old" != "never" ] &&
8510 [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8511 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
8512 facet_active_host $host; done | sort -u)
8513 do_nodes $hosts lctl set_param $soc=never
8516 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
8518 local BEFORE=`date +%s`
8519 cancel_lru_locks osc
8520 local AFTER=`date +%s`
8521 local DIFF=$((AFTER-BEFORE))
8522 if [ $DIFF -gt 1 ] ; then
8523 error "elapsed for 1M@1T = $DIFF"
8526 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
8530 run_test 80 "Page eviction is equally fast at high offsets too ===="
8532 test_81a() { # LU-456
8533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8534 remote_ost_nodsh && skip "remote OST with nodsh"
8536 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8537 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8538 do_facet ost1 lctl set_param fail_loc=0x80000228
8540 # write should trigger a retry and success
8541 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8542 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8544 if [ $RC -ne 0 ] ; then
8545 error "write should success, but failed for $RC"
8548 run_test 81a "OST should retry write when get -ENOSPC ==============="
8550 test_81b() { # LU-456
8551 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8552 remote_ost_nodsh && skip "remote OST with nodsh"
8554 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8555 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8556 do_facet ost1 lctl set_param fail_loc=0x228
8558 # write should retry several times and return -ENOSPC finally
8559 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8560 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8563 if [ $RC -ne $ENOSPC ] ; then
8564 error "dd should fail for -ENOSPC, but succeed."
8567 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8569 test_82() { # LU-1031
8570 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
8574 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
8576 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
8578 kill -USR1 $MULTIPID2
8580 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
8581 error "First grouplock does not block second one"
8583 echo "Second grouplock blocks first one"
8585 kill -USR1 $MULTIPID1
8589 run_test 82 "Basic grouplock test"
8592 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
8594 test_mkdir $DIR/$tdir.cvsroot
8595 chown $RUNAS_ID $DIR/$tdir.cvsroot
8598 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
8601 # some versions of cvs import exit(1) when asked to import links or
8602 # files they can't read. ignore those files.
8603 local toignore=$(find . -type l -printf '-I %f\n' -o \
8604 ! -perm /4 -printf '-I %f\n')
8605 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
8606 $tdir.reposname vtag rtag
8609 test_mkdir $DIR/$tdir.reposname
8610 chown $RUNAS_ID $DIR/$tdir.reposname
8611 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
8613 cd $DIR/$tdir.reposname
8615 $RUNAS cvs add -m 'addmsg' foo99
8617 $RUNAS cvs commit -m 'nomsg' foo99
8618 rm -fr $DIR/$tdir.cvsroot
8620 run_test 99 "cvs strange file/directory operations"
8623 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8624 [[ "$NETTYPE" =~ tcp ]] ||
8625 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
8626 remote_ost_nodsh && skip "remote OST with nodsh"
8627 remote_mds_nodsh && skip "remote MDS with nodsh"
8629 skip "useless for local single node setup"
8631 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
8632 [ "$PROT" != "tcp" ] && continue
8633 RPORT=$(echo $REMOTE | cut -d: -f2)
8634 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
8637 LPORT=`echo $LOCAL | cut -d: -f2`
8638 if [ $LPORT -ge 1024 ]; then
8639 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
8641 error_exit "local: $LPORT > 1024, remote: $RPORT"
8644 [ "$rc" = 0 ] || error_exit "privileged port not found" )
8646 run_test 100 "check local port using privileged port ==========="
8648 function get_named_value()
8657 echo $line | sed "s/^$tag[ ]*//"
8664 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
8665 awk '/^max_cached_mb/ { print $2 }')
8668 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
8673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8678 local cache_limit=32
8680 $LCTL set_param -n osc.*-osc*.rpc_stats 0
8681 trap cleanup_101a EXIT
8682 $LCTL set_param -n llite.*.read_ahead_stats 0
8683 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
8686 # randomly read 10000 of 64K chunks from file 3x 32MB in size
8688 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
8689 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
8692 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
8693 get_named_value 'read but discarded' | cut -d" " -f1); do
8694 discard=$(($discard + $s))
8698 $LCTL get_param osc.*-osc*.rpc_stats
8699 $LCTL get_param llite.*.read_ahead_stats
8701 # Discard is generally zero, but sometimes a few random reads line up
8702 # and trigger larger readahead, which is wasted & leads to discards.
8703 if [[ $(($discard)) -gt $nreads ]]; then
8704 error "too many ($discard) discarded pages"
8706 rm -f $DIR/$tfile || true
8708 run_test 101a "check read-ahead for random reads"
8711 test_mkdir $DIR/$tdir
8713 local FILE_LENGTH=$2
8716 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
8718 local list=$(comma_list $(osts_nodes))
8719 set_osd_param $list '' read_cache_enable 0
8720 set_osd_param $list '' writethrough_cache_enable 0
8722 trap cleanup_test101bc EXIT
8723 # prepare the read-ahead file
8724 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8726 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
8727 count=$FILE_SIZE_MB 2> /dev/null
8731 cleanup_test101bc() {
8736 local list=$(comma_list $(osts_nodes))
8737 set_osd_param $list '' read_cache_enable 1
8738 set_osd_param $list '' writethrough_cache_enable 1
8742 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8747 local STRIPE_SIZE=$2
8748 local FILE_LENGTH=$3
8749 local RA_INC=1048576
8750 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8751 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8752 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8753 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8754 get_named_value 'read but discarded' |
8755 cut -d" " -f1 | calc_total)
8756 if [[ $DISCARD -gt $discard_limit ]]; then
8757 $LCTL get_param llite.*.read_ahead_stats
8758 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8760 echo "Read-ahead success for size ${READ_SIZE}"
8765 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8766 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8768 local STRIPE_SIZE=1048576
8769 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8771 if [ $SLOW == "yes" ]; then
8772 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8774 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8777 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8779 # prepare the read-ahead file
8780 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8781 cancel_lru_locks osc
8782 for BIDX in 2 4 8 16 32 64 128 256
8784 local BSIZE=$((BIDX*4096))
8785 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
8786 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
8787 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
8788 $LCTL set_param -n llite.*.read_ahead_stats 0
8789 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
8790 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
8791 cancel_lru_locks osc
8792 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
8797 run_test 101b "check stride-io mode read-ahead ================="
8800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8802 local STRIPE_SIZE=1048576
8803 local FILE_LENGTH=$((STRIPE_SIZE*100))
8808 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8810 cancel_lru_locks osc
8811 $LCTL set_param osc.*.rpc_stats 0
8812 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
8813 $LCTL get_param osc.*.rpc_stats
8814 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
8815 local stats=$($LCTL get_param -n $osc_rpc_stats)
8816 local lines=$(echo "$stats" | awk 'END {print NR;}')
8819 if [ $lines -le 20 ]; then
8820 echo "continue debug"
8823 for size in 1 2 4 8; do
8824 local rpc=$(echo "$stats" |
8825 awk '($1 == "'$size':") {print $2; exit; }')
8826 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
8827 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
8829 echo "$osc_rpc_stats check passed!"
8834 run_test 101c "check stripe_size aligned read-ahead ================="
8837 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
8838 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
8842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8844 local file=$DIR/$tfile
8845 local sz_MB=${FILESIZE_101d:-500}
8846 local ra_MB=${READAHEAD_MB:-40}
8848 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
8849 [ $free_MB -lt $sz_MB ] &&
8850 skip "Need free space ${sz_MB}M, have ${free_MB}M"
8852 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
8853 $LFS setstripe -c -1 $file || error "setstripe failed"
8855 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
8856 echo Cancel LRU locks on lustre client to flush the client cache
8857 cancel_lru_locks osc
8859 echo Disable read-ahead
8860 local old_READAHEAD=$(set_read_ahead 0)
8862 echo Reading the test file $file with read-ahead disabled
8863 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8865 echo Cancel LRU locks on lustre client to flush the client cache
8866 cancel_lru_locks osc
8867 echo Enable read-ahead with ${ra_MB}MB
8868 set_read_ahead $ra_MB
8870 echo Reading the test file $file with read-ahead enabled
8871 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8873 echo "read-ahead disabled time read $raOFF"
8874 echo "read-ahead enabled time read $raON"
8876 set_read_ahead $old_READAHEAD
8878 wait_delete_completed
8880 [ $raOFF -le 1 ] || [ $raON -lt $raOFF ] ||
8881 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
8883 run_test 101d "file read with and without read-ahead enabled"
8886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8888 local file=$DIR/$tfile
8889 local size_KB=500 #KB
8893 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
8894 local need_KB=$((count * size_KB))
8895 [[ $free_KB -le $need_KB ]] &&
8896 skip_env "Need free space $need_KB, have $free_KB"
8898 echo "Creating $count ${size_KB}K test files"
8899 for ((i = 0; i < $count; i++)); do
8900 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
8903 echo "Cancel LRU locks on lustre client to flush the client cache"
8904 cancel_lru_locks $OSC
8906 echo "Reset readahead stats"
8907 $LCTL set_param -n llite.*.read_ahead_stats 0
8909 for ((i = 0; i < $count; i++)); do
8910 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
8913 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8914 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8916 for ((i = 0; i < $count; i++)); do
8917 rm -rf $file.$i 2>/dev/null
8920 #10000 means 20% reads are missing in readahead
8921 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
8923 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
8926 which iozone || skip_env "no iozone installed"
8928 local old_debug=$($LCTL get_param debug)
8929 old_debug=${old_debug#*=}
8930 $LCTL set_param debug="reada mmap"
8932 # create a test file
8933 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
8935 echo Cancel LRU locks on lustre client to flush the client cache
8936 cancel_lru_locks osc
8938 echo Reset readahead stats
8939 $LCTL set_param -n llite.*.read_ahead_stats 0
8941 echo mmap read the file with small block size
8942 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
8945 echo checking missing pages
8946 $LCTL get_param llite.*.read_ahead_stats
8947 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8948 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8950 $LCTL set_param debug="$old_debug"
8951 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
8954 run_test 101f "check mmap read performance"
8956 test_101g_brw_size_test() {
8958 local pages=$((mb * 1048576 / PAGE_SIZE))
8959 local file=$DIR/$tfile
8961 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
8962 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
8963 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
8964 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
8968 stack_trap "rm -f $file" EXIT
8969 $LCTL set_param -n osc.*.rpc_stats=0
8971 # 10 RPCs should be enough for the test
8973 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
8974 { error "dd write ${mb} MB blocks failed"; return 3; }
8975 cancel_lru_locks osc
8976 dd of=/dev/null if=$file bs=${mb}M count=$count ||
8977 { error "dd write ${mb} MB blocks failed"; return 4; }
8979 # calculate number of full-sized read and write RPCs
8980 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
8981 sed -n '/pages per rpc/,/^$/p' |
8982 awk '/'$pages':/ { reads += $2; writes += $6 }; \
8983 END { print reads,writes }'))
8984 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
8986 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
8993 remote_ost_nodsh && skip "remote OST with nodsh"
8996 local osts=$(get_facets OST)
8997 local list=$(comma_list $(osts_nodes))
8998 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8999 local brw_size="obdfilter.*.brw_size"
9001 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9003 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
9005 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
9006 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
9007 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
9008 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
9009 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
9010 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
9012 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
9015 if [[ $orig_mb -lt 16 ]]; then
9016 save_lustre_params $osts "$brw_size" > $p
9017 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
9018 error "set 16MB RPC size failed"
9020 echo "remount client to enable new RPC size"
9021 remount_client $MOUNT || error "remount_client failed"
9024 test_101g_brw_size_test 16 || error "16MB RPC test failed"
9025 # should be able to set brw_size=12, but no rpc_stats for that
9026 test_101g_brw_size_test 8 || error "8MB RPC test failed"
9029 test_101g_brw_size_test 4 || error "4MB RPC test failed"
9031 if [[ $orig_mb -lt 16 ]]; then
9032 restore_lustre_params < $p
9033 remount_client $MOUNT || error "remount_client restore failed"
9036 rm -f $p $DIR/$tfile
9038 run_test 101g "Big bulk(4/16 MiB) readahead"
9041 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9043 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
9044 error "dd 70M file failed"
9045 echo Cancel LRU locks on lustre client to flush the client cache
9046 cancel_lru_locks osc
9048 echo "Reset readahead stats"
9049 $LCTL set_param -n llite.*.read_ahead_stats 0
9051 echo "Read 10M of data but cross 64M bundary"
9052 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
9053 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9054 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9055 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
9056 rm -f $p $DIR/$tfile
9058 run_test 101h "Readahead should cover current read window"
9061 test_mkdir $DIR/$tdir
9062 chown $RUNAS_ID $DIR/$tdir
9065 STRIPE_COUNT=$OSTCOUNT
9066 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
9068 trap cleanup_test102 EXIT
9070 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
9072 for num in 1 2 3 4; do
9073 for count in $(seq 1 $STRIPE_COUNT); do
9074 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
9075 local size=`expr $STRIPE_SIZE \* $num`
9076 local file=file"$num-$idx-$count"
9077 $1 $LFS setstripe -S $size -i $idx -c $count $file
9083 $1 tar cf $TMP/f102.tar $tdir --xattrs
9089 rm -rf $DIR/d0.sanity/d102
9093 [ "$UID" != 0 ] && skip "must run as root"
9094 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
9095 skip_env "must have user_xattr"
9097 [ -z "$(which setfattr 2>/dev/null)" ] &&
9098 skip_env "could not find setfattr"
9100 local testfile=$DIR/$tfile
9103 echo "set/get xattr..."
9104 setfattr -n trusted.name1 -v value1 $testfile ||
9105 error "setfattr -n trusted.name1=value1 $testfile failed"
9106 getfattr -n trusted.name1 $testfile 2> /dev/null |
9107 grep "trusted.name1=.value1" ||
9108 error "$testfile missing trusted.name1=value1"
9110 setfattr -n user.author1 -v author1 $testfile ||
9111 error "setfattr -n user.author1=author1 $testfile failed"
9112 getfattr -n user.author1 $testfile 2> /dev/null |
9113 grep "user.author1=.author1" ||
9114 error "$testfile missing trusted.author1=author1"
9117 setfattr -n trusted.name2 -v value2 $testfile ||
9118 error "$testfile unable to set trusted.name2"
9119 setfattr -n trusted.name3 -v value3 $testfile ||
9120 error "$testfile unable to set trusted.name3"
9121 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
9122 grep "trusted.name" | wc -l) -eq 3 ] ||
9123 error "$testfile missing 3 trusted.name xattrs"
9125 setfattr -n user.author2 -v author2 $testfile ||
9126 error "$testfile unable to set user.author2"
9127 setfattr -n user.author3 -v author3 $testfile ||
9128 error "$testfile unable to set user.author3"
9129 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
9130 grep "user.author" | wc -l) -eq 3 ] ||
9131 error "$testfile missing 3 user.author xattrs"
9133 echo "remove xattr..."
9134 setfattr -x trusted.name1 $testfile ||
9135 error "$testfile error deleting trusted.name1"
9136 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
9137 error "$testfile did not delete trusted.name1 xattr"
9139 setfattr -x user.author1 $testfile ||
9140 error "$testfile error deleting user.author1"
9141 echo "set lustre special xattr ..."
9142 $LFS setstripe -c1 $testfile
9143 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
9144 awk -F "=" '/trusted.lov/ { print $2 }' )
9145 setfattr -n "trusted.lov" -v $lovea $testfile ||
9146 error "$testfile doesn't ignore setting trusted.lov again"
9147 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
9148 error "$testfile allow setting invalid trusted.lov"
9151 run_test 102a "user xattr test =================================="
9154 [ -z "$(which setfattr 2>/dev/null)" ] &&
9155 skip_env "could not find setfattr"
9156 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9158 # b10930: get/set/list trusted.lov xattr
9159 echo "get/set/list trusted.lov xattr ..."
9160 local testfile=$DIR/$tfile
9161 $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
9162 error "setstripe failed"
9163 local STRIPECOUNT=$($LFS getstripe -c $testfile) ||
9164 error "getstripe failed"
9165 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
9166 error "can't get trusted.lov from $testfile"
9168 local testfile2=${testfile}2
9169 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
9170 grep "trusted.lov" | sed -e 's/[^=]\+=//')
9173 setfattr -n trusted.lov -v $value $testfile2
9174 local stripe_size=$($LFS getstripe -S $testfile2)
9175 local stripe_count=$($LFS getstripe -c $testfile2)
9176 [[ $stripe_size -eq 65536 ]] ||
9177 error "stripe size $stripe_size != 65536"
9178 [[ $stripe_count -eq $STRIPECOUNT ]] ||
9179 error "stripe count $stripe_count != $STRIPECOUNT"
9182 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
9185 [ -z "$(which setfattr 2>/dev/null)" ] &&
9186 skip_env "could not find setfattr"
9187 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9189 # b10930: get/set/list lustre.lov xattr
9190 echo "get/set/list lustre.lov xattr ..."
9191 test_mkdir $DIR/$tdir
9192 chown $RUNAS_ID $DIR/$tdir
9193 local testfile=$DIR/$tdir/$tfile
9194 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
9195 error "setstripe failed"
9196 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
9197 error "getstripe failed"
9198 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
9199 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
9201 local testfile2=${testfile}2
9202 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
9203 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
9205 $RUNAS $MCREATE $testfile2
9206 $RUNAS setfattr -n lustre.lov -v $value $testfile2
9207 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
9208 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
9209 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
9210 [ $stripe_count -eq $STRIPECOUNT ] ||
9211 error "stripe count $stripe_count != $STRIPECOUNT"
9213 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
9215 compare_stripe_info1() {
9216 local stripe_index_all_zero=true
9218 for num in 1 2 3 4; do
9219 for count in $(seq 1 $STRIPE_COUNT); do
9220 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
9221 local size=$((STRIPE_SIZE * num))
9222 local file=file"$num-$offset-$count"
9223 stripe_size=$($LFS getstripe -S $PWD/$file)
9224 [[ $stripe_size -ne $size ]] &&
9225 error "$file: size $stripe_size != $size"
9226 stripe_count=$($LFS getstripe -c $PWD/$file)
9227 # allow fewer stripes to be created, ORI-601
9228 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
9229 error "$file: count $stripe_count != $count"
9230 stripe_index=$($LFS getstripe -i $PWD/$file)
9231 [[ $stripe_index -ne 0 ]] &&
9232 stripe_index_all_zero=false
9236 $stripe_index_all_zero &&
9237 error "all files are being extracted starting from OST index 0"
9241 have_xattrs_include() {
9242 tar --help | grep -q xattrs-include &&
9243 echo --xattrs-include="lustre.*"
9247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9248 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9250 XINC=$(have_xattrs_include)
9252 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9254 compare_stripe_info1
9256 run_test 102d "tar restore stripe info from tarfile,not keep osts"
9259 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9260 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9262 XINC=$(have_xattrs_include)
9264 test_mkdir $DIR/$tdir.restore
9266 tar cf - --xattrs $tdir | tar xf - \
9267 -C $DIR/$tdir.restore --xattrs $XINC
9268 cd $DIR/$tdir.restore/$tdir
9269 compare_stripe_info1
9271 run_test 102f "tar copy files, not keep osts"
9274 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
9275 skip "must have user_xattr"
9276 [ -z "$(which setfattr 2>/dev/null)" ] &&
9277 skip_env "could not find setfattr"
9278 [ -z "$(which getfattr 2>/dev/null)" ] &&
9279 skip_env "could not find getfattr"
9281 local xsize=${1:-1024} # in bytes
9282 local file=$DIR/$tfile
9283 local value="$(generate_string $xsize)"
9284 local xbig=trusted.big
9288 log "save $xbig on $file"
9291 setfattr -n $xbig -v $value $file ||
9292 error "saving $xbig on $file failed"
9294 setfattr -n $xbig -v $value $file &&
9295 error "saving $xbig on $file succeeded"
9299 local orig=$(get_xattr_value $xbig $file)
9300 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
9302 local xsml=trusted.sml
9303 log "save $xsml on $file"
9304 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
9306 local new=$(get_xattr_value $xbig $file)
9307 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
9309 log "grow $xsml on $file"
9310 setfattr -n $xsml -v "$value" $file ||
9311 error "growing $xsml on $file failed"
9313 new=$(get_xattr_value $xbig $file)
9314 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
9315 log "$xbig still valid after growing $xsml"
9320 test_102h() { # bug 15777
9323 run_test 102h "grow xattr from inside inode to external block"
9326 large_xattr_enabled || skip_env "ea_inode feature disabled"
9328 echo "setting xattr of max xattr size: $(max_xattr_size)"
9329 grow_xattr $(max_xattr_size)
9331 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
9332 echo "This should fail:"
9333 grow_xattr $(($(max_xattr_size) + 10)) 1
9335 run_test 102ha "grow xattr from inside inode to external inode"
9337 test_102i() { # bug 17038
9338 [ -z "$(which getfattr 2>/dev/null)" ] &&
9339 skip "could not find getfattr"
9342 ln -s $DIR/$tfile $DIR/${tfile}link
9343 getfattr -n trusted.lov $DIR/$tfile ||
9344 error "lgetxattr on $DIR/$tfile failed"
9345 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
9346 grep -i "no such attr" ||
9347 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
9348 rm -f $DIR/$tfile $DIR/${tfile}link
9350 run_test 102i "lgetxattr test on symbolic link ============"
9353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9354 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9356 XINC=$(have_xattrs_include)
9357 setup_test102 "$RUNAS"
9358 chown $RUNAS_ID $DIR/$tdir
9359 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9361 compare_stripe_info1 "$RUNAS"
9363 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
9366 [ -z "$(which setfattr 2>/dev/null)" ] &&
9367 skip "could not find setfattr"
9370 # b22187 just check that does not crash for regular file.
9371 setfattr -n trusted.lov $DIR/$tfile
9372 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9373 local test_kdir=$DIR/$tdir
9374 test_mkdir $test_kdir
9375 local default_size=$($LFS getstripe -S $test_kdir)
9376 local default_count=$($LFS getstripe -c $test_kdir)
9377 local default_offset=$($LFS getstripe -i $test_kdir)
9378 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9379 error 'dir setstripe failed'
9380 setfattr -n trusted.lov $test_kdir
9381 local stripe_size=$($LFS getstripe -S $test_kdir)
9382 local stripe_count=$($LFS getstripe -c $test_kdir)
9383 local stripe_offset=$($LFS getstripe -i $test_kdir)
9384 [ $stripe_size -eq $default_size ] ||
9385 error "stripe size $stripe_size != $default_size"
9386 [ $stripe_count -eq $default_count ] ||
9387 error "stripe count $stripe_count != $default_count"
9388 [ $stripe_offset -eq $default_offset ] ||
9389 error "stripe offset $stripe_offset != $default_offset"
9390 rm -rf $DIR/$tfile $test_kdir
9392 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9395 [ -z "$(which getfattr 2>/dev/null)" ] &&
9396 skip "could not find getfattr"
9398 # LU-532 trusted. xattr is invisible to non-root
9399 local testfile=$DIR/$tfile
9403 echo "listxattr as user..."
9404 chown $RUNAS_ID $testfile
9405 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9406 grep -q "trusted" &&
9407 error "$testfile trusted xattrs are user visible"
9411 run_test 102l "listxattr size test =================================="
9413 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9414 local path=$DIR/$tfile
9417 listxattr_size_check $path || error "listattr_size_check $path failed"
9419 run_test 102m "Ensure listxattr fails on small bufffer ========"
9423 getxattr() { # getxattr path name
9424 # Return the base64 encoding of the value of xattr name on path.
9428 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9430 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9432 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9434 getfattr --absolute-names --encoding=base64 --name=$name $path |
9435 awk -F= -v name=$name '$1 == name {
9436 print substr($0, index($0, "=") + 1);
9440 test_102n() { # LU-4101 mdt: protect internal xattrs
9441 [ -z "$(which setfattr 2>/dev/null)" ] &&
9442 skip "could not find setfattr"
9443 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9445 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
9448 local file0=$DIR/$tfile.0
9449 local file1=$DIR/$tfile.1
9450 local xattr0=$TMP/$tfile.0
9451 local xattr1=$TMP/$tfile.1
9452 local namelist="lov lma lmv link fid version som hsm"
9456 rm -rf $file0 $file1 $xattr0 $xattr1
9459 # Get 'before' xattrs of $file1.
9460 getfattr --absolute-names --dump --match=- $file1 > $xattr0
9462 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
9463 namelist+=" lfsck_namespace"
9464 for name in $namelist; do
9465 # Try to copy xattr from $file0 to $file1.
9466 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9468 setfattr --name=trusted.$name --value="$value" $file1 ||
9469 error "setxattr 'trusted.$name' failed"
9471 # Try to set a garbage xattr.
9472 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9474 if [[ x$name == "xlov" ]]; then
9475 setfattr --name=trusted.lov --value="$value" $file1 &&
9476 error "setxattr invalid 'trusted.lov' success"
9478 setfattr --name=trusted.$name --value="$value" $file1 ||
9479 error "setxattr invalid 'trusted.$name' failed"
9482 # Try to remove the xattr from $file1. We don't care if this
9483 # appears to succeed or fail, we just don't want there to be
9484 # any changes or crashes.
9485 setfattr --remove=$trusted.$name $file1 2> /dev/null
9488 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
9491 # Try to copy xattr from $file0 to $file1.
9492 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9494 setfattr --name=trusted.$name --value="$value" $file1 ||
9495 error "setxattr 'trusted.$name' failed"
9497 # Try to set a garbage xattr.
9498 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9500 setfattr --name=trusted.$name --value="$value" $file1 ||
9501 error "setxattr 'trusted.$name' failed"
9503 # Try to remove the xattr from $file1. We don't care if this
9504 # appears to succeed or fail, we just don't want there to be
9505 # any changes or crashes.
9506 setfattr --remove=$trusted.$name $file1 2> /dev/null
9509 # Get 'after' xattrs of file1.
9510 getfattr --absolute-names --dump --match=- $file1 > $xattr1
9512 if ! diff $xattr0 $xattr1; then
9513 error "before and after xattrs of '$file1' differ"
9516 rm -rf $file0 $file1 $xattr0 $xattr1
9520 run_test 102n "silently ignore setxattr on internal trusted xattrs"
9522 test_102p() { # LU-4703 setxattr did not check ownership
9523 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
9524 skip "MDS needs to be at least 2.5.56"
9526 local testfile=$DIR/$tfile
9530 echo "setfacl as user..."
9531 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
9532 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
9534 echo "setfattr as user..."
9535 setfacl -m "u:$RUNAS_ID:---" $testfile
9536 $RUNAS setfattr -x system.posix_acl_access $testfile
9537 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
9539 run_test 102p "check setxattr(2) correctly fails without permission"
9542 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
9543 skip "MDS needs to be at least 2.6.92"
9545 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
9547 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
9550 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
9551 skip "MDS needs to be at least 2.6.93"
9553 touch $DIR/$tfile || error "touch"
9554 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
9555 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
9556 rm $DIR/$tfile || error "rm"
9559 mkdir -p $DIR/$tdir || error "mkdir"
9560 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9561 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9562 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9563 error "$testfile error deleting user.author1"
9564 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9565 grep "user.$(basename $tdir)" &&
9566 error "$tdir did not delete user.$(basename $tdir)"
9567 rmdir $DIR/$tdir || error "rmdir"
9570 test_mkdir $DIR/$tdir
9571 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9572 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9573 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9574 error "$testfile error deleting user.author1"
9575 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9576 grep "user.$(basename $tdir)" &&
9577 error "$tdir did not delete user.$(basename $tdir)"
9578 rmdir $DIR/$tdir || error "rm striped dir"
9580 run_test 102r "set EAs with empty values"
9583 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9584 skip "MDS needs to be at least 2.11.52"
9586 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9588 save_lustre_params client "llite.*.xattr_cache" > $save
9590 for cache in 0 1; do
9591 lctl set_param llite.*.xattr_cache=$cache
9594 touch $DIR/$tfile || error "touch"
9595 for prefix in lustre security system trusted user; do
9596 # Note getxattr() may fail with 'Operation not
9597 # supported' or 'No such attribute' depending
9598 # on prefix and cache.
9599 getfattr -n $prefix.n102s $DIR/$tfile &&
9600 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
9604 restore_lustre_params < $save
9606 run_test 102s "getting nonexistent xattrs should fail"
9609 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9610 skip "MDS needs to be at least 2.11.52"
9612 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9614 save_lustre_params client "llite.*.xattr_cache" > $save
9616 for cache in 0 1; do
9617 lctl set_param llite.*.xattr_cache=$cache
9619 for buf_size in 0 256; do
9621 touch $DIR/$tfile || error "touch"
9622 setfattr -n user.multiop $DIR/$tfile
9623 $MULTIOP $DIR/$tfile oa$buf_size ||
9624 error "cannot get zero length xattr value (buf_size = $buf_size)"
9628 restore_lustre_params < $save
9630 run_test 102t "zero length xattr values handled correctly"
9634 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
9639 [ "$UID" != 0 ] && skip "must run as root"
9640 $GSS && skip_env "could not run under gss"
9641 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
9642 skip_env "must have acl enabled"
9643 [ -z "$(which setfacl 2>/dev/null)" ] &&
9644 skip_env "could not find setfacl"
9645 remote_mds_nodsh && skip "remote MDS with nodsh"
9647 gpasswd -a daemon bin # LU-5641
9648 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
9650 declare -a identity_old
9652 for num in $(seq $MDSCOUNT); do
9653 switch_identity $num true || identity_old[$num]=$?
9661 echo "performing cp ..."
9662 run_acl_subtest cp || error "run_acl_subtest cp failed"
9663 echo "performing getfacl-noacl..."
9664 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
9665 echo "performing misc..."
9666 run_acl_subtest misc || error "misc test failed"
9667 echo "performing permissions..."
9668 run_acl_subtest permissions || error "permissions failed"
9669 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
9670 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
9671 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
9672 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
9674 echo "performing permissions xattr..."
9675 run_acl_subtest permissions_xattr ||
9676 error "permissions_xattr failed"
9678 echo "performing setfacl..."
9679 run_acl_subtest setfacl || error "setfacl test failed"
9681 # inheritance test got from HP
9682 echo "performing inheritance..."
9683 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
9684 chmod +x make-tree || error "chmod +x failed"
9685 run_acl_subtest inheritance || error "inheritance test failed"
9688 echo "LU-974 ignore umask when acl is enabled..."
9689 run_acl_subtest 974 || error "LU-974 umask test failed"
9690 if [ $MDSCOUNT -ge 2 ]; then
9691 run_acl_subtest 974_remote ||
9692 error "LU-974 umask test failed under remote dir"
9695 echo "LU-2561 newly created file is same size as directory..."
9696 if [ "$mds1_FSTYPE" != "zfs" ]; then
9697 run_acl_subtest 2561 || error "LU-2561 test failed"
9699 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
9702 run_acl_subtest 4924 || error "LU-4924 test failed"
9707 for num in $(seq $MDSCOUNT); do
9708 if [ "${identity_old[$num]}" = 1 ]; then
9709 switch_identity $num false || identity_old[$num]=$?
9713 run_test 103a "acl test"
9719 for U in {0..511}; do
9721 local O=$(printf "%04o" $U)
9723 umask $(printf "%04o" $((511 ^ $O)))
9724 $LFS setstripe -c 1 $DIR/$tfile.s$O
9725 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9727 (( $S == ($O & 0666) )) ||
9728 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9730 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9731 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9732 (( $S == ($O & 0666) )) ||
9733 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9735 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9736 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9737 (( $S == ($O & 0666) )) ||
9738 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9739 rm -f $DIR/$tfile.[smp]$0
9743 # limit the concurrently running threads to 64. LU-11878
9744 local idx=$((U % 64))
9745 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9750 run_test 103b "umask lfs setstripe"
9754 cp -rp $DIR/$tdir $DIR/$tdir.bak
9756 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9757 error "$DIR/$tdir shouldn't contain default ACL"
9758 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9759 error "$DIR/$tdir.bak shouldn't contain default ACL"
9762 run_test 103c "'cp -rp' won't set empty acl"
9765 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9768 lfs df || error "lfs df failed"
9769 lfs df -ih || error "lfs df -ih failed"
9770 lfs df -h $DIR || error "lfs df -h $DIR failed"
9771 lfs df -i $DIR || error "lfs df -i $DIR failed"
9772 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9773 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9775 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9776 lctl --device %$OSC deactivate
9777 lfs df || error "lfs df with deactivated OSC failed"
9778 lctl --device %$OSC activate
9779 # wait the osc back to normal
9780 wait_osc_import_ready client ost
9782 lfs df || error "lfs df with reactivated OSC failed"
9785 run_test 104a "lfs df [-ih] [path] test ========================="
9788 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9789 [ $RUNAS_ID -eq $UID ] &&
9790 skip_env "RUNAS_ID = UID = $UID -- skipping"
9792 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
9793 grep "Permission denied" | wc -l)))
9794 if [ $denied_cnt -ne 0 ]; then
9795 error "lfs check servers test failed"
9798 run_test 104b "$RUNAS lfs check servers test ===================="
9801 # doesn't work on 2.4 kernels
9803 if $(flock_is_enabled); then
9804 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
9806 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
9810 run_test 105a "flock when mounted without -o flock test ========"
9814 if $(flock_is_enabled); then
9815 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
9817 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
9821 run_test 105b "fcntl when mounted without -o flock test ========"
9825 if $(flock_is_enabled); then
9826 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
9828 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
9832 run_test 105c "lockf when mounted without -o flock test"
9834 test_105d() { # bug 15924
9835 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9837 test_mkdir $DIR/$tdir
9838 flock_is_enabled || skip_env "mount w/o flock enabled"
9839 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
9840 $LCTL set_param fail_loc=0x80000315
9841 flocks_test 2 $DIR/$tdir
9843 run_test 105d "flock race (should not freeze) ========"
9845 test_105e() { # bug 22660 && 22040
9846 flock_is_enabled || skip_env "mount w/o flock enabled"
9849 flocks_test 3 $DIR/$tfile
9851 run_test 105e "Two conflicting flocks from same process"
9853 test_106() { #bug 10921
9854 test_mkdir $DIR/$tdir
9855 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
9856 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
9858 run_test 106 "attempt exec of dir followed by chown of that dir"
9861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9869 local save_pattern=$(sysctl -n kernel.core_pattern)
9870 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
9871 sysctl -w kernel.core_pattern=$file
9872 sysctl -w kernel.core_uses_pid=0
9880 kill -s 11 $SLEEPPID
9882 if [ -e $file ]; then
9883 size=`stat -c%s $file`
9884 [ $size -eq 0 ] && error "Fail to create core file $file"
9886 error "Fail to create core file $file"
9889 sysctl -w kernel.core_pattern=$save_pattern
9890 sysctl -w kernel.core_uses_pid=$save_uses_pid
9893 run_test 107 "Coredump on SIG"
9896 test_mkdir $DIR/$tdir
9897 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
9898 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
9899 error "mkdir with 256 char should fail, but did not"
9900 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
9901 error "create with 255 char failed"
9902 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
9903 error "create with 256 char should fail, but did not"
9908 run_test 110 "filename length checking"
9911 # Purpose: To verify dynamic thread (OSS) creation.
9914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9915 remote_ost_nodsh && skip "remote OST with nodsh"
9917 # Lustre does not stop service threads once they are started.
9918 # Reset number of running threads to default.
9923 local save_params="$TMP/sanity-$TESTNAME.parameters"
9925 # Get ll_ost_io count before I/O
9926 OSTIO_pre=$(do_facet ost1 \
9927 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9928 # Exit if lustre is not running (ll_ost_io not running).
9929 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9931 echo "Starting with $OSTIO_pre threads"
9932 local thread_max=$((OSTIO_pre * 2))
9933 local rpc_in_flight=$((thread_max * 2))
9934 # Number of I/O Process proposed to be started.
9936 local facets=$(get_facets OST)
9938 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9939 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9941 # Set in_flight to $rpc_in_flight
9942 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9943 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9944 nfiles=${rpc_in_flight}
9945 # Set ost thread_max to $thread_max
9946 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
9948 # 5 Minutes should be sufficient for max number of OSS
9949 # threads(thread_max) to be created.
9953 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
9954 test_mkdir $DIR/$tdir
9955 for i in $(seq $nfiles); do
9956 local file=$DIR/$tdir/${tfile}-$i
9957 $LFS setstripe -c -1 -i 0 $file
9958 ($WTL $file $timeout)&
9961 # I/O Started - Wait for thread_started to reach thread_max or report
9962 # error if thread_started is more than thread_max.
9963 echo "Waiting for thread_started to reach thread_max"
9964 local thread_started=0
9965 local end_time=$((SECONDS + timeout))
9967 while [ $SECONDS -le $end_time ] ; do
9969 # Get ost i/o thread_started count.
9970 thread_started=$(do_facet ost1 \
9972 ost.OSS.ost_io.threads_started | cut -d= -f2")
9973 # Break out if thread_started is equal/greater than thread_max
9974 if [[ $thread_started -ge $thread_max ]]; then
9975 echo ll_ost_io thread_started $thread_started, \
9976 equal/greater than thread_max $thread_max
9982 # Cleanup - We have the numbers, Kill i/o jobs if running.
9983 jobcount=($(jobs -p))
9984 for i in $(seq 0 $((${#jobcount[@]}-1)))
9986 kill -9 ${jobcount[$i]}
9987 if [ $? -ne 0 ] ; then
9989 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
9993 # Cleanup files left by WTL binary.
9994 for i in $(seq $nfiles); do
9995 local file=$DIR/$tdir/${tfile}-$i
9997 if [ $? -ne 0 ] ; then
9998 echo "Warning: Failed to delete file $file"
10002 restore_lustre_params <$save_params
10003 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
10005 # Error out if no new thread has started or Thread started is greater
10007 if [[ $thread_started -le $OSTIO_pre ||
10008 $thread_started -gt $thread_max ]]; then
10009 error "ll_ost_io: thread_started $thread_started" \
10010 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
10011 "No new thread started or thread started greater " \
10015 run_test 115 "verify dynamic thread creation===================="
10018 wait_delete_completed
10019 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
10020 echo "OST kbytes available: ${AVAIL[@]}"
10025 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
10026 #echo OST $i: ${AVAIL[i]}kb
10027 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
10031 if [[ ${AVAIL[i]} -lt $MINV ]]; then
10036 echo "Min free space: OST $MINI: $MINV"
10037 echo "Max free space: OST $MAXI: $MAXV"
10040 test_116a() { # was previously test_116()
10041 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10042 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10043 remote_mds_nodsh && skip "remote MDS with nodsh"
10045 echo -n "Free space priority "
10046 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
10051 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
10052 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
10053 trap simple_cleanup_common EXIT
10055 # Check if we need to generate uneven OSTs
10056 test_mkdir -p $DIR/$tdir/OST${MINI}
10057 local FILL=$((MINV / 4))
10058 local DIFF=$((MAXV - MINV))
10059 local DIFF2=$((DIFF * 100 / MINV))
10061 local threshold=$(do_facet $SINGLEMDS \
10062 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
10063 threshold=${threshold%%%}
10064 echo -n "Check for uneven OSTs: "
10065 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
10067 if [[ $DIFF2 -gt $threshold ]]; then
10069 echo "Don't need to fill OST$MINI"
10071 # generate uneven OSTs. Write 2% over the QOS threshold value
10073 DIFF=$((threshold - DIFF2 + 2))
10074 DIFF2=$((MINV * DIFF / 100))
10075 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
10076 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
10077 error "setstripe failed"
10078 DIFF=$((DIFF2 / 2048))
10080 while [ $i -lt $DIFF ]; do
10082 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
10083 bs=2M count=1 2>/dev/null
10092 DIFF=$((MAXV - MINV))
10093 DIFF2=$((DIFF * 100 / MINV))
10094 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
10095 if [ $DIFF2 -gt $threshold ]; then
10098 echo "failed - QOS mode won't be used"
10099 simple_cleanup_common
10100 skip "QOS imbalance criteria not met"
10108 # now fill using QOS
10109 $LFS setstripe -c 1 $DIR/$tdir
10110 FILL=$((FILL / 200))
10111 if [ $FILL -gt 600 ]; then
10114 echo "writing $FILL files to QOS-assigned OSTs"
10116 while [ $i -lt $FILL ]; do
10118 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
10119 count=1 2>/dev/null
10122 echo "wrote $i 200k files"
10126 echo "Note: free space may not be updated, so measurements might be off"
10128 DIFF2=$((MAXV - MINV))
10129 echo "free space delta: orig $DIFF final $DIFF2"
10130 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
10131 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
10132 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
10133 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
10134 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
10135 if [[ $DIFF -gt 0 ]]; then
10136 FILL=$((DIFF2 * 100 / DIFF - 100))
10137 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
10140 # Figure out which files were written where
10141 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10142 awk '/'$MINI1': / {print $2; exit}')
10144 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10145 echo "$MINC files created on smaller OST $MINI1"
10146 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10147 awk '/'$MAXI1': / {print $2; exit}')
10149 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10150 echo "$MAXC files created on larger OST $MAXI1"
10151 if [[ $MINC -gt 0 ]]; then
10152 FILL=$((MAXC * 100 / MINC - 100))
10153 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
10155 [[ $MAXC -gt $MINC ]] ||
10156 error_ignore LU-9 "stripe QOS didn't balance free space"
10157 simple_cleanup_common
10159 run_test 116a "stripe QOS: free space balance ==================="
10161 test_116b() { # LU-2093
10162 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10163 remote_mds_nodsh && skip "remote MDS with nodsh"
10165 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
10166 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
10167 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
10168 [ -z "$old_rr" ] && skip "no QOS"
10169 do_facet $SINGLEMDS lctl set_param \
10170 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
10171 mkdir -p $DIR/$tdir
10172 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
10173 createmany -o $DIR/$tdir/f- 20 || error "can't create"
10174 do_facet $SINGLEMDS lctl set_param fail_loc=0
10176 do_facet $SINGLEMDS lctl set_param \
10177 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
10179 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
10181 test_117() # bug 10891
10183 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10185 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
10186 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
10187 lctl set_param fail_loc=0x21e
10188 > $DIR/$tfile || error "truncate failed"
10189 lctl set_param fail_loc=0
10190 echo "Truncate succeeded."
10193 run_test 117 "verify osd extend =========="
10195 NO_SLOW_RESENDCOUNT=4
10196 export OLD_RESENDCOUNT=""
10197 set_resend_count () {
10198 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
10199 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
10200 lctl set_param -n $PROC_RESENDCOUNT $1
10201 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
10204 # for reduce test_118* time (b=14842)
10205 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10207 # Reset async IO behavior after error case
10209 FILE=$DIR/reset_async
10211 # Ensure all OSCs are cleared
10212 $LFS setstripe -c -1 $FILE
10213 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
10218 test_118a() #bug 11710
10220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10224 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10225 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10226 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10228 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10229 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10234 run_test 118a "verify O_SYNC works =========="
10238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10239 remote_ost_nodsh && skip "remote OST with nodsh"
10243 #define OBD_FAIL_SRV_ENOENT 0x217
10244 set_nodes_failloc "$(osts_nodes)" 0x217
10245 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10247 set_nodes_failloc "$(osts_nodes)" 0
10248 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10249 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10252 if [[ $RC -eq 0 ]]; then
10253 error "Must return error due to dropped pages, rc=$RC"
10257 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10258 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10262 echo "Dirty pages not leaked on ENOENT"
10264 # Due to the above error the OSC will issue all RPCs syncronously
10265 # until a subsequent RPC completes successfully without error.
10266 $MULTIOP $DIR/$tfile Ow4096yc
10271 run_test 118b "Reclaim dirty pages on fatal error =========="
10275 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10277 # for 118c, restore the original resend count, LU-1940
10278 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
10279 set_resend_count $OLD_RESENDCOUNT
10280 remote_ost_nodsh && skip "remote OST with nodsh"
10284 #define OBD_FAIL_OST_EROFS 0x216
10285 set_nodes_failloc "$(osts_nodes)" 0x216
10287 # multiop should block due to fsync until pages are written
10288 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10292 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10293 error "Multiop failed to block on fsync, pid=$MULTIPID"
10296 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10298 if [[ $WRITEBACK -eq 0 ]]; then
10299 error "No page in writeback, writeback=$WRITEBACK"
10302 set_nodes_failloc "$(osts_nodes)" 0
10305 if [[ $RC -ne 0 ]]; then
10306 error "Multiop fsync failed, rc=$RC"
10309 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10310 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10312 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10313 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10317 echo "Dirty pages flushed via fsync on EROFS"
10320 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
10322 # continue to use small resend count to reduce test_118* time (b=14842)
10323 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10327 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10328 remote_ost_nodsh && skip "remote OST with nodsh"
10332 #define OBD_FAIL_OST_BRW_PAUSE_BULK
10333 set_nodes_failloc "$(osts_nodes)" 0x214
10334 # multiop should block due to fsync until pages are written
10335 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10339 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10340 error "Multiop failed to block on fsync, pid=$MULTIPID"
10343 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10345 if [[ $WRITEBACK -eq 0 ]]; then
10346 error "No page in writeback, writeback=$WRITEBACK"
10349 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
10350 set_nodes_failloc "$(osts_nodes)" 0
10352 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10353 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10355 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10356 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10360 echo "Dirty pages gaurenteed flushed via fsync"
10363 run_test 118d "Fsync validation inject a delay of the bulk =========="
10366 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10370 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10371 lctl set_param fail_loc=0x8000040a
10373 # Should simulate EINVAL error which is fatal
10374 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10376 if [[ $RC -eq 0 ]]; then
10377 error "Must return error due to dropped pages, rc=$RC"
10380 lctl set_param fail_loc=0x0
10382 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10383 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10384 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10386 if [[ $LOCKED -ne 0 ]]; then
10387 error "Locked pages remain in cache, locked=$LOCKED"
10390 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10391 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10395 echo "No pages locked after fsync"
10400 run_test 118f "Simulate unrecoverable OSC side error =========="
10403 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10407 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10408 lctl set_param fail_loc=0x406
10410 # simulate local -ENOMEM
10411 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10414 lctl set_param fail_loc=0
10415 if [[ $RC -eq 0 ]]; then
10416 error "Must return error due to dropped pages, rc=$RC"
10419 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10420 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10421 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10423 if [[ $LOCKED -ne 0 ]]; then
10424 error "Locked pages remain in cache, locked=$LOCKED"
10427 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10428 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10432 echo "No pages locked after fsync"
10437 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10440 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10441 remote_ost_nodsh && skip "remote OST with nodsh"
10445 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10446 set_nodes_failloc "$(osts_nodes)" 0x20e
10447 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10448 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10451 set_nodes_failloc "$(osts_nodes)" 0
10452 if [[ $RC -eq 0 ]]; then
10453 error "Must return error due to dropped pages, rc=$RC"
10456 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10457 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10458 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10460 if [[ $LOCKED -ne 0 ]]; then
10461 error "Locked pages remain in cache, locked=$LOCKED"
10464 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10465 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10469 echo "No pages locked after fsync"
10473 run_test 118h "Verify timeout in handling recoverables errors =========="
10475 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10478 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10479 remote_ost_nodsh && skip "remote OST with nodsh"
10483 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10484 set_nodes_failloc "$(osts_nodes)" 0x20e
10486 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10487 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10490 set_nodes_failloc "$(osts_nodes)" 0
10494 if [[ $RC -ne 0 ]]; then
10495 error "got error, but should be not, rc=$RC"
10498 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10499 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10500 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10501 if [[ $LOCKED -ne 0 ]]; then
10502 error "Locked pages remain in cache, locked=$LOCKED"
10505 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10506 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10510 echo "No pages locked after fsync"
10514 run_test 118i "Fix error before timeout in recoverable error =========="
10516 [ "$SLOW" = "no" ] && set_resend_count 4
10519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10520 remote_ost_nodsh && skip "remote OST with nodsh"
10524 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
10525 set_nodes_failloc "$(osts_nodes)" 0x220
10527 # return -EIO from OST
10528 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10530 set_nodes_failloc "$(osts_nodes)" 0x0
10531 if [[ $RC -eq 0 ]]; then
10532 error "Must return error due to dropped pages, rc=$RC"
10535 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10536 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10537 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10538 if [[ $LOCKED -ne 0 ]]; then
10539 error "Locked pages remain in cache, locked=$LOCKED"
10542 # in recoverable error on OST we want resend and stay until it finished
10543 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10544 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10548 echo "No pages locked after fsync"
10552 run_test 118j "Simulate unrecoverable OST side error =========="
10556 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10557 remote_ost_nodsh && skip "remote OSTs with nodsh"
10559 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10560 set_nodes_failloc "$(osts_nodes)" 0x20e
10561 test_mkdir $DIR/$tdir
10563 for ((i=0;i<10;i++)); do
10564 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
10565 error "dd to $DIR/$tdir/$tfile-$i failed" )&
10572 set_nodes_failloc "$(osts_nodes)" 0
10575 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
10577 test_118l() # LU-646
10579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10581 test_mkdir $DIR/$tdir
10582 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
10585 run_test 118l "fsync dir"
10587 test_118m() # LU-3066
10589 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10591 test_mkdir $DIR/$tdir
10592 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
10595 run_test 118m "fdatasync dir ========="
10597 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10605 remote_ost_nodsh && skip "remote OSTs with nodsh"
10607 # Sleep to avoid a cached response.
10608 #define OBD_STATFS_CACHE_SECONDS 1
10611 # Inject a 10 second delay in the OST_STATFS handler.
10612 #define OBD_FAIL_OST_STATFS_DELAY 0x242
10613 set_nodes_failloc "$(osts_nodes)" 0x242
10616 stat --file-system $MOUNT > /dev/null
10619 set_nodes_failloc "$(osts_nodes)" 0
10621 if ((end - begin > 20)); then
10622 error "statfs took $((end - begin)) seconds, expected 10"
10625 run_test 118n "statfs() sends OST_STATFS requests in parallel"
10627 test_119a() # bug 11737
10629 BSIZE=$((512 * 1024))
10630 directio write $DIR/$tfile 0 1 $BSIZE
10631 # We ask to read two blocks, which is more than a file size.
10632 # directio will indicate an error when requested and actual
10633 # sizes aren't equeal (a normal situation in this case) and
10634 # print actual read amount.
10635 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
10636 if [ "$NOB" != "$BSIZE" ]; then
10637 error "read $NOB bytes instead of $BSIZE"
10641 run_test 119a "Short directIO read must return actual read amount"
10643 test_119b() # bug 11737
10645 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10647 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
10648 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
10650 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
10651 error "direct read failed"
10654 run_test 119b "Sparse directIO read must return actual read amount"
10656 test_119c() # bug 13099
10659 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
10660 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
10663 run_test 119c "Testing for direct read hitting hole"
10665 test_119d() # bug 15950
10667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10669 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
10670 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
10672 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
10673 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
10674 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
10675 lctl set_param fail_loc=0x40d
10676 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
10679 cat $DIR/$tfile > /dev/null &
10680 lctl set_param fail_loc=0
10683 log "the DIO writes have completed, now wait for the reads (should not block very long)"
10685 [ -n "`ps h -p $pid_reads -o comm`" ] && \
10686 error "the read rpcs have not completed in 2s"
10688 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
10690 run_test 119d "The DIO path should try to send a new rpc once one is completed"
10693 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10694 remote_mds_nodsh && skip "remote MDS with nodsh"
10695 test_mkdir -i0 -c1 $DIR/$tdir
10696 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10697 skip_env "no early lock cancel on server"
10699 lru_resize_disable mdc
10700 lru_resize_disable osc
10701 cancel_lru_locks mdc
10702 # asynchronous object destroy at MDT could cause bl ast to client
10703 cancel_lru_locks osc
10705 stat $DIR/$tdir > /dev/null
10706 can1=$(do_facet mds1 \
10707 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10708 awk '/ldlm_cancel/ {print $2}')
10709 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10710 awk '/ldlm_bl_callback/ {print $2}')
10711 test_mkdir -i0 -c1 $DIR/$tdir/d1
10712 can2=$(do_facet mds1 \
10713 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10714 awk '/ldlm_cancel/ {print $2}')
10715 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10716 awk '/ldlm_bl_callback/ {print $2}')
10717 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10718 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10719 lru_resize_enable mdc
10720 lru_resize_enable osc
10722 run_test 120a "Early Lock Cancel: mkdir test"
10725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10726 remote_mds_nodsh && skip "remote MDS with nodsh"
10727 test_mkdir $DIR/$tdir
10728 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10729 skip_env "no early lock cancel on server"
10731 lru_resize_disable mdc
10732 lru_resize_disable osc
10733 cancel_lru_locks mdc
10734 stat $DIR/$tdir > /dev/null
10735 can1=$(do_facet $SINGLEMDS \
10736 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10737 awk '/ldlm_cancel/ {print $2}')
10738 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10739 awk '/ldlm_bl_callback/ {print $2}')
10740 touch $DIR/$tdir/f1
10741 can2=$(do_facet $SINGLEMDS \
10742 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10743 awk '/ldlm_cancel/ {print $2}')
10744 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10745 awk '/ldlm_bl_callback/ {print $2}')
10746 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10747 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10748 lru_resize_enable mdc
10749 lru_resize_enable osc
10751 run_test 120b "Early Lock Cancel: create test"
10754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10755 remote_mds_nodsh && skip "remote MDS with nodsh"
10756 test_mkdir -i0 -c1 $DIR/$tdir
10757 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10758 skip "no early lock cancel on server"
10760 lru_resize_disable mdc
10761 lru_resize_disable osc
10762 test_mkdir -i0 -c1 $DIR/$tdir/d1
10763 test_mkdir -i0 -c1 $DIR/$tdir/d2
10764 touch $DIR/$tdir/d1/f1
10765 cancel_lru_locks mdc
10766 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10767 can1=$(do_facet mds1 \
10768 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10769 awk '/ldlm_cancel/ {print $2}')
10770 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10771 awk '/ldlm_bl_callback/ {print $2}')
10772 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10773 can2=$(do_facet mds1 \
10774 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10775 awk '/ldlm_cancel/ {print $2}')
10776 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10777 awk '/ldlm_bl_callback/ {print $2}')
10778 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10779 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10780 lru_resize_enable mdc
10781 lru_resize_enable osc
10783 run_test 120c "Early Lock Cancel: link test"
10786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10787 remote_mds_nodsh && skip "remote MDS with nodsh"
10788 test_mkdir -i0 -c1 $DIR/$tdir
10789 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10790 skip_env "no early lock cancel on server"
10792 lru_resize_disable mdc
10793 lru_resize_disable osc
10795 cancel_lru_locks mdc
10796 stat $DIR/$tdir > /dev/null
10797 can1=$(do_facet mds1 \
10798 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10799 awk '/ldlm_cancel/ {print $2}')
10800 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10801 awk '/ldlm_bl_callback/ {print $2}')
10802 chmod a+x $DIR/$tdir
10803 can2=$(do_facet mds1 \
10804 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10805 awk '/ldlm_cancel/ {print $2}')
10806 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10807 awk '/ldlm_bl_callback/ {print $2}')
10808 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10809 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10810 lru_resize_enable mdc
10811 lru_resize_enable osc
10813 run_test 120d "Early Lock Cancel: setattr test"
10816 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10817 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10818 skip_env "no early lock cancel on server"
10819 remote_mds_nodsh && skip "remote MDS with nodsh"
10821 local dlmtrace_set=false
10823 test_mkdir -i0 -c1 $DIR/$tdir
10824 lru_resize_disable mdc
10825 lru_resize_disable osc
10826 ! $LCTL get_param debug | grep -q dlmtrace &&
10827 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
10828 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
10829 cancel_lru_locks mdc
10830 cancel_lru_locks osc
10831 dd if=$DIR/$tdir/f1 of=/dev/null
10832 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
10833 # XXX client can not do early lock cancel of OST lock
10834 # during unlink (LU-4206), so cancel osc lock now.
10836 cancel_lru_locks osc
10837 can1=$(do_facet mds1 \
10838 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10839 awk '/ldlm_cancel/ {print $2}')
10840 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10841 awk '/ldlm_bl_callback/ {print $2}')
10842 unlink $DIR/$tdir/f1
10844 can2=$(do_facet mds1 \
10845 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10846 awk '/ldlm_cancel/ {print $2}')
10847 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10848 awk '/ldlm_bl_callback/ {print $2}')
10849 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
10850 $LCTL dk $TMP/cancel.debug.txt
10851 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
10852 $LCTL dk $TMP/blocking.debug.txt
10853 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
10854 lru_resize_enable mdc
10855 lru_resize_enable osc
10857 run_test 120e "Early Lock Cancel: unlink test"
10860 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10861 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10862 skip_env "no early lock cancel on server"
10863 remote_mds_nodsh && skip "remote MDS with nodsh"
10865 test_mkdir -i0 -c1 $DIR/$tdir
10866 lru_resize_disable mdc
10867 lru_resize_disable osc
10868 test_mkdir -i0 -c1 $DIR/$tdir/d1
10869 test_mkdir -i0 -c1 $DIR/$tdir/d2
10870 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
10871 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
10872 cancel_lru_locks mdc
10873 cancel_lru_locks osc
10874 dd if=$DIR/$tdir/d1/f1 of=/dev/null
10875 dd if=$DIR/$tdir/d2/f2 of=/dev/null
10876 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
10877 # XXX client can not do early lock cancel of OST lock
10878 # during rename (LU-4206), so cancel osc lock now.
10880 cancel_lru_locks osc
10881 can1=$(do_facet mds1 \
10882 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10883 awk '/ldlm_cancel/ {print $2}')
10884 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10885 awk '/ldlm_bl_callback/ {print $2}')
10886 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10888 can2=$(do_facet mds1 \
10889 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10890 awk '/ldlm_cancel/ {print $2}')
10891 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10892 awk '/ldlm_bl_callback/ {print $2}')
10893 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10894 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10895 lru_resize_enable mdc
10896 lru_resize_enable osc
10898 run_test 120f "Early Lock Cancel: rename test"
10901 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10902 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10903 skip_env "no early lock cancel on server"
10904 remote_mds_nodsh && skip "remote MDS with nodsh"
10906 lru_resize_disable mdc
10907 lru_resize_disable osc
10909 echo create $count files
10910 test_mkdir $DIR/$tdir
10911 cancel_lru_locks mdc
10912 cancel_lru_locks osc
10915 can0=$(do_facet $SINGLEMDS \
10916 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10917 awk '/ldlm_cancel/ {print $2}')
10918 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10919 awk '/ldlm_bl_callback/ {print $2}')
10920 createmany -o $DIR/$tdir/f $count
10922 can1=$(do_facet $SINGLEMDS \
10923 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10924 awk '/ldlm_cancel/ {print $2}')
10925 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10926 awk '/ldlm_bl_callback/ {print $2}')
10928 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
10929 echo rm $count files
10932 can2=$(do_facet $SINGLEMDS \
10933 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10934 awk '/ldlm_cancel/ {print $2}')
10935 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10936 awk '/ldlm_bl_callback/ {print $2}')
10938 echo total: $count removes in $((t2-t1))
10939 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
10941 # wait for commitment of removal
10942 lru_resize_enable mdc
10943 lru_resize_enable osc
10945 run_test 120g "Early Lock Cancel: performance test"
10947 test_121() { #bug #10589
10948 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10951 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
10952 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
10953 lctl set_param fail_loc=0x310
10954 cancel_lru_locks osc > /dev/null
10955 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
10956 lctl set_param fail_loc=0
10957 [[ $reads -eq $writes ]] ||
10958 error "read $reads blocks, must be $writes blocks"
10960 run_test 121 "read cancel race ========="
10962 test_123a() { # was test 123, statahead(bug 11401)
10963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10966 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
10967 log "testing UP system. Performance may be lower than expected."
10972 test_mkdir $DIR/$tdir
10973 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
10974 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
10976 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
10977 createmany -o $DIR/$tdir/$tfile $j $((i - j))
10979 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10980 lctl set_param -n llite.*.statahead_max 0
10981 lctl get_param llite.*.statahead_max
10982 cancel_lru_locks mdc
10983 cancel_lru_locks osc
10985 time ls -l $DIR/$tdir | wc -l
10987 delta=$((etime - stime))
10988 log "ls $i files without statahead: $delta sec"
10989 lctl set_param llite.*.statahead_max=$max
10991 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10992 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
10993 cancel_lru_locks mdc
10994 cancel_lru_locks osc
10996 time ls -l $DIR/$tdir | wc -l
10998 delta_sa=$((etime - stime))
10999 log "ls $i files with statahead: $delta_sa sec"
11000 lctl get_param -n llite.*.statahead_stats
11001 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
11003 [[ $swrong -lt $ewrong ]] &&
11004 log "statahead was stopped, maybe too many locks held!"
11005 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
11007 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11008 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
11009 lctl set_param -n llite.*.statahead_max 0
11010 lctl get_param llite.*.statahead_max
11011 cancel_lru_locks mdc
11012 cancel_lru_locks osc
11014 time ls -l $DIR/$tdir | wc -l
11016 delta=$((etime - stime))
11017 log "ls $i files again without statahead: $delta sec"
11018 lctl set_param llite.*.statahead_max=$max
11019 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11020 if [ $SLOWOK -eq 0 ]; then
11021 error "ls $i files is slower with statahead!"
11023 log "ls $i files is slower with statahead!"
11029 [ $delta -gt 20 ] && break
11030 [ $delta -gt 8 ] && MULT=$((50 / delta))
11031 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
11039 delta=$((etime - stime))
11040 log "rm -r $DIR/$tdir/: $delta seconds"
11042 lctl get_param -n llite.*.statahead_stats
11044 run_test 123a "verify statahead work"
11046 test_123b () { # statahead(bug 15027)
11047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11049 test_mkdir $DIR/$tdir
11050 createmany -o $DIR/$tdir/$tfile-%d 1000
11052 cancel_lru_locks mdc
11053 cancel_lru_locks osc
11055 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
11056 lctl set_param fail_loc=0x80000803
11057 ls -lR $DIR/$tdir > /dev/null
11059 lctl set_param fail_loc=0x0
11060 lctl get_param -n llite.*.statahead_stats
11065 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
11068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11069 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11070 skip_env "no lru resize on server"
11074 test_mkdir $DIR/$tdir
11076 log "create $NR files at $DIR/$tdir"
11077 createmany -o $DIR/$tdir/f $NR ||
11078 error "failed to create $NR files in $DIR/$tdir"
11080 cancel_lru_locks mdc
11081 ls -l $DIR/$tdir > /dev/null
11085 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
11086 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
11087 LRU_SIZE=$($LCTL get_param -n $PARAM)
11088 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
11089 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
11091 log "NS=$(basename $NSDIR)"
11096 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
11097 skip "Not enough cached locks created!"
11099 log "LRU=$LRU_SIZE"
11103 # We know that lru resize allows one client to hold $LIMIT locks
11104 # for 10h. After that locks begin to be killed by client.
11106 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
11108 if [ $LIMIT -lt $LRU_SIZE ]; then
11109 skip "Limit is too small $LIMIT"
11112 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
11113 # killing locks. Some time was spent for creating locks. This means
11114 # that up to the moment of sleep finish we must have killed some of
11115 # them (10-100 locks). This depends on how fast ther were created.
11116 # Many of them were touched in almost the same moment and thus will
11117 # be killed in groups.
11118 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
11120 # Use $LRU_SIZE_B here to take into account real number of locks
11121 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
11122 local LRU_SIZE_B=$LRU_SIZE
11124 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
11125 log "OLD_LVF=$OLD_LVF"
11126 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
11128 # Let's make sure that we really have some margin. Client checks
11129 # cached locks every 10 sec.
11130 SLEEP=$((SLEEP+20))
11131 log "Sleep ${SLEEP} sec"
11133 while ((SEC<$SLEEP)); do
11137 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
11138 echo -n "$LRU_SIZE"
11141 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
11142 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
11144 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
11145 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
11146 unlinkmany $DIR/$tdir/f $NR
11150 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
11151 log "unlink $NR files at $DIR/$tdir"
11152 unlinkmany $DIR/$tdir/f $NR
11154 run_test 124a "lru resize ======================================="
11156 get_max_pool_limit()
11158 local limit=$($LCTL get_param \
11159 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
11161 for l in $limit; do
11162 if [[ $l -gt $max ]]; then
11170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11171 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11172 skip_env "no lru resize on server"
11174 LIMIT=$(get_max_pool_limit)
11176 NR=$(($(default_lru_size)*20))
11177 if [[ $NR -gt $LIMIT ]]; then
11178 log "Limit lock number by $LIMIT locks"
11182 IFree=$(mdsrate_inodes_available)
11183 if [ $IFree -lt $NR ]; then
11184 log "Limit lock number by $IFree inodes"
11188 lru_resize_disable mdc
11189 test_mkdir -p $DIR/$tdir/disable_lru_resize
11191 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
11192 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
11193 cancel_lru_locks mdc
11196 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11199 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11202 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11206 nolruresize_delta=$((etime-stime))
11207 log "ls -la time: $nolruresize_delta seconds"
11208 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11209 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
11211 lru_resize_enable mdc
11212 test_mkdir -p $DIR/$tdir/enable_lru_resize
11214 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
11215 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
11216 cancel_lru_locks mdc
11219 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11222 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11225 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11229 lruresize_delta=$((etime-stime))
11230 log "ls -la time: $lruresize_delta seconds"
11231 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11233 if [ $lruresize_delta -gt $nolruresize_delta ]; then
11234 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
11235 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
11236 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
11238 log "lru resize performs the same with no lru resize"
11240 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
11242 run_test 124b "lru resize (performance test) ======================="
11245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11246 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11247 skip_env "no lru resize on server"
11249 # cache ununsed locks on client
11251 cancel_lru_locks mdc
11252 test_mkdir $DIR/$tdir
11253 createmany -o $DIR/$tdir/f $nr ||
11254 error "failed to create $nr files in $DIR/$tdir"
11255 ls -l $DIR/$tdir > /dev/null
11257 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11258 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11259 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11260 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11261 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11263 # set lru_max_age to 1 sec
11264 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11265 echo "sleep $((recalc_p * 2)) seconds..."
11266 sleep $((recalc_p * 2))
11268 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11269 # restore lru_max_age
11270 $LCTL set_param -n $nsdir.lru_max_age $max_age
11271 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11272 unlinkmany $DIR/$tdir/f $nr
11274 run_test 124c "LRUR cancel very aged locks"
11277 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11278 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11279 skip_env "no lru resize on server"
11281 # cache ununsed locks on client
11284 lru_resize_disable mdc
11285 stack_trap "lru_resize_enable mdc" EXIT
11287 cancel_lru_locks mdc
11289 # asynchronous object destroy at MDT could cause bl ast to client
11290 test_mkdir $DIR/$tdir
11291 createmany -o $DIR/$tdir/f $nr ||
11292 error "failed to create $nr files in $DIR/$tdir"
11293 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
11295 ls -l $DIR/$tdir > /dev/null
11297 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11298 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11299 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11300 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11302 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11304 # set lru_max_age to 1 sec
11305 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11306 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
11308 echo "sleep $((recalc_p * 2)) seconds..."
11309 sleep $((recalc_p * 2))
11311 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11313 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11315 run_test 124d "cancel very aged locks if lru-resize diasbaled"
11317 test_125() { # 13358
11318 $LCTL get_param -n llite.*.client_type | grep -q local ||
11319 skip "must run as local client"
11320 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
11321 skip_env "must have acl enabled"
11322 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11324 test_mkdir $DIR/$tdir
11325 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
11326 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
11327 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
11329 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
11331 test_126() { # bug 12829/13455
11332 $GSS && skip_env "must run as gss disabled"
11333 $LCTL get_param -n llite.*.client_type | grep -q local ||
11334 skip "must run as local client"
11335 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
11337 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
11338 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
11340 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
11342 run_test 126 "check that the fsgid provided by the client is taken into account"
11344 test_127a() { # bug 15521
11345 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11347 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
11348 $LCTL set_param osc.*.stats=0
11349 FSIZE=$((2048 * 1024))
11350 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
11351 cancel_lru_locks osc
11352 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
11354 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
11355 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
11356 echo "got $COUNT $NAME"
11357 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
11358 eval $NAME=$COUNT || error "Wrong proc format"
11361 read_bytes|write_bytes)
11362 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
11363 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
11364 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
11365 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
11366 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
11367 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
11368 error "sumsquare is too small: $SUMSQ"
11369 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
11370 error "sumsquare is too big: $SUMSQ"
11374 done < $DIR/${tfile}.tmp
11376 #check that we actually got some stats
11377 [ "$read_bytes" ] || error "Missing read_bytes stats"
11378 [ "$write_bytes" ] || error "Missing write_bytes stats"
11379 [ "$read_bytes" != 0 ] || error "no read done"
11380 [ "$write_bytes" != 0 ] || error "no write done"
11382 run_test 127a "verify the client stats are sane"
11384 test_127b() { # bug LU-333
11385 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11386 local name count samp unit min max sum sumsq
11388 $LCTL set_param llite.*.stats=0
11390 # perform 2 reads and writes so MAX is different from SUM.
11391 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11392 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11393 cancel_lru_locks osc
11394 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11395 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11397 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11398 while read name count samp unit min max sum sumsq; do
11399 echo "got $count $name"
11400 eval $name=$count || error "Wrong proc format"
11404 [ $count -ne 2 ] && error "count is not 2: $count"
11405 [ $min -ne $PAGE_SIZE ] &&
11406 error "min is not $PAGE_SIZE: $min"
11407 [ $max -ne $PAGE_SIZE ] &&
11408 error "max is incorrect: $max"
11409 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11410 error "sum is wrong: $sum"
11413 [ $count -ne 2 ] && error "count is not 2: $count"
11414 [ $min -ne $PAGE_SIZE ] &&
11415 error "min is not $PAGE_SIZE: $min"
11416 [ $max -ne $PAGE_SIZE ] &&
11417 error "max is incorrect: $max"
11418 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11419 error "sum is wrong: $sum"
11423 done < $TMP/$tfile.tmp
11425 #check that we actually got some stats
11426 [ "$read_bytes" ] || error "Missing read_bytes stats"
11427 [ "$write_bytes" ] || error "Missing write_bytes stats"
11428 [ "$read_bytes" != 0 ] || error "no read done"
11429 [ "$write_bytes" != 0 ] || error "no write done"
11431 rm -f $TMP/${tfile}.tmp
11433 run_test 127b "verify the llite client stats are sane"
11435 test_127c() { # LU-12394
11436 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11443 $LCTL set_param llite.*.extents_stats=1
11444 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
11446 # Use two stripes so there is enough space in default config
11447 $LFS setstripe -c 2 $DIR/$tfile
11449 # Extent stats start at 0-4K and go in power of two buckets
11450 # LL_HIST_START = 12 --> 2^12 = 4K
11451 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
11452 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
11454 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
11456 # Write and read, 2x each, second time at a non-zero offset
11457 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
11458 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
11459 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
11460 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
11464 $LCTL get_param llite.*.extents_stats
11467 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
11469 local bucket=$($LCTL get_param -n llite.*.extents_stats |
11471 reads=$(echo $bucket | awk '{print $5}')
11472 writes=$(echo $bucket | awk '{print $9}')
11473 [ "$reads" -eq $count ] ||
11474 error "$reads reads in < $bsize bucket, expect $count"
11475 [ "$writes" -eq $count ] ||
11476 error "$writes writes in < $bsize bucket, expect $count"
11479 # Test mmap write and read
11480 $LCTL set_param llite.*.extents_stats=c
11482 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
11483 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
11484 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
11486 $LCTL get_param llite.*.extents_stats
11488 count=$(((size*1024) / PAGE_SIZE))
11490 bsize=$((2 * PAGE_SIZE / 1024))K
11492 bucket=$($LCTL get_param -n llite.*.extents_stats |
11494 reads=$(echo $bucket | awk '{print $5}')
11495 writes=$(echo $bucket | awk '{print $9}')
11496 # mmap writes fault in the page first, creating an additonal read
11497 [ "$reads" -eq $((2 * count)) ] ||
11498 error "$reads reads in < $bsize bucket, expect $count"
11499 [ "$writes" -eq $count ] ||
11500 error "$writes writes in < $bsize bucket, expect $count"
11502 run_test 127c "test llite extent stats with regular & mmap i/o"
11504 test_128() { # bug 15212
11506 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
11511 result=$(grep error $TMP/$tfile.log)
11512 rm -f $DIR/$tfile $TMP/$tfile.log
11513 [ -z "$result" ] ||
11514 error "consecutive find's under interactive lfs failed"
11516 run_test 128 "interactive lfs for 2 consecutive find's"
11518 set_dir_limits () {
11523 local ldproc=/proc/fs/ldiskfs
11524 local facets=$(get_facets MDS)
11526 for facet in ${facets//,/ }; do
11527 canondev=$(ldiskfs_canon \
11528 *.$(convert_facet2label $facet).mntdev $facet)
11529 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
11530 ldproc=/sys/fs/ldiskfs
11531 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
11532 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
11536 check_mds_dmesg() {
11537 local facets=$(get_facets MDS)
11538 for facet in ${facets//,/ }; do
11539 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
11545 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11546 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
11547 skip "Need MDS version with at least 2.5.56"
11548 if [ "$mds1_FSTYPE" != ldiskfs ]; then
11549 skip_env "ldiskfs only test"
11551 remote_mds_nodsh && skip "remote MDS with nodsh"
11555 local has_warning=false
11558 mkdir -p $DIR/$tdir
11560 # block size of mds1
11561 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
11562 set_dir_limits $maxsize $maxsize
11563 local dirsize=$(stat -c%s "$DIR/$tdir")
11565 while [[ $dirsize -le $maxsize ]]; do
11566 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
11568 if ! $has_warning; then
11569 check_mds_dmesg '"is approaching"' && has_warning=true
11571 # check two errors:
11572 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
11573 # EFBIG for previous versions included in ldiskfs series
11574 if [ $rc -eq $EFBIG ] || [ $rc -eq $ENOSPC ]; then
11576 echo "return code $rc received as expected"
11578 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
11579 error_exit "create failed w/o dir size limit"
11581 check_mds_dmesg '"has reached"' ||
11582 error_exit "reached message should be output"
11584 [ $has_warning = "false" ] &&
11585 error_exit "warning message should be output"
11587 dirsize=$(stat -c%s "$DIR/$tdir")
11589 [[ $dirsize -ge $maxsize ]] && return 0
11590 error_exit "current dir size $dirsize, " \
11591 "previous limit $maxsize"
11592 elif [ $rc -ne 0 ]; then
11594 error_exit "return $rc received instead of expected " \
11595 "$EFBIG or $ENOSPC, files in dir $dirsize"
11597 nfiles=$((nfiles + 1))
11598 dirsize=$(stat -c%s "$DIR/$tdir")
11602 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
11604 run_test 129 "test directory size limit ========================"
11613 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11614 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11616 trap cleanup_130 EXIT RETURN
11618 local fm_file=$DIR/$tfile
11619 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
11620 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
11621 error "dd failed for $fm_file"
11623 # LU-1795: test filefrag/FIEMAP once, even if unsupported
11624 filefrag -ves $fm_file
11626 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11627 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11628 [ $RC != 0 ] && error "filefrag $fm_file failed"
11630 filefrag_op=$(filefrag -ve -k $fm_file |
11631 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11632 lun=$($LFS getstripe -i $fm_file)
11634 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
11637 for line in $filefrag_op
11639 frag_lun=`echo $line | cut -d: -f5`
11640 ext_len=`echo $line | cut -d: -f4`
11641 if (( $frag_lun != $lun )); then
11643 error "FIEMAP on 1-stripe file($fm_file) failed"
11646 (( tot_len += ext_len ))
11649 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
11651 error "FIEMAP on 1-stripe file($fm_file) failed;"
11657 echo "FIEMAP on single striped file succeeded"
11659 run_test 130a "FIEMAP (1-stripe file)"
11662 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11664 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11665 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11667 trap cleanup_130 EXIT RETURN
11669 local fm_file=$DIR/$tfile
11670 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
11671 error "setstripe on $fm_file"
11672 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11673 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11675 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
11676 error "dd failed on $fm_file"
11678 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11679 filefrag_op=$(filefrag -ve -k $fm_file |
11680 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11682 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11683 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11688 for line in $filefrag_op
11690 frag_lun=$(echo $line | cut -d: -f5 |
11691 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11692 ext_len=$(echo $line | cut -d: -f4)
11693 if (( $frag_lun != $last_lun )); then
11694 if (( tot_len != 1024 )); then
11696 error "FIEMAP on $fm_file failed; returned " \
11697 "len $tot_len for OST $last_lun instead of 1024"
11700 (( num_luns += 1 ))
11704 (( tot_len += ext_len ))
11707 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
11709 error "FIEMAP on $fm_file failed; returned wrong number of " \
11710 "luns or wrong len for OST $last_lun"
11716 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
11718 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
11721 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11723 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11724 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11726 trap cleanup_130 EXIT RETURN
11728 local fm_file=$DIR/$tfile
11729 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
11730 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11731 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11733 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
11734 error "dd failed on $fm_file"
11736 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11737 filefrag_op=$(filefrag -ve -k $fm_file |
11738 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11740 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11741 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11746 for line in $filefrag_op
11748 frag_lun=$(echo $line | cut -d: -f5 |
11749 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11750 ext_len=$(echo $line | cut -d: -f4)
11751 if (( $frag_lun != $last_lun )); then
11752 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
11753 if (( logical != 512 )); then
11755 error "FIEMAP on $fm_file failed; returned " \
11756 "logical start for lun $logical instead of 512"
11759 if (( tot_len != 512 )); then
11761 error "FIEMAP on $fm_file failed; returned " \
11762 "len $tot_len for OST $last_lun instead of 1024"
11765 (( num_luns += 1 ))
11769 (( tot_len += ext_len ))
11772 if (( num_luns != 2 || tot_len != 512 )); then
11774 error "FIEMAP on $fm_file failed; returned wrong number of " \
11775 "luns or wrong len for OST $last_lun"
11781 echo "FIEMAP on 2-stripe file with hole succeeded"
11783 run_test 130c "FIEMAP (2-stripe file with hole)"
11786 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
11788 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11789 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11791 trap cleanup_130 EXIT RETURN
11793 local fm_file=$DIR/$tfile
11794 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
11795 error "setstripe on $fm_file"
11796 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11797 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11799 local actual_stripe_count=$($LFS getstripe -c $fm_file)
11800 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
11801 error "dd failed on $fm_file"
11803 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11804 filefrag_op=$(filefrag -ve -k $fm_file |
11805 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11807 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11808 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11813 for line in $filefrag_op
11815 frag_lun=$(echo $line | cut -d: -f5 |
11816 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11817 ext_len=$(echo $line | cut -d: -f4)
11818 if (( $frag_lun != $last_lun )); then
11819 if (( tot_len != 1024 )); then
11821 error "FIEMAP on $fm_file failed; returned " \
11822 "len $tot_len for OST $last_lun instead of 1024"
11825 (( num_luns += 1 ))
11829 (( tot_len += ext_len ))
11832 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
11834 error "FIEMAP on $fm_file failed; returned wrong number of " \
11835 "luns or wrong len for OST $last_lun"
11841 echo "FIEMAP on N-stripe file succeeded"
11843 run_test 130d "FIEMAP (N-stripe file)"
11846 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11848 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11849 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11851 trap cleanup_130 EXIT RETURN
11853 local fm_file=$DIR/$tfile
11854 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
11855 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11856 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11859 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
11860 for ((i = 0; i < $NUM_BLKS; i++))
11862 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
11865 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11866 filefrag_op=$(filefrag -ve -k $fm_file |
11867 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11869 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11870 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11875 for line in $filefrag_op
11877 frag_lun=$(echo $line | cut -d: -f5 |
11878 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11879 ext_len=$(echo $line | cut -d: -f4)
11880 if (( $frag_lun != $last_lun )); then
11881 if (( tot_len != $EXPECTED_LEN )); then
11883 error "FIEMAP on $fm_file failed; returned " \
11884 "len $tot_len for OST $last_lun instead " \
11888 (( num_luns += 1 ))
11892 (( tot_len += ext_len ))
11895 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
11897 error "FIEMAP on $fm_file failed; returned wrong number " \
11898 "of luns or wrong len for OST $last_lun"
11904 echo "FIEMAP with continuation calls succeeded"
11906 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
11909 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11910 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11912 local fm_file=$DIR/$tfile
11913 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
11914 error "multiop create with lov_delay_create on $fm_file"
11916 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11917 filefrag_extents=$(filefrag -vek $fm_file |
11918 awk '/extents? found/ { print $2 }')
11919 if [[ "$filefrag_extents" != "0" ]]; then
11920 error "FIEMAP on $fm_file failed; " \
11921 "returned $filefrag_extents expected 0"
11926 run_test 130f "FIEMAP (unstriped file)"
11928 # Test for writev/readv
11930 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
11931 error "writev test failed"
11932 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
11933 error "readv failed"
11936 run_test 131a "test iov's crossing stripe boundary for writev/readv"
11939 local fsize=$((524288 + 1048576 + 1572864))
11940 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
11941 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11942 error "append writev test failed"
11944 ((fsize += 1572864 + 1048576))
11945 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
11946 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11947 error "append writev test failed"
11950 run_test 131b "test append writev"
11953 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
11956 run_test 131c "test read/write on file w/o objects"
11959 rwv -f $DIR/$tfile -w -n 1 1572864
11960 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
11961 if [ "$NOB" != 1572864 ]; then
11962 error "Short read filed: read $NOB bytes instead of 1572864"
11966 run_test 131d "test short read"
11969 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
11970 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
11971 error "read hitting hole failed"
11974 run_test 131e "test read hitting hole"
11983 mds*) res=$(do_facet $facet \
11984 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
11986 ost*) res=$(do_facet $facet \
11987 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
11989 *) error "Wrong facet '$facet'" ;;
11991 [ "$res" ] || error "The counter for $op on $facet was not incremented"
11992 # if the argument $3 is zero, it means any stat increment is ok.
11993 if [[ $want -gt 0 ]]; then
11994 local count=$(echo $res | awk '{ print $2 }')
11995 [[ $count -ne $want ]] &&
11996 error "The $op counter on $facet is $count, not $want"
12001 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12002 remote_ost_nodsh && skip "remote OST with nodsh"
12003 remote_mds_nodsh && skip "remote MDS with nodsh"
12004 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12005 skip_env "MDS doesn't support rename stats"
12007 local testdir=$DIR/${tdir}/stats_testdir
12009 mkdir -p $DIR/${tdir}
12012 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12013 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12015 # verify mdt stats first.
12016 mkdir ${testdir} || error "mkdir failed"
12017 check_stats $SINGLEMDS "mkdir" 1
12018 touch ${testdir}/${tfile} || error "touch failed"
12019 check_stats $SINGLEMDS "open" 1
12020 check_stats $SINGLEMDS "close" 1
12021 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
12022 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
12023 check_stats $SINGLEMDS "mknod" 2
12025 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
12026 check_stats $SINGLEMDS "unlink" 1
12027 rm -f ${testdir}/${tfile} || error "file remove failed"
12028 check_stats $SINGLEMDS "unlink" 2
12030 # remove working dir and check mdt stats again.
12031 rmdir ${testdir} || error "rmdir failed"
12032 check_stats $SINGLEMDS "rmdir" 1
12034 local testdir1=$DIR/${tdir}/stats_testdir1
12035 mkdir -p ${testdir}
12036 mkdir -p ${testdir1}
12037 touch ${testdir1}/test1
12038 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
12039 check_stats $SINGLEMDS "crossdir_rename" 1
12041 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
12042 check_stats $SINGLEMDS "samedir_rename" 1
12044 rm -rf $DIR/${tdir}
12046 run_test 133a "Verifying MDT stats ========================================"
12051 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12052 remote_ost_nodsh && skip "remote OST with nodsh"
12053 remote_mds_nodsh && skip "remote MDS with nodsh"
12055 local testdir=$DIR/${tdir}/stats_testdir
12057 mkdir -p ${testdir} || error "mkdir failed"
12058 touch ${testdir}/${tfile} || error "touch failed"
12059 cancel_lru_locks mdc
12062 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12063 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12065 # extra mdt stats verification.
12066 chmod 444 ${testdir}/${tfile} || error "chmod failed"
12067 check_stats $SINGLEMDS "setattr" 1
12068 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12069 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
12071 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
12072 check_stats $SINGLEMDS "getattr" 1
12074 rm -rf $DIR/${tdir}
12076 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
12077 # so the check below is not reliable
12078 [ $MDSCOUNT -eq 1 ] || return 0
12080 # Sleep to avoid a cached response.
12081 #define OBD_STATFS_CACHE_SECONDS 1
12083 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12084 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12085 $LFS df || error "lfs failed"
12086 check_stats $SINGLEMDS "statfs" 1
12088 # check aggregated statfs (LU-10018)
12089 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
12091 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
12094 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12095 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12097 check_stats $SINGLEMDS "statfs" 1
12099 # We want to check that the client didn't send OST_STATFS to
12100 # ost1 but the MDT also uses OST_STATFS for precreate. So some
12101 # extra care is needed here.
12102 if remote_mds; then
12103 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
12104 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
12106 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
12107 [ "$res" ] && error "OST got STATFS"
12112 run_test 133b "Verifying extra MDT stats =================================="
12115 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12116 remote_ost_nodsh && skip "remote OST with nodsh"
12117 remote_mds_nodsh && skip "remote MDS with nodsh"
12119 local testdir=$DIR/$tdir/stats_testdir
12121 test_mkdir -p $testdir
12123 # verify obdfilter stats.
12124 $LFS setstripe -c 1 -i 0 $testdir/$tfile
12126 cancel_lru_locks osc
12127 wait_delete_completed
12130 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12131 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12133 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
12136 cancel_lru_locks osc
12137 check_stats ost1 "write" 1
12139 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
12140 check_stats ost1 "read" 1
12142 > $testdir/$tfile || error "truncate failed"
12143 check_stats ost1 "punch" 1
12145 rm -f $testdir/$tfile || error "file remove failed"
12146 wait_delete_completed
12147 check_stats ost1 "destroy" 1
12151 run_test 133c "Verifying OST stats ========================================"
12158 while [ $value -ge 2 ]; do
12163 if [ $orig -gt $order ]; then
12171 local size=('K' 'M' 'G' 'T');
12173 local size_string=$value
12175 while [ $value -ge 1024 ]; do
12176 if [ $i -gt 3 ]; then
12177 #T is the biggest unit we get here, if that is bigger,
12179 size_string=${value}T
12182 value=$((value >> 10))
12183 if [ $value -lt 1024 ]; then
12184 size_string=${value}${size[$i]}
12193 get_rename_size() {
12195 local context=${2:-.}
12196 local sample=$(do_facet $SINGLEMDS $LCTL \
12197 get_param mdt.$FSNAME-MDT0000.rename_stats |
12198 grep -A1 $context |
12199 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
12204 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12205 remote_ost_nodsh && skip "remote OST with nodsh"
12206 remote_mds_nodsh && skip "remote MDS with nodsh"
12207 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12208 skip_env "MDS doesn't support rename stats"
12210 local testdir1=$DIR/${tdir}/stats_testdir1
12211 local testdir2=$DIR/${tdir}/stats_testdir2
12212 mkdir -p $DIR/${tdir}
12214 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12216 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
12217 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
12219 createmany -o $testdir1/test 512 || error "createmany failed"
12221 # check samedir rename size
12222 mv ${testdir1}/test0 ${testdir1}/test_0
12224 local testdir1_size=$(ls -l $DIR/${tdir} |
12225 awk '/stats_testdir1/ {print $5}')
12226 local testdir2_size=$(ls -l $DIR/${tdir} |
12227 awk '/stats_testdir2/ {print $5}')
12229 testdir1_size=$(order_2 $testdir1_size)
12230 testdir2_size=$(order_2 $testdir2_size)
12232 testdir1_size=$(size_in_KMGT $testdir1_size)
12233 testdir2_size=$(size_in_KMGT $testdir2_size)
12235 echo "source rename dir size: ${testdir1_size}"
12236 echo "target rename dir size: ${testdir2_size}"
12238 local cmd="do_facet $SINGLEMDS $LCTL "
12239 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
12241 eval $cmd || error "$cmd failed"
12242 local samedir=$($cmd | grep 'same_dir')
12243 local same_sample=$(get_rename_size $testdir1_size)
12244 [ -z "$samedir" ] && error "samedir_rename_size count error"
12245 [[ $same_sample -eq 1 ]] ||
12246 error "samedir_rename_size error $same_sample"
12247 echo "Check same dir rename stats success"
12249 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12251 # check crossdir rename size
12252 mv ${testdir1}/test_0 ${testdir2}/test_0
12254 testdir1_size=$(ls -l $DIR/${tdir} |
12255 awk '/stats_testdir1/ {print $5}')
12256 testdir2_size=$(ls -l $DIR/${tdir} |
12257 awk '/stats_testdir2/ {print $5}')
12259 testdir1_size=$(order_2 $testdir1_size)
12260 testdir2_size=$(order_2 $testdir2_size)
12262 testdir1_size=$(size_in_KMGT $testdir1_size)
12263 testdir2_size=$(size_in_KMGT $testdir2_size)
12265 echo "source rename dir size: ${testdir1_size}"
12266 echo "target rename dir size: ${testdir2_size}"
12268 eval $cmd || error "$cmd failed"
12269 local crossdir=$($cmd | grep 'crossdir')
12270 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
12271 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
12272 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
12273 [[ $src_sample -eq 1 ]] ||
12274 error "crossdir_rename_size error $src_sample"
12275 [[ $tgt_sample -eq 1 ]] ||
12276 error "crossdir_rename_size error $tgt_sample"
12277 echo "Check cross dir rename stats success"
12278 rm -rf $DIR/${tdir}
12280 run_test 133d "Verifying rename_stats ========================================"
12283 remote_mds_nodsh && skip "remote MDS with nodsh"
12284 remote_ost_nodsh && skip "remote OST with nodsh"
12285 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12287 local testdir=$DIR/${tdir}/stats_testdir
12288 local ctr f0 f1 bs=32768 count=42 sum
12290 mkdir -p ${testdir} || error "mkdir failed"
12292 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
12294 for ctr in {write,read}_bytes; do
12296 cancel_lru_locks osc
12298 do_facet ost1 $LCTL set_param -n \
12299 "obdfilter.*.exports.clear=clear"
12301 if [ $ctr = write_bytes ]; then
12303 f1=${testdir}/${tfile}
12305 f0=${testdir}/${tfile}
12309 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
12312 cancel_lru_locks osc
12314 sum=$(do_facet ost1 $LCTL get_param \
12315 "obdfilter.*.exports.*.stats" |
12316 awk -v ctr=$ctr 'BEGIN { sum = 0 }
12317 $1 == ctr { sum += $7 }
12318 END { printf("%0.0f", sum) }')
12320 if ((sum != bs * count)); then
12321 error "Bad $ctr sum, expected $((bs * count)), got $sum"
12325 rm -rf $DIR/${tdir}
12327 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
12329 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
12331 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
12332 # not honor the -ignore_readdir_race option correctly. So we call
12333 # error_ignore() rather than error() in these cases. See LU-11152.
12335 if (find --version; do_facet mds1 find --version) |
12336 grep -q '\b4\.5\.1[1-4]\b'; then
12337 error_ignore LU-11152 "$@"
12344 # First without trusting modes.
12345 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
12346 echo "proc_dirs='$proc_dirs'"
12347 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
12348 find $proc_dirs -exec cat '{}' \; &> /dev/null
12350 # Second verifying readability.
12351 $LCTL get_param -R '*' &> /dev/null
12353 # Verifing writability with badarea_io.
12355 -ignore_readdir_race \
12357 -not -name force_lbug \
12358 -not -name changelog_mask \
12359 -exec badarea_io '{}' \; ||
12360 error_133 "find $proc_dirs failed"
12362 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
12365 remote_mds_nodsh && skip "remote MDS with nodsh"
12366 remote_ost_nodsh && skip "remote OST with nodsh"
12368 # eventually, this can also be replaced with "lctl get_param -R",
12369 # but not until that option is always available on the server
12371 for facet in mds1 ost1; do
12372 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
12373 skip_noexit "Too old lustre on $facet"
12374 local facet_proc_dirs=$(do_facet $facet \
12375 \\\ls -d $proc_regexp 2>/dev/null)
12376 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12377 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12378 do_facet $facet find $facet_proc_dirs \
12379 ! -name req_history \
12380 -exec cat '{}' \\\; &> /dev/null
12382 do_facet $facet find $facet_proc_dirs \
12383 ! -name req_history \
12385 -exec cat '{}' \\\; &> /dev/null ||
12386 error "proc file read failed"
12388 do_facet $facet find $facet_proc_dirs \
12389 -ignore_readdir_race \
12391 -not -name force_lbug \
12392 -not -name changelog_mask \
12393 -exec badarea_io '{}' \\\; ||
12394 error_133 "$facet find $facet_proc_dirs failed"
12397 # remount the FS in case writes/reads /proc break the FS
12398 cleanup || error "failed to unmount"
12399 setup || error "failed to setup"
12402 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12405 remote_mds_nodsh && skip "remote MDS with nodsh"
12406 remote_ost_nodsh && skip "remote OST with nodsh"
12407 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12408 skip "Need MDS version at least 2.9.54"
12412 for facet in client mds1 ost1; do
12413 local facet_proc_dirs=$(do_facet $facet \
12414 \\\ls -d $proc_regexp 2> /dev/null)
12415 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12416 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12417 # Get the list of files that are missing the terminating newline
12418 local missing=($(do_facet $facet \
12419 find ${facet_proc_dirs} -type f \| \
12420 while read F\; do \
12421 awk -v FS='\v' -v RS='\v\v' \
12422 "'END { if(NR>0 && \
12423 \\\$NF !~ /.*\\\n\$/) \
12424 print FILENAME}'" \
12427 [ ${#missing[*]} -eq 0 ] ||
12428 error "files do not end with newline: ${missing[*]}"
12431 run_test 133h "Proc files should end with newlines"
12434 remote_mds_nodsh && skip "remote MDS with nodsh"
12435 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12436 skip "Need MDS version at least 2.7.54"
12438 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12439 cancel_lru_locks mdc
12441 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12442 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12443 [ $unused -eq 0 ] || error "$unused locks are not cleared"
12446 createmany -o $DIR/$tdir/f $nr ||
12447 error "failed to create $nr files in $DIR/$tdir"
12448 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12450 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
12451 do_facet mds1 $LCTL set_param fail_loc=0x327
12452 do_facet mds1 $LCTL set_param fail_val=500
12455 echo "sleep 10 seconds ..."
12457 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
12459 do_facet mds1 $LCTL set_param fail_loc=0
12460 do_facet mds1 $LCTL set_param fail_val=0
12461 [ $lck_cnt -lt $unused ] ||
12462 error "No locks reclaimed, before:$unused, after:$lck_cnt"
12465 unlinkmany $DIR/$tdir/f $nr
12467 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
12470 remote_mds_nodsh && skip "remote MDS with nodsh"
12471 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12472 skip "Need MDS version at least 2.7.54"
12474 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12475 cancel_lru_locks mdc
12477 local low_wm=$(do_facet mds1 $LCTL get_param -n \
12478 ldlm.lock_reclaim_threshold_mb)
12479 # disable reclaim temporarily
12480 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
12482 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
12483 do_facet mds1 $LCTL set_param fail_loc=0x328
12484 do_facet mds1 $LCTL set_param fail_val=500
12486 $LCTL set_param debug=+trace
12489 createmany -o $DIR/$tdir/f $nr &
12490 local create_pid=$!
12492 echo "Sleep $TIMEOUT seconds ..."
12494 if ! ps -p $create_pid > /dev/null 2>&1; then
12495 do_facet mds1 $LCTL set_param fail_loc=0
12496 do_facet mds1 $LCTL set_param fail_val=0
12497 do_facet mds1 $LCTL set_param \
12498 ldlm.lock_reclaim_threshold_mb=${low_wm}m
12499 error "createmany finished incorrectly!"
12501 do_facet mds1 $LCTL set_param fail_loc=0
12502 do_facet mds1 $LCTL set_param fail_val=0
12503 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
12504 wait $create_pid || return 1
12506 unlinkmany $DIR/$tdir/f $nr
12508 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
12510 test_140() { #bug-17379
12511 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12513 test_mkdir $DIR/$tdir
12514 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
12515 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
12517 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
12518 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
12520 while i=$((i + 1)); do
12522 cd $i || error "Changing to $i"
12523 ln -s ../stat stat || error "Creating stat symlink"
12524 # Read the symlink until ELOOP present,
12525 # not LBUGing the system is considered success,
12526 # we didn't overrun the stack.
12527 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
12528 if [ $ret -ne 0 ]; then
12529 if [ $ret -eq 40 ]; then
12532 error "Open stat symlink"
12538 echo "The symlink depth = $i"
12539 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
12540 error "Invalid symlink depth"
12542 # Test recursive symlink
12543 ln -s symlink_self symlink_self
12544 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
12545 echo "open symlink_self returns $ret"
12546 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
12548 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
12551 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12553 local TF="$TMP/$tfile"
12555 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12557 cancel_lru_locks $OSC
12558 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
12559 remount_client $MOUNT
12561 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
12564 $TRUNCATE $DIR/$tfile 6000
12565 cancel_lru_locks $OSC
12566 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
12569 echo "12345" >>$DIR/$tfile
12570 cancel_lru_locks $OSC
12571 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
12574 echo "12345" >>$DIR/$tfile
12575 cancel_lru_locks $OSC
12576 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
12581 run_test 150 "truncate/append tests"
12583 #LU-2902 roc_hit was not able to read all values from lproc
12584 function roc_hit_init() {
12585 local list=$(comma_list $(osts_nodes))
12586 local dir=$DIR/$tdir-check
12587 local file=$dir/$tfile
12593 #use setstripe to do a write to every ost
12594 for i in $(seq 0 $((OSTCOUNT-1))); do
12595 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
12596 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
12597 idx=$(printf %04x $i)
12598 BEFORE=$(get_osd_param $list *OST*$idx stats |
12599 awk '$1 == "cache_access" {sum += $7}
12600 END { printf("%0.0f", sum) }')
12602 cancel_lru_locks osc
12603 cat $file >/dev/null
12605 AFTER=$(get_osd_param $list *OST*$idx stats |
12606 awk '$1 == "cache_access" {sum += $7}
12607 END { printf("%0.0f", sum) }')
12609 echo BEFORE:$BEFORE AFTER:$AFTER
12610 if ! let "AFTER - BEFORE == 4"; then
12612 error "roc_hit is not safe to use"
12620 function roc_hit() {
12621 local list=$(comma_list $(osts_nodes))
12622 echo $(get_osd_param $list '' stats |
12623 awk '$1 == "cache_hit" {sum += $7}
12624 END { printf("%0.0f", sum) }')
12627 function set_cache() {
12630 if [ "$2" == "off" ]; then
12633 local list=$(comma_list $(osts_nodes))
12634 set_osd_param $list '' $1_cache_enable $on
12636 cancel_lru_locks osc
12640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12641 remote_ost_nodsh && skip "remote OST with nodsh"
12644 local list=$(comma_list $(osts_nodes))
12646 # check whether obdfilter is cache capable at all
12647 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
12648 skip "not cache-capable obdfilter"
12651 # check cache is enabled on all obdfilters
12652 if get_osd_param $list '' read_cache_enable | grep 0; then
12653 skip "oss cache is disabled"
12656 set_osd_param $list '' writethrough_cache_enable 1
12658 # check write cache is enabled on all obdfilters
12659 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
12660 skip "oss write cache is NOT enabled"
12665 #define OBD_FAIL_OBD_NO_LRU 0x609
12666 do_nodes $list $LCTL set_param fail_loc=0x609
12668 # pages should be in the case right after write
12669 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
12672 local BEFORE=$(roc_hit)
12673 cancel_lru_locks osc
12674 cat $DIR/$tfile >/dev/null
12675 local AFTER=$(roc_hit)
12677 do_nodes $list $LCTL set_param fail_loc=0
12679 if ! let "AFTER - BEFORE == CPAGES"; then
12680 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12683 # the following read invalidates the cache
12684 cancel_lru_locks osc
12685 set_osd_param $list '' read_cache_enable 0
12686 cat $DIR/$tfile >/dev/null
12688 # now data shouldn't be found in the cache
12690 cancel_lru_locks osc
12691 cat $DIR/$tfile >/dev/null
12693 if let "AFTER - BEFORE != 0"; then
12694 error "IN CACHE: before: $BEFORE, after: $AFTER"
12697 set_osd_param $list '' read_cache_enable 1
12700 run_test 151 "test cache on oss and controls ==============================="
12703 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12705 local TF="$TMP/$tfile"
12707 # simulate ENOMEM during write
12708 #define OBD_FAIL_OST_NOMEM 0x226
12709 lctl set_param fail_loc=0x80000226
12710 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12712 sync || error "sync failed"
12713 lctl set_param fail_loc=0
12715 # discard client's cache
12716 cancel_lru_locks osc
12718 # simulate ENOMEM during read
12719 lctl set_param fail_loc=0x80000226
12720 cmp $TF $DIR/$tfile || error "cmp failed"
12721 lctl set_param fail_loc=0
12725 run_test 152 "test read/write with enomem ============================"
12728 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
12730 run_test 153 "test if fdatasync does not crash ======================="
12732 dot_lustre_fid_permission_check() {
12734 local ffid=$MOUNT/.lustre/fid/$fid
12737 echo "stat fid $fid"
12738 stat $ffid > /dev/null || error "stat $ffid failed."
12739 echo "touch fid $fid"
12740 touch $ffid || error "touch $ffid failed."
12741 echo "write to fid $fid"
12742 cat /etc/hosts > $ffid || error "write $ffid failed."
12743 echo "read fid $fid"
12744 diff /etc/hosts $ffid || error "read $ffid failed."
12745 echo "append write to fid $fid"
12746 cat /etc/hosts >> $ffid || error "append write $ffid failed."
12747 echo "rename fid $fid"
12748 mv $ffid $test_dir/$tfile.1 &&
12749 error "rename $ffid to $tfile.1 should fail."
12750 touch $test_dir/$tfile.1
12751 mv $test_dir/$tfile.1 $ffid &&
12752 error "rename $tfile.1 to $ffid should fail."
12753 rm -f $test_dir/$tfile.1
12754 echo "truncate fid $fid"
12755 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
12756 echo "link fid $fid"
12757 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
12758 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
12759 echo "setfacl fid $fid"
12760 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
12761 echo "getfacl fid $fid"
12762 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
12764 echo "unlink fid $fid"
12765 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
12766 echo "mknod fid $fid"
12767 mknod $ffid c 1 3 && error "mknod $ffid should fail."
12769 fid=[0xf00000400:0x1:0x0]
12770 ffid=$MOUNT/.lustre/fid/$fid
12772 echo "stat non-exist fid $fid"
12773 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
12774 echo "write to non-exist fid $fid"
12775 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
12776 echo "link new fid $fid"
12777 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
12779 mkdir -p $test_dir/$tdir
12780 touch $test_dir/$tdir/$tfile
12781 fid=$($LFS path2fid $test_dir/$tdir)
12784 error "error: could not get fid for $test_dir/$dir/$tfile."
12786 ffid=$MOUNT/.lustre/fid/$fid
12789 ls $ffid > /dev/null || error "ls $ffid failed."
12790 echo "touch $fid/$tfile.1"
12791 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
12793 echo "touch $MOUNT/.lustre/fid/$tfile"
12794 touch $MOUNT/.lustre/fid/$tfile && \
12795 error "touch $MOUNT/.lustre/fid/$tfile should fail."
12797 echo "setxattr to $MOUNT/.lustre/fid"
12798 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
12800 echo "listxattr for $MOUNT/.lustre/fid"
12801 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
12803 echo "delxattr from $MOUNT/.lustre/fid"
12804 setfattr -x trusted.name1 $MOUNT/.lustre/fid
12806 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
12807 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
12808 error "touch invalid fid should fail."
12810 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
12811 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
12812 error "touch non-normal fid should fail."
12814 echo "rename $tdir to $MOUNT/.lustre/fid"
12815 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
12816 error "rename to $MOUNT/.lustre/fid should fail."
12818 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
12820 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
12821 local new_obf_mode=777
12823 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
12824 chmod $new_obf_mode $DIR/.lustre/fid ||
12825 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
12827 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
12828 [ $obf_mode -eq $new_obf_mode ] ||
12829 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
12831 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
12832 chmod $old_obf_mode $DIR/.lustre/fid ||
12833 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
12836 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
12837 fid=$($LFS path2fid $test_dir/$tfile-2)
12839 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
12841 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
12842 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
12843 error "create lov data thru .lustre failed"
12845 echo "cp /etc/passwd $test_dir/$tfile-2"
12846 cp /etc/passwd $test_dir/$tfile-2 ||
12847 error "copy to $test_dir/$tfile-2 failed."
12848 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
12849 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
12850 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
12852 rm -rf $test_dir/tfile.lnk
12853 rm -rf $test_dir/$tfile-2
12857 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12858 skip "Need MDS version at least 2.4.1"
12860 local tf=$DIR/$tfile
12863 local fid=$($LFS path2fid $tf)
12864 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
12866 # check that we get the same pathname back
12867 local found=$($LFS fid2path $MOUNT "$fid")
12868 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
12869 [ "$found" == "$tf" ] ||
12870 error "fid2path($fid=path2fid($tf)) = $found != $tf"
12872 run_test 154A "lfs path2fid and fid2path basic checks"
12875 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12876 skip "Need MDS version at least 2.4.1"
12878 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
12879 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
12880 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
12881 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
12883 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
12884 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
12886 # check that we get the same pathname
12887 echo "PFID: $PFID, name: $name"
12888 local FOUND=$($LFS fid2path $MOUNT "$PFID")
12889 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
12890 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
12891 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
12893 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
12895 run_test 154B "verify the ll_decode_linkea tool"
12898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12899 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12900 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12901 skip "Need MDS version at least 2.2.51"
12902 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12904 cp /etc/hosts $DIR/$tfile
12906 fid=$($LFS path2fid $DIR/$tfile)
12908 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
12910 dot_lustre_fid_permission_check "$fid" $DIR ||
12911 error "dot lustre permission check $fid failed"
12913 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
12915 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
12917 touch $MOUNT/.lustre/file &&
12918 error "creation is not allowed under .lustre"
12920 mkdir $MOUNT/.lustre/dir &&
12921 error "mkdir is not allowed under .lustre"
12925 run_test 154a "Open-by-FID"
12928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12929 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12930 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12931 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12932 skip "Need MDS version at least 2.2.51"
12934 local remote_dir=$DIR/$tdir/remote_dir
12938 mkdir -p $DIR/$tdir
12939 $LFS mkdir -i $MDTIDX $remote_dir ||
12940 error "create remote directory failed"
12942 cp /etc/hosts $remote_dir/$tfile
12944 fid=$($LFS path2fid $remote_dir/$tfile)
12946 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
12948 dot_lustre_fid_permission_check "$fid" $remote_dir ||
12949 error "dot lustre permission check $fid failed"
12952 run_test 154b "Open-by-FID for remote directory"
12955 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12956 skip "Need MDS version at least 2.4.1"
12958 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
12959 local FID1=$($LFS path2fid $DIR/$tfile.1)
12960 local FID2=$($LFS path2fid $DIR/$tfile.2)
12961 local FID3=$($LFS path2fid $DIR/$tfile.3)
12964 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
12965 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
12966 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
12968 [ "$FID" = "${!want}" ] ||
12969 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
12973 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
12975 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
12976 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
12980 run_test 154c "lfs path2fid and fid2path multiple arguments"
12983 remote_mds_nodsh && skip "remote MDS with nodsh"
12984 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
12985 skip "Need MDS version at least 2.5.53"
12987 if remote_mds; then
12988 nid=$($LCTL list_nids | sed "s/\./\\\./g")
12992 local proc_ofile="mdt.*.exports.'$nid'.open_files"
12999 local fid=$($LFS path2fid $DIR/$tfile)
13002 cmd="exec $fd<$DIR/$tfile"
13004 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
13005 echo "$fid_list" | grep "$fid"
13008 cmd="exec $fd>/dev/null"
13010 if [ $rc -ne 0 ]; then
13011 error "FID $fid not found in open files list $fid_list"
13014 run_test 154d "Verify open file fid"
13018 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
13019 skip "Need MDS version at least 2.6.50"
13021 if ls -a $MOUNT | grep -q '^\.lustre$'; then
13022 error ".lustre returned by readdir"
13025 run_test 154e ".lustre is not returned by readdir"
13028 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13030 # create parent directory on a single MDT to avoid cross-MDT hardlinks
13031 test_mkdir -p -c1 $DIR/$tdir/d
13032 # test dirs inherit from its stripe
13033 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
13034 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
13035 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
13036 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
13039 # get fid of parents
13040 local FID0=$($LFS path2fid $DIR/$tdir/d)
13041 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
13042 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
13043 local FID3=$($LFS path2fid $DIR)
13045 # check that path2fid --parents returns expected <parent_fid>/name
13046 # 1) test for a directory (single parent)
13047 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
13048 [ "$parent" == "$FID0/foo1" ] ||
13049 error "expected parent: $FID0/foo1, got: $parent"
13051 # 2) test for a file with nlink > 1 (multiple parents)
13052 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
13053 echo "$parent" | grep -F "$FID1/$tfile" ||
13054 error "$FID1/$tfile not returned in parent list"
13055 echo "$parent" | grep -F "$FID2/link" ||
13056 error "$FID2/link not returned in parent list"
13058 # 3) get parent by fid
13059 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
13060 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13061 echo "$parent" | grep -F "$FID1/$tfile" ||
13062 error "$FID1/$tfile not returned in parent list (by fid)"
13063 echo "$parent" | grep -F "$FID2/link" ||
13064 error "$FID2/link not returned in parent list (by fid)"
13066 # 4) test for entry in root directory
13067 parent=$($LFS path2fid --parents $DIR/f)
13068 echo "$parent" | grep -F "$FID3/f" ||
13069 error "$FID3/f not returned in parent list"
13071 # 5) test it on root directory
13072 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
13073 error "$MOUNT should not have parents"
13075 # enable xattr caching and check that linkea is correctly updated
13076 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
13077 save_lustre_params client "llite.*.xattr_cache" > $save
13078 lctl set_param llite.*.xattr_cache 1
13080 # 6.1) linkea update on rename
13081 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
13083 # get parents by fid
13084 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13085 # foo1 should no longer be returned in parent list
13086 echo "$parent" | grep -F "$FID1" &&
13087 error "$FID1 should no longer be in parent list"
13088 # the new path should appear
13089 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
13090 error "$FID2/$tfile.moved is not in parent list"
13092 # 6.2) linkea update on unlink
13093 rm -f $DIR/$tdir/d/foo2/link
13094 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13095 # foo2/link should no longer be returned in parent list
13096 echo "$parent" | grep -F "$FID2/link" &&
13097 error "$FID2/link should no longer be in parent list"
13101 restore_lustre_params < $save
13104 run_test 154f "get parent fids by reading link ea"
13108 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13109 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
13110 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
13111 skip "Need MDS version at least 2.6.92"
13113 mkdir -p $DIR/$tdir
13114 llapi_fid_test -d $DIR/$tdir
13116 run_test 154g "various llapi FID tests"
13118 test_155_small_load() {
13119 local temp=$TMP/$tfile
13120 local file=$DIR/$tfile
13122 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
13123 error "dd of=$temp bs=6096 count=1 failed"
13125 cancel_lru_locks $OSC
13126 cmp $temp $file || error "$temp $file differ"
13128 $TRUNCATE $temp 6000
13129 $TRUNCATE $file 6000
13130 cmp $temp $file || error "$temp $file differ (truncate1)"
13132 echo "12345" >>$temp
13133 echo "12345" >>$file
13134 cmp $temp $file || error "$temp $file differ (append1)"
13136 echo "12345" >>$temp
13137 echo "12345" >>$file
13138 cmp $temp $file || error "$temp $file differ (append2)"
13144 test_155_big_load() {
13145 remote_ost_nodsh && skip "remote OST with nodsh"
13147 local temp=$TMP/$tfile
13148 local file=$DIR/$tfile
13151 local cache_size=$(do_facet ost$((MAXI+1)) \
13152 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
13153 local large_file_size=$((cache_size * 2))
13155 echo "OSS cache size: $cache_size KB"
13156 echo "Large file size: $large_file_size KB"
13158 [ $MAXV -le $large_file_size ] &&
13159 skip_env "max available OST size needs > $large_file_size KB"
13161 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
13163 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
13164 error "dd of=$temp bs=$large_file_size count=1k failed"
13167 cancel_lru_locks osc
13168 cmp $temp $file || error "$temp $file differ"
13174 save_writethrough() {
13175 local facets=$(get_facets OST)
13177 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
13181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13183 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13185 save_writethrough $p
13188 set_cache writethrough on
13189 test_155_small_load
13190 restore_lustre_params < $p
13193 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
13196 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13198 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13200 save_writethrough $p
13203 set_cache writethrough off
13204 test_155_small_load
13205 restore_lustre_params < $p
13208 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
13211 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13213 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13215 save_writethrough $p
13218 set_cache writethrough on
13219 test_155_small_load
13220 restore_lustre_params < $p
13223 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
13226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13228 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13230 save_writethrough $p
13233 set_cache writethrough off
13234 test_155_small_load
13235 restore_lustre_params < $p
13238 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
13241 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13243 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13245 save_writethrough $p
13248 set_cache writethrough on
13250 restore_lustre_params < $p
13253 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
13256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13258 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13260 save_writethrough $p
13263 set_cache writethrough off
13265 restore_lustre_params < $p
13268 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
13271 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13273 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13275 save_writethrough $p
13278 set_cache writethrough on
13280 restore_lustre_params < $p
13283 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
13286 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13288 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13290 save_writethrough $p
13293 set_cache writethrough off
13295 restore_lustre_params < $p
13298 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
13301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13302 remote_ost_nodsh && skip "remote OST with nodsh"
13303 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
13304 skip "stats not implemented on old servers"
13305 [ "$ost1_FSTYPE" = "zfs" ] &&
13306 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
13311 local file="$DIR/$tfile"
13312 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13314 save_writethrough $p
13317 log "Turn on read and write cache"
13319 set_cache writethrough on
13321 log "Write data and read it back."
13322 log "Read should be satisfied from the cache."
13323 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13325 cancel_lru_locks osc
13326 cat $file >/dev/null
13328 if ! let "AFTER - BEFORE == CPAGES"; then
13329 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13331 log "cache hits:: before: $BEFORE, after: $AFTER"
13334 log "Read again; it should be satisfied from the cache."
13336 cancel_lru_locks osc
13337 cat $file >/dev/null
13339 if ! let "AFTER - BEFORE == CPAGES"; then
13340 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13342 log "cache hits:: before: $BEFORE, after: $AFTER"
13345 log "Turn off the read cache and turn on the write cache"
13347 set_cache writethrough on
13349 log "Read again; it should be satisfied from the cache."
13351 cancel_lru_locks osc
13352 cat $file >/dev/null
13354 if ! let "AFTER - BEFORE == CPAGES"; then
13355 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13357 log "cache hits:: before: $BEFORE, after: $AFTER"
13360 log "Read again; it should not be satisfied from the cache."
13362 cancel_lru_locks osc
13363 cat $file >/dev/null
13365 if ! let "AFTER - BEFORE == 0"; then
13366 error "IN CACHE: before: $BEFORE, after: $AFTER"
13368 log "cache hits:: before: $BEFORE, after: $AFTER"
13371 log "Write data and read it back."
13372 log "Read should be satisfied from the cache."
13373 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13375 cancel_lru_locks osc
13376 cat $file >/dev/null
13378 if ! let "AFTER - BEFORE == CPAGES"; then
13379 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13381 log "cache hits:: before: $BEFORE, after: $AFTER"
13384 log "Read again; it should not be satisfied from the cache."
13386 cancel_lru_locks osc
13387 cat $file >/dev/null
13389 if ! let "AFTER - BEFORE == 0"; then
13390 error "IN CACHE: before: $BEFORE, after: $AFTER"
13392 log "cache hits:: before: $BEFORE, after: $AFTER"
13395 log "Turn off read and write cache"
13397 set_cache writethrough off
13399 log "Write data and read it back"
13400 log "It should not be satisfied from the cache."
13402 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13403 cancel_lru_locks osc
13405 cat $file >/dev/null
13407 if ! let "AFTER - BEFORE == 0"; then
13408 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13410 log "cache hits:: before: $BEFORE, after: $AFTER"
13413 log "Turn on the read cache and turn off the write cache"
13415 set_cache writethrough off
13417 log "Write data and read it back"
13418 log "It should not be satisfied from the cache."
13420 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13422 cancel_lru_locks osc
13423 cat $file >/dev/null
13425 if ! let "AFTER - BEFORE == 0"; then
13426 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13428 log "cache hits:: before: $BEFORE, after: $AFTER"
13431 log "Read again; it should be satisfied from the cache."
13433 cancel_lru_locks osc
13434 cat $file >/dev/null
13436 if ! let "AFTER - BEFORE == CPAGES"; then
13437 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13439 log "cache hits:: before: $BEFORE, after: $AFTER"
13442 restore_lustre_params < $p
13445 run_test 156 "Verification of tunables"
13448 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13449 remote_mds_nodsh && skip "remote MDS with nodsh"
13450 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13451 skip "Need MDS version at least 2.2.0"
13453 changelog_register || error "changelog_register failed"
13454 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13455 changelog_users $SINGLEMDS | grep -q $cl_user ||
13456 error "User $cl_user not found in changelog_users"
13459 test_mkdir -p $DIR/$tdir/pics/2008/zachy
13460 changelog_clear 0 || error "changelog_clear failed"
13461 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
13462 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
13463 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
13464 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
13465 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
13466 rm $DIR/$tdir/pics/desktop.jpg
13468 changelog_dump | tail -10
13470 echo "verifying changelog mask"
13471 changelog_chmask "-MKDIR"
13472 changelog_chmask "-CLOSE"
13474 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
13475 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
13477 changelog_chmask "+MKDIR"
13478 changelog_chmask "+CLOSE"
13480 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
13481 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
13483 changelog_dump | tail -10
13484 MKDIRS=$(changelog_dump | grep -c "MKDIR")
13485 CLOSES=$(changelog_dump | grep -c "CLOSE")
13486 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
13487 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
13490 echo "verifying target fid"
13491 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
13492 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
13493 [ "$fidc" == "$fidf" ] ||
13494 error "changelog '$tfile' fid $fidc != file fid $fidf"
13495 echo "verifying parent fid"
13496 # The FID returned from the Changelog may be the directory shard on
13497 # a different MDT, and not the FID returned by path2fid on the parent.
13498 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
13499 # since this is what will matter when recreating this file in the tree.
13500 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
13501 local pathp=$($LFS fid2path $MOUNT "$fidp")
13502 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
13503 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
13505 echo "getting records for $cl_user"
13506 changelog_users $SINGLEMDS
13507 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
13509 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
13510 error "changelog_clear failed"
13511 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
13512 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
13513 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
13514 error "user index expect $user_rec1 + $nclr != $user_rec2"
13516 local min0_rec=$(changelog_users $SINGLEMDS |
13517 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
13518 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
13519 awk '{ print $1; exit; }')
13521 changelog_dump | tail -n 5
13522 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
13523 [ $first_rec == $((min0_rec + 1)) ] ||
13524 error "first index should be $min0_rec + 1 not $first_rec"
13526 # LU-3446 changelog index reset on MDT restart
13527 local cur_rec1=$(changelog_users $SINGLEMDS |
13528 awk '/^current.index:/ { print $NF }')
13529 changelog_clear 0 ||
13530 error "clear all changelog records for $cl_user failed"
13531 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
13532 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
13533 error "Fail to start $SINGLEMDS"
13534 local cur_rec2=$(changelog_users $SINGLEMDS |
13535 awk '/^current.index:/ { print $NF }')
13536 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
13537 [ $cur_rec1 == $cur_rec2 ] ||
13538 error "current index should be $cur_rec1 not $cur_rec2"
13540 echo "verifying users from this test are deregistered"
13541 changelog_deregister || error "changelog_deregister failed"
13542 changelog_users $SINGLEMDS | grep -q $cl_user &&
13543 error "User '$cl_user' still in changelog_users"
13545 # lctl get_param -n mdd.*.changelog_users
13546 # current index: 144
13547 # ID index (idle seconds)
13549 if ! changelog_users $SINGLEMDS | grep "^cl"; then
13550 # this is the normal case where all users were deregistered
13551 # make sure no new records are added when no users are present
13552 local last_rec1=$(changelog_users $SINGLEMDS |
13553 awk '/^current.index:/ { print $NF }')
13554 touch $DIR/$tdir/chloe
13555 local last_rec2=$(changelog_users $SINGLEMDS |
13556 awk '/^current.index:/ { print $NF }')
13557 echo "verify changelogs are off: $last_rec1 == $last_rec2"
13558 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
13560 # any changelog users must be leftovers from a previous test
13561 changelog_users $SINGLEMDS
13562 echo "other changelog users; can't verify off"
13565 run_test 160a "changelog sanity"
13567 test_160b() { # LU-3587
13568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13569 remote_mds_nodsh && skip "remote MDS with nodsh"
13570 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13571 skip "Need MDS version at least 2.2.0"
13573 changelog_register || error "changelog_register failed"
13574 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13575 changelog_users $SINGLEMDS | grep -q $cl_user ||
13576 error "User '$cl_user' not found in changelog_users"
13578 local longname1=$(str_repeat a 255)
13579 local longname2=$(str_repeat b 255)
13582 echo "creating very long named file"
13583 touch $longname1 || error "create of '$longname1' failed"
13584 echo "renaming very long named file"
13585 mv $longname1 $longname2
13587 changelog_dump | grep RENME | tail -n 5
13590 run_test 160b "Verify that very long rename doesn't crash in changelog"
13593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13594 remote_mds_nodsh && skip "remote MDS with nodsh"
13596 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
13597 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
13598 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
13599 skip "Need MDS version at least 2.5.58 or 2.5.2+"
13603 # Registration step
13604 changelog_register || error "changelog_register failed"
13607 mkdir -p $DIR/$tdir
13608 $MCREATE $DIR/$tdir/foo_160c
13609 changelog_chmask "-TRUNC"
13610 $TRUNCATE $DIR/$tdir/foo_160c 200
13611 changelog_chmask "+TRUNC"
13612 $TRUNCATE $DIR/$tdir/foo_160c 199
13613 changelog_dump | tail -n 5
13614 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
13615 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
13617 run_test 160c "verify that changelog log catch the truncate event"
13620 remote_mds_nodsh && skip "remote MDS with nodsh"
13621 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13623 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
13624 skip "Need MDS version at least 2.7.60"
13626 # Registration step
13627 changelog_register || error "changelog_register failed"
13629 mkdir -p $DIR/$tdir/migrate_dir
13630 changelog_clear 0 || error "changelog_clear failed"
13632 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
13633 changelog_dump | tail -n 5
13634 local migrates=$(changelog_dump | grep -c "MIGRT")
13635 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
13637 run_test 160d "verify that changelog log catch the migrate event"
13640 remote_mds_nodsh && skip "remote MDS with nodsh"
13643 changelog_register || error "changelog_register failed"
13645 # Delete a future user (expect fail)
13646 local MDT0=$(facet_svc $SINGLEMDS)
13647 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
13650 if [ $rc -eq 0 ]; then
13651 error "Deleted non-existant user cl77"
13652 elif [ $rc -ne 2 ]; then
13653 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
13656 # Clear to a bad index (1 billion should be safe)
13657 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
13660 if [ $rc -eq 0 ]; then
13661 error "Successfully cleared to invalid CL index"
13662 elif [ $rc -ne 22 ]; then
13663 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
13666 run_test 160e "changelog negative testing (should return errors)"
13669 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13670 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13671 skip "Need MDS version at least 2.10.56"
13673 local mdts=$(comma_list $(mdts_nodes))
13676 changelog_register || error "first changelog_register failed"
13677 changelog_register || error "second changelog_register failed"
13679 declare -A cl_user1
13680 declare -A cl_user2
13685 # generate some changelog records to accumulate on each MDT
13686 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13687 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13688 error "create $DIR/$tdir/$tfile failed"
13690 # check changelogs have been generated
13691 local nbcl=$(changelog_dump | wc -l)
13692 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13694 for param in "changelog_max_idle_time=10" \
13696 "changelog_min_gc_interval=2" \
13697 "changelog_min_free_cat_entries=3"; do
13698 local MDT0=$(facet_svc $SINGLEMDS)
13699 local var="${param%=*}"
13700 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13702 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13703 do_nodes $mdts $LCTL set_param mdd.*.$param
13706 # force cl_user2 to be idle (1st part)
13709 # simulate changelog catalog almost full
13710 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13711 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13713 for i in $(seq $MDSCOUNT); do
13714 cl_users=(${CL_USERS[mds$i]})
13715 cl_user1[mds$i]="${cl_users[0]}"
13716 cl_user2[mds$i]="${cl_users[1]}"
13718 [ -n "${cl_user1[mds$i]}" ] ||
13719 error "mds$i: no user registered"
13720 [ -n "${cl_user2[mds$i]}" ] ||
13721 error "mds$i: only ${cl_user2[mds$i]} is registered"
13723 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13724 [ -n "$user_rec1" ] ||
13725 error "mds$i: User ${cl_user1[mds$i]} not registered"
13726 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13727 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13728 [ -n "$user_rec2" ] ||
13729 error "mds$i: User ${cl_user1[mds$i]} not registered"
13730 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13731 "$user_rec1 + 2 == $user_rec2"
13732 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13733 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13734 "$user_rec1 + 2, but is $user_rec2"
13735 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13736 [ -n "$user_rec2" ] ||
13737 error "mds$i: User ${cl_user2[mds$i]} not registered"
13738 [ $user_rec1 == $user_rec2 ] ||
13739 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13740 "$user_rec1, but is $user_rec2"
13743 # force cl_user2 to be idle (2nd part) and to reach
13744 # changelog_max_idle_time
13747 # generate one more changelog to trigger fail_loc
13748 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13749 error "create $DIR/$tdir/${tfile}bis failed"
13751 # ensure gc thread is done
13752 for i in $(mdts_nodes); do
13754 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13755 error "$i: GC-thread not done"
13759 for i in $(seq $MDSCOUNT); do
13760 # check cl_user1 still registered
13761 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13762 error "mds$i: User ${cl_user1[mds$i]} not registered"
13763 # check cl_user2 unregistered
13764 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13765 error "mds$i: User ${cl_user2[mds$i]} still registered"
13767 # check changelogs are present and starting at $user_rec1 + 1
13768 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13769 [ -n "$user_rec1" ] ||
13770 error "mds$i: User ${cl_user1[mds$i]} not registered"
13771 first_rec=$($LFS changelog $(facet_svc mds$i) |
13772 awk '{ print $1; exit; }')
13774 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13775 [ $((user_rec1 + 1)) == $first_rec ] ||
13776 error "mds$i: first index should be $user_rec1 + 1, " \
13777 "but is $first_rec"
13780 run_test 160f "changelog garbage collect (timestamped users)"
13783 remote_mds_nodsh && skip "remote MDS with nodsh"
13784 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13785 skip "Need MDS version at least 2.10.56"
13787 local mdts=$(comma_list $(mdts_nodes))
13789 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
13790 do_nodes $mdts $LCTL set_param fail_loc=0x1314
13793 changelog_register || error "first changelog_register failed"
13794 changelog_register || error "second changelog_register failed"
13796 declare -A cl_user1
13797 declare -A cl_user2
13802 # generate some changelog records to accumulate on each MDT
13803 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13804 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13805 error "create $DIR/$tdir/$tfile failed"
13807 # check changelogs have been generated
13808 local nbcl=$(changelog_dump | wc -l)
13809 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13811 # reduce the max_idle_indexes value to make sure we exceed it
13812 max_ndx=$((nbcl / 2 - 1))
13814 for param in "changelog_max_idle_indexes=$max_ndx" \
13816 "changelog_min_gc_interval=2" \
13817 "changelog_min_free_cat_entries=3"; do
13818 local MDT0=$(facet_svc $SINGLEMDS)
13819 local var="${param%=*}"
13820 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13822 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13823 do_nodes $mdts $LCTL set_param mdd.*.$param ||
13824 error "unable to set mdd.*.$param"
13827 # simulate changelog catalog almost full
13828 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13829 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13831 for i in $(seq $MDSCOUNT); do
13832 cl_users=(${CL_USERS[mds$i]})
13833 cl_user1[mds$i]="${cl_users[0]}"
13834 cl_user2[mds$i]="${cl_users[1]}"
13836 [ -n "${cl_user1[mds$i]}" ] ||
13837 error "mds$i: no user registered"
13838 [ -n "${cl_user2[mds$i]}" ] ||
13839 error "mds$i: only ${cl_user1[mds$i]} is registered"
13841 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13842 [ -n "$user_rec1" ] ||
13843 error "mds$i: User ${cl_user1[mds$i]} not registered"
13844 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13845 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13846 [ -n "$user_rec2" ] ||
13847 error "mds$i: User ${cl_user1[mds$i]} not registered"
13848 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13849 "$user_rec1 + 2 == $user_rec2"
13850 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13851 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13852 "$user_rec1 + 2, but is $user_rec2"
13853 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13854 [ -n "$user_rec2" ] ||
13855 error "mds$i: User ${cl_user2[mds$i]} not registered"
13856 [ $user_rec1 == $user_rec2 ] ||
13857 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13858 "$user_rec1, but is $user_rec2"
13861 # ensure we are past the previous changelog_min_gc_interval set above
13864 # generate one more changelog to trigger fail_loc
13865 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13866 error "create $DIR/$tdir/${tfile}bis failed"
13868 # ensure gc thread is done
13869 for i in $(mdts_nodes); do
13871 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13872 error "$i: GC-thread not done"
13876 for i in $(seq $MDSCOUNT); do
13877 # check cl_user1 still registered
13878 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13879 error "mds$i: User ${cl_user1[mds$i]} not registered"
13880 # check cl_user2 unregistered
13881 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13882 error "mds$i: User ${cl_user2[mds$i]} still registered"
13884 # check changelogs are present and starting at $user_rec1 + 1
13885 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13886 [ -n "$user_rec1" ] ||
13887 error "mds$i: User ${cl_user1[mds$i]} not registered"
13888 first_rec=$($LFS changelog $(facet_svc mds$i) |
13889 awk '{ print $1; exit; }')
13891 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13892 [ $((user_rec1 + 1)) == $first_rec ] ||
13893 error "mds$i: first index should be $user_rec1 + 1, " \
13894 "but is $first_rec"
13897 run_test 160g "changelog garbage collect (old users)"
13900 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13901 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13902 skip "Need MDS version at least 2.10.56"
13904 local mdts=$(comma_list $(mdts_nodes))
13907 changelog_register || error "first changelog_register failed"
13908 changelog_register || error "second changelog_register failed"
13910 declare -A cl_user1
13911 declare -A cl_user2
13916 # generate some changelog records to accumulate on each MDT
13917 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13918 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13919 error "create $DIR/$tdir/$tfile failed"
13921 # check changelogs have been generated
13922 local nbcl=$(changelog_dump | wc -l)
13923 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13925 for param in "changelog_max_idle_time=10" \
13927 "changelog_min_gc_interval=2"; do
13928 local MDT0=$(facet_svc $SINGLEMDS)
13929 local var="${param%=*}"
13930 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13932 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13933 do_nodes $mdts $LCTL set_param mdd.*.$param
13936 # force cl_user2 to be idle (1st part)
13939 for i in $(seq $MDSCOUNT); do
13940 cl_users=(${CL_USERS[mds$i]})
13941 cl_user1[mds$i]="${cl_users[0]}"
13942 cl_user2[mds$i]="${cl_users[1]}"
13944 [ -n "${cl_user1[mds$i]}" ] ||
13945 error "mds$i: no user registered"
13946 [ -n "${cl_user2[mds$i]}" ] ||
13947 error "mds$i: only ${cl_user2[mds$i]} is registered"
13949 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13950 [ -n "$user_rec1" ] ||
13951 error "mds$i: User ${cl_user1[mds$i]} not registered"
13952 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13953 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13954 [ -n "$user_rec2" ] ||
13955 error "mds$i: User ${cl_user1[mds$i]} not registered"
13956 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13957 "$user_rec1 + 2 == $user_rec2"
13958 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13959 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13960 "$user_rec1 + 2, but is $user_rec2"
13961 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13962 [ -n "$user_rec2" ] ||
13963 error "mds$i: User ${cl_user2[mds$i]} not registered"
13964 [ $user_rec1 == $user_rec2 ] ||
13965 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13966 "$user_rec1, but is $user_rec2"
13969 # force cl_user2 to be idle (2nd part) and to reach
13970 # changelog_max_idle_time
13973 # force each GC-thread start and block then
13974 # one per MDT/MDD, set fail_val accordingly
13975 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
13976 do_nodes $mdts $LCTL set_param fail_loc=0x1316
13978 # generate more changelogs to trigger fail_loc
13979 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13980 error "create $DIR/$tdir/${tfile}bis failed"
13982 # stop MDT to stop GC-thread, should be done in back-ground as it will
13983 # block waiting for the thread to be released and exit
13984 declare -A stop_pids
13985 for i in $(seq $MDSCOUNT); do
13987 stop_pids[mds$i]=$!
13990 for i in $(mdts_nodes); do
13993 local facets=$(facets_up_on_host $i)
13995 for facet in ${facets//,/ }; do
13996 if [[ $facet == mds* ]]; then
14000 # ensure each MDS's gc threads are still present and all in "R"
14001 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
14002 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
14003 error "$i: expected $nb GC-thread"
14005 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
14007 error "$i: GC-thread not found in R-state"
14008 # check umounts of each MDT on MDS have reached kthread_stop()
14009 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
14010 error "$i: expected $nb umount"
14012 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
14013 error "$i: umount not found in D-state"
14016 # release all GC-threads
14017 do_nodes $mdts $LCTL set_param fail_loc=0
14019 # wait for MDT stop to complete
14020 for i in $(seq $MDSCOUNT); do
14021 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
14025 # may try to check if any orphan changelog records are present
14026 # via ldiskfs/zfs and llog_reader...
14028 # re-start/mount MDTs
14029 for i in $(seq $MDSCOUNT); do
14030 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
14031 error "Fail to start mds$i"
14035 for i in $(seq $MDSCOUNT); do
14036 # check cl_user1 still registered
14037 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14038 error "mds$i: User ${cl_user1[mds$i]} not registered"
14039 # check cl_user2 unregistered
14040 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14041 error "mds$i: User ${cl_user2[mds$i]} still registered"
14043 # check changelogs are present and starting at $user_rec1 + 1
14044 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14045 [ -n "$user_rec1" ] ||
14046 error "mds$i: User ${cl_user1[mds$i]} not registered"
14047 first_rec=$($LFS changelog $(facet_svc mds$i) |
14048 awk '{ print $1; exit; }')
14050 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14051 [ $((user_rec1 + 1)) == $first_rec ] ||
14052 error "mds$i: first index should be $user_rec1 + 1, " \
14053 "but is $first_rec"
14056 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
14061 local mdts=$(comma_list $(mdts_nodes))
14063 changelog_register || error "first changelog_register failed"
14065 # generate some changelog records to accumulate on each MDT
14066 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
14067 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14068 error "create $DIR/$tdir/$tfile failed"
14070 # check changelogs have been generated
14071 local nbcl=$(changelog_dump | wc -l)
14072 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14074 # simulate race between register and unregister
14075 # XXX as fail_loc is set per-MDS, with DNE configs the race
14076 # simulation will only occur for one MDT per MDS and for the
14077 # others the normal race scenario will take place
14078 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
14079 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
14080 do_nodes $mdts $LCTL set_param fail_val=1
14082 # unregister 1st user
14083 changelog_deregister &
14085 # wait some time for deregister work to reach race rdv
14087 # register 2nd user
14088 changelog_register || error "2nd user register failed"
14090 wait $pid1 || error "1st user deregister failed"
14094 declare -A LAST_REC
14095 for i in $(seq $MDSCOUNT); do
14096 if changelog_users mds$i | grep "^cl"; then
14097 # make sure new records are added with one user present
14098 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
14099 awk '/^current.index:/ { print $NF }')
14101 error "mds$i has no user registered"
14105 # generate more changelog records to accumulate on each MDT
14106 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14107 error "create $DIR/$tdir/${tfile}bis failed"
14109 for i in $(seq $MDSCOUNT); do
14110 last_rec=$(changelog_users $SINGLEMDS |
14111 awk '/^current.index:/ { print $NF }')
14112 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
14113 [ $last_rec != ${LAST_REC[mds$i]} ] ||
14114 error "changelogs are off on mds$i"
14117 run_test 160i "changelog user register/unregister race"
14120 remote_mds_nodsh && skip "remote MDS with nodsh"
14121 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
14122 skip "Need MDS version at least 2.12.56"
14124 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
14126 changelog_register || error "first changelog_register failed"
14128 # generate some changelog
14129 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
14130 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14131 error "create $DIR/$tdir/${tfile}bis failed"
14133 # open the changelog device
14134 exec 3>/dev/changelog-$FSNAME-MDT0000
14135 exec 4</dev/changelog-$FSNAME-MDT0000
14137 # umount the first lustre mount
14141 cat <&4 >/dev/null || error "read changelog failed"
14144 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14145 changelog_users $SINGLEMDS | grep -q $cl_user ||
14146 error "User $cl_user not found in changelog_users"
14148 printf 'clear:'$cl_user':0' >&3
14155 changelog_deregister || error "changelog_deregister failed"
14158 mount_client $MOUNT || error "mount_client on $MOUNT failed"
14160 run_test 160j "client can be umounted while its chanangelog is being used"
14163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14164 remote_mds_nodsh && skip "remote MDS with nodsh"
14166 mkdir -p $DIR/$tdir/1/1
14168 changelog_register || error "changelog_register failed"
14169 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14171 changelog_users $SINGLEMDS | grep -q $cl_user ||
14172 error "User '$cl_user' not found in changelog_users"
14173 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
14174 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
14175 rmdir $DIR/$tdir/1/1 & sleep 1
14177 touch $DIR/$tdir/2/2
14178 rm -rf $DIR/$tdir/2
14183 changelog_dump | grep rmdir || error "rmdir not recorded"
14186 changelog_deregister
14188 run_test 160k "Verify that changelog records are not lost"
14191 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14193 test_mkdir -c1 $DIR/$tdir
14194 cp /etc/hosts $DIR/$tdir/$tfile
14195 test_mkdir -c1 $DIR/$tdir/foo1
14196 test_mkdir -c1 $DIR/$tdir/foo2
14197 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
14198 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
14199 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
14200 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
14201 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
14202 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14203 $LFS fid2path $DIR $FID
14204 error "bad link ea"
14207 rm $DIR/$tdir/foo2/zachary
14209 rm $DIR/$tdir/foo2/thor
14211 rm $DIR/$tdir/$tfile
14213 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
14214 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
14215 { $LFS fid2path $DIR $FID; error "bad link rename"; }
14216 rm $DIR/$tdir/foo2/maggie
14219 local longname=$tfile.avg_len_is_thirty_two_
14220 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
14221 error_noexit 'failed to unlink many hardlinks'" EXIT
14222 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
14223 error "failed to hardlink many files"
14224 links=$($LFS fid2path $DIR $FID | wc -l)
14225 echo -n "${links}/1000 links in link EA"
14226 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
14228 run_test 161a "link ea sanity"
14231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14232 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
14235 local remote_dir=$DIR/$tdir/remote_dir
14237 mkdir -p $DIR/$tdir
14238 $LFS mkdir -i $MDTIDX $remote_dir ||
14239 error "create remote directory failed"
14241 cp /etc/hosts $remote_dir/$tfile
14242 mkdir -p $remote_dir/foo1
14243 mkdir -p $remote_dir/foo2
14244 ln $remote_dir/$tfile $remote_dir/foo1/sofia
14245 ln $remote_dir/$tfile $remote_dir/foo2/zachary
14246 ln $remote_dir/$tfile $remote_dir/foo1/luna
14247 ln $remote_dir/$tfile $remote_dir/foo2/thor
14249 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
14251 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14252 $LFS fid2path $DIR $FID
14253 error "bad link ea"
14256 rm $remote_dir/foo2/zachary
14258 rm $remote_dir/foo2/thor
14260 rm $remote_dir/$tfile
14262 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
14263 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
14264 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
14265 $LFS fid2path $DIR $FID
14266 error "bad link rename"
14268 rm $remote_dir/foo2/maggie
14271 local longname=filename_avg_len_is_thirty_two_
14272 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
14273 error "failed to hardlink many files"
14274 links=$($LFS fid2path $DIR $FID | wc -l)
14275 echo -n "${links}/1000 links in link EA"
14276 [[ ${links} -gt 60 ]] ||
14277 error "expected at least 60 links in link EA"
14278 unlinkmany $remote_dir/foo2/$longname 1000 ||
14279 error "failed to unlink many hardlinks"
14281 run_test 161b "link ea sanity under remote directory"
14284 remote_mds_nodsh && skip "remote MDS with nodsh"
14285 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14286 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
14287 skip "Need MDS version at least 2.1.5"
14289 # define CLF_RENAME_LAST 0x0001
14290 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
14291 changelog_register || error "changelog_register failed"
14294 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
14295 touch $DIR/$tdir/foo_161c
14296 touch $DIR/$tdir/bar_161c
14297 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14298 changelog_dump | grep RENME | tail -n 5
14299 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14300 changelog_clear 0 || error "changelog_clear failed"
14301 if [ x$flags != "x0x1" ]; then
14302 error "flag $flags is not 0x1"
14305 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
14306 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
14307 touch $DIR/$tdir/foo_161c
14308 touch $DIR/$tdir/bar_161c
14309 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14310 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14311 changelog_dump | grep RENME | tail -n 5
14312 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14313 changelog_clear 0 || error "changelog_clear failed"
14314 if [ x$flags != "x0x0" ]; then
14315 error "flag $flags is not 0x0"
14317 echo "rename overwrite a target having nlink > 1," \
14318 "changelog record has flags of $flags"
14320 # rename doesn't overwrite a target (changelog flag 0x0)
14321 touch $DIR/$tdir/foo_161c
14322 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
14323 changelog_dump | grep RENME | tail -n 5
14324 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
14325 changelog_clear 0 || error "changelog_clear failed"
14326 if [ x$flags != "x0x0" ]; then
14327 error "flag $flags is not 0x0"
14329 echo "rename doesn't overwrite a target," \
14330 "changelog record has flags of $flags"
14332 # define CLF_UNLINK_LAST 0x0001
14333 # unlink a file having nlink = 1 (changelog flag 0x1)
14334 rm -f $DIR/$tdir/foo2_161c
14335 changelog_dump | grep UNLNK | tail -n 5
14336 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14337 changelog_clear 0 || error "changelog_clear failed"
14338 if [ x$flags != "x0x1" ]; then
14339 error "flag $flags is not 0x1"
14341 echo "unlink a file having nlink = 1," \
14342 "changelog record has flags of $flags"
14344 # unlink a file having nlink > 1 (changelog flag 0x0)
14345 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14346 rm -f $DIR/$tdir/foobar_161c
14347 changelog_dump | grep UNLNK | tail -n 5
14348 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14349 changelog_clear 0 || error "changelog_clear failed"
14350 if [ x$flags != "x0x0" ]; then
14351 error "flag $flags is not 0x0"
14353 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
14355 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
14358 remote_mds_nodsh && skip "remote MDS with nodsh"
14359 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
14364 changelog_register || error "changelog_register failed"
14366 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
14367 # interfer with $MOUNT/.lustre/fid/ access
14369 [[ $? -eq 0 ]] || error "mkdir failed"
14371 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
14372 $LCTL set_param fail_loc=0x8000140c
14374 $LCTL set_param fail_val=5
14377 echo foofoo > $DIR/$tdir/$tfile &
14380 # wait for create to be delayed
14384 [[ $? -eq 0 ]] || error "create should be blocked"
14386 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
14387 stack_trap "rm -f $tempfile"
14388 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
14389 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
14390 # some delay may occur during ChangeLog publishing and file read just
14391 # above, that could allow file write to happen finally
14392 [[ -s $tempfile ]] && echo "file should be empty"
14394 $LCTL set_param fail_loc=0
14397 [[ $? -eq 0 ]] || error "create failed"
14399 run_test 161d "create with concurrent .lustre/fid access"
14402 local expected="$1"
14407 path=$($LFS fid2path "$@")
14410 if [ $rc -ne 0 ]; then
14411 error "path looked up of '$expected' failed: rc=$rc"
14412 elif [ "$path" != "$expected" ]; then
14413 error "path looked up '$path' instead of '$expected'"
14415 echo "FID '$fid' resolves to path '$path' as expected"
14419 test_162a() { # was test_162
14420 test_mkdir -p -c1 $DIR/$tdir/d2
14421 touch $DIR/$tdir/d2/$tfile
14422 touch $DIR/$tdir/d2/x1
14423 touch $DIR/$tdir/d2/x2
14424 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
14425 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
14427 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
14428 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
14431 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
14432 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
14433 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
14435 # softlink to wrong file
14436 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
14437 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
14438 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
14441 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
14442 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
14443 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
14444 # fid2path dir/fsname should both work
14445 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
14446 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
14448 # hardlink count: check that there are 2 links
14449 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
14450 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
14452 # hardlink indexing: remove the first link
14453 rm $DIR/$tdir/d2/p/q/r/hlink
14454 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
14456 run_test 162a "path lookup sanity"
14459 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14460 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14463 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
14464 error "create striped dir failed"
14466 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
14467 tail -n 1 | awk '{print $2}')
14468 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
14470 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
14471 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
14474 for ((i=0;i<5;i++)); do
14475 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
14476 error "get fid for f$i failed"
14477 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
14479 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
14480 error "get fid for d$i failed"
14481 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
14486 run_test 162b "striped directory path lookup sanity"
14488 # LU-4239: Verify fid2path works with paths 100 or more directories deep
14490 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
14491 skip "Need MDS version at least 2.7.51"
14493 local lpath=$tdir.local
14494 local rpath=$tdir.remote
14496 test_mkdir $DIR/$lpath
14497 test_mkdir $DIR/$rpath
14499 for ((i = 0; i <= 101; i++)); do
14502 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
14503 error "get fid for local directory $DIR/$lpath failed"
14504 check_path "$DIR/$lpath" $MOUNT $FID --link 0
14507 test_mkdir $DIR/$rpath
14508 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
14509 error "get fid for remote directory $DIR/$rpath failed"
14510 check_path "$DIR/$rpath" $MOUNT $FID --link 0
14515 run_test 162c "fid2path works with paths 100 or more directories deep"
14518 # do directio so as not to populate the page cache
14519 log "creating a 10 Mb file"
14520 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14521 log "starting reads"
14522 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14523 log "truncating the file"
14524 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14526 kill %+ || true # reads might have finished
14527 echo "wait until dd is finished"
14529 log "removing the temporary file"
14530 rm -rf $DIR/$tfile || error "tmp file removal failed"
14532 run_test 169 "parallel read and truncate should not deadlock"
14535 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14537 $LCTL clear # bug 18514
14538 $LCTL debug_daemon start $TMP/${tfile}_log_good
14540 $LCTL debug_daemon stop
14541 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
14542 error "sed failed to read log_good"
14544 $LCTL debug_daemon start $TMP/${tfile}_log_good
14546 $LCTL debug_daemon stop
14548 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
14549 error "lctl df log_bad failed"
14551 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14552 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14554 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
14555 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
14557 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
14558 error "bad_line good_line1 good_line2 are empty"
14560 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14561 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
14562 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14564 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
14565 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14566 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14568 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
14569 error "bad_line_new good_line_new are empty"
14571 local expected_good=$((good_line1 + good_line2*2))
14573 rm -f $TMP/${tfile}*
14574 # LU-231, short malformed line may not be counted into bad lines
14575 if [ $bad_line -ne $bad_line_new ] &&
14576 [ $bad_line -ne $((bad_line_new - 1)) ]; then
14577 error "expected $bad_line bad lines, but got $bad_line_new"
14581 if [ $expected_good -ne $good_line_new ]; then
14582 error "expected $expected_good good lines, but got $good_line_new"
14587 run_test 170 "test lctl df to handle corrupted log ====================="
14589 test_171() { # bug20592
14590 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14592 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
14593 $LCTL set_param fail_loc=0x50e
14594 $LCTL set_param fail_val=3000
14595 multiop_bg_pause $DIR/$tfile O_s || true
14597 kill -USR1 $MULTIPID
14601 if dmesg | grep "recursive fault"; then
14602 error "caught a recursive fault"
14604 $LCTL set_param fail_loc=0
14607 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
14609 # it would be good to share it with obdfilter-survey/iokit-libecho code
14610 setup_obdecho_osc () {
14613 local obdfilter_name=$2
14614 echo "Creating new osc for $obdfilter_name on $ost_nid"
14615 # make sure we can find loopback nid
14616 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
14618 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
14619 ${obdfilter_name}_osc_UUID || rc=2; }
14620 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
14621 ${obdfilter_name}_UUID $ost_nid || rc=3; }
14625 cleanup_obdecho_osc () {
14626 local obdfilter_name=$1
14627 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
14628 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
14635 local pages=${3:-64}
14640 local obd_size=$(get_obd_size $node $OBD)
14641 local page_size=$(get_page_size $node)
14642 if [[ -n "$obd_size" ]]; then
14643 local new_count=$((obd_size / (pages * page_size / 1024)))
14644 [[ $new_count -ge $count ]] || count=$new_count
14647 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
14648 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
14650 if [ $rc -eq 0 ]; then
14651 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
14652 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
14654 echo "New object id is $id"
14655 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
14657 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
14658 "test_brw $count w v $pages $id" || rc=4; }
14659 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
14661 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
14662 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
14663 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
14664 { do_facet $node "$LCTL --device ec detach" || rc=6; }
14665 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
14670 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14672 if ! module_loaded obdecho; then
14673 load_module obdecho/obdecho &&
14674 stack_trap "rmmod obdecho" EXIT ||
14675 error "unable to load obdecho on client"
14678 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
14679 local host=$($LCTL get_param -n osc.$osc.import |
14680 awk '/current_connection:/ { print $2 }' )
14681 local target=$($LCTL get_param -n osc.$osc.import |
14682 awk '/target:/ { print $2 }' )
14683 target=${target%_UUID}
14685 if [ -n "$target" ]; then
14686 setup_obdecho_osc $host $target &&
14687 stack_trap "cleanup_obdecho_osc $target" EXIT ||
14688 { error "obdecho setup failed with $?"; return; }
14690 obdecho_test ${target}_osc client ||
14691 error "obdecho_test failed on ${target}_osc"
14693 $LCTL get_param osc.$osc.import
14694 error "there is no osc.$osc.import target"
14697 run_test 180a "test obdecho on osc"
14700 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14701 remote_ost_nodsh && skip "remote OST with nodsh"
14703 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14704 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14705 error "failed to load module obdecho"
14707 local target=$(do_facet ost1 $LCTL dl |
14708 awk '/obdfilter/ { print $4; exit; }')
14710 if [ -n "$target" ]; then
14711 obdecho_test $target ost1 || error "obdecho_test failed with $?"
14713 do_facet ost1 $LCTL dl
14714 error "there is no obdfilter target on ost1"
14717 run_test 180b "test obdecho directly on obdfilter"
14719 test_180c() { # LU-2598
14720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14721 remote_ost_nodsh && skip "remote OST with nodsh"
14722 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
14723 skip "Need MDS version at least 2.4.0"
14725 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14726 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14727 error "failed to load module obdecho"
14729 local target=$(do_facet ost1 $LCTL dl |
14730 awk '/obdfilter/ { print $4; exit; }')
14732 if [ -n "$target" ]; then
14733 local pages=16384 # 64MB bulk I/O RPC size
14735 obdecho_test "$target" ost1 "$pages" ||
14736 error "obdecho_test with pages=$pages failed with $?"
14738 do_facet ost1 $LCTL dl
14739 error "there is no obdfilter target on ost1"
14742 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
14744 test_181() { # bug 22177
14745 test_mkdir $DIR/$tdir
14746 # create enough files to index the directory
14747 createmany -o $DIR/$tdir/foobar 4000
14748 # print attributes for debug purpose
14751 multiop_bg_pause $DIR/$tdir D_Sc || return 1
14753 # remove the files & current working dir
14754 unlinkmany $DIR/$tdir/foobar 4000
14756 kill -USR1 $MULTIPID
14758 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
14761 run_test 181 "Test open-unlinked dir ========================"
14767 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14769 $LCTL set_param mdc.*.rpc_stats=clear
14771 for (( i = 0; i < $tcount; i++ )) ; do
14772 mkdir $DIR/$tdir/$i
14775 for (( i = 0; i < $tcount; i++ )) ; do
14776 createmany -o $DIR/$tdir/$i/f- $fcount &
14780 for (( i = 0; i < $tcount; i++ )) ; do
14781 unlinkmany $DIR/$tdir/$i/f- $fcount &
14785 $LCTL get_param mdc.*.rpc_stats
14789 run_test 182 "Test parallel modify metadata operations ================"
14791 test_183() { # LU-2275
14792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14793 remote_mds_nodsh && skip "remote MDS with nodsh"
14794 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
14795 skip "Need MDS version at least 2.3.56"
14797 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14798 echo aaa > $DIR/$tdir/$tfile
14800 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
14801 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
14803 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
14804 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
14806 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14808 # Flush negative dentry cache
14809 touch $DIR/$tdir/$tfile
14811 # We are not checking for any leaked references here, they'll
14812 # become evident next time we do cleanup with module unload.
14815 run_test 183 "No crash or request leak in case of strange dispositions ========"
14817 # test suite 184 is for LU-2016, LU-2017
14819 check_swap_layouts_support
14821 dir0=$DIR/$tdir/$testnum
14822 test_mkdir -p -c1 $dir0
14827 $LFS setstripe -c1 $file1
14829 $LFS setstripe -c2 $file2
14831 gen1=$($LFS getstripe -g $file1)
14832 gen2=$($LFS getstripe -g $file2)
14834 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
14835 gen=$($LFS getstripe -g $file1)
14836 [[ $gen1 != $gen ]] ||
14837 "Layout generation on $file1 does not change"
14838 gen=$($LFS getstripe -g $file2)
14839 [[ $gen2 != $gen ]] ||
14840 "Layout generation on $file2 does not change"
14842 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
14843 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14845 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
14847 run_test 184a "Basic layout swap"
14850 check_swap_layouts_support
14852 dir0=$DIR/$tdir/$testnum
14853 mkdir -p $dir0 || error "creating dir $dir0"
14860 $LFS setstripe -c1 $file1
14861 $LFS setstripe -c2 $file2
14862 $LFS setstripe -c1 $file3
14863 chown $RUNAS_ID $file3
14864 gen1=$($LFS getstripe -g $file1)
14865 gen2=$($LFS getstripe -g $file2)
14867 $LFS swap_layouts $dir1 $dir2 &&
14868 error "swap of directories layouts should fail"
14869 $LFS swap_layouts $dir1 $file1 &&
14870 error "swap of directory and file layouts should fail"
14871 $RUNAS $LFS swap_layouts $file1 $file2 &&
14872 error "swap of file we cannot write should fail"
14873 $LFS swap_layouts $file1 $file3 &&
14874 error "swap of file with different owner should fail"
14875 /bin/true # to clear error code
14877 run_test 184b "Forbidden layout swap (will generate errors)"
14880 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
14881 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
14882 check_swap_layouts_support
14884 local dir0=$DIR/$tdir/$testnum
14885 mkdir -p $dir0 || error "creating dir $dir0"
14887 local ref1=$dir0/ref1
14888 local ref2=$dir0/ref2
14889 local file1=$dir0/file1
14890 local file2=$dir0/file2
14891 # create a file large enough for the concurrent test
14892 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
14893 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
14894 echo "ref file size: ref1($(stat -c %s $ref1))," \
14895 "ref2($(stat -c %s $ref2))"
14898 dd if=$ref1 of=$file1 bs=16k &
14901 # Make sure dd starts to copy file
14902 while [ ! -f $file1 ]; do sleep 0.1; done
14904 $LFS swap_layouts $file1 $file2
14907 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
14908 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
14910 # how many bytes copied before swapping layout
14911 local copied=$(stat -c %s $file2)
14912 local remaining=$(stat -c %s $ref1)
14913 remaining=$((remaining - copied))
14914 echo "Copied $copied bytes before swapping layout..."
14916 cmp -n $copied $file1 $ref2 | grep differ &&
14917 error "Content mismatch [0, $copied) of ref2 and file1"
14918 cmp -n $copied $file2 $ref1 ||
14919 error "Content mismatch [0, $copied) of ref1 and file2"
14920 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
14921 error "Content mismatch [$copied, EOF) of ref1 and file1"
14924 rm -f $ref1 $ref2 $file1 $file2
14926 run_test 184c "Concurrent write and layout swap"
14929 check_swap_layouts_support
14930 [ -z "$(which getfattr 2>/dev/null)" ] &&
14931 skip_env "no getfattr command"
14933 local file1=$DIR/$tdir/$tfile-1
14934 local file2=$DIR/$tdir/$tfile-2
14935 local file3=$DIR/$tdir/$tfile-3
14939 mkdir -p $DIR/$tdir
14940 touch $file1 || error "create $file1 failed"
14941 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14942 error "create $file2 failed"
14943 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14944 error "create $file3 failed"
14945 lovea1=$(get_layout_param $file1)
14947 $LFS swap_layouts $file2 $file3 ||
14948 error "swap $file2 $file3 layouts failed"
14949 $LFS swap_layouts $file1 $file2 ||
14950 error "swap $file1 $file2 layouts failed"
14952 lovea2=$(get_layout_param $file2)
14955 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
14957 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14958 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
14960 run_test 184d "allow stripeless layouts swap"
14963 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
14964 skip "Need MDS version at least 2.6.94"
14965 check_swap_layouts_support
14966 [ -z "$(which getfattr 2>/dev/null)" ] &&
14967 skip_env "no getfattr command"
14969 local file1=$DIR/$tdir/$tfile-1
14970 local file2=$DIR/$tdir/$tfile-2
14971 local file3=$DIR/$tdir/$tfile-3
14974 mkdir -p $DIR/$tdir
14975 touch $file1 || error "create $file1 failed"
14976 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14977 error "create $file2 failed"
14978 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14979 error "create $file3 failed"
14981 $LFS swap_layouts $file1 $file2 ||
14982 error "swap $file1 $file2 layouts failed"
14984 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14985 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
14987 echo 123 > $file1 || error "Should be able to write into $file1"
14989 $LFS swap_layouts $file1 $file3 ||
14990 error "swap $file1 $file3 layouts failed"
14992 echo 123 > $file1 || error "Should be able to write into $file1"
14994 rm -rf $file1 $file2 $file3
14996 run_test 184e "Recreate layout after stripeless layout swaps"
14999 # Create a file with name longer than sizeof(struct stat) ==
15000 # 144 to see if we can get chars from the file name to appear
15001 # in the returned striping. Note that 'f' == 0x66.
15002 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
15004 mkdir -p $DIR/$tdir
15005 mcreate $DIR/$tdir/$file
15006 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
15007 error "IOC_MDC_GETFILEINFO returned garbage striping"
15010 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
15012 test_185() { # LU-2441
15013 # LU-3553 - no volatile file support in old servers
15014 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
15015 skip "Need MDS version at least 2.3.60"
15017 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15018 touch $DIR/$tdir/spoo
15019 local mtime1=$(stat -c "%Y" $DIR/$tdir)
15020 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
15021 error "cannot create/write a volatile file"
15022 [ "$FILESET" == "" ] &&
15023 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
15024 error "FID is still valid after close"
15026 multiop_bg_pause $DIR/$tdir vVw4096_c
15033 # assume that the next FID for this client is sequential, since stdout
15034 # is unfortunately eaten by multiop_bg_pause
15035 local n=$((${fidv[1]} + 1))
15036 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
15037 if [ "$FILESET" == "" ]; then
15038 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
15039 error "FID is missing before close"
15041 kill -USR1 $multi_pid
15042 # 1 second delay, so if mtime change we will see it
15044 local mtime2=$(stat -c "%Y" $DIR/$tdir)
15045 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
15047 run_test 185 "Volatile file support"
15049 function create_check_volatile() {
15053 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
15056 local FID=$(cat /tmp/${tfile}.fid)
15057 [ "$FID" == "" ] && error "can't get FID for volatile"
15058 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
15059 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
15060 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
15064 cancel_lru_locks mdc # flush opencache
15065 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
15070 # LU-12516 - volatile creation via .lustre
15071 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
15072 skip "Need MDS version at least 2.3.55"
15074 create_check_volatile 0
15075 [ $MDSCOUNT -lt 2 ] && return 0
15078 create_check_volatile 1
15082 run_test 185a "Volatile file creation in .lustre/fid/"
15085 remote_mds_nodsh && skip "remote MDS with nodsh"
15086 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15087 skip "Need MDS version at least 2.3.0"
15089 local dir0=$DIR/$tdir/$testnum
15090 mkdir -p $dir0 || error "creating dir $dir0"
15092 local file=$dir0/file1
15093 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
15094 local dv1=$($LFS data_version $file)
15095 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
15096 local dv2=$($LFS data_version $file)
15097 [[ $dv1 != $dv2 ]] ||
15098 error "data version did not change on write $dv1 == $dv2"
15103 run_test 187a "Test data version change"
15106 remote_mds_nodsh && skip "remote MDS with nodsh"
15107 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15108 skip "Need MDS version at least 2.3.0"
15110 local dir0=$DIR/$tdir/$testnum
15111 mkdir -p $dir0 || error "creating dir $dir0"
15113 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
15114 [[ ${DV[0]} != ${DV[1]} ]] ||
15115 error "data version did not change on write"\
15116 " ${DV[0]} == ${DV[1]}"
15121 run_test 187b "Test data version change on volatile file"
15124 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15125 remote_mgs_nodsh && skip "remote MGS with nodsh"
15126 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15128 local POOL=${POOL:-cea1}
15129 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
15130 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
15133 local last_ost=$(($OSTCOUNT - 1))
15135 local ost_list=$(seq $first_ost $ost_step $last_ost)
15136 local ost_range="$first_ost $last_ost $ost_step"
15137 local test_path=$POOL_ROOT/$POOL_DIR_NAME
15138 local file_dir=$POOL_ROOT/file_tst
15139 local subdir=$test_path/subdir
15143 # former test_200a test_200b
15144 pool_add $POOL || { rc=$? ; break; }
15145 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
15146 # former test_200c test_200d
15147 mkdir -p $test_path
15148 pool_set_dir $POOL $test_path || { rc=$? ; break; }
15149 pool_check_dir $POOL $test_path || { rc=$? ; break; }
15151 pool_check_dir $POOL $subdir || { rc=$? ; break; }
15152 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
15153 || { rc=$? ; break; }
15154 # former test_200e test_200f
15155 local files=$((OSTCOUNT*3))
15156 pool_alloc_files $POOL $test_path $files "$ost_list" \
15157 || { rc=$? ; break; }
15158 pool_create_files $POOL $file_dir $files "$ost_list" \
15159 || { rc=$? ; break; }
15160 # former test_200g test_200h
15161 pool_lfs_df $POOL || { rc=$? ; break; }
15162 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
15164 # former test_201a test_201b test_201c
15165 pool_remove_first_target $POOL || { rc=$? ; break; }
15167 local f=$test_path/$tfile
15168 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
15169 pool_remove $POOL $f || { rc=$? ; break; }
15177 run_test 200 "OST pools"
15179 # usage: default_attr <count | size | offset>
15181 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
15184 # usage: check_default_stripe_attr
15185 check_default_stripe_attr() {
15186 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
15189 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
15191 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
15195 error "unknown getstripe attr '$1'"
15198 [ $ACTUAL == $EXPECTED ] ||
15199 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
15203 test_mkdir $DIR/$tdir
15204 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
15206 check_default_stripe_attr --stripe-count
15207 check_default_stripe_attr --stripe-size
15208 check_default_stripe_attr --stripe-index
15210 run_test 204a "Print default stripe attributes"
15213 test_mkdir $DIR/$tdir
15214 $LFS setstripe --stripe-count 1 $DIR/$tdir
15216 check_default_stripe_attr --stripe-size
15217 check_default_stripe_attr --stripe-index
15219 run_test 204b "Print default stripe size and offset"
15222 test_mkdir $DIR/$tdir
15223 $LFS setstripe --stripe-size 65536 $DIR/$tdir
15225 check_default_stripe_attr --stripe-count
15226 check_default_stripe_attr --stripe-index
15228 run_test 204c "Print default stripe count and offset"
15231 test_mkdir $DIR/$tdir
15232 $LFS setstripe --stripe-index 0 $DIR/$tdir
15234 check_default_stripe_attr --stripe-count
15235 check_default_stripe_attr --stripe-size
15237 run_test 204d "Print default stripe count and size"
15240 test_mkdir $DIR/$tdir
15241 $LFS setstripe -d $DIR/$tdir
15243 check_default_stripe_attr --stripe-count --raw
15244 check_default_stripe_attr --stripe-size --raw
15245 check_default_stripe_attr --stripe-index --raw
15247 run_test 204e "Print raw stripe attributes"
15250 test_mkdir $DIR/$tdir
15251 $LFS setstripe --stripe-count 1 $DIR/$tdir
15253 check_default_stripe_attr --stripe-size --raw
15254 check_default_stripe_attr --stripe-index --raw
15256 run_test 204f "Print raw stripe size and offset"
15259 test_mkdir $DIR/$tdir
15260 $LFS setstripe --stripe-size 65536 $DIR/$tdir
15262 check_default_stripe_attr --stripe-count --raw
15263 check_default_stripe_attr --stripe-index --raw
15265 run_test 204g "Print raw stripe count and offset"
15268 test_mkdir $DIR/$tdir
15269 $LFS setstripe --stripe-index 0 $DIR/$tdir
15271 check_default_stripe_attr --stripe-count --raw
15272 check_default_stripe_attr --stripe-size --raw
15274 run_test 204h "Print raw stripe count and size"
15276 # Figure out which job scheduler is being used, if any,
15277 # or use a fake one
15278 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
15279 JOBENV=SLURM_JOB_ID
15280 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
15282 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
15284 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
15285 JOBENV=LOADL_STEP_ID
15286 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
15289 $LCTL list_param jobid_name > /dev/null 2>&1
15290 if [ $? -eq 0 ]; then
15296 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
15298 verify_jobstats() {
15303 # we don't really need to clear the stats for this test to work, since each
15304 # command has a unique jobid, but it makes debugging easier if needed.
15305 # for facet in $facets; do
15306 # local dev=$(convert_facet2label $facet)
15307 # # clear old jobstats
15308 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
15311 # use a new JobID for each test, or we might see an old one
15312 [ "$JOBENV" = "FAKE_JOBID" ] &&
15313 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
15315 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
15317 [ "$JOBENV" = "nodelocal" ] && {
15318 FAKE_JOBID=id.$testnum.%e.$RANDOM
15319 $LCTL set_param jobid_name=$FAKE_JOBID
15320 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
15323 log "Test: ${cmd[*]}"
15324 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
15326 if [ $JOBENV = "FAKE_JOBID" ]; then
15327 FAKE_JOBID=$JOBVAL ${cmd[*]}
15332 # all files are created on OST0000
15333 for facet in $facets; do
15334 local stats="*.$(convert_facet2label $facet).job_stats"
15336 # strip out libtool wrappers for in-tree executables
15337 if [ $(do_facet $facet lctl get_param $stats |
15338 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
15339 do_facet $facet lctl get_param $stats
15340 error "No jobstats for $JOBVAL found on $facet::$stats"
15346 local new_jobenv=$1
15348 set_persistent_param_and_check client "jobid_var" \
15349 "$FSNAME.sys.jobid_var" $new_jobenv
15352 test_205() { # Job stats
15353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15354 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
15355 skip "Need MDS version with at least 2.7.1"
15356 remote_mgs_nodsh && skip "remote MGS with nodsh"
15357 remote_mds_nodsh && skip "remote MDS with nodsh"
15358 remote_ost_nodsh && skip "remote OST with nodsh"
15359 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
15360 skip "Server doesn't support jobstats"
15361 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
15363 local old_jobenv=$($LCTL get_param -n jobid_var)
15364 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
15366 if [[ $PERM_CMD == *"set_param -P"* ]]; then
15367 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
15369 stack_trap "do_facet mgs $PERM_CMD \
15370 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
15374 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
15375 mdt.*.job_cleanup_interval | head -n 1)
15376 local new_interval=5
15377 do_facet $SINGLEMDS \
15378 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
15379 stack_trap "do_facet $SINGLEMDS \
15380 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
15381 local start=$SECONDS
15385 cmd="mkdir $DIR/$tdir"
15386 verify_jobstats "$cmd" "$SINGLEMDS"
15388 cmd="rmdir $DIR/$tdir"
15389 verify_jobstats "$cmd" "$SINGLEMDS"
15390 # mkdir on secondary MDT
15391 if [ $MDSCOUNT -gt 1 ]; then
15392 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
15393 verify_jobstats "$cmd" "mds2"
15396 cmd="mknod $DIR/$tfile c 1 3"
15397 verify_jobstats "$cmd" "$SINGLEMDS"
15399 cmd="rm -f $DIR/$tfile"
15400 verify_jobstats "$cmd" "$SINGLEMDS"
15401 # create all files on OST0000 so verify_jobstats can find OST stats
15403 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
15404 verify_jobstats "$cmd" "$SINGLEMDS"
15406 cmd="touch $DIR/$tfile"
15407 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15409 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
15410 verify_jobstats "$cmd" "ost1"
15412 cancel_lru_locks osc
15413 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
15414 verify_jobstats "$cmd" "ost1"
15416 cmd="$TRUNCATE $DIR/$tfile 0"
15417 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15419 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
15420 verify_jobstats "$cmd" "$SINGLEMDS"
15421 # jobstats expiry - sleep until old stats should be expired
15422 local left=$((new_interval + 5 - (SECONDS - start)))
15423 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
15424 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
15426 cmd="mkdir $DIR/$tdir.expire"
15427 verify_jobstats "$cmd" "$SINGLEMDS"
15428 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
15429 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
15431 # Ensure that jobid are present in changelog (if supported by MDS)
15432 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
15433 changelog_dump | tail -10
15434 jobids=$(changelog_dump | tail -9 | grep -c "j=")
15435 [ $jobids -eq 9 ] ||
15436 error "Wrong changelog jobid count $jobids != 9"
15440 jobstats_set $JOBENV
15442 changelog_dump | grep $tfile
15443 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
15444 [ $jobids -eq 0 ] ||
15445 error "Unexpected jobids when jobid_var=$JOBENV"
15448 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
15449 JOBENV="JOBCOMPLEX"
15450 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
15452 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
15454 run_test 205 "Verify job stats"
15456 # LU-1480, LU-1773 and LU-1657
15458 mkdir -p $DIR/$tdir
15459 $LFS setstripe -c -1 $DIR/$tdir
15460 #define OBD_FAIL_LOV_INIT 0x1403
15461 $LCTL set_param fail_loc=0xa0001403
15462 $LCTL set_param fail_val=1
15463 touch $DIR/$tdir/$tfile || true
15465 run_test 206 "fail lov_init_raid0() doesn't lbug"
15468 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15469 local fsz=`stat -c %s $DIR/$tfile`
15470 cancel_lru_locks mdc
15472 # do not return layout in getattr intent
15473 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
15474 $LCTL set_param fail_loc=0x170
15475 local sz=`stat -c %s $DIR/$tfile`
15477 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
15481 run_test 207a "can refresh layout at glimpse"
15484 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15485 local cksum=`md5sum $DIR/$tfile`
15486 local fsz=`stat -c %s $DIR/$tfile`
15487 cancel_lru_locks mdc
15488 cancel_lru_locks osc
15490 # do not return layout in getattr intent
15491 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
15492 $LCTL set_param fail_loc=0x171
15494 # it will refresh layout after the file is opened but before read issues
15495 echo checksum is "$cksum"
15496 echo "$cksum" |md5sum -c --quiet || error "file differs"
15500 run_test 207b "can refresh layout at open"
15503 # FIXME: in this test suite, only RD lease is used. This is okay
15504 # for now as only exclusive open is supported. After generic lease
15505 # is done, this test suite should be revised. - Jinshan
15507 remote_mds_nodsh && skip "remote MDS with nodsh"
15508 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
15509 skip "Need MDS version at least 2.4.52"
15511 echo "==== test 1: verify get lease work"
15512 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
15514 echo "==== test 2: verify lease can be broken by upcoming open"
15515 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15519 $MULTIOP $DIR/$tfile oO_RDONLY:c
15520 kill -USR1 $PID && wait $PID || error "break lease error"
15522 echo "==== test 3: verify lease can't be granted if an open already exists"
15523 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
15527 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
15528 kill -USR1 $PID && wait $PID || error "open file error"
15530 echo "==== test 4: lease can sustain over recovery"
15531 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
15537 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
15539 echo "==== test 5: lease broken can't be regained by replay"
15540 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15544 # open file to break lease and then recovery
15545 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
15548 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
15552 run_test 208 "Exclusive open"
15555 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
15556 skip_env "must have disp_stripe"
15559 sync; sleep 5; sync;
15561 echo 3 > /proc/sys/vm/drop_caches
15562 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15564 # open/close 500 times
15565 for i in $(seq 500); do
15569 echo 3 > /proc/sys/vm/drop_caches
15570 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15572 echo "before: $req_before, after: $req_after"
15573 [ $((req_after - req_before)) -ge 300 ] &&
15574 error "open/close requests are not freed"
15577 run_test 209 "read-only open/close requests should be freed promptly"
15581 size=$((size % 8192 + 1))
15582 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
15583 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
15584 rm -f $DIR/f212 $DIR/f212.xyz
15586 run_test 212 "Sendfile test ============================================"
15589 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
15590 cancel_lru_locks osc
15591 lctl set_param fail_loc=0x8000040f
15592 # generate a read lock
15593 cat $DIR/$tfile > /dev/null
15594 # write to the file, it will try to cancel the above read lock.
15595 cat /etc/hosts >> $DIR/$tfile
15597 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
15599 test_214() { # for bug 20133
15600 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
15601 for (( i=0; i < 340; i++ )) ; do
15602 touch $DIR/$tdir/d214c/a$i
15605 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
15606 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
15607 ls $DIR/d214c || error "ls $DIR/d214c failed"
15608 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
15609 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
15611 run_test 214 "hash-indexed directory test - bug 20133"
15613 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
15614 create_lnet_proc_files() {
15615 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
15618 # counterpart of create_lnet_proc_files
15619 remove_lnet_proc_files() {
15620 rm -f $TMP/lnet_$1.sys
15623 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15624 # 3rd arg as regexp for body
15625 check_lnet_proc_stats() {
15626 local l=$(cat "$TMP/lnet_$1" |wc -l)
15627 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
15629 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
15632 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15633 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
15634 # optional and can be regexp for 2nd line (lnet.routes case)
15635 check_lnet_proc_entry() {
15636 local blp=2 # blp stands for 'position of 1st line of body'
15637 [ -z "$5" ] || blp=3 # lnet.routes case
15639 local l=$(cat "$TMP/lnet_$1" |wc -l)
15640 # subtracting one from $blp because the body can be empty
15641 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
15643 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
15644 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
15646 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
15647 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
15649 # bail out if any unexpected line happened
15650 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
15651 [ "$?" != 0 ] || error "$2 misformatted"
15654 test_215() { # for bugs 18102, 21079, 21517
15655 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15657 local N='(0|[1-9][0-9]*)' # non-negative numeric
15658 local P='[1-9][0-9]*' # positive numeric
15659 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
15660 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
15661 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
15662 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
15664 local L1 # regexp for 1st line
15665 local L2 # regexp for 2nd line (optional)
15666 local BR # regexp for the rest (body)
15668 # lnet.stats should look as 11 space-separated non-negative numerics
15669 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
15670 create_lnet_proc_files "stats"
15671 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
15672 remove_lnet_proc_files "stats"
15674 # lnet.routes should look like this:
15675 # Routing disabled/enabled
15676 # net hops priority state router
15677 # where net is a string like tcp0, hops > 0, priority >= 0,
15678 # state is up/down,
15679 # router is a string like 192.168.1.1@tcp2
15680 L1="^Routing (disabled|enabled)$"
15681 L2="^net +hops +priority +state +router$"
15682 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
15683 create_lnet_proc_files "routes"
15684 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
15685 remove_lnet_proc_files "routes"
15687 # lnet.routers should look like this:
15688 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
15689 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
15690 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
15691 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
15692 L1="^ref +rtr_ref +alive +router$"
15693 BR="^$P +$P +(up|down) +$NID$"
15694 create_lnet_proc_files "routers"
15695 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
15696 remove_lnet_proc_files "routers"
15698 # lnet.peers should look like this:
15699 # nid refs state last max rtr min tx min queue
15700 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
15701 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
15702 # numeric (0 or >0 or <0), queue >= 0.
15703 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
15704 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
15705 create_lnet_proc_files "peers"
15706 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
15707 remove_lnet_proc_files "peers"
15709 # lnet.buffers should look like this:
15710 # pages count credits min
15711 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
15712 L1="^pages +count +credits +min$"
15713 BR="^ +$N +$N +$I +$I$"
15714 create_lnet_proc_files "buffers"
15715 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
15716 remove_lnet_proc_files "buffers"
15718 # lnet.nis should look like this:
15719 # nid status alive refs peer rtr max tx min
15720 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
15721 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
15722 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
15723 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
15724 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
15725 create_lnet_proc_files "nis"
15726 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
15727 remove_lnet_proc_files "nis"
15729 # can we successfully write to lnet.stats?
15730 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
15732 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
15734 test_216() { # bug 20317
15735 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15736 remote_ost_nodsh && skip "remote OST with nodsh"
15739 local facets=$(get_facets OST)
15740 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15742 save_lustre_params client "osc.*.contention_seconds" > $p
15743 save_lustre_params $facets \
15744 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
15745 save_lustre_params $facets \
15746 "ldlm.namespaces.filter-*.contended_locks" >> $p
15747 save_lustre_params $facets \
15748 "ldlm.namespaces.filter-*.contention_seconds" >> $p
15749 clear_stats osc.*.osc_stats
15751 # agressive lockless i/o settings
15752 do_nodes $(comma_list $(osts_nodes)) \
15753 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
15754 ldlm.namespaces.filter-*.contended_locks=0 \
15755 ldlm.namespaces.filter-*.contention_seconds=60"
15756 lctl set_param -n osc.*.contention_seconds=60
15758 $DIRECTIO write $DIR/$tfile 0 10 4096
15759 $CHECKSTAT -s 40960 $DIR/$tfile
15761 # disable lockless i/o
15762 do_nodes $(comma_list $(osts_nodes)) \
15763 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
15764 ldlm.namespaces.filter-*.contended_locks=32 \
15765 ldlm.namespaces.filter-*.contention_seconds=0"
15766 lctl set_param -n osc.*.contention_seconds=0
15767 clear_stats osc.*.osc_stats
15769 dd if=/dev/zero of=$DIR/$tfile count=0
15770 $CHECKSTAT -s 0 $DIR/$tfile
15772 restore_lustre_params <$p
15776 run_test 216 "check lockless direct write updates file size and kms correctly"
15778 test_217() { # bug 22430
15779 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15784 for node in $(nodes_list); do
15785 nid=$(host_nids_address $node $NETTYPE)
15786 if [[ $nid = *-* ]] ; then
15787 echo "lctl ping $(h2nettype $nid)"
15788 lctl ping $(h2nettype $nid)
15790 echo "skipping $node (no hyphen detected)"
15794 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
15797 # do directio so as not to populate the page cache
15798 log "creating a 10 Mb file"
15799 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
15800 log "starting reads"
15801 dd if=$DIR/$tfile of=/dev/null bs=4096 &
15802 log "truncating the file"
15803 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
15805 kill %+ || true # reads might have finished
15806 echo "wait until dd is finished"
15808 log "removing the temporary file"
15809 rm -rf $DIR/$tfile || error "tmp file removal failed"
15811 run_test 218 "parallel read and truncate should not deadlock"
15814 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15816 # write one partial page
15817 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
15818 # set no grant so vvp_io_commit_write will do sync write
15819 $LCTL set_param fail_loc=0x411
15820 # write a full page at the end of file
15821 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
15823 $LCTL set_param fail_loc=0
15824 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
15825 $LCTL set_param fail_loc=0x411
15826 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
15829 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
15830 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
15832 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
15834 test_220() { #LU-325
15835 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15836 remote_ost_nodsh && skip "remote OST with nodsh"
15837 remote_mds_nodsh && skip "remote MDS with nodsh"
15838 remote_mgs_nodsh && skip "remote MGS with nodsh"
15842 # create on MDT0000 so the last_id and next_id are correct
15844 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
15848 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
15849 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
15850 osp.$mdtosc_proc1.prealloc_last_id)
15851 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
15852 osp.$mdtosc_proc1.prealloc_next_id)
15856 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
15857 #define OBD_FAIL_OST_ENOINO 0x229
15858 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
15859 create_pool $FSNAME.$TESTNAME || return 1
15860 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
15862 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
15864 MDSOBJS=$((last_id - next_id))
15865 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
15867 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
15868 echo "OST still has $count kbytes free"
15870 echo "create $MDSOBJS files @next_id..."
15871 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
15873 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15874 osp.$mdtosc_proc1.prealloc_last_id)
15875 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15876 osp.$mdtosc_proc1.prealloc_next_id)
15878 echo "after creation, last_id=$last_id2, next_id=$next_id2"
15883 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
15884 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
15886 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
15887 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
15888 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15889 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
15890 echo "unlink $MDSOBJS files @$next_id..."
15891 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
15893 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
15896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15898 dd if=`which date` of=$MOUNT/date oflag=sync
15899 chmod +x $MOUNT/date
15901 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
15902 $LCTL set_param fail_loc=0x80001401
15904 $MOUNT/date > /dev/null
15907 run_test 221 "make sure fault and truncate race to not cause OOM"
15910 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15913 test_mkdir $DIR/$tdir
15914 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15915 createmany -o $DIR/$tdir/$tfile 10
15916 cancel_lru_locks mdc
15917 cancel_lru_locks osc
15918 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15919 $LCTL set_param fail_loc=0x31a
15920 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
15921 $LCTL set_param fail_loc=0
15924 run_test 222a "AGL for ls should not trigger CLIO lock failure"
15927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15930 test_mkdir $DIR/$tdir
15931 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15932 createmany -o $DIR/$tdir/$tfile 10
15933 cancel_lru_locks mdc
15934 cancel_lru_locks osc
15935 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15936 $LCTL set_param fail_loc=0x31a
15937 rm -r $DIR/$tdir || error "AGL for rmdir failed"
15938 $LCTL set_param fail_loc=0
15940 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
15943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15946 test_mkdir $DIR/$tdir
15947 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15948 createmany -o $DIR/$tdir/$tfile 10
15949 cancel_lru_locks mdc
15950 cancel_lru_locks osc
15951 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
15952 $LCTL set_param fail_loc=0x31b
15953 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
15954 $LCTL set_param fail_loc=0
15957 run_test 223 "osc reenqueue if without AGL lock granted ======================="
15959 test_224a() { # LU-1039, MRP-303
15960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15962 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
15963 $LCTL set_param fail_loc=0x508
15964 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
15965 $LCTL set_param fail_loc=0
15968 run_test 224a "Don't panic on bulk IO failure"
15970 test_224b() { # LU-1039, MRP-303
15971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15973 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
15974 cancel_lru_locks osc
15975 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
15976 $LCTL set_param fail_loc=0x515
15977 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
15978 $LCTL set_param fail_loc=0
15981 run_test 224b "Don't panic on bulk IO failure"
15983 test_224c() { # LU-6441
15984 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15985 remote_mds_nodsh && skip "remote MDS with nodsh"
15987 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15988 save_writethrough $p
15989 set_cache writethrough on
15991 local pages_per_rpc=$($LCTL get_param \
15992 osc.*.max_pages_per_rpc)
15993 local at_max=$($LCTL get_param -n at_max)
15994 local timeout=$($LCTL get_param -n timeout)
15995 local test_at="at_max"
15996 local param_at="$FSNAME.sys.at_max"
15997 local test_timeout="timeout"
15998 local param_timeout="$FSNAME.sys.timeout"
16000 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
16002 set_persistent_param_and_check client "$test_at" "$param_at" 0
16003 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
16005 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
16006 do_facet ost1 "$LCTL set_param fail_loc=0x520"
16007 $LFS setstripe -c 1 -i 0 $DIR/$tfile
16008 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
16010 do_facet ost1 "$LCTL set_param fail_loc=0"
16012 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
16013 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
16016 $LCTL set_param -n $pages_per_rpc
16017 restore_lustre_params < $p
16020 run_test 224c "Don't hang if one of md lost during large bulk RPC"
16022 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
16024 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16025 if [ -z ${MDSSURVEY} ]; then
16026 skip_env "mds-survey not found"
16028 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16029 skip "Need MDS version at least 2.2.51"
16031 local mds=$(facet_host $SINGLEMDS)
16032 local target=$(do_nodes $mds 'lctl dl' |
16033 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16035 local cmd1="file_count=1000 thrhi=4"
16036 local cmd2="dir_count=2 layer=mdd stripe_count=0"
16037 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16038 local cmd="$cmd1 $cmd2 $cmd3"
16040 rm -f ${TMP}/mds_survey*
16042 eval $cmd || error "mds-survey with zero-stripe failed"
16043 cat ${TMP}/mds_survey*
16044 rm -f ${TMP}/mds_survey*
16046 run_test 225a "Metadata survey sanity with zero-stripe"
16049 if [ -z ${MDSSURVEY} ]; then
16050 skip_env "mds-survey not found"
16052 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16053 skip "Need MDS version at least 2.2.51"
16054 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16055 remote_mds_nodsh && skip "remote MDS with nodsh"
16056 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
16057 skip_env "Need to mount OST to test"
16060 local mds=$(facet_host $SINGLEMDS)
16061 local target=$(do_nodes $mds 'lctl dl' |
16062 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16064 local cmd1="file_count=1000 thrhi=4"
16065 local cmd2="dir_count=2 layer=mdd stripe_count=1"
16066 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16067 local cmd="$cmd1 $cmd2 $cmd3"
16069 rm -f ${TMP}/mds_survey*
16071 eval $cmd || error "mds-survey with stripe_count failed"
16072 cat ${TMP}/mds_survey*
16073 rm -f ${TMP}/mds_survey*
16075 run_test 225b "Metadata survey sanity with stripe_count = 1"
16077 mcreate_path2fid () {
16083 local path=$DIR/$tdir/$name
16088 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
16089 error "cannot create $desc"
16091 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
16093 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
16095 fid_path=$($LFS fid2path $MOUNT $fid)
16097 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
16099 [ "$path" == "$fid_path" ] ||
16100 error "fid2path returned $fid_path, expected $path"
16102 echo "pass with $path and $fid"
16107 mkdir -p $DIR/$tdir
16109 mcreate_path2fid 0010666 0 0 fifo "FIFO"
16110 mcreate_path2fid 0020666 1 3 null "character special file (null)"
16111 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
16112 mcreate_path2fid 0040666 0 0 dir "directory"
16113 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
16114 mcreate_path2fid 0100666 0 0 file "regular file"
16115 mcreate_path2fid 0120666 0 0 link "symbolic link"
16116 mcreate_path2fid 0140666 0 0 sock "socket"
16118 run_test 226a "call path2fid and fid2path on files of all type"
16121 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16126 mkdir -p $DIR/$tdir
16127 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
16128 error "create remote directory failed"
16129 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
16130 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
16131 "character special file (null)"
16132 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
16133 "character special file (no device)"
16134 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
16135 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
16136 "block special file (loop)"
16137 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
16138 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
16139 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
16141 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
16143 # LU-1299 Executing or running ldd on a truncated executable does not
16144 # cause an out-of-memory condition.
16146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16147 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
16149 dd if=$(which date) of=$MOUNT/date bs=1k count=1
16150 chmod +x $MOUNT/date
16152 $MOUNT/date > /dev/null
16153 ldd $MOUNT/date > /dev/null
16156 run_test 227 "running truncated executable does not cause OOM"
16158 # LU-1512 try to reuse idle OI blocks
16160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16161 remote_mds_nodsh && skip "remote MDS with nodsh"
16162 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16164 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16165 local myDIR=$DIR/$tdir
16168 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16169 $LCTL set_param fail_loc=0x80001002
16170 createmany -o $myDIR/t- 10000
16171 $LCTL set_param fail_loc=0
16172 # The guard is current the largest FID holder
16174 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16176 local IDX=$(($SEQ % 64))
16178 do_facet $SINGLEMDS sync
16179 # Make sure journal flushed.
16181 local blk1=$(do_facet $SINGLEMDS \
16182 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16183 grep Blockcount | awk '{print $4}')
16185 # Remove old files, some OI blocks will become idle.
16186 unlinkmany $myDIR/t- 10000
16187 # Create new files, idle OI blocks should be reused.
16188 createmany -o $myDIR/t- 2000
16189 do_facet $SINGLEMDS sync
16190 # Make sure journal flushed.
16192 local blk2=$(do_facet $SINGLEMDS \
16193 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16194 grep Blockcount | awk '{print $4}')
16196 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16198 run_test 228a "try to reuse idle OI blocks"
16201 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16202 remote_mds_nodsh && skip "remote MDS with nodsh"
16203 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16205 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16206 local myDIR=$DIR/$tdir
16209 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16210 $LCTL set_param fail_loc=0x80001002
16211 createmany -o $myDIR/t- 10000
16212 $LCTL set_param fail_loc=0
16213 # The guard is current the largest FID holder
16215 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16217 local IDX=$(($SEQ % 64))
16219 do_facet $SINGLEMDS sync
16220 # Make sure journal flushed.
16222 local blk1=$(do_facet $SINGLEMDS \
16223 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16224 grep Blockcount | awk '{print $4}')
16226 # Remove old files, some OI blocks will become idle.
16227 unlinkmany $myDIR/t- 10000
16230 stop $SINGLEMDS || error "Fail to stop MDT."
16232 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
16234 df $MOUNT || error "Fail to df."
16235 # Create new files, idle OI blocks should be reused.
16236 createmany -o $myDIR/t- 2000
16237 do_facet $SINGLEMDS sync
16238 # Make sure journal flushed.
16240 local blk2=$(do_facet $SINGLEMDS \
16241 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16242 grep Blockcount | awk '{print $4}')
16244 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16246 run_test 228b "idle OI blocks can be reused after MDT restart"
16250 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16251 remote_mds_nodsh && skip "remote MDS with nodsh"
16252 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16254 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16255 local myDIR=$DIR/$tdir
16258 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16259 $LCTL set_param fail_loc=0x80001002
16260 # 20000 files can guarantee there are index nodes in the OI file
16261 createmany -o $myDIR/t- 20000
16262 $LCTL set_param fail_loc=0
16263 # The guard is current the largest FID holder
16265 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16267 local IDX=$(($SEQ % 64))
16269 do_facet $SINGLEMDS sync
16270 # Make sure journal flushed.
16272 local blk1=$(do_facet $SINGLEMDS \
16273 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16274 grep Blockcount | awk '{print $4}')
16276 # Remove old files, some OI blocks will become idle.
16277 unlinkmany $myDIR/t- 20000
16279 # The OI file should become empty now
16281 # Create new files, idle OI blocks should be reused.
16282 createmany -o $myDIR/t- 2000
16283 do_facet $SINGLEMDS sync
16284 # Make sure journal flushed.
16286 local blk2=$(do_facet $SINGLEMDS \
16287 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16288 grep Blockcount | awk '{print $4}')
16290 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16292 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
16294 test_229() { # LU-2482, LU-3448
16295 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16296 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
16297 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
16298 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
16302 # Create a file with a released layout and stripe count 2.
16303 $MULTIOP $DIR/$tfile H2c ||
16304 error "failed to create file with released layout"
16306 $LFS getstripe -v $DIR/$tfile
16308 local pattern=$($LFS getstripe -L $DIR/$tfile)
16309 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
16311 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
16313 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
16314 stat $DIR/$tfile || error "failed to stat released file"
16316 chown $RUNAS_ID $DIR/$tfile ||
16317 error "chown $RUNAS_ID $DIR/$tfile failed"
16319 chgrp $RUNAS_ID $DIR/$tfile ||
16320 error "chgrp $RUNAS_ID $DIR/$tfile failed"
16322 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
16323 rm $DIR/$tfile || error "failed to remove released file"
16325 run_test 229 "getstripe/stat/rm/attr changes work on released files"
16328 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16329 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16330 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16331 skip "Need MDS version at least 2.11.52"
16335 test_mkdir $DIR/$tdir
16336 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
16337 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
16338 [ $mdt_idx -ne 0 ] &&
16339 error "create local directory on wrong MDT $mdt_idx"
16341 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
16342 error "create remote directory failed"
16343 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
16344 [ $mdt_idx -ne $MDTIDX ] &&
16345 error "create remote directory on wrong MDT $mdt_idx"
16347 createmany -o $DIR/$tdir/test_230/t- 10 ||
16348 error "create files on remote directory failed"
16349 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
16350 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
16351 rm -r $DIR/$tdir || error "unlink remote directory failed"
16353 run_test 230a "Create remote directory and files under the remote directory"
16356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16357 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16358 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16359 skip "Need MDS version at least 2.11.52"
16367 local migrate_dir=$DIR/$tdir/migrate_dir
16368 local other_dir=$DIR/$tdir/other_dir
16370 test_mkdir $DIR/$tdir
16371 test_mkdir -i0 -c1 $migrate_dir
16372 test_mkdir -i0 -c1 $other_dir
16373 for ((i=0; i<10; i++)); do
16374 mkdir -p $migrate_dir/dir_${i}
16375 createmany -o $migrate_dir/dir_${i}/f 10 ||
16376 error "create files under remote dir failed $i"
16379 cp /etc/passwd $migrate_dir/$tfile
16380 cp /etc/passwd $other_dir/$tfile
16381 chattr +SAD $migrate_dir
16382 chattr +SAD $migrate_dir/$tfile
16384 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16385 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16386 local old_dir_mode=$(stat -c%f $migrate_dir)
16387 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
16389 mkdir -p $migrate_dir/dir_default_stripe2
16390 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
16391 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
16393 mkdir -p $other_dir
16394 ln $migrate_dir/$tfile $other_dir/luna
16395 ln $migrate_dir/$tfile $migrate_dir/sofia
16396 ln $other_dir/$tfile $migrate_dir/david
16397 ln -s $migrate_dir/$tfile $other_dir/zachary
16398 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
16399 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
16401 $LFS migrate -m $MDTIDX $migrate_dir ||
16402 error "fails on migrating remote dir to MDT1"
16404 echo "migratate to MDT1, then checking.."
16405 for ((i = 0; i < 10; i++)); do
16406 for file in $(find $migrate_dir/dir_${i}); do
16407 mdt_index=$($LFS getstripe -m $file)
16408 [ $mdt_index == $MDTIDX ] ||
16409 error "$file is not on MDT${MDTIDX}"
16413 # the multiple link file should still in MDT0
16414 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
16415 [ $mdt_index == 0 ] ||
16416 error "$file is not on MDT${MDTIDX}"
16418 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16419 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16420 error " expect $old_dir_flag get $new_dir_flag"
16422 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16423 [ "$old_file_flag" = "$new_file_flag" ] ||
16424 error " expect $old_file_flag get $new_file_flag"
16426 local new_dir_mode=$(stat -c%f $migrate_dir)
16427 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16428 error "expect mode $old_dir_mode get $new_dir_mode"
16430 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16431 [ "$old_file_mode" = "$new_file_mode" ] ||
16432 error "expect mode $old_file_mode get $new_file_mode"
16434 diff /etc/passwd $migrate_dir/$tfile ||
16435 error "$tfile different after migration"
16437 diff /etc/passwd $other_dir/luna ||
16438 error "luna different after migration"
16440 diff /etc/passwd $migrate_dir/sofia ||
16441 error "sofia different after migration"
16443 diff /etc/passwd $migrate_dir/david ||
16444 error "david different after migration"
16446 diff /etc/passwd $other_dir/zachary ||
16447 error "zachary different after migration"
16449 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16450 error "${tfile}_ln different after migration"
16452 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16453 error "${tfile}_ln_other different after migration"
16455 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
16456 [ $stripe_count = 2 ] ||
16457 error "dir strpe_count $d != 2 after migration."
16459 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
16460 [ $stripe_count = 2 ] ||
16461 error "file strpe_count $d != 2 after migration."
16463 #migrate back to MDT0
16466 $LFS migrate -m $MDTIDX $migrate_dir ||
16467 error "fails on migrating remote dir to MDT0"
16469 echo "migrate back to MDT0, checking.."
16470 for file in $(find $migrate_dir); do
16471 mdt_index=$($LFS getstripe -m $file)
16472 [ $mdt_index == $MDTIDX ] ||
16473 error "$file is not on MDT${MDTIDX}"
16476 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16477 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16478 error " expect $old_dir_flag get $new_dir_flag"
16480 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16481 [ "$old_file_flag" = "$new_file_flag" ] ||
16482 error " expect $old_file_flag get $new_file_flag"
16484 local new_dir_mode=$(stat -c%f $migrate_dir)
16485 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16486 error "expect mode $old_dir_mode get $new_dir_mode"
16488 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16489 [ "$old_file_mode" = "$new_file_mode" ] ||
16490 error "expect mode $old_file_mode get $new_file_mode"
16492 diff /etc/passwd ${migrate_dir}/$tfile ||
16493 error "$tfile different after migration"
16495 diff /etc/passwd ${other_dir}/luna ||
16496 error "luna different after migration"
16498 diff /etc/passwd ${migrate_dir}/sofia ||
16499 error "sofia different after migration"
16501 diff /etc/passwd ${other_dir}/zachary ||
16502 error "zachary different after migration"
16504 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16505 error "${tfile}_ln different after migration"
16507 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16508 error "${tfile}_ln_other different after migration"
16510 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
16511 [ $stripe_count = 2 ] ||
16512 error "dir strpe_count $d != 2 after migration."
16514 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
16515 [ $stripe_count = 2 ] ||
16516 error "file strpe_count $d != 2 after migration."
16518 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16520 run_test 230b "migrate directory"
16523 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16524 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16525 remote_mds_nodsh && skip "remote MDS with nodsh"
16526 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16527 skip "Need MDS version at least 2.11.52"
16533 local migrate_dir=$DIR/$tdir/migrate_dir
16535 #If migrating directory fails in the middle, all entries of
16536 #the directory is still accessiable.
16537 test_mkdir $DIR/$tdir
16538 test_mkdir -i0 -c1 $migrate_dir
16539 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
16541 createmany -o $migrate_dir/f $total ||
16542 error "create files under ${migrate_dir} failed"
16544 # fail after migrating top dir, and this will fail only once, so the
16545 # first sub file migration will fail (currently f3), others succeed.
16546 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
16547 do_facet mds1 lctl set_param fail_loc=0x1801
16548 local t=$(ls $migrate_dir | wc -l)
16549 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
16550 error "migrate should fail"
16551 local u=$(ls $migrate_dir | wc -l)
16552 [ "$u" == "$t" ] || error "$u != $t during migration"
16554 # add new dir/file should succeed
16555 mkdir $migrate_dir/dir ||
16556 error "mkdir failed under migrating directory"
16557 touch $migrate_dir/file ||
16558 error "create file failed under migrating directory"
16560 # add file with existing name should fail
16561 for file in $migrate_dir/f*; do
16562 stat $file > /dev/null || error "stat $file failed"
16563 $OPENFILE -f O_CREAT:O_EXCL $file &&
16564 error "open(O_CREAT|O_EXCL) $file should fail"
16565 $MULTIOP $file m && error "create $file should fail"
16566 touch $DIR/$tdir/remote_dir/$tfile ||
16567 error "touch $tfile failed"
16568 ln $DIR/$tdir/remote_dir/$tfile $file &&
16569 error "link $file should fail"
16570 mdt_index=$($LFS getstripe -m $file)
16571 if [ $mdt_index == 0 ]; then
16572 # file failed to migrate is not allowed to rename to
16573 mv $DIR/$tdir/remote_dir/$tfile $file &&
16574 error "rename to $file should fail"
16576 mv $DIR/$tdir/remote_dir/$tfile $file ||
16577 error "rename to $file failed"
16579 echo hello >> $file || error "write $file failed"
16582 # resume migration with different options should fail
16583 $LFS migrate -m 0 $migrate_dir &&
16584 error "migrate -m 0 $migrate_dir should fail"
16586 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
16587 error "migrate -c 2 $migrate_dir should fail"
16589 # resume migration should succeed
16590 $LFS migrate -m $MDTIDX $migrate_dir ||
16591 error "migrate $migrate_dir failed"
16593 echo "Finish migration, then checking.."
16594 for file in $(find $migrate_dir); do
16595 mdt_index=$($LFS getstripe -m $file)
16596 [ $mdt_index == $MDTIDX ] ||
16597 error "$file is not on MDT${MDTIDX}"
16600 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16602 run_test 230c "check directory accessiblity if migration failed"
16605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16606 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16607 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16608 skip "Need MDS version at least 2.11.52"
16610 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
16612 local migrate_dir=$DIR/$tdir/migrate_dir
16622 old_index=$((RANDOM % MDSCOUNT))
16623 old_count=$((MDSCOUNT - old_index))
16624 new_index=$((RANDOM % MDSCOUNT))
16625 new_count=$((MDSCOUNT - new_index))
16626 new_hash="all_char"
16628 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
16629 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
16631 test_mkdir $DIR/$tdir
16632 test_mkdir -i $old_index -c $old_count $migrate_dir
16634 for ((i=0; i<100; i++)); do
16635 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
16636 createmany -o $migrate_dir/dir_${i}/f 100 ||
16637 error "create files under remote dir failed $i"
16640 echo -n "Migrate from MDT$old_index "
16641 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
16642 echo -n "to MDT$new_index"
16643 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
16646 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
16647 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
16648 error "migrate remote dir error"
16650 echo "Finish migration, then checking.."
16651 for file in $(find $migrate_dir); do
16652 mdt_index=$($LFS getstripe -m $file)
16653 if [ $mdt_index -lt $new_index ] ||
16654 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
16655 error "$file is on MDT$mdt_index"
16659 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16661 run_test 230d "check migrate big directory"
16664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16665 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16666 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16667 skip "Need MDS version at least 2.11.52"
16674 mkdir -p $DIR/$tdir
16675 mkdir $DIR/$tdir/migrate_dir
16676 mkdir $DIR/$tdir/other_dir
16677 touch $DIR/$tdir/migrate_dir/a
16678 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
16679 ls $DIR/$tdir/other_dir
16681 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16682 error "migrate dir fails"
16684 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16685 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16687 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16688 [ $mdt_index == 0 ] || error "a is not on MDT0"
16690 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
16691 error "migrate dir fails"
16693 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
16694 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
16696 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16697 [ $mdt_index == 1 ] || error "a is not on MDT1"
16699 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
16700 [ $mdt_index == 1 ] || error "b is not on MDT1"
16702 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16703 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
16705 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
16707 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16709 run_test 230e "migrate mulitple local link files"
16712 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16713 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16714 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16715 skip "Need MDS version at least 2.11.52"
16720 mkdir -p $DIR/$tdir
16721 mkdir $DIR/$tdir/migrate_dir
16722 $LFS mkdir -i1 $DIR/$tdir/other_dir
16723 touch $DIR/$tdir/migrate_dir/a
16724 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
16725 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
16726 ls $DIR/$tdir/other_dir
16728 # a should be migrated to MDT1, since no other links on MDT0
16729 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16730 error "#1 migrate dir fails"
16731 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16732 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16733 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16734 [ $mdt_index == 1 ] || error "a is not on MDT1"
16736 # a should stay on MDT1, because it is a mulitple link file
16737 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16738 error "#2 migrate dir fails"
16739 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16740 [ $mdt_index == 1 ] || error "a is not on MDT1"
16742 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16743 error "#3 migrate dir fails"
16745 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16746 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
16747 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
16749 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
16750 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
16752 # a should be migrated to MDT0, since no other links on MDT1
16753 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16754 error "#4 migrate dir fails"
16755 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16756 [ $mdt_index == 0 ] || error "a is not on MDT0"
16758 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16760 run_test 230f "migrate mulitple remote link files"
16763 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16764 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16765 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16766 skip "Need MDS version at least 2.11.52"
16768 mkdir -p $DIR/$tdir/migrate_dir
16770 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
16771 error "migrating dir to non-exist MDT succeeds"
16774 run_test 230g "migrate dir to non-exist MDT"
16777 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16778 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16779 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16780 skip "Need MDS version at least 2.11.52"
16784 mkdir -p $DIR/$tdir/migrate_dir
16786 $LFS migrate -m1 $DIR &&
16787 error "migrating mountpoint1 should fail"
16789 $LFS migrate -m1 $DIR/$tdir/.. &&
16790 error "migrating mountpoint2 should fail"
16793 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
16794 error "migrating $tdir/migrate_dir/.. should fail"
16798 run_test 230h "migrate .. and root"
16801 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16802 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16803 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16804 skip "Need MDS version at least 2.11.52"
16806 mkdir -p $DIR/$tdir/migrate_dir
16808 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
16809 error "migration fails with a tailing slash"
16811 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
16812 error "migration fails with two tailing slashes"
16814 run_test 230i "lfs migrate -m tolerates trailing slashes"
16817 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16818 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16819 skip "Need MDS version at least 2.11.52"
16821 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
16822 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
16823 error "create $tfile failed"
16824 cat /etc/passwd > $DIR/$tdir/$tfile
16826 $LFS migrate -m 1 $DIR/$tdir
16828 cmp /etc/passwd $DIR/$tdir/$tfile ||
16829 error "DoM file mismatch after migration"
16831 run_test 230j "DoM file data not changed after dir migration"
16834 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
16835 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16836 skip "Need MDS version at least 2.11.56"
16839 local files_on_starting_mdt=0
16841 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
16842 $LFS getdirstripe $DIR/$tdir
16843 for i in $(seq $total); do
16844 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
16845 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16846 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16849 echo "$files_on_starting_mdt files on MDT0"
16851 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
16852 $LFS getdirstripe $DIR/$tdir
16854 files_on_starting_mdt=0
16855 for i in $(seq $total); do
16856 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16857 error "file $tfile.$i mismatch after migration"
16858 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
16859 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16862 echo "$files_on_starting_mdt files on MDT1 after migration"
16863 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
16865 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
16866 $LFS getdirstripe $DIR/$tdir
16868 files_on_starting_mdt=0
16869 for i in $(seq $total); do
16870 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16871 error "file $tfile.$i mismatch after 2nd migration"
16872 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16873 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16876 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
16877 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
16881 run_test 230k "file data not changed after dir migration"
16884 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16885 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16886 skip "Need MDS version at least 2.11.56"
16888 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
16889 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
16890 error "create files under remote dir failed $i"
16891 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
16893 run_test 230l "readdir between MDTs won't crash"
16897 # For simplicity this test assumes that max_pages_per_rpc
16898 # is the same across all OSCs
16899 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
16900 local bulk_size=$((max_pages * PAGE_SIZE))
16901 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
16904 mkdir -p $DIR/$tdir
16905 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
16906 error "failed to set stripe with -S ${brw_size}M option"
16908 # clear the OSC stats
16909 $LCTL set_param osc.*.stats=0 &>/dev/null
16912 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
16913 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
16914 oflag=direct &>/dev/null || error "dd failed"
16916 sync; sleep 1; sync # just to be safe
16917 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
16918 if [ x$nrpcs != "x1" ]; then
16919 $LCTL get_param osc.*.stats
16920 error "found $nrpcs ost_write RPCs, not 1 as expected"
16924 # Drop the OSC cache, otherwise we will read from it
16925 cancel_lru_locks osc
16927 # clear the OSC stats
16928 $LCTL set_param osc.*.stats=0 &>/dev/null
16930 # Client reads $bulk_size.
16931 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
16932 iflag=direct &>/dev/null || error "dd failed"
16934 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
16935 if [ x$nrpcs != "x1" ]; then
16936 $LCTL get_param osc.*.stats
16937 error "found $nrpcs ost_read RPCs, not 1 as expected"
16940 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
16943 mkdir -p $DIR/$tdir
16945 for i in {0..1023}; do
16946 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
16947 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
16948 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
16952 run_test 231b "must not assert on fully utilized OST request buffer"
16955 mkdir -p $DIR/$tdir
16956 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16958 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16959 do_facet ost1 $LCTL set_param fail_loc=0x31c
16961 # ignore dd failure
16962 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
16964 do_facet ost1 $LCTL set_param fail_loc=0
16965 umount_client $MOUNT || error "umount failed"
16966 mount_client $MOUNT || error "mount failed"
16967 stop ost1 || error "cannot stop ost1"
16968 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16970 run_test 232a "failed lock should not block umount"
16973 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
16974 skip "Need MDS version at least 2.10.58"
16976 mkdir -p $DIR/$tdir
16977 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16978 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
16980 cancel_lru_locks osc
16982 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16983 do_facet ost1 $LCTL set_param fail_loc=0x31c
16986 $LFS data_version $DIR/$tdir/$tfile || true
16988 do_facet ost1 $LCTL set_param fail_loc=0
16989 umount_client $MOUNT || error "umount failed"
16990 mount_client $MOUNT || error "mount failed"
16991 stop ost1 || error "cannot stop ost1"
16992 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16994 run_test 232b "failed data version lock should not block umount"
16997 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
16998 skip "Need MDS version at least 2.3.64"
16999 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
17001 local fid=$($LFS path2fid $MOUNT)
17003 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17004 error "cannot access $MOUNT using its FID '$fid'"
17006 run_test 233a "checking that OBF of the FS root succeeds"
17009 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
17010 skip "Need MDS version at least 2.5.90"
17011 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
17013 local fid=$($LFS path2fid $MOUNT/.lustre)
17015 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17016 error "cannot access $MOUNT/.lustre using its FID '$fid'"
17018 fid=$($LFS path2fid $MOUNT/.lustre/fid)
17019 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17020 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
17022 run_test 233b "checking that OBF of the FS .lustre succeeds"
17025 local p="$TMP/sanityN-$TESTNAME.parameters"
17026 save_lustre_params client "llite.*.xattr_cache" > $p
17027 lctl set_param llite.*.xattr_cache 1 ||
17028 skip_env "xattr cache is not supported"
17030 mkdir -p $DIR/$tdir || error "mkdir failed"
17031 touch $DIR/$tdir/$tfile || error "touch failed"
17032 # OBD_FAIL_LLITE_XATTR_ENOMEM
17033 $LCTL set_param fail_loc=0x1405
17034 getfattr -n user.attr $DIR/$tdir/$tfile &&
17035 error "getfattr should have failed with ENOMEM"
17036 $LCTL set_param fail_loc=0x0
17039 restore_lustre_params < $p
17042 run_test 234 "xattr cache should not crash on ENOMEM"
17045 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
17046 skip "Need MDS version at least 2.4.52"
17048 flock_deadlock $DIR/$tfile
17053 124) error "process hangs on a deadlock"
17055 *) error "error executing flock_deadlock $DIR/$tfile"
17059 run_test 235 "LU-1715: flock deadlock detection does not work properly"
17063 check_swap_layouts_support
17065 local ref1=/etc/passwd
17066 local ref2=/etc/group
17067 local file1=$DIR/$tdir/f1
17068 local file2=$DIR/$tdir/f2
17070 test_mkdir -c1 $DIR/$tdir
17071 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
17072 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
17073 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
17074 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
17075 local fd=$(free_fd)
17076 local cmd="exec $fd<>$file2"
17079 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
17080 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
17083 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
17088 run_test 236 "Layout swap on open unlinked file"
17090 # LU-4659 linkea consistency
17092 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
17093 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
17094 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
17095 skip "Need MDS version at least 2.5.58 or 2.5.2+"
17098 ln $DIR/$tfile $DIR/$tfile.lnk
17099 touch $DIR/$tfile.new
17100 mv $DIR/$tfile.new $DIR/$tfile
17101 local fid1=$($LFS path2fid $DIR/$tfile)
17102 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
17103 local path1=$($LFS fid2path $FSNAME "$fid1")
17104 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
17105 local path2=$($LFS fid2path $FSNAME "$fid2")
17106 [ $tfile.lnk == $path2 ] ||
17107 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
17110 run_test 238 "Verify linkea consistency"
17112 test_239A() { # was test_239
17113 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
17114 skip "Need MDS version at least 2.5.60"
17116 local list=$(comma_list $(mdts_nodes))
17118 mkdir -p $DIR/$tdir
17119 createmany -o $DIR/$tdir/f- 5000
17120 unlinkmany $DIR/$tdir/f- 5000
17121 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
17122 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
17123 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
17124 osp.*MDT*.sync_in_flight" | calc_sum)
17125 [ "$changes" -eq 0 ] || error "$changes not synced"
17127 run_test 239A "osp_sync test"
17129 test_239a() { #LU-5297
17130 remote_mds_nodsh && skip "remote MDS with nodsh"
17133 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
17134 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
17135 chgrp $RUNAS_GID $DIR/$tfile
17136 wait_delete_completed
17138 run_test 239a "process invalid osp sync record correctly"
17140 test_239b() { #LU-5297
17141 remote_mds_nodsh && skip "remote MDS with nodsh"
17144 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
17145 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
17146 chgrp $RUNAS_GID $DIR/$tfile1
17147 wait_delete_completed
17148 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17150 chgrp $RUNAS_GID $DIR/$tfile2
17151 wait_delete_completed
17153 run_test 239b "process osp sync record with ENOMEM error correctly"
17156 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17157 remote_mds_nodsh && skip "remote MDS with nodsh"
17159 mkdir -p $DIR/$tdir
17161 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
17162 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
17163 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
17164 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
17166 umount_client $MOUNT || error "umount failed"
17167 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
17168 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
17169 mount_client $MOUNT || error "failed to mount client"
17171 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
17172 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
17174 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
17180 for LOOP in $(seq $count); do
17181 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
17182 cancel_lru_locks $OSC || true
17190 for LOOP in $(seq $1); do
17191 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
17196 test_241a() { # was test_241
17197 local bsize=$PAGE_SIZE
17199 (( bsize < 40960 )) && bsize=40960
17200 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17202 cancel_lru_locks $OSC
17203 test_241_bio 1000 $bsize &
17205 test_241_dio 1000 $bsize
17208 run_test 241a "bio vs dio"
17211 local bsize=$PAGE_SIZE
17213 (( bsize < 40960 )) && bsize=40960
17214 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17216 test_241_dio 1000 $bsize &
17218 test_241_dio 1000 $bsize
17221 run_test 241b "dio vs dio"
17224 remote_mds_nodsh && skip "remote MDS with nodsh"
17226 mkdir -p $DIR/$tdir
17227 touch $DIR/$tdir/$tfile
17229 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
17230 do_facet mds1 lctl set_param fail_loc=0x105
17231 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
17233 do_facet mds1 lctl set_param fail_loc=0
17234 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
17236 run_test 242 "mdt_readpage failure should not cause directory unreadable"
17240 test_mkdir $DIR/$tdir
17241 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
17243 run_test 243 "various group lock tests"
17247 test_mkdir $DIR/$tdir
17248 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
17249 sendfile_grouplock $DIR/$tdir/$tfile || \
17250 error "sendfile+grouplock failed"
17253 run_test 244a "sendfile with group lock tests"
17257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17260 local size=$((1024*1024))
17262 test_mkdir $DIR/$tdir
17263 for i in $(seq 1 $threads); do
17264 local file=$DIR/$tdir/file_$((i / 10))
17265 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
17268 for i in $(seq 1 $threads); do
17272 run_test 244b "multi-threaded write with group lock"
17275 local flagname="multi_mod_rpcs"
17276 local connect_data_name="max_mod_rpcs"
17279 # check if multiple modify RPCs flag is set
17280 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
17281 grep "connect_flags:")
17284 echo "$out" | grep -qw $flagname
17285 if [ $? -ne 0 ]; then
17286 echo "connect flag $flagname is not set"
17290 # check if multiple modify RPCs data is set
17291 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
17294 echo "$out" | grep -qw $connect_data_name ||
17295 error "import should have connect data $connect_data_name"
17297 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
17299 test_246() { # LU-7371
17300 remote_ost_nodsh && skip "remote OST with nodsh"
17301 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
17302 skip "Need OST version >= 2.7.62"
17304 do_facet ost1 $LCTL set_param fail_val=4095
17305 #define OBD_FAIL_OST_READ_SIZE 0x234
17306 do_facet ost1 $LCTL set_param fail_loc=0x234
17307 $LFS setstripe $DIR/$tfile -i 0 -c 1
17308 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
17309 cancel_lru_locks $FSNAME-OST0000
17310 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
17312 run_test 246 "Read file of size 4095 should return right length"
17318 umount_client $submount
17323 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17325 skip_env "Fileset feature is not supported"
17327 local submount=${MOUNT}_$tdir
17330 mkdir -p $submount || error "mkdir $submount failed"
17331 FILESET="$FILESET/$tdir" mount_client $submount ||
17332 error "mount $submount failed"
17333 trap "cleanup_247 $submount" EXIT
17334 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
17335 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
17336 error "read $MOUNT/$tdir/$tfile failed"
17337 cleanup_247 $submount
17339 run_test 247a "mount subdir as fileset"
17342 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17343 skip_env "Fileset feature is not supported"
17345 local submount=${MOUNT}_$tdir
17347 rm -rf $MOUNT/$tdir
17348 mkdir -p $submount || error "mkdir $submount failed"
17350 FILESET="$FILESET/$tdir" mount_client $submount &&
17351 error "mount $submount should fail"
17354 run_test 247b "mount subdir that dose not exist"
17357 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17358 skip_env "Fileset feature is not supported"
17360 local submount=${MOUNT}_$tdir
17362 mkdir -p $MOUNT/$tdir/dir1
17363 mkdir -p $submount || error "mkdir $submount failed"
17364 trap "cleanup_247 $submount" EXIT
17365 FILESET="$FILESET/$tdir" mount_client $submount ||
17366 error "mount $submount failed"
17367 local fid=$($LFS path2fid $MOUNT/)
17368 $LFS fid2path $submount $fid && error "fid2path should fail"
17369 cleanup_247 $submount
17371 run_test 247c "running fid2path outside root"
17374 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17375 skip "Fileset feature is not supported"
17377 local submount=${MOUNT}_$tdir
17379 mkdir -p $MOUNT/$tdir/dir1
17380 mkdir -p $submount || error "mkdir $submount failed"
17381 FILESET="$FILESET/$tdir" mount_client $submount ||
17382 error "mount $submount failed"
17383 trap "cleanup_247 $submount" EXIT
17384 local fid=$($LFS path2fid $submount/dir1)
17385 $LFS fid2path $submount $fid || error "fid2path should succeed"
17386 cleanup_247 $submount
17388 run_test 247d "running fid2path inside root"
17392 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17394 skip "Fileset feature is not supported"
17396 local submount=${MOUNT}_$tdir
17399 mkdir -p $submount || error "mkdir $submount failed"
17400 FILESET="$FILESET/.." mount_client $submount &&
17401 error "mount $submount should fail"
17404 run_test 247e "mount .. as fileset"
17407 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
17408 [ -z "$fast_read_sav" ] && skip "no fast read support"
17410 # create a large file for fast read verification
17411 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
17413 # make sure the file is created correctly
17414 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
17415 { rm -f $DIR/$tfile; skip "file creation error"; }
17417 echo "Test 1: verify that fast read is 4 times faster on cache read"
17419 # small read with fast read enabled
17420 $LCTL set_param -n llite.*.fast_read=1
17421 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17422 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17423 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17424 # small read with fast read disabled
17425 $LCTL set_param -n llite.*.fast_read=0
17426 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17427 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17428 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17430 # verify that fast read is 4 times faster for cache read
17431 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
17432 error_not_in_vm "fast read was not 4 times faster: " \
17433 "$t_fast vs $t_slow"
17435 echo "Test 2: verify the performance between big and small read"
17436 $LCTL set_param -n llite.*.fast_read=1
17438 # 1k non-cache read
17439 cancel_lru_locks osc
17440 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17441 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17442 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17444 # 1M non-cache read
17445 cancel_lru_locks osc
17446 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17447 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17448 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17450 # verify that big IO is not 4 times faster than small IO
17451 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
17452 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
17454 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
17457 run_test 248 "fast read verification"
17459 test_249() { # LU-7890
17460 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
17461 skip "Need at least version 2.8.54"
17464 $LFS setstripe -c 1 $DIR/$tfile
17465 # Offset 2T == 4k * 512M
17466 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
17467 error "dd to 2T offset failed"
17469 run_test 249 "Write above 2T file size"
17472 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
17473 && skip "no 16TB file size limit on ZFS"
17475 $LFS setstripe -c 1 $DIR/$tfile
17476 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
17477 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
17478 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
17479 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
17480 conv=notrunc,fsync && error "append succeeded"
17483 run_test 250 "Write above 16T limit"
17486 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
17488 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
17489 #Skip once - writing the first stripe will succeed
17490 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17491 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
17492 error "short write happened"
17494 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17495 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
17496 error "short read happened"
17500 run_test 251 "Handling short read and write correctly"
17503 remote_mds_nodsh && skip "remote MDS with nodsh"
17504 remote_ost_nodsh && skip "remote OST with nodsh"
17505 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
17506 skip_env "ldiskfs only test"
17516 # check lr_reader on OST0000
17518 dev=$(facet_device $tgt)
17519 out=$(do_facet $tgt $LR_READER $dev)
17520 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17522 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
17523 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
17524 error "Invalid uuid returned by $LR_READER on target $tgt"
17525 echo -e "uuid returned by $LR_READER is '$uuid'\n"
17527 # check lr_reader -c on MDT0000
17529 dev=$(facet_device $tgt)
17530 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
17531 skip "$LR_READER does not support additional options"
17533 out=$(do_facet $tgt $LR_READER -c $dev)
17534 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17536 num=$(echo "$out" | grep -c "mdtlov")
17537 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
17538 error "Invalid number of mdtlov clients returned by $LR_READER"
17539 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
17541 # check lr_reader -cr on MDT0000
17542 out=$(do_facet $tgt $LR_READER -cr $dev)
17543 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17545 echo "$out" | grep -q "^reply_data:$" ||
17546 error "$LR_READER should have returned 'reply_data' section"
17547 num=$(echo "$out" | grep -c "client_generation")
17548 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
17550 run_test 252 "check lr_reader tool"
17553 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17554 remote_mds_nodsh && skip "remote MDS with nodsh"
17555 remote_mgs_nodsh && skip "remote MGS with nodsh"
17559 local ost_name=$(ostname_from_index $ostidx)
17562 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
17563 do_facet $SINGLEMDS $LCTL get_param -n \
17564 osp.$mdtosc_proc1.reserved_mb_high ||
17565 skip "remote MDS does not support reserved_mb_high"
17569 wait_delete_completed
17572 pool_add $TESTNAME || error "Pool creation failed"
17573 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
17575 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
17576 error "Setstripe failed"
17578 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
17580 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
17582 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
17584 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17585 osp.$mdtosc_proc1.prealloc_status)
17586 echo "prealloc_status $oa_status"
17588 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
17589 error "File creation should fail"
17591 #object allocation was stopped, but we still able to append files
17592 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
17593 oflag=append || error "Append failed"
17595 rm -f $DIR/$tdir/$tfile.0
17597 # For this test, we want to delete the files we created to go out of
17598 # space but leave the watermark, so we remain nearly out of space
17599 ost_watermarks_enospc_delete_files $tfile $ostidx
17601 wait_delete_completed
17605 for i in $(seq 10 12); do
17606 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
17607 2>/dev/null || error "File creation failed after rm"
17610 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17611 osp.$mdtosc_proc1.prealloc_status)
17612 echo "prealloc_status $oa_status"
17614 if (( oa_status != 0 )); then
17615 error "Object allocation still disable after rm"
17618 run_test 253 "Check object allocation limit"
17621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17622 remote_mds_nodsh && skip "remote MDS with nodsh"
17623 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
17624 skip "MDS does not support changelog_size"
17627 local MDT0=$(facet_svc $SINGLEMDS)
17629 changelog_register || error "changelog_register failed"
17631 changelog_clear 0 || error "changelog_clear failed"
17633 local size1=$(do_facet $SINGLEMDS \
17634 $LCTL get_param -n mdd.$MDT0.changelog_size)
17635 echo "Changelog size $size1"
17638 $LFS mkdir -i 0 $DIR/$tdir
17640 mkdir -p $DIR/$tdir/pics/2008/zachy
17641 touch $DIR/$tdir/pics/2008/zachy/timestamp
17642 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
17643 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
17644 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
17645 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
17646 rm $DIR/$tdir/pics/desktop.jpg
17648 local size2=$(do_facet $SINGLEMDS \
17649 $LCTL get_param -n mdd.$MDT0.changelog_size)
17650 echo "Changelog size after work $size2"
17652 (( $size2 > $size1 )) ||
17653 error "new Changelog size=$size2 less than old size=$size1"
17655 run_test 254 "Check changelog size"
17662 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
17663 awk -F: '{print $2}' | grep $type > /dev/null
17664 if [ $? -ne 0 ]; then
17674 lfs ladvise -a willread $file > /dev/null 2>&1
17675 if [ $? -eq 0 ]; then
17679 lfs ladvise -a willread $file 2>&1 |
17680 grep "Inappropriate ioctl for device" > /dev/null
17681 if [ $? -eq 0 ]; then
17688 bc <<<"scale=2; ($1 - $2) * 100 / $2"
17691 # run a random read IO workload
17692 # usage: random_read_iops <filename> <filesize> <iosize>
17693 random_read_iops() {
17696 local iosize=${3:-4096}
17698 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
17699 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
17702 drop_file_oss_cache() {
17706 $LFS ladvise -a dontneed $file 2>/dev/null ||
17707 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
17710 ladvise_willread_performance()
17713 local average_origin=0
17714 local average_cache=0
17715 local average_ladvise=0
17717 for ((i = 1; i <= $repeat; i++)); do
17718 echo "Iter $i/$repeat: reading without willread hint"
17719 cancel_lru_locks osc
17720 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17721 local speed_origin=$(random_read_iops $DIR/$tfile $size)
17722 echo "Iter $i/$repeat: uncached speed: $speed_origin"
17723 average_origin=$(bc <<<"$average_origin + $speed_origin")
17725 cancel_lru_locks osc
17726 local speed_cache=$(random_read_iops $DIR/$tfile $size)
17727 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
17728 average_cache=$(bc <<<"$average_cache + $speed_cache")
17730 cancel_lru_locks osc
17731 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17732 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
17733 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
17734 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
17735 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
17737 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
17738 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
17739 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
17741 speedup_cache=$(percent $average_cache $average_origin)
17742 speedup_ladvise=$(percent $average_ladvise $average_origin)
17744 echo "Average uncached read: $average_origin"
17745 echo "Average speedup with OSS cached read: " \
17746 "$average_cache = +$speedup_cache%"
17747 echo "Average speedup with ladvise willread: " \
17748 "$average_ladvise = +$speedup_ladvise%"
17750 local lowest_speedup=20
17751 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
17752 echo "Speedup with OSS cached read less than $lowest_speedup%," \
17753 "got $average_cache%. Skipping ladvise willread check."
17757 # the test won't work on ZFS until it supports 'ladvise dontneed', but
17758 # it is still good to run until then to exercise 'ladvise willread'
17759 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17760 [ "$ost1_FSTYPE" = "zfs" ] &&
17761 echo "osd-zfs does not support dontneed or drop_caches" &&
17764 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
17765 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
17766 error_not_in_vm "Speedup with willread is less than " \
17767 "$lowest_speedup%, got $average_ladvise%"
17771 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17772 skip "lustre < 2.8.54 does not support ladvise "
17773 remote_ost_nodsh && skip "remote OST with nodsh"
17775 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
17777 ladvise_no_type willread $DIR/$tfile &&
17778 skip "willread ladvise is not supported"
17780 ladvise_no_ioctl $DIR/$tfile &&
17781 skip "ladvise ioctl is not supported"
17784 local size=$((size_mb * 1048576))
17785 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17786 error "dd to $DIR/$tfile failed"
17788 lfs ladvise -a willread $DIR/$tfile ||
17789 error "Ladvise failed with no range argument"
17791 lfs ladvise -a willread -s 0 $DIR/$tfile ||
17792 error "Ladvise failed with no -l or -e argument"
17794 lfs ladvise -a willread -e 1 $DIR/$tfile ||
17795 error "Ladvise failed with only -e argument"
17797 lfs ladvise -a willread -l 1 $DIR/$tfile ||
17798 error "Ladvise failed with only -l argument"
17800 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
17801 error "End offset should not be smaller than start offset"
17803 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
17804 error "End offset should not be equal to start offset"
17806 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
17807 error "Ladvise failed with overflowing -s argument"
17809 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
17810 error "Ladvise failed with overflowing -e argument"
17812 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
17813 error "Ladvise failed with overflowing -l argument"
17815 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
17816 error "Ladvise succeeded with conflicting -l and -e arguments"
17818 echo "Synchronous ladvise should wait"
17820 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
17821 do_nodes $(comma_list $(osts_nodes)) \
17822 $LCTL set_param fail_val=$delay fail_loc=0x237
17824 local start_ts=$SECONDS
17825 lfs ladvise -a willread $DIR/$tfile ||
17826 error "Ladvise failed with no range argument"
17827 local end_ts=$SECONDS
17828 local inteval_ts=$((end_ts - start_ts))
17830 if [ $inteval_ts -lt $(($delay - 1)) ]; then
17831 error "Synchronous advice didn't wait reply"
17834 echo "Asynchronous ladvise shouldn't wait"
17835 local start_ts=$SECONDS
17836 lfs ladvise -a willread -b $DIR/$tfile ||
17837 error "Ladvise failed with no range argument"
17838 local end_ts=$SECONDS
17839 local inteval_ts=$((end_ts - start_ts))
17841 if [ $inteval_ts -gt $(($delay / 2)) ]; then
17842 error "Asynchronous advice blocked"
17845 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
17846 ladvise_willread_performance
17848 run_test 255a "check 'lfs ladvise -a willread'"
17854 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
17858 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17859 skip "lustre < 2.8.54 does not support ladvise "
17860 remote_ost_nodsh && skip "remote OST with nodsh"
17862 lfs setstripe -c 1 -i 0 $DIR/$tfile
17864 ladvise_no_type dontneed $DIR/$tfile &&
17865 skip "dontneed ladvise is not supported"
17867 ladvise_no_ioctl $DIR/$tfile &&
17868 skip "ladvise ioctl is not supported"
17870 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17871 [ "$ost1_FSTYPE" = "zfs" ] &&
17872 skip "zfs-osd does not support 'ladvise dontneed'"
17875 local size=$((size_mb * 1048576))
17876 # In order to prevent disturbance of other processes, only check 3/4
17877 # of the memory usage
17878 local kibibytes=$((size_mb * 1024 * 3 / 4))
17880 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17881 error "dd to $DIR/$tfile failed"
17883 #force write to complete before dropping OST cache & checking memory
17886 local total=$(facet_meminfo ost1 MemTotal)
17887 echo "Total memory: $total KiB"
17889 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
17890 local before_read=$(facet_meminfo ost1 Cached)
17891 echo "Cache used before read: $before_read KiB"
17893 lfs ladvise -a willread $DIR/$tfile ||
17894 error "Ladvise willread failed"
17895 local after_read=$(facet_meminfo ost1 Cached)
17896 echo "Cache used after read: $after_read KiB"
17898 lfs ladvise -a dontneed $DIR/$tfile ||
17899 error "Ladvise dontneed again failed"
17900 local no_read=$(facet_meminfo ost1 Cached)
17901 echo "Cache used after dontneed ladvise: $no_read KiB"
17903 if [ $total -lt $((before_read + kibibytes)) ]; then
17904 echo "Memory is too small, abort checking"
17908 if [ $((before_read + kibibytes)) -gt $after_read ]; then
17909 error "Ladvise willread should use more memory" \
17910 "than $kibibytes KiB"
17913 if [ $((no_read + kibibytes)) -gt $after_read ]; then
17914 error "Ladvise dontneed should release more memory" \
17915 "than $kibibytes KiB"
17918 run_test 255b "check 'lfs ladvise -a dontneed'"
17921 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
17922 skip "lustre < 2.10.50 does not support lockahead"
17930 test_mkdir -p $DIR/$tdir
17931 $LFS setstripe -i 0 -c 1 $DIR/$tdir
17933 #test 10 returns only success/failure
17935 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17937 if [ $rc -eq 255 ]; then
17938 error "Ladvise test${i} failed, ${rc}"
17941 #test 11 counts lock enqueue requests, all others count new locks
17943 count=$(do_facet ost1 \
17944 $LCTL get_param -n ost.OSS.ost.stats)
17945 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
17947 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17949 if [ $rc -eq 255 ]; then
17950 error "Ladvise test${i} failed, ${rc}"
17953 new_count=$(do_facet ost1 \
17954 $LCTL get_param -n ost.OSS.ost.stats)
17955 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
17956 awk '{ print $2 }')
17958 difference="$((new_count - count))"
17959 if [ $difference -ne $rc ]; then
17960 error "Ladvise test${i}, bad enqueue count, returned " \
17961 "${rc}, actual ${difference}"
17964 for i in $(seq 12 21); do
17965 # If we do not do this, we run the risk of having too many
17966 # locks and starting lock cancellation while we are checking
17968 cancel_lru_locks osc
17970 count=$($LCTL get_param -n \
17971 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17973 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17975 if [ $rc -eq 255 ]; then
17976 error "Ladvise test ${i} failed, ${rc}"
17979 new_count=$($LCTL get_param -n \
17980 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17981 difference="$((new_count - count))"
17983 # Test 15 output is divided by 100 to map down to valid return
17984 if [ $i -eq 15 ]; then
17988 if [ $difference -ne $rc ]; then
17989 error "Ladvise test ${i}, bad lock count, returned " \
17990 "${rc}, actual ${difference}"
17994 #test 22 returns only success/failure
17996 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17998 if [ $rc -eq 255 ]; then
17999 error "Ladvise test${i} failed, ${rc}"
18002 run_test 255c "suite of ladvise lockahead tests"
18005 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18006 remote_mds_nodsh && skip "remote MDS with nodsh"
18007 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18008 changelog_users $SINGLEMDS | grep "^cl" &&
18009 skip "active changelog user"
18015 mdt_dev=$(mdsdevname 1)
18018 changelog_register || error "changelog_register failed"
18021 mkdir -p $DIR/$tdir
18023 changelog_clear 0 || error "changelog_clear failed"
18026 touch $DIR/$tdir/{1..10}
18029 stop $SINGLEMDS || error "Fail to stop MDT"
18033 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
18035 #after mount new plainllog is used
18036 touch $DIR/$tdir/{11..19}
18037 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
18038 stack_trap "rm -f $tmpfile"
18039 cat_sl=$(do_facet $SINGLEMDS "sync; \
18040 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18041 llog_reader $tmpfile | grep -c type=1064553b")
18042 do_facet $SINGLEMDS llog_reader $tmpfile
18044 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
18046 changelog_clear 0 || error "changelog_clear failed"
18048 cat_sl=$(do_facet $SINGLEMDS "sync; \
18049 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18050 llog_reader $tmpfile | grep -c type=1064553b")
18052 if (( cat_sl == 2 )); then
18053 error "Empty plain llog was not deleted from changelog catalog"
18054 elif (( cat_sl != 1 )); then
18055 error "Active plain llog shouldn't be deleted from catalog"
18058 run_test 256 "Check llog delete for empty and not full state"
18061 remote_mds_nodsh && skip "remote MDS with nodsh"
18062 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
18063 skip "Need MDS version at least 2.8.55"
18065 test_mkdir $DIR/$tdir
18067 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
18068 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
18071 #define OBD_FAIL_MDS_XATTR_REP 0x161
18072 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18073 local facet=mds$((mdtidx + 1))
18074 set_nodes_failloc $(facet_active_host $facet) 0x80000161
18075 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
18077 stop $facet || error "stop MDS failed"
18078 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
18079 error "start MDS fail"
18080 wait_recovery_complete $facet
18082 run_test 257 "xattr locks are not lost"
18084 # Verify we take the i_mutex when security requires it
18086 #define OBD_FAIL_IMUTEX_SEC 0x141c
18087 $LCTL set_param fail_loc=0x141c
18089 chmod u+s $DIR/$tfile
18090 chmod a+rwx $DIR/$tfile
18091 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18093 if [ $RC -ne 0 ]; then
18094 error "error, failed to take i_mutex, rc=$?"
18098 run_test 258a "verify i_mutex security behavior when suid attributes is set"
18100 # Verify we do NOT take the i_mutex in the normal case
18102 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
18103 $LCTL set_param fail_loc=0x141d
18106 chmod a+rw $DIR/$tfile
18107 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18109 if [ $RC -ne 0 ]; then
18110 error "error, took i_mutex unnecessarily, rc=$?"
18115 run_test 258b "verify i_mutex security behavior"
18118 local file=$DIR/$tfile
18122 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18124 stack_trap "rm -f $file" EXIT
18126 wait_delete_completed
18127 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18128 echo "before: $before"
18130 $LFS setstripe -i 0 -c 1 $file
18131 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
18133 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18134 echo "after write: $after"
18136 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
18137 do_facet ost1 $LCTL set_param fail_loc=0x2301
18139 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18140 echo "after truncate: $after"
18143 do_facet ost1 $LCTL set_param fail_loc=0
18144 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18146 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18147 echo "after restart: $after"
18148 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
18149 error "missing truncate?"
18153 run_test 259 "crash at delayed truncate"
18156 #define OBD_FAIL_MDC_CLOSE 0x806
18157 $LCTL set_param fail_loc=0x80000806
18161 run_test 260 "Check mdc_close fail"
18163 ### Data-on-MDT sanity tests ###
18165 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18166 skip "Need MDS version at least 2.10.55 for DoM"
18169 local dom=$DIR/$tdir/dom_file
18170 local tmp=$DIR/$tdir/tmp_file
18172 mkdir -p $DIR/$tdir
18174 # basic checks for DoM component creation
18175 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
18176 error "Can set MDT layout to non-first entry"
18178 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
18179 error "Can define multiple entries as MDT layout"
18181 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
18183 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
18184 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
18185 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
18187 local mdtidx=$($LFS getstripe -m $dom)
18188 local mdtname=MDT$(printf %04x $mdtidx)
18189 local facet=mds$((mdtidx + 1))
18190 local space_check=1
18192 # Skip free space checks with ZFS
18193 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
18197 local size_tmp=$((65536 * 3))
18198 local mdtfree1=$(do_facet $facet \
18199 lctl get_param -n osd*.*$mdtname.kbytesfree)
18201 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18202 # check also direct IO along write
18203 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
18204 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18206 cmp $tmp $dom || error "file data is different"
18207 [ $(stat -c%s $dom) == $size_tmp ] ||
18208 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18209 if [ $space_check == 1 ]; then
18210 local mdtfree2=$(do_facet $facet \
18211 lctl get_param -n osd*.*$mdtname.kbytesfree)
18213 # increase in usage from by $size_tmp
18214 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18215 error "MDT free space wrong after write: " \
18216 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18220 local size_dom=10000
18222 $TRUNCATE $dom $size_dom
18223 [ $(stat -c%s $dom) == $size_dom ] ||
18224 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
18225 if [ $space_check == 1 ]; then
18226 mdtfree1=$(do_facet $facet \
18227 lctl get_param -n osd*.*$mdtname.kbytesfree)
18228 # decrease in usage from $size_tmp to new $size_dom
18229 [ $(($mdtfree1 - $mdtfree2)) -ge \
18230 $(((size_tmp - size_dom) / 1024)) ] ||
18231 error "MDT free space is wrong after truncate: " \
18232 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
18238 size_dom=$((size_dom + size_tmp))
18239 [ $(stat -c%s $dom) == $size_dom ] ||
18240 error "bad size after append: $(stat -c%s $dom) != $size_dom"
18241 if [ $space_check == 1 ]; then
18242 mdtfree2=$(do_facet $facet \
18243 lctl get_param -n osd*.*$mdtname.kbytesfree)
18244 # increase in usage by $size_tmp from previous
18245 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18246 error "MDT free space is wrong after append: " \
18247 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18252 if [ $space_check == 1 ]; then
18253 mdtfree1=$(do_facet $facet \
18254 lctl get_param -n osd*.*$mdtname.kbytesfree)
18255 # decrease in usage by $size_dom from previous
18256 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
18257 error "MDT free space is wrong after removal: " \
18258 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
18261 # combined striping
18262 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
18263 error "Can't create DoM + OST striping"
18265 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
18266 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18267 # check also direct IO along write
18268 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18270 cmp $tmp $dom || error "file data is different"
18271 [ $(stat -c%s $dom) == $size_tmp ] ||
18272 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18277 run_test 270a "DoM: basic functionality tests"
18280 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18281 skip "Need MDS version at least 2.10.55"
18283 local dom=$DIR/$tdir/dom_file
18284 local max_size=1048576
18286 mkdir -p $DIR/$tdir
18287 $LFS setstripe -E $max_size -L mdt $dom
18289 # truncate over the limit
18290 $TRUNCATE $dom $(($max_size + 1)) &&
18291 error "successful truncate over the maximum size"
18292 # write over the limit
18293 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
18294 error "successful write over the maximum size"
18295 # append over the limit
18296 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
18297 echo "12345" >> $dom && error "successful append over the maximum size"
18302 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
18305 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18306 skip "Need MDS version at least 2.10.55"
18308 mkdir -p $DIR/$tdir
18309 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18311 # check files inherit DoM EA
18312 touch $DIR/$tdir/first
18313 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
18314 error "bad pattern"
18315 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
18316 error "bad stripe count"
18317 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
18318 error "bad stripe size"
18320 # check directory inherits DoM EA and uses it as default
18321 mkdir $DIR/$tdir/subdir
18322 touch $DIR/$tdir/subdir/second
18323 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
18324 error "bad pattern in sub-directory"
18325 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
18326 error "bad stripe count in sub-directory"
18327 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
18328 error "bad stripe size in sub-directory"
18331 run_test 270c "DoM: DoM EA inheritance tests"
18334 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18335 skip "Need MDS version at least 2.10.55"
18337 mkdir -p $DIR/$tdir
18338 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18340 # inherit default DoM striping
18341 mkdir $DIR/$tdir/subdir
18342 touch $DIR/$tdir/subdir/f1
18344 # change default directory striping
18345 $LFS setstripe -c 1 $DIR/$tdir/subdir
18346 touch $DIR/$tdir/subdir/f2
18347 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
18348 error "wrong default striping in file 2"
18349 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
18350 error "bad pattern in file 2"
18353 run_test 270d "DoM: change striping from DoM to RAID0"
18356 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18357 skip "Need MDS version at least 2.10.55"
18359 mkdir -p $DIR/$tdir/dom
18360 mkdir -p $DIR/$tdir/norm
18363 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
18364 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
18366 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
18367 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
18369 # find DoM files by layout
18370 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
18371 [ $NUM -eq $DOMFILES ] ||
18372 error "lfs find -L: found $NUM, expected $DOMFILES"
18373 echo "Test 1: lfs find 20 DOM files by layout: OK"
18375 # there should be 1 dir with default DOM striping
18376 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
18378 error "lfs find -L: found $NUM, expected 1 dir"
18379 echo "Test 2: lfs find 1 DOM dir by layout: OK"
18381 # find DoM files by stripe size
18382 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
18383 [ $NUM -eq $DOMFILES ] ||
18384 error "lfs find -S: found $NUM, expected $DOMFILES"
18385 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
18387 # find files by stripe offset except DoM files
18388 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
18389 [ $NUM -eq $NORMFILES ] ||
18390 error "lfs find -i: found $NUM, expected $NORMFILES"
18391 echo "Test 5: lfs find no DOM files by stripe index: OK"
18394 run_test 270e "DoM: lfs find with DoM files test"
18397 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18398 skip "Need MDS version at least 2.10.55"
18400 local mdtname=${FSNAME}-MDT0000-mdtlov
18401 local dom=$DIR/$tdir/dom_file
18402 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
18403 lod.$mdtname.dom_stripesize)
18404 local dom_limit=131072
18406 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
18407 local dom_current=$(do_facet mds1 $LCTL get_param -n \
18408 lod.$mdtname.dom_stripesize)
18409 [ ${dom_limit} -eq ${dom_current} ] ||
18410 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
18412 $LFS mkdir -i 0 -c 1 $DIR/$tdir
18413 $LFS setstripe -d $DIR/$tdir
18414 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
18415 error "Can't set directory default striping"
18417 # exceed maximum stripe size
18418 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18419 error "Can't create file with $((dom_limit * 2)) DoM stripe"
18420 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
18421 error "Able to create DoM component size more than LOD limit"
18423 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
18424 dom_current=$(do_facet mds1 $LCTL get_param -n \
18425 lod.$mdtname.dom_stripesize)
18426 [ 0 -eq ${dom_current} ] ||
18427 error "Can't set zero DoM stripe limit"
18430 # attempt to create DoM file on server with disabled DoM should
18431 # remove DoM entry from layout and be succeed
18432 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
18433 error "Can't create DoM file (DoM is disabled)"
18434 [ $($LFS getstripe -L $dom) == "mdt" ] &&
18435 error "File has DoM component while DoM is disabled"
18438 # attempt to create DoM file with only DoM stripe should return error
18439 $LFS setstripe -E $dom_limit -L mdt $dom &&
18440 error "Able to create DoM-only file while DoM is disabled"
18442 # too low values to be aligned with smallest stripe size 64K
18443 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
18444 dom_current=$(do_facet mds1 $LCTL get_param -n \
18445 lod.$mdtname.dom_stripesize)
18446 [ 30000 -eq ${dom_current} ] &&
18447 error "Can set too small DoM stripe limit"
18449 # 64K is a minimal stripe size in Lustre, expect limit of that size
18450 [ 65536 -eq ${dom_current} ] ||
18451 error "Limit is not set to 64K but ${dom_current}"
18453 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
18454 dom_current=$(do_facet mds1 $LCTL get_param -n \
18455 lod.$mdtname.dom_stripesize)
18457 [ 2147483648 -eq ${dom_current} ] &&
18458 error "Can set too large DoM stripe limit"
18460 do_facet mds1 $LCTL set_param -n \
18461 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
18462 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18463 error "Can't create DoM component size after limit change"
18464 do_facet mds1 $LCTL set_param -n \
18465 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
18466 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
18467 error "Can't create DoM file after limit decrease"
18468 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
18469 error "Can create big DoM component after limit decrease"
18470 touch ${dom}_def ||
18471 error "Can't create file with old default layout"
18473 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
18476 run_test 270f "DoM: maximum DoM stripe size checks"
18479 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18480 skip "Need MDS version at least 2.10.55"
18482 local dom=$DIR/$tdir/dom
18484 mkdir -p $DIR/$tdir
18486 $LFS setstripe -E 1024K -L mdt $dom
18488 lctl set_param -n mdc.*.stats=clear
18489 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18490 cat $dom > /dev/null
18491 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
18492 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
18496 run_test 271a "DoM: data is cached for read after write"
18499 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18500 skip "Need MDS version at least 2.10.55"
18502 local dom=$DIR/$tdir/dom
18504 mkdir -p $DIR/$tdir
18506 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18508 lctl set_param -n mdc.*.stats=clear
18509 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18510 cancel_lru_locks mdc
18511 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
18512 # second stat to check size is cached on client
18513 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
18514 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18515 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
18518 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
18521 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18522 skip "Need MDS version at least 2.10.55"
18524 local dom=$DIR/$tdir/dom
18526 mkdir -p $DIR/$tdir
18528 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18530 lctl set_param -n mdc.*.stats=clear
18531 lctl set_param -n osc.*.stats=clear
18532 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
18533 cancel_lru_locks mdc
18534 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18535 # second stat to check size is cached on client
18536 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18537 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18538 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
18539 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
18540 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
18543 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
18549 local mdt=MDT$(printf %04x $mdtidx)
18551 if [ -z $param ]; then
18552 lctl get_param -n mdc.*$mdt*.stats
18554 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
18559 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18560 skip "Need MDS version at least 2.10.55"
18562 local dom=$DIR/$tdir/dom
18564 mkdir -p $DIR/$tdir
18566 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18568 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18569 local facet=mds$((mdtidx + 1))
18571 cancel_lru_locks mdc
18572 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
18573 createmany -o $dom 1000
18574 lctl set_param -n mdc.*.stats=clear
18575 smalliomany -w $dom 1000 200
18576 get_mdc_stats $mdtidx
18577 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18578 # Each file has 1 open, 1 IO enqueues, total 2000
18579 # but now we have also +1 getxattr for security.capability, total 3000
18580 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
18581 unlinkmany $dom 1000
18583 cancel_lru_locks mdc
18584 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
18585 createmany -o $dom 1000
18586 lctl set_param -n mdc.*.stats=clear
18587 smalliomany -w $dom 1000 200
18588 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18589 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
18590 # for OPEN and IO lock.
18591 [ $((enq - enq_2)) -ge 1000 ] ||
18592 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
18593 unlinkmany $dom 1000
18596 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
18598 cleanup_271def_tests() {
18604 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18605 skip "Need MDS version at least 2.10.57"
18607 local dom=$DIR/$tdir/dom
18608 local tmp=$TMP/$tfile
18609 trap "cleanup_271def_tests $tmp" EXIT
18611 mkdir -p $DIR/$tdir
18613 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18615 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18617 cancel_lru_locks mdc
18618 dd if=/dev/urandom of=$tmp bs=1000 count=1
18619 dd if=$tmp of=$dom bs=1000 count=1
18620 cancel_lru_locks mdc
18622 cat /etc/hosts >> $tmp
18623 lctl set_param -n mdc.*.stats=clear
18625 # append data to the same file it should update local page
18626 echo "Append to the same page"
18627 cat /etc/hosts >> $dom
18628 local num=$(get_mdc_stats $mdtidx ost_read)
18629 local ra=$(get_mdc_stats $mdtidx req_active)
18630 local rw=$(get_mdc_stats $mdtidx req_waittime)
18632 [ -z $num ] || error "$num READ RPC occured"
18633 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18637 cmp $tmp $dom || error "file miscompare"
18639 cancel_lru_locks mdc
18640 lctl set_param -n mdc.*.stats=clear
18642 echo "Open and read file"
18643 cat $dom > /dev/null
18644 local num=$(get_mdc_stats $mdtidx ost_read)
18645 local ra=$(get_mdc_stats $mdtidx req_active)
18646 local rw=$(get_mdc_stats $mdtidx req_waittime)
18648 [ -z $num ] || error "$num READ RPC occured"
18649 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18653 cmp $tmp $dom || error "file miscompare"
18657 run_test 271d "DoM: read on open (1K file in reply buffer)"
18660 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18661 skip "Need MDS version at least 2.10.57"
18663 local dom=$DIR/$tdir/dom
18664 local tmp=$TMP/$tfile
18665 trap "cleanup_271def_tests $tmp" EXIT
18667 mkdir -p $DIR/$tdir
18669 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18671 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18673 cancel_lru_locks mdc
18674 dd if=/dev/urandom of=$tmp bs=265000 count=1
18675 dd if=$tmp of=$dom bs=265000 count=1
18676 cancel_lru_locks mdc
18677 cat /etc/hosts >> $tmp
18678 lctl set_param -n mdc.*.stats=clear
18680 echo "Append to the same page"
18681 cat /etc/hosts >> $dom
18682 local num=$(get_mdc_stats $mdtidx ost_read)
18683 local ra=$(get_mdc_stats $mdtidx req_active)
18684 local rw=$(get_mdc_stats $mdtidx req_waittime)
18686 [ -z $num ] || error "$num READ RPC occured"
18687 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18691 cmp $tmp $dom || error "file miscompare"
18693 cancel_lru_locks mdc
18694 lctl set_param -n mdc.*.stats=clear
18696 echo "Open and read file"
18697 cat $dom > /dev/null
18698 local num=$(get_mdc_stats $mdtidx ost_read)
18699 local ra=$(get_mdc_stats $mdtidx req_active)
18700 local rw=$(get_mdc_stats $mdtidx req_waittime)
18702 [ -z $num ] && num=0
18703 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
18704 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18708 cmp $tmp $dom || error "file miscompare"
18712 run_test 271f "DoM: read on open (200K file and read tail)"
18715 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
18716 skip "Skipping due to old client or server version"
18718 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
18720 $CHECKSTAT -t file $DIR1/$tfile
18722 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
18725 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
18726 $LCTL set_param fail_loc=0x80000314
18727 rm $DIR1/$tfile || error "Unlink fails"
18729 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
18730 [ $RC -eq 0 ] || error "Failed write to stale object"
18732 run_test 271g "Discard DoM data vs client flush race"
18735 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18736 skip "Need MDS version at least 2.11.50"
18738 local dom=$DIR/$tdir/dom
18739 mkdir -p $DIR/$tdir
18741 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
18742 dd if=/dev/urandom of=$dom bs=512K count=1 ||
18743 error "failed to write data into $dom"
18744 local old_md5=$(md5sum $dom)
18746 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
18747 error "failed to migrate to the same DoM component"
18749 local new_md5=$(md5sum $dom)
18751 [ "$old_md5" == "$new_md5" ] ||
18752 error "md5sum differ: $old_md5, $new_md5"
18754 [ $($LFS getstripe -c $dom) -eq 2 ] ||
18755 error "migrate stripe count bad: $(LFS getstripe -c $dom) != 2"
18757 run_test 272a "DoM migration: new layout with the same DOM component"
18760 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18761 skip "Need MDS version at least 2.11.50"
18763 local dom=$DIR/$tdir/dom
18764 mkdir -p $DIR/$tdir
18765 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18767 local mdtidx=$($LFS getstripe -m $dom)
18768 local mdtname=MDT$(printf %04x $mdtidx)
18769 local facet=mds$((mdtidx + 1))
18771 local mdtfree1=$(do_facet $facet \
18772 lctl get_param -n osd*.*$mdtname.kbytesfree)
18773 dd if=/dev/urandom of=$dom bs=2M count=1 ||
18774 error "failed to write data into $dom"
18775 local old_md5=$(md5sum $dom)
18776 cancel_lru_locks mdc
18777 local mdtfree1=$(do_facet $facet \
18778 lctl get_param -n osd*.*$mdtname.kbytesfree)
18780 $LFS migrate -c2 $dom ||
18781 error "failed to migrate to the new composite layout"
18782 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
18783 error "MDT stripe was not removed"
18785 cancel_lru_locks mdc
18786 local new_md5=$(md5sum $dom)
18787 [ "$old_md5" == "$new_md5" ] ||
18788 error "$old_md5 != $new_md5"
18790 # Skip free space checks with ZFS
18791 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18792 local mdtfree2=$(do_facet $facet \
18793 lctl get_param -n osd*.*$mdtname.kbytesfree)
18794 [ $mdtfree2 -gt $mdtfree1 ] ||
18795 error "MDT space is not freed after migration"
18799 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
18802 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18803 skip "Need MDS version at least 2.11.50"
18805 local dom=$DIR/$tdir/$tfile
18806 mkdir -p $DIR/$tdir
18807 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18809 local mdtidx=$($LFS getstripe -m $dom)
18810 local mdtname=MDT$(printf %04x $mdtidx)
18811 local facet=mds$((mdtidx + 1))
18813 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
18814 error "failed to write data into $dom"
18815 local old_md5=$(md5sum $dom)
18816 cancel_lru_locks mdc
18817 local mdtfree1=$(do_facet $facet \
18818 lctl get_param -n osd*.*$mdtname.kbytesfree)
18820 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
18821 error "failed to migrate to the new composite layout"
18822 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18823 error "MDT stripe was not removed"
18825 cancel_lru_locks mdc
18826 local new_md5=$(md5sum $dom)
18827 [ "$old_md5" == "$new_md5" ] ||
18828 error "$old_md5 != $new_md5"
18830 # Skip free space checks with ZFS
18831 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18832 local mdtfree2=$(do_facet $facet \
18833 lctl get_param -n osd*.*$mdtname.kbytesfree)
18834 [ $mdtfree2 -gt $mdtfree1 ] ||
18835 error "MDS space is not freed after migration"
18839 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
18842 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
18843 skip "Need MDS version at least 2.12.55"
18845 local dom=$DIR/$tdir/$tfile
18846 mkdir -p $DIR/$tdir
18847 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18849 local mdtidx=$($LFS getstripe -m $dom)
18850 local mdtname=MDT$(printf %04x $mdtidx)
18851 local facet=mds$((mdtidx + 1))
18853 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
18854 error "failed to write data into $dom"
18855 local old_md5=$(md5sum $dom)
18856 cancel_lru_locks mdc
18857 local mdtfree1=$(do_facet $facet \
18858 lctl get_param -n osd*.*$mdtname.kbytesfree)
18860 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
18861 error "failed mirroring to the new composite layout"
18862 $LFS mirror resync $dom ||
18863 error "failed mirror resync"
18864 $LFS mirror split --mirror-id 1 -d $dom ||
18865 error "failed mirror split"
18867 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
18868 error "MDT stripe was not removed"
18870 cancel_lru_locks mdc
18871 local new_md5=$(md5sum $dom)
18872 [ "$old_md5" == "$new_md5" ] ||
18873 error "$old_md5 != $new_md5"
18875 # Skip free space checks with ZFS
18876 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18877 local mdtfree2=$(do_facet $facet \
18878 lctl get_param -n osd*.*$mdtname.kbytesfree)
18879 [ $mdtfree2 -gt $mdtfree1 ] ||
18880 error "MDS space is not freed after DOM mirror deletion"
18884 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
18887 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
18888 skip "Need MDS version at least 2.12.55"
18890 local dom=$DIR/$tdir/$tfile
18891 mkdir -p $DIR/$tdir
18892 $LFS setstripe -c 2 $dom
18894 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
18895 error "failed to write data into $dom"
18896 local old_md5=$(md5sum $dom)
18897 cancel_lru_locks mdc
18899 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
18900 error "failed mirroring to the DOM layout"
18901 $LFS mirror resync $dom ||
18902 error "failed mirror resync"
18903 $LFS mirror split --mirror-id 1 -d $dom ||
18904 error "failed mirror split"
18906 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
18907 error "MDT stripe was not removed"
18909 cancel_lru_locks mdc
18910 local new_md5=$(md5sum $dom)
18911 [ "$old_md5" == "$new_md5" ] ||
18912 error "$old_md5 != $new_md5"
18916 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
18919 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
18920 skip "Need MDS version at least 2.12.55"
18922 local dom=$DIR/$tdir/$tfile
18923 mkdir -p $DIR/$tdir
18924 $LFS setstripe -c 2 $dom
18926 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
18927 error "failed to write data into $dom"
18928 local old_md5=$(md5sum $dom)
18929 cancel_lru_locks mdc
18931 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
18932 error "failed migrating to the DOM file"
18934 cancel_lru_locks mdc
18935 local new_md5=$(md5sum $dom)
18936 [ "$old_md5" != "$new_md5" ] &&
18937 error "$old_md5 != $new_md5"
18941 run_test 272f "DoM migration: OST-striped file to DOM file"
18944 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18945 skip "Need MDS version at least 2.11.50"
18947 # Layout swap cannot be done if either file has DOM component,
18948 # this will never be supported, migration should be used instead
18950 local dom=$DIR/$tdir/$tfile
18951 mkdir -p $DIR/$tdir
18953 $LFS setstripe -c2 ${dom}_plain
18954 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
18955 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
18956 error "can swap layout with DoM component"
18957 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
18958 error "can swap layout with DoM component"
18960 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
18961 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
18962 error "can swap layout with DoM component"
18963 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
18964 error "can swap layout with DoM component"
18967 run_test 273a "DoM: layout swapping should fail with DOM"
18970 remote_ost_nodsh && skip "remote OST with nodsh"
18971 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
18972 skip "Need OST version >= 2.10.57"
18974 local file=$DIR/$tfile
18977 oss=$(comma_list $(osts_nodes))
18979 dd if=/dev/urandom of=$file bs=1M count=2 ||
18980 error "failed to create a file"
18981 cancel_lru_locks osc
18984 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18985 error "failed to read a file"
18987 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
18988 $LCTL set_param fail_loc=0x8000031f
18990 cancel_lru_locks osc &
18993 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
18994 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
18995 #IO takes another lock, but matches the PENDING one
18996 #and places it to the IO RPC
18997 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18998 error "failed to read a file with PENDING lock"
19000 run_test 275 "Read on a canceled duplicate lock"
19003 remote_ost_nodsh && skip "remote OST with nodsh"
19006 do_facet ost1 "(while true; do \
19007 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
19008 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
19011 for LOOP in $(seq 20); do
19013 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
19016 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
19017 rm $TMP/sanity_276_pid"
19019 run_test 276 "Race between mount and obd_statfs"
19022 $LCTL set_param ldlm.namespaces.*.lru_size=0
19023 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
19024 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
19025 grep ^used_mb | awk '{print $2}')
19026 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
19027 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
19028 oflag=direct conv=notrunc
19029 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
19030 grep ^used_mb | awk '{print $2}')
19031 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
19033 run_test 277 "Direct IO shall drop page cache"
19036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
19037 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19038 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
19039 skip "needs the same host for mdt1 mdt2" && return
19044 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
19045 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
19051 echo "Starting MDTs"
19052 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
19054 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
19056 do_facet mds2 $LCTL set_param fail_loc=0
19058 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
19059 wait_recovery_complete mds2
19061 run_test 278 "Race starting MDS between MDTs stop/start"
19063 cleanup_test_300() {
19067 test_striped_dir() {
19072 mkdir -p $DIR/$tdir
19074 SAVE_UMASK=$(umask)
19075 trap cleanup_test_300 RETURN EXIT
19077 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
19078 $DIR/$tdir/striped_dir ||
19079 error "set striped dir error"
19081 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
19082 [ "$mode" = "755" ] || error "expect 755 got $mode"
19084 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
19085 error "getdirstripe failed"
19086 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
19087 if [ "$stripe_count" != "2" ]; then
19088 error "1:stripe_count is $stripe_count, expect 2"
19090 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
19091 if [ "$stripe_count" != "2" ]; then
19092 error "2:stripe_count is $stripe_count, expect 2"
19095 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
19096 if [ "$stripe_index" != "$mdt_index" ]; then
19097 error "stripe_index is $stripe_index, expect $mdt_index"
19100 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
19101 error "nlink error after create striped dir"
19103 mkdir $DIR/$tdir/striped_dir/a
19104 mkdir $DIR/$tdir/striped_dir/b
19106 stat $DIR/$tdir/striped_dir/a ||
19107 error "create dir under striped dir failed"
19108 stat $DIR/$tdir/striped_dir/b ||
19109 error "create dir under striped dir failed"
19111 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
19112 error "nlink error after mkdir"
19114 rmdir $DIR/$tdir/striped_dir/a
19115 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
19116 error "nlink error after rmdir"
19118 rmdir $DIR/$tdir/striped_dir/b
19119 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
19120 error "nlink error after rmdir"
19122 chattr +i $DIR/$tdir/striped_dir
19123 createmany -o $DIR/$tdir/striped_dir/f 10 &&
19124 error "immutable flags not working under striped dir!"
19125 chattr -i $DIR/$tdir/striped_dir
19127 rmdir $DIR/$tdir/striped_dir ||
19128 error "rmdir striped dir error"
19136 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19137 skip "skipped for lustre < 2.7.0"
19138 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19139 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19141 test_striped_dir 0 || error "failed on striped dir on MDT0"
19142 test_striped_dir 1 || error "failed on striped dir on MDT0"
19144 run_test 300a "basic striped dir sanity test"
19147 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19148 skip "skipped for lustre < 2.7.0"
19149 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19150 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19157 test_mkdir $DIR/$tdir || error "mkdir fail"
19158 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19159 error "set striped dir error"
19160 for i in {0..9}; do
19161 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
19163 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
19164 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
19165 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
19167 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
19168 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
19169 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
19173 run_test 300b "check ctime/mtime for striped dir"
19176 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19177 skip "skipped for lustre < 2.7.0"
19178 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19179 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19183 mkdir -p $DIR/$tdir
19184 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
19185 error "set striped dir error"
19187 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
19188 error "chown striped dir failed"
19190 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
19191 error "create 5k files failed"
19193 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
19195 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
19199 run_test 300c "chown && check ls under striped directory"
19202 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19203 skip "skipped for lustre < 2.7.0"
19204 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19205 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19210 mkdir -p $DIR/$tdir
19211 $LFS setstripe -c 2 $DIR/$tdir
19213 #local striped directory
19214 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19215 error "set striped dir error"
19216 createmany -o $DIR/$tdir/striped_dir/f 10 ||
19217 error "create 10 files failed"
19219 #remote striped directory
19220 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
19221 error "set striped dir error"
19222 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
19223 error "create 10 files failed"
19225 for file in $(find $DIR/$tdir); do
19226 stripe_count=$($LFS getstripe -c $file)
19227 [ $stripe_count -eq 2 ] ||
19228 error "wrong stripe $stripe_count for $file"
19233 run_test 300d "check default stripe under striped directory"
19236 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19237 skip "Need MDS version at least 2.7.55"
19238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19239 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19244 mkdir -p $DIR/$tdir
19246 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19247 error "set striped dir error"
19249 touch $DIR/$tdir/striped_dir/a
19250 touch $DIR/$tdir/striped_dir/b
19251 touch $DIR/$tdir/striped_dir/c
19253 mkdir $DIR/$tdir/striped_dir/dir_a
19254 mkdir $DIR/$tdir/striped_dir/dir_b
19255 mkdir $DIR/$tdir/striped_dir/dir_c
19257 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
19258 error "set striped adir under striped dir error"
19260 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
19261 error "set striped bdir under striped dir error"
19263 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
19264 error "set striped cdir under striped dir error"
19266 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
19267 error "rename dir under striped dir fails"
19269 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
19270 error "rename dir under different stripes fails"
19272 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
19273 error "rename file under striped dir should succeed"
19275 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
19276 error "rename dir under striped dir should succeed"
19280 run_test 300e "check rename under striped directory"
19283 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19284 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19285 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19286 skip "Need MDS version at least 2.7.55"
19292 mkdir -p $DIR/$tdir
19294 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19295 error "set striped dir error"
19297 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
19298 error "set striped dir error"
19300 touch $DIR/$tdir/striped_dir/a
19301 mkdir $DIR/$tdir/striped_dir/dir_a
19302 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
19303 error "create striped dir under striped dir fails"
19305 touch $DIR/$tdir/striped_dir1/b
19306 mkdir $DIR/$tdir/striped_dir1/dir_b
19307 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
19308 error "create striped dir under striped dir fails"
19310 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
19311 error "rename dir under different striped dir should fail"
19313 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
19314 error "rename striped dir under diff striped dir should fail"
19316 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
19317 error "rename file under diff striped dirs fails"
19321 run_test 300f "check rename cross striped directory"
19323 test_300_check_default_striped_dir()
19326 local default_count=$2
19327 local default_index=$3
19330 local dir_stripe_index
19333 echo "checking $dirname $default_count $default_index"
19334 $LFS setdirstripe -D -c $default_count -i $default_index \
19335 -t all_char $DIR/$tdir/$dirname ||
19336 error "set default stripe on striped dir error"
19337 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
19338 [ $stripe_count -eq $default_count ] ||
19339 error "expect $default_count get $stripe_count for $dirname"
19341 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
19342 [ $stripe_index -eq $default_index ] ||
19343 error "expect $default_index get $stripe_index for $dirname"
19345 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
19346 error "create dirs failed"
19348 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
19349 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
19350 for dir in $(find $DIR/$tdir/$dirname/*); do
19351 stripe_count=$($LFS getdirstripe -c $dir)
19352 [ $stripe_count -eq $default_count ] ||
19353 [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
19354 error "stripe count $default_count != $stripe_count for $dir"
19356 stripe_index=$($LFS getdirstripe -i $dir)
19357 [ $default_index -eq -1 ] ||
19358 [ $stripe_index -eq $default_index ] ||
19359 error "$stripe_index != $default_index for $dir"
19361 #check default stripe
19362 stripe_count=$($LFS getdirstripe -D -c $dir)
19363 [ $stripe_count -eq $default_count ] ||
19364 error "default count $default_count != $stripe_count for $dir"
19366 stripe_index=$($LFS getdirstripe -D -i $dir)
19367 [ $stripe_index -eq $default_index ] ||
19368 error "default index $default_index != $stripe_index for $dir"
19370 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
19374 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19375 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19376 skip "Need MDS version at least 2.7.55"
19383 mkdir $DIR/$tdir/normal_dir
19385 #Checking when client cache stripe index
19386 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
19387 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
19388 error "create striped_dir failed"
19390 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
19391 error "create dir0 fails"
19392 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
19393 [ $stripe_index -eq 0 ] ||
19394 error "dir0 expect index 0 got $stripe_index"
19396 mkdir $DIR/$tdir/striped_dir/dir1 ||
19397 error "create dir1 fails"
19398 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
19399 [ $stripe_index -eq 1 ] ||
19400 error "dir1 expect index 1 got $stripe_index"
19402 #check default stripe count/stripe index
19403 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
19404 test_300_check_default_striped_dir normal_dir 1 0
19405 test_300_check_default_striped_dir normal_dir 2 1
19406 test_300_check_default_striped_dir normal_dir 2 -1
19408 #delete default stripe information
19409 echo "delete default stripeEA"
19410 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
19411 error "set default stripe on striped dir error"
19413 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
19414 for dir in $(find $DIR/$tdir/normal_dir/*); do
19415 stripe_count=$($LFS getdirstripe -c $dir)
19416 [ $stripe_count -eq 0 ] ||
19417 error "expect 1 get $stripe_count for $dir"
19418 stripe_index=$($LFS getdirstripe -i $dir)
19419 [ $stripe_index -eq 0 ] ||
19420 error "expect 0 get $stripe_index for $dir"
19423 run_test 300g "check default striped directory for normal directory"
19426 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19427 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19428 skip "Need MDS version at least 2.7.55"
19434 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19435 error "set striped dir error"
19437 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
19438 test_300_check_default_striped_dir striped_dir 1 0
19439 test_300_check_default_striped_dir striped_dir 2 1
19440 test_300_check_default_striped_dir striped_dir 2 -1
19442 #delete default stripe information
19443 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
19444 error "set default stripe on striped dir error"
19446 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
19447 for dir in $(find $DIR/$tdir/striped_dir/*); do
19448 stripe_count=$($LFS getdirstripe -c $dir)
19449 [ $stripe_count -eq 0 ] ||
19450 error "expect 1 get $stripe_count for $dir"
19453 run_test 300h "check default striped directory for striped directory"
19456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19457 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19458 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19459 skip "Need MDS version at least 2.7.55"
19466 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19467 error "set striped dir error"
19469 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19470 error "create files under striped dir failed"
19472 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
19473 error "set striped hashdir error"
19475 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
19476 error "create dir0 under hash dir failed"
19477 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
19478 error "create dir1 under hash dir failed"
19480 # unfortunately, we need to umount to clear dir layout cache for now
19481 # once we fully implement dir layout, we can drop this
19482 umount_client $MOUNT || error "umount failed"
19483 mount_client $MOUNT || error "mount failed"
19485 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
19486 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
19487 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
19489 #set the stripe to be unknown hash type
19490 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
19491 $LCTL set_param fail_loc=0x1901
19492 for ((i = 0; i < 10; i++)); do
19493 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
19494 error "stat f-$i failed"
19495 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
19498 touch $DIR/$tdir/striped_dir/f0 &&
19499 error "create under striped dir with unknown hash should fail"
19501 $LCTL set_param fail_loc=0
19503 umount_client $MOUNT || error "umount failed"
19504 mount_client $MOUNT || error "mount failed"
19508 run_test 300i "client handle unknown hash type striped directory"
19511 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19512 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19513 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19514 skip "Need MDS version at least 2.7.55"
19521 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
19522 $LCTL set_param fail_loc=0x1702
19523 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19524 error "set striped dir error"
19526 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19527 error "create files under striped dir failed"
19529 $LCTL set_param fail_loc=0
19531 rm -rf $DIR/$tdir || error "unlink striped dir fails"
19535 run_test 300j "test large update record"
19538 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19539 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19540 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19541 skip "Need MDS version at least 2.7.55"
19543 # this test needs a huge transaction
19545 kb=$(do_facet $SINGLEMDS lctl get_param -n osd*.lustre-MDT0000.kbytestotal)
19546 [ $kb -lt $((1024*1024)) ] && skip "too small mds: $kb"
19553 #define OBD_FAIL_LARGE_STRIPE 0x1703
19554 $LCTL set_param fail_loc=0x1703
19555 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
19556 error "set striped dir error"
19557 $LCTL set_param fail_loc=0
19559 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19560 error "getstripeddir fails"
19561 rm -rf $DIR/$tdir/striped_dir ||
19562 error "unlink striped dir fails"
19566 run_test 300k "test large striped directory"
19569 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19570 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19571 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19572 skip "Need MDS version at least 2.7.55"
19576 test_mkdir -p $DIR/$tdir/striped_dir
19577 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
19578 error "chown $RUNAS_ID failed"
19579 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
19580 error "set default striped dir failed"
19582 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
19583 $LCTL set_param fail_loc=0x80000158
19584 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
19586 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
19587 [ $stripe_index -eq 1 ] ||
19588 error "expect 1 get $stripe_index for $dir"
19590 run_test 300l "non-root user to create dir under striped dir with stale layout"
19593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19594 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
19595 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19596 skip "Need MDS version at least 2.7.55"
19598 mkdir -p $DIR/$tdir/striped_dir
19599 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
19600 error "set default stripes dir error"
19602 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
19604 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
19605 [ $stripe_count -eq 0 ] ||
19606 error "expect 0 get $stripe_count for a"
19608 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
19609 error "set default stripes dir error"
19611 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
19613 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
19614 [ $stripe_count -eq 0 ] ||
19615 error "expect 0 get $stripe_count for b"
19617 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
19618 error "set default stripes dir error"
19620 mkdir $DIR/$tdir/striped_dir/c &&
19621 error "default stripe_index is invalid, mkdir c should fails"
19623 rm -rf $DIR/$tdir || error "rmdir fails"
19625 run_test 300m "setstriped directory on single MDT FS"
19628 local list=$(comma_list $(mdts_nodes))
19631 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19636 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19637 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19638 skip "Need MDS version at least 2.7.55"
19639 remote_mds_nodsh && skip "remote MDS with nodsh"
19642 local list=$(comma_list $(mdts_nodes))
19644 trap cleanup_300n RETURN EXIT
19645 mkdir -p $DIR/$tdir
19646 chmod 777 $DIR/$tdir
19647 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
19648 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19649 error "create striped dir succeeds with gid=0"
19651 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19652 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
19653 error "create striped dir fails with gid=-1"
19655 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19656 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
19657 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19658 error "set default striped dir succeeds with gid=0"
19661 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19662 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
19663 error "set default striped dir fails with gid=-1"
19666 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19667 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
19668 error "create test_dir fails"
19669 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
19670 error "create test_dir1 fails"
19671 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
19672 error "create test_dir2 fails"
19675 run_test 300n "non-root user to create dir under striped dir with default EA"
19678 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19679 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19680 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19681 skip "Need MDS version at least 2.7.55"
19686 mkdir -p $DIR/$tdir
19688 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
19689 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
19690 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
19691 skip "not enough free inodes $numfree1 $numfree2"
19694 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
19695 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
19696 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
19697 skip "not enough free space $numfree1 $numfree2"
19700 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
19701 error "setdirstripe fails"
19703 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
19704 error "create dirs fails"
19706 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
19707 ls $DIR/$tdir/striped_dir > /dev/null ||
19708 error "ls striped dir fails"
19709 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
19710 error "unlink big striped dir fails"
19712 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
19715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19716 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19717 remote_mds_nodsh && skip "remote MDS with nodsh"
19719 mkdir -p $DIR/$tdir
19721 #define OBD_FAIL_OUT_ENOSPC 0x1704
19722 do_facet mds2 lctl set_param fail_loc=0x80001704
19723 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
19724 && error "create striped directory should fail"
19726 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
19728 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
19731 run_test 300p "create striped directory without space"
19734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19735 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19737 local fd=$(free_fd)
19738 local cmd="exec $fd<$tdir"
19740 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
19743 trap "eval $cmd" EXIT
19744 cd $tdir || error "cd $tdir fails"
19745 rmdir ../$tdir || error "rmdir $tdir fails"
19746 mkdir local_dir && error "create dir succeeds"
19747 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
19751 run_test 300q "create remote directory under orphan directory"
19754 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
19755 skip "Need MDS version at least 2.7.55" && return
19756 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19760 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
19761 error "set striped dir error"
19763 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19764 error "getstripeddir fails"
19767 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
19768 awk '/lmv_stripe_count:/ { print $2 }')
19770 [ $MDSCOUNT -ne $stripe_count ] &&
19771 error "wrong stripe count $stripe_count expected $MDSCOUNT"
19773 rm -rf $DIR/$tdir/striped_dir ||
19774 error "unlink striped dir fails"
19776 run_test 300r "test -1 striped directory"
19778 prepare_remote_file() {
19779 mkdir $DIR/$tdir/src_dir ||
19780 error "create remote source failed"
19782 cp /etc/hosts $DIR/$tdir/src_dir/a ||
19783 error "cp to remote source failed"
19784 touch $DIR/$tdir/src_dir/a
19786 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
19787 error "create remote target dir failed"
19789 touch $DIR/$tdir/tgt_dir/b
19791 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
19792 error "rename dir cross MDT failed!"
19794 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
19795 error "src_child still exists after rename"
19797 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
19798 error "missing file(a) after rename"
19800 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
19801 error "diff after rename"
19805 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19806 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19808 local remote_file=$DIR/$tdir/tgt_dir/b
19810 mkdir -p $DIR/$tdir
19812 prepare_remote_file || error "prepare remote file failed"
19815 $OPENUNLINK $remote_file $remote_file ||
19816 error "openunlink $remote_file failed"
19817 $CHECKSTAT -a $remote_file || error "$remote_file exists"
19819 run_test 310a "open unlink remote file"
19822 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19823 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19825 local remote_file=$DIR/$tdir/tgt_dir/b
19827 mkdir -p $DIR/$tdir
19829 prepare_remote_file || error "prepare remote file failed"
19831 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19832 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
19833 $CHECKSTAT -t file $remote_file || error "check file failed"
19835 run_test 310b "unlink remote file with multiple links while open"
19838 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19839 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
19841 local remote_file=$DIR/$tdir/tgt_dir/b
19843 mkdir -p $DIR/$tdir
19845 prepare_remote_file || error "prepare remote file failed"
19847 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19848 multiop_bg_pause $remote_file O_uc ||
19849 error "mulitop failed for remote file"
19851 $MULTIOP $DIR/$tfile Ouc
19852 kill -USR1 $MULTIPID
19855 run_test 310c "open-unlink remote file with multiple links"
19859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19860 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19861 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
19862 skip "lustre < 2.8.54 does not contain LU-4825 fix"
19863 remote_mds_nodsh && skip "remote MDS with nodsh"
19865 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19866 local mdts=$(comma_list $(mdts_nodes))
19868 mkdir -p $DIR/$tdir
19869 $LFS setstripe -i 0 -c 1 $DIR/$tdir
19870 createmany -o $DIR/$tdir/$tfile. 1000
19872 # statfs data is not real time, let's just calculate it
19873 old_iused=$((old_iused + 1000))
19875 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19876 osp.*OST0000*MDT0000.create_count")
19877 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19878 osp.*OST0000*MDT0000.max_create_count")
19879 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
19881 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
19882 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
19883 [ $index -ne 0 ] || error "$tfile stripe index is 0"
19885 unlinkmany $DIR/$tdir/$tfile. 1000
19887 do_nodes $mdts "$LCTL set_param -n \
19888 osp.*OST0000*.max_create_count=$max_count"
19889 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
19890 do_nodes $mdts "$LCTL set_param -n \
19891 osp.*OST0000*.create_count=$count"
19892 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
19893 grep "=0" && error "create_count is zero"
19896 for i in $(seq 120); do
19897 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19898 # system may be too busy to destroy all objs in time, use
19899 # a somewhat small value to not fail autotest
19900 [ $((old_iused - new_iused)) -gt 400 ] && break
19904 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
19905 [ $((old_iused - new_iused)) -gt 400 ] ||
19906 error "objs not destroyed after unlink"
19908 run_test 311 "disable OSP precreate, and unlink should destroy objs"
19915 local vdevdir=$(dirname $(facet_vdevice $ost))
19916 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
19917 local zfs_zapid=$(do_facet $ost $cmd |
19918 grep -w "/O/0/d$((objid%32))" -C 5 |
19919 awk '/Object/{getline; print $1}')
19920 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
19921 awk "/$objid = /"'{printf $3}')
19926 zfs_object_blksz() {
19930 local vdevdir=$(dirname $(facet_vdevice $ost))
19931 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
19932 local blksz=$(do_facet $ost $cmd $objid |
19933 awk '/dblk/{getline; printf $4}')
19935 case "${blksz: -1}" in
19936 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
19937 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
19944 test_312() { # LU-4856
19945 remote_ost_nodsh && skip "remote OST with nodsh"
19946 [ "$ost1_FSTYPE" = "zfs" ] ||
19947 skip_env "the test only applies to zfs"
19949 local max_blksz=$(do_facet ost1 \
19950 $ZFS get -p recordsize $(facet_device ost1) |
19951 awk '!/VALUE/{print $3}')
19953 # to make life a little bit easier
19954 $LFS mkdir -c 1 -i 0 $DIR/$tdir
19955 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19957 local tf=$DIR/$tdir/$tfile
19959 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19961 # Get ZFS object id
19962 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19963 # block size change by sequential overwrite
19966 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
19967 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
19969 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
19970 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
19974 # block size change by sequential append write
19975 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
19976 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19977 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19980 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
19981 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
19982 oflag=sync conv=notrunc
19984 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19985 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
19986 error "blksz error, actual $blksz, " \
19987 "expected: 2 * $count * $PAGE_SIZE"
19993 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19994 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19996 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
19997 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19998 [ $blksz -eq $PAGE_SIZE ] ||
19999 error "blksz error: $blksz, expected: $PAGE_SIZE"
20001 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
20002 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20003 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
20005 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
20006 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20007 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
20009 run_test 312 "make sure ZFS adjusts its block size by write pattern"
20012 remote_ost_nodsh && skip "remote OST with nodsh"
20014 local file=$DIR/$tfile
20017 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
20019 # define OBD_FAIL_TGT_RCVD_EIO 0x720
20020 do_facet ost1 "$LCTL set_param fail_loc=0x720"
20021 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
20022 error "write should failed"
20023 do_facet ost1 "$LCTL set_param fail_loc=0"
20026 run_test 313 "io should fail after last_rcvd update fail"
20029 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
20031 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
20032 do_facet ost1 "$LCTL set_param fail_loc=0x720"
20034 wait_delete_completed
20035 do_facet ost1 "$LCTL set_param fail_loc=0"
20037 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
20039 test_315() { # LU-618
20040 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
20042 local file=$DIR/$tfile
20045 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
20046 error "multiop file write failed"
20047 $MULTIOP $file oO_RDONLY:r4063232_c &
20052 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
20055 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
20058 run_test 315 "read should be accounted"
20061 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20062 large_xattr_enabled || skip_env "ea_inode feature disabled"
20064 rm -rf $DIR/$tdir/d
20065 mkdir -p $DIR/$tdir/d
20066 chown nobody $DIR/$tdir/d
20067 touch $DIR/$tdir/d/file
20069 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
20071 run_test 316 "lfs mv"
20074 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
20075 skip "Need MDS version at least 2.11.53"
20076 if [ "$ost1_FSTYPE" == "zfs" ]; then
20077 skip "LU-10370: no implementation for ZFS"
20081 local grant_blk_size
20083 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
20084 awk '/grant_block_size:/ { print $2; exit; }')
20086 # Create File of size 5M. Truncate it to below size's and verify
20089 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
20090 error "Create file $DIR/$tfile failed"
20091 stack_trap "rm -f $DIR/$tfile" EXIT
20093 for trunc_sz in 2097152 4097 4000 509 0; do
20094 $TRUNCATE $DIR/$tfile $trunc_sz ||
20095 error "truncate $tfile to $trunc_sz failed"
20096 local sz=$(stat --format=%s $DIR/$tfile)
20097 local blk=$(stat --format=%b $DIR/$tfile)
20098 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
20099 grant_blk_size) * 8))
20101 if [[ $blk -ne $trunc_blk ]]; then
20102 $(which stat) $DIR/$tfile
20103 error "Expected Block $trunc_blk got $blk for $tfile"
20106 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20107 error "Expected Size $trunc_sz got $sz for $tfile"
20112 # Create file with a hole and write actual two blocks. Block count
20115 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
20116 conv=fsync || error "Create file : $DIR/$tfile"
20118 # Calculate the final truncate size.
20119 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
20122 # truncate to size $trunc_sz bytes. Strip the last block
20123 # The block count must drop to 8
20125 $TRUNCATE $DIR/$tfile $trunc_sz ||
20126 error "truncate $tfile to $trunc_sz failed"
20128 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
20129 sz=$(stat --format=%s $DIR/$tfile)
20130 blk=$(stat --format=%b $DIR/$tfile)
20132 if [[ $blk -ne $trunc_bsz ]]; then
20133 $(which stat) $DIR/$tfile
20134 error "Expected Block $trunc_bsz got $blk for $tfile"
20137 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20138 error "Expected Size $trunc_sz got $sz for $tfile"
20140 run_test 317 "Verify blocks get correctly update after truncate"
20143 local old_max_active=$($LCTL get_param -n \
20144 llite.*.max_read_ahead_async_active 2>/dev/null)
20146 $LCTL set_param llite.*.max_read_ahead_async_active=256
20147 local max_active=$($LCTL get_param -n \
20148 llite.*.max_read_ahead_async_active 2>/dev/null)
20149 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
20151 # currently reset to 0 is unsupported, leave it 512 for now.
20152 $LCTL set_param llite.*.max_read_ahead_async_active=0 &&
20153 error "set max_read_ahead_async_active should fail"
20155 $LCTL set_param llite.*.max_read_ahead_async_active=512
20156 max_active=$($LCTL get_param -n \
20157 llite.*.max_read_ahead_async_active 2>/dev/null)
20158 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
20160 # restore @max_active
20161 [ $old_max_active -ne 0 ] && $LCTL set_param \
20162 llite.*.max_read_ahead_async_active=$old_max_active
20164 local old_threshold=$($LCTL get_param -n \
20165 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
20166 local max_per_file_mb=$($LCTL get_param -n \
20167 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
20169 local invalid=$(($max_per_file_mb + 1))
20171 llite.*.read_ahead_async_file_threshold_mb=$invalid\
20172 && error "set $invalid should fail"
20174 local valid=$(($invalid - 1))
20176 llite.*.read_ahead_async_file_threshold_mb=$valid ||
20177 error "set $valid should succeed"
20178 local threshold=$($LCTL get_param -n \
20179 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
20180 [ $threshold -eq $valid ] || error \
20181 "expect threshold $valid got $threshold"
20183 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
20185 run_test 318 "Verify async readahead tunables"
20188 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
20190 local before=$(date +%s)
20192 local mdir=$DIR/$tdir
20193 local file=$mdir/xxx
20195 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
20198 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
20199 $LCTL set_param fail_val=5 fail_loc=0x8000032c
20200 $LFS mv -m1 $file &
20203 dd if=$file of=/dev/null
20205 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
20206 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
20208 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
20210 run_test 319 "lost lease lock on migrate error"
20213 local read_write=$1
20214 if [ "$read_write" = "write" ]; then
20215 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
20216 elif [ "$read_write" = "read" ]; then
20217 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
20219 error "argument error"
20222 # turn off debug for performance testing
20223 local saved_debug=$($LCTL get_param -n debug)
20224 $LCTL set_param debug=0
20226 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20228 # get ost1 size - lustre-OST0000
20229 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
20230 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
20231 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
20233 if [ "$read_write" = "read" ]; then
20234 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
20237 local start_time=$(date +%s.%N)
20238 $dd_cmd bs=1M count=$blocks oflag=sync ||
20239 error "real dd $read_write error"
20240 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
20242 if [ "$read_write" = "write" ]; then
20246 # define OBD_FAIL_OST_FAKE_RW 0x238
20247 do_facet ost1 $LCTL set_param fail_loc=0x238
20249 local start_time=$(date +%s.%N)
20250 $dd_cmd bs=1M count=$blocks oflag=sync ||
20251 error "fake dd $read_write error"
20252 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
20254 if [ "$read_write" = "write" ]; then
20256 cancel_lru_locks osc
20257 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
20258 error "$tfile size not $blocks MB"
20260 do_facet ost1 $LCTL set_param fail_loc=0
20262 echo "fake $read_write $duration_fake vs. normal $read_write" \
20263 "$duration in seconds"
20264 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
20265 error_not_in_vm "fake write is slower"
20267 $LCTL set_param -n debug="$saved_debug"
20270 test_399a() { # LU-7655 for OST fake write
20271 remote_ost_nodsh && skip "remote OST with nodsh"
20275 run_test 399a "fake write should not be slower than normal write"
20277 test_399b() { # LU-8726 for OST fake read
20278 remote_ost_nodsh && skip "remote OST with nodsh"
20279 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
20280 skip_env "ldiskfs only test"
20285 run_test 399b "fake read should not be slower than normal read"
20287 test_400a() { # LU-1606, was conf-sanity test_74
20288 if ! which $CC > /dev/null 2>&1; then
20289 skip_env "$CC is not installed"
20292 local extra_flags=''
20293 local out=$TMP/$tfile
20294 local prefix=/usr/include/lustre
20297 if ! [[ -d $prefix ]]; then
20298 # Assume we're running in tree and fixup the include path.
20299 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
20300 extra_flags+=" -L$LUSTRE/utils/.lib"
20303 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
20304 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
20305 error "client api broken"
20309 run_test 400a "Lustre client api program can compile and link"
20311 test_400b() { # LU-1606, LU-5011
20313 local out=$TMP/$tfile
20314 local prefix=/usr/include/linux/lustre
20316 # We use a hard coded prefix so that this test will not fail
20317 # when run in tree. There are headers in lustre/include/lustre/
20318 # that are not packaged (like lustre_idl.h) and have more
20319 # complicated include dependencies (like config.h and lnet/types.h).
20320 # Since this test about correct packaging we just skip them when
20321 # they don't exist (see below) rather than try to fixup cppflags.
20323 if ! which $CC > /dev/null 2>&1; then
20324 skip_env "$CC is not installed"
20327 for header in $prefix/*.h; do
20328 if ! [[ -f "$header" ]]; then
20332 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
20333 continue # lustre_ioctl.h is internal header
20336 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
20337 error "cannot compile '$header'"
20341 run_test 400b "packaged headers can be compiled"
20343 test_401a() { #LU-7437
20344 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
20345 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
20347 #count the number of parameters by "list_param -R"
20348 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
20349 #count the number of parameters by listing proc files
20350 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
20351 echo "proc_dirs='$proc_dirs'"
20352 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
20353 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
20356 [ $params -eq $procs ] ||
20357 error "found $params parameters vs. $procs proc files"
20359 # test the list_param -D option only returns directories
20360 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
20361 #count the number of parameters by listing proc directories
20362 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
20365 [ $params -eq $procs ] ||
20366 error "found $params parameters vs. $procs proc files"
20368 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
20371 local save=$($LCTL get_param -n jobid_var)
20374 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
20375 error "no error returned when setting bad parameters"
20377 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
20378 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
20380 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
20381 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
20382 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
20384 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
20387 local jobid_var_old=$($LCTL get_param -n jobid_var)
20388 local jobid_var_new
20390 $LCTL set_param jobid_var= &&
20391 error "no error returned for 'set_param a='"
20393 jobid_var_new=$($LCTL get_param -n jobid_var)
20394 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20395 error "jobid_var was changed by setting without value"
20397 $LCTL set_param jobid_var &&
20398 error "no error returned for 'set_param a'"
20400 jobid_var_new=$($LCTL get_param -n jobid_var)
20401 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20402 error "jobid_var was changed by setting without value"
20404 run_test 401c "Verify 'lctl set_param' without value fails in either format."
20407 local jobid_var_old=$($LCTL get_param -n jobid_var)
20408 local jobid_var_new
20409 local new_value="foo=bar"
20411 $LCTL set_param jobid_var=$new_value ||
20412 error "'set_param a=b' did not accept a value containing '='"
20414 jobid_var_new=$($LCTL get_param -n jobid_var)
20415 [[ "$jobid_var_new" == "$new_value" ]] ||
20416 error "'set_param a=b' failed on a value containing '='"
20418 # Reset the jobid_var to test the other format
20419 $LCTL set_param jobid_var=$jobid_var_old
20420 jobid_var_new=$($LCTL get_param -n jobid_var)
20421 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20422 error "failed to reset jobid_var"
20424 $LCTL set_param jobid_var $new_value ||
20425 error "'set_param a b' did not accept a value containing '='"
20427 jobid_var_new=$($LCTL get_param -n jobid_var)
20428 [[ "$jobid_var_new" == "$new_value" ]] ||
20429 error "'set_param a b' failed on a value containing '='"
20431 $LCTL set_param jobid_var $jobid_var_old
20432 jobid_var_new=$($LCTL get_param -n jobid_var)
20433 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20434 error "failed to reset jobid_var"
20436 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
20439 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
20440 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
20441 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
20442 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
20443 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
20444 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
20445 remote_mds_nodsh && skip "remote MDS with nodsh"
20447 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
20448 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
20449 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
20450 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
20451 echo "Touch failed - OK"
20453 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
20456 local file1=$DIR/$tfile.1
20457 local file2=$DIR/$tfile.2
20458 local tfile=$TMP/$tfile
20460 rm -f $file1 $file2 $tfile
20465 # 30 sec OBD_TIMEOUT in ll_getattr()
20466 # right before populating st_nlink
20467 $LCTL set_param fail_loc=0x80001409
20468 stat -c %h $file1 > $tfile &
20470 # create an alias, drop all locks and reclaim the dentry
20472 cancel_lru_locks mdc
20473 cancel_lru_locks osc
20474 sysctl -w vm.drop_caches=2
20478 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
20480 rm -f $tfile $file1 $file2
20482 run_test 403 "i_nlink should not drop to zero due to aliasing"
20484 test_404() { # LU-6601
20485 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
20486 skip "Need server version newer than 2.8.52"
20487 remote_mds_nodsh && skip "remote MDS with nodsh"
20489 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
20490 awk '/osp .*-osc-MDT/ { print $4}')
20493 for osp in $mosps; do
20494 echo "Deactivate: " $osp
20495 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
20496 local stat=$(do_facet $SINGLEMDS $LCTL dl |
20497 awk -vp=$osp '$4 == p { print $2 }')
20498 [ $stat = IN ] || {
20499 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
20500 error "deactivate error"
20502 echo "Activate: " $osp
20503 do_facet $SINGLEMDS $LCTL --device %$osp activate
20504 local stat=$(do_facet $SINGLEMDS $LCTL dl |
20505 awk -vp=$osp '$4 == p { print $2 }')
20506 [ $stat = UP ] || {
20507 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
20508 error "activate error"
20512 run_test 404 "validate manual {de}activated works properly for OSPs"
20515 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
20516 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
20517 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
20518 skip "Layout swap lock is not supported"
20520 check_swap_layouts_support
20522 test_mkdir $DIR/$tdir
20523 swap_lock_test -d $DIR/$tdir ||
20524 error "One layout swap locked test failed"
20526 run_test 405 "Various layout swap lock tests"
20529 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20530 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
20531 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
20532 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20533 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
20534 skip "Need MDS version at least 2.8.50"
20536 local def_stripe_size=$($LFS getstripe -S $MOUNT)
20537 local test_pool=$TESTNAME
20539 pool_add $test_pool || error "pool_add failed"
20540 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
20541 error "pool_add_targets failed"
20543 save_layout_restore_at_exit $MOUNT
20545 # parent set default stripe count only, child will stripe from both
20546 # parent and fs default
20547 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
20548 error "setstripe $MOUNT failed"
20549 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
20550 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
20551 for i in $(seq 10); do
20552 local f=$DIR/$tdir/$tfile.$i
20553 touch $f || error "touch failed"
20554 local count=$($LFS getstripe -c $f)
20555 [ $count -eq $OSTCOUNT ] ||
20556 error "$f stripe count $count != $OSTCOUNT"
20557 local offset=$($LFS getstripe -i $f)
20558 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
20559 local size=$($LFS getstripe -S $f)
20560 [ $size -eq $((def_stripe_size * 2)) ] ||
20561 error "$f stripe size $size != $((def_stripe_size * 2))"
20562 local pool=$($LFS getstripe -p $f)
20563 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
20566 # change fs default striping, delete parent default striping, now child
20567 # will stripe from new fs default striping only
20568 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
20569 error "change $MOUNT default stripe failed"
20570 $LFS setstripe -c 0 $DIR/$tdir ||
20571 error "delete $tdir default stripe failed"
20572 for i in $(seq 11 20); do
20573 local f=$DIR/$tdir/$tfile.$i
20574 touch $f || error "touch $f failed"
20575 local count=$($LFS getstripe -c $f)
20576 [ $count -eq 1 ] || error "$f stripe count $count != 1"
20577 local offset=$($LFS getstripe -i $f)
20578 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
20579 local size=$($LFS getstripe -S $f)
20580 [ $size -eq $def_stripe_size ] ||
20581 error "$f stripe size $size != $def_stripe_size"
20582 local pool=$($LFS getstripe -p $f)
20583 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
20586 unlinkmany $DIR/$tdir/$tfile. 1 20
20588 local f=$DIR/$tdir/$tfile
20589 pool_remove_all_targets $test_pool $f
20590 pool_remove $test_pool $f
20592 run_test 406 "DNE support fs default striping"
20595 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20596 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
20597 skip "Need MDS version at least 2.8.55"
20598 remote_mds_nodsh && skip "remote MDS with nodsh"
20600 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
20601 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
20602 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
20603 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
20604 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
20606 #define OBD_FAIL_DT_TXN_STOP 0x2019
20607 for idx in $(seq $MDSCOUNT); do
20608 do_facet mds$idx "lctl set_param fail_loc=0x2019"
20610 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
20611 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
20612 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
20615 run_test 407 "transaction fail should cause operation fail"
20618 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
20620 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
20621 lctl set_param fail_loc=0x8000040a
20622 # let ll_prepare_partial_page() fail
20623 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
20627 # create at least 100 unused inodes so that
20628 # shrink_icache_memory(0) should not return 0
20629 touch $DIR/$tfile-{0..100}
20630 rm -f $DIR/$tfile-{0..100}
20633 echo 2 > /proc/sys/vm/drop_caches
20635 run_test 408 "drop_caches should not hang due to page leaks"
20639 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20641 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
20642 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
20643 touch $DIR/$tdir/guard || error "(2) Fail to create"
20645 local PREFIX=$(str_repeat 'A' 128)
20646 echo "Create 1K hard links start at $(date)"
20647 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20648 error "(3) Fail to hard link"
20650 echo "Links count should be right although linkEA overflow"
20651 stat $DIR/$tdir/guard || error "(4) Fail to stat"
20652 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
20653 [ $linkcount -eq 1001 ] ||
20654 error "(5) Unexpected hard links count: $linkcount"
20656 echo "List all links start at $(date)"
20657 ls -l $DIR/$tdir/foo > /dev/null ||
20658 error "(6) Fail to list $DIR/$tdir/foo"
20660 echo "Unlink hard links start at $(date)"
20661 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20662 error "(7) Fail to unlink"
20663 echo "Unlink hard links finished at $(date)"
20665 run_test 409 "Large amount of cross-MDTs hard links on the same file"
20669 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
20670 skip "Need client version at least 2.9.59"
20672 # Create a file, and stat it from the kernel
20673 local testfile=$DIR/$tfile
20676 local run_id=$RANDOM
20677 local my_ino=$(stat --format "%i" $testfile)
20679 # Try to insert the module. This will always fail as the
20680 # module is designed to not be inserted.
20681 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
20684 # Anything but success is a test failure
20686 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
20687 error "no inode match"
20689 run_test 410 "Test inode number returned from kernel thread"
20691 cleanup_test411_cgroup() {
20697 local cg_basedir=/sys/fs/cgroup/memory
20699 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
20700 skip "no setup for cgroup"
20702 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
20703 error "test file creation failed"
20704 cancel_lru_locks osc
20706 # Create a very small memory cgroup to force a slab allocation error
20707 local cgdir=$cg_basedir/osc_slab_alloc
20708 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
20709 trap "cleanup_test411_cgroup $cgdir" EXIT
20710 echo 2M > $cgdir/memory.kmem.limit_in_bytes
20711 echo 1M > $cgdir/memory.limit_in_bytes
20713 # Should not LBUG, just be killed by oom-killer
20714 # dd will return 0 even allocation failure in some environment.
20715 # So don't check return value
20716 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
20717 cleanup_test411_cgroup $cgdir
20721 run_test 411 "Slab allocation error with cgroup does not LBUG"
20724 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20725 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20726 skip "Need server version at least 2.10.55"
20729 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
20730 error "mkdir failed"
20731 $LFS getdirstripe $DIR/$tdir
20732 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20733 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
20734 error "expect $((MDSCOUT - 1)) get $stripe_index"
20735 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
20736 [ $stripe_count -eq 2 ] ||
20737 error "expect 2 get $stripe_count"
20739 run_test 412 "mkdir on specific MDTs"
20742 [ $MDSCOUNT -lt 2 ] &&
20743 skip "We need at least 2 MDTs for this test"
20745 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20746 skip "Need server version at least 2.10.55"
20749 mkdir $DIR/$tdir || error "mkdir failed"
20751 # find MDT that is the most full
20752 local max=$($LFS df | grep MDT |
20761 END { split(b, c, ":")
20766 for i in $(seq $((MDSCOUNT - 1))); do
20767 $LFS mkdir -c $i $DIR/$tdir/d$i ||
20768 error "mkdir d$i failed"
20769 $LFS getdirstripe $DIR/$tdir/d$i
20770 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
20771 [ $stripe_index -ne $max ] ||
20772 error "don't expect $max"
20775 run_test 413a "mkdir on less full MDTs"
20778 [ $MDSCOUNT -lt 2 ] &&
20779 skip "We need at least 2 MDTs for this test"
20781 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
20782 skip "Need server version at least 2.12.52"
20784 mkdir $DIR/$tdir || error "mkdir failed"
20785 $LFS setdirstripe -D -i -1 -H space $DIR/$tdir ||
20786 error "setdirstripe failed"
20788 local qos_prio_free
20789 local qos_threshold_rr
20792 qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
20793 qos_prio_free=${qos_prio_free%%%}
20794 qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
20795 qos_threshold_rr=${qos_threshold_rr%%%}
20796 qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
20798 stack_trap "$LCTL set_param lmv.*.qos_prio_free=$qos_prio_free" EXIT
20799 stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$qos_threshold_rr" \
20801 stack_trap "$LCTL set_param lmv.*.qos_maxage=$qos_maxage" EXIT
20803 echo "mkdir with roundrobin"
20805 $LCTL set_param lmv.*.qos_threshold_rr=100
20806 for i in $(seq $((100 * MDSCOUNT))); do
20807 mkdir $DIR/$tdir/subdir$i || error "mkdir subdir$i failed"
20809 for i in $(seq $MDSCOUNT); do
20810 count=$($LFS getdirstripe -i $DIR/$tdir/* | grep ^$((i - 1))$ |
20812 echo "$count directories created on MDT$((i - 1))"
20813 [ $count -eq 100 ] || error "subdirs are not evenly distributed"
20816 rm -rf $DIR/$tdir/*
20818 $LCTL set_param lmv.*.qos_threshold_rr=$qos_threshold_rr
20819 # Shorten statfs result age, so that it can be updated in time
20820 $LCTL set_param lmv.*.qos_maxage=1
20831 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
20832 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
20833 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
20835 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
20836 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
20839 for ((i = 1; i < ${#ffree[@]}; i++)); do
20840 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
20841 if [ $tmp -gt $max ]; then
20845 if [ $tmp -lt $min ]; then
20851 [ ${ffree[min_index]} -eq 0 ] &&
20852 skip "no free files in MDT$min_index"
20853 [ ${ffree[min_index]} -gt 100000000 ] &&
20854 skip "too much free files in MDT$min_index"
20856 # Check if we need to generate uneven MDTs
20858 local diff=$(((max - min ) * 100 / min))
20859 local value="$(generate_string 1024)"
20862 while [ $diff -lt $threshold ]; do
20863 # generate uneven MDTs, create till $threshold% diff
20864 echo -n "weight diff=$diff% must be > $threshold% ..."
20865 count=$((${ffree[min_index]} / 10))
20866 # 50 sec per 10000 files in vm
20867 [ $count -gt 40000 ] && [ "$SLOW" = "no" ] &&
20868 skip "$count files to create"
20869 echo "Fill MDT$min_index with $count files"
20870 [ -d $DIR/$tdir-MDT$min_index ] ||
20871 $LFS mkdir -i $min_index $DIR/$tdir-MDT$min_index ||
20872 error "mkdir $tdir-MDT$min_index failed"
20873 for i in $(seq $count); do
20874 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE \
20875 $DIR/$tdir-MDT$min_index/f$i > /dev/null ||
20876 error "create f$i failed"
20877 setfattr -n user.413b -v $value \
20878 $DIR/$tdir-MDT$min_index/f$i ||
20879 error "setfattr f$i failed"
20882 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
20883 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
20884 max=$(((${ffree[max_index]} >> 8) * \
20885 (${bavail[max_index]} * bsize >> 16)))
20886 min=$(((${ffree[min_index]} >> 8) * \
20887 (${bavail[min_index]} * bsize >> 16)))
20888 diff=$(((max - min) * 100 / min))
20891 echo "MDT filesfree available: ${ffree[@]}"
20892 echo "MDT blocks available: ${bavail[@]}"
20893 echo "weight diff=$diff%"
20895 echo "mkdir with balanced space usage"
20896 $LCTL set_param lmv.*.qos_prio_free=100
20897 for i in $(seq $((100 * MDSCOUNT))); do
20898 mkdir $DIR/$tdir/subdir$i || error "mkdir subdir$i failed"
20901 for i in $(seq $MDSCOUNT); do
20902 count=$($LFS getdirstripe -i $DIR/$tdir/* | grep ^$((i - 1))$ |
20904 echo "$count directories created on MDT$((i - 1))"
20907 max=$($LFS getdirstripe -i $DIR/$tdir/* | grep ^$max_index$ | wc -l)
20908 min=$($LFS getdirstripe -i $DIR/$tdir/* | grep ^$min_index$ | wc -l)
20910 [ $((max - min)) -lt 10 ] &&
20911 error "subdirs shouldn't be evenly distributed"
20913 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
20915 $LFS setdirstripe -D -d $DIR/$tdir || error "setdirstripe -d failed"
20916 getfattr -n trusted.dmv $DIR/$tdir &&
20917 error "default dir layout exists" || true
20919 run_test 413b "mkdir with balanced space usage"
20922 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
20923 $LCTL set_param fail_loc=0x80000521
20924 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
20927 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
20930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20931 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
20932 skip "Need server version at least 2.11.52"
20942 # this test may be slow on ZFS
20943 [ "$mds1_FSTYPE" == "zfs" ] && total=100
20945 # though this test is designed for striped directory, let's test normal
20946 # directory too since lock is always saved as CoS lock.
20947 test_mkdir $DIR/$tdir || error "mkdir $tdir"
20948 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
20957 start_time=$(date +%s)
20958 for i in $(seq $total); do
20959 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
20962 end_time=$(date +%s)
20963 duration=$((end_time - start_time))
20965 kill -9 $setattr_pid
20967 echo "rename $total files took $duration sec"
20968 [ $duration -lt 100 ] || error "rename took $duration sec"
20970 run_test 415 "lock revoke is not missing"
20973 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
20974 skip "Need server version at least 2.11.55"
20976 # define OBD_FAIL_OSD_TXN_START 0x19a
20977 do_facet mds1 lctl set_param fail_loc=0x19a
20979 lfs mkdir -c $MDSCOUNT $DIR/$tdir
20983 run_test 416 "transaction start failure won't cause system hung"
20987 do_nodes $(comma_list $(mdts_nodes)) \
20988 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
20989 do_nodes $(comma_list $(mdts_nodes)) \
20990 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
20991 do_nodes $(comma_list $(mdts_nodes)) \
20992 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
20996 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20997 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
20998 skip "Need MDS version at least 2.11.56"
21000 trap cleanup_417 RETURN EXIT
21002 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
21003 do_nodes $(comma_list $(mdts_nodes)) \
21004 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
21005 $LFS migrate -m 0 $DIR/$tdir.1 &&
21006 error "migrate dir $tdir.1 should fail"
21008 do_nodes $(comma_list $(mdts_nodes)) \
21009 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
21010 $LFS mkdir -i 1 $DIR/$tdir.2 &&
21011 error "create remote dir $tdir.2 should fail"
21013 do_nodes $(comma_list $(mdts_nodes)) \
21014 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
21015 $LFS mkdir -c 2 $DIR/$tdir.3 &&
21016 error "create striped dir $tdir.3 should fail"
21019 run_test 417 "disable remote dir, striped dir and dir migration"
21021 # Checks that the outputs of df [-i] and lfs df [-i] match
21023 # usage: check_lfs_df <blocks | inodes> <mountpoint>
21033 [ "$1" == "blocks" ] && inodes= || inodes="-i"
21035 for count in {1..100}; do
21039 # read the lines of interest
21040 df_out=($(df -P $inodes $dir | tail -n +2)) ||
21041 error "df $inodes $dir | tail -n +2 failed"
21042 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
21043 error "lfs df $inodes $dir | grep summary: failed"
21045 # skip first substrings of each output as they are different
21046 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
21047 # compare the two outputs
21049 for i in {1..5}; do
21050 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
21058 lfs df $inodes $dir
21059 error "df and lfs df $1 output mismatch: " \
21060 "df ${inodes}: ${df_out[*]}, " \
21061 "lfs df ${inodes}: ${lfs_df_out[*]}"
21066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21068 local dir=$DIR/$tdir
21069 local numfiles=$((RANDOM % 4096 + 2))
21070 local numblocks=$((RANDOM % 256 + 1))
21072 wait_delete_completed
21075 # check block output
21076 check_lfs_df blocks $dir
21077 # check inode output
21078 check_lfs_df inodes $dir
21080 # create a single file and retest
21081 echo "Creating a single file and testing"
21082 createmany -o $dir/$tfile- 1 &>/dev/null ||
21083 error "creating 1 file in $dir failed"
21084 check_lfs_df blocks $dir
21085 check_lfs_df inodes $dir
21087 # create a random number of files
21088 echo "Creating $((numfiles - 1)) files and testing"
21089 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
21090 error "creating $((numfiles - 1)) files in $dir failed"
21092 # write a random number of blocks to the first test file
21093 echo "Writing $numblocks 4K blocks and testing"
21094 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
21095 count=$numblocks &>/dev/null ||
21096 error "dd to $dir/${tfile}-0 failed"
21099 check_lfs_df blocks $dir
21100 check_lfs_df inodes $dir
21102 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
21103 error "unlinking $numfiles files in $dir failed"
21105 run_test 418 "df and lfs df outputs match"
21109 local dir=$DIR/$tdir
21114 cancel_lru_locks mdc
21116 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
21117 $LCTL set_param fail_loc=0x1410
21119 $LCTL set_param fail_loc=0
21122 run_test 419 "Verify open file by name doesn't crash kernel"
21126 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
21127 skip "Need MDS version at least 2.12.53"
21129 local SAVE_UMASK=$(umask)
21130 local dir=$DIR/$tdir
21131 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
21135 mkdir -m03777 $dir/testdir
21136 ls -dn $dir/testdir
21137 # Need to remove trailing '.' when SELinux is enabled
21138 local dirperms=$(ls -dn $dir/testdir |
21139 awk '{ sub(/\.$/, "", $1); print $1}')
21140 [ $dirperms == "drwxrwsrwt" ] ||
21141 error "incorrect perms on $dir/testdir"
21143 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
21144 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
21145 ls -n $dir/testdir/testfile
21146 local fileperms=$(ls -n $dir/testdir/testfile |
21147 awk '{ sub(/\.$/, "", $1); print $1}')
21148 [ $fileperms == "-rwxr-xr-x" ] ||
21149 error "incorrect perms on $dir/testdir/testfile"
21153 run_test 420 "clear SGID bit on non-directories for non-members"
21160 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21161 skip "Need MDS version at least 2.12.54"
21163 test_mkdir $DIR/$tdir
21164 createmany -o $DIR/$tdir/f 3
21165 cnt=$(ls -1 $DIR/$tdir | wc -l)
21166 [ $cnt != 3 ] && error "unexpected #files: $cnt"
21168 fid1=$(lfs path2fid $DIR/$tdir/f1)
21169 fid2=$(lfs path2fid $DIR/$tdir/f2)
21170 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
21172 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
21173 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
21175 cnt=$(ls -1 $DIR/$tdir | wc -l)
21176 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
21178 rm -f $DIR/$tdir/f3 || error "can't remove f3"
21179 createmany -o $DIR/$tdir/f 3
21180 cnt=$(ls -1 $DIR/$tdir | wc -l)
21181 [ $cnt != 3 ] && error "unexpected #files: $cnt"
21183 fid1=$(lfs path2fid $DIR/$tdir/f1)
21184 fid2=$(lfs path2fid $DIR/$tdir/f2)
21185 echo "remove using fsname $FSNAME"
21186 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
21188 cnt=$(ls -1 $DIR/$tdir | wc -l)
21189 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
21191 run_test 421a "simple rm by fid"
21198 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21199 skip "Need MDS version at least 2.12.54"
21201 test_mkdir $DIR/$tdir
21202 createmany -o $DIR/$tdir/f 3
21203 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
21206 FID1=$(lfs path2fid $DIR/$tdir/f1)
21207 FID2=$(lfs path2fid $DIR/$tdir/f2)
21208 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
21210 kill -USR1 $MULTIPID
21213 cnt=$(ls $DIR/$tdir | wc -l)
21214 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
21216 run_test 421b "rm by fid on open file"
21222 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21223 skip "Need MDS version at least 2.12.54"
21225 test_mkdir $DIR/$tdir
21226 createmany -o $DIR/$tdir/f 3
21227 touch $DIR/$tdir/$tfile
21228 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
21229 cnt=$(ls -1 $DIR/$tdir | wc -l)
21230 [ $cnt != 184 ] && error "unexpected #files: $cnt"
21232 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
21233 $LFS rmfid $DIR $FID1 || error "rmfid failed"
21235 cnt=$(ls $DIR/$tdir | wc -l)
21236 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
21238 run_test 421c "rm by fid against hardlinked files"
21244 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21245 skip "Need MDS version at least 2.12.54"
21247 test_mkdir $DIR/$tdir
21248 createmany -o $DIR/$tdir/f 4097
21249 cnt=$(ls -1 $DIR/$tdir | wc -l)
21250 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
21252 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
21253 $LFS rmfid $DIR $FIDS || error "rmfid failed"
21255 cnt=$(ls $DIR/$tdir | wc -l)
21257 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21259 run_test 421d "rmfid en masse"
21265 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21266 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21267 skip "Need MDS version at least 2.12.54"
21269 mkdir -p $DIR/$tdir
21270 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
21271 createmany -o $DIR/$tdir/striped_dir/f 512
21272 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21273 [ $cnt != 512 ] && error "unexpected #files: $cnt"
21275 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
21276 sed "s/[/][^:]*://g")
21277 $LFS rmfid $DIR $FIDS || error "rmfid failed"
21279 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21281 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21283 run_test 421e "rmfid in DNE"
21289 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21290 skip "Need MDS version at least 2.12.54"
21292 test_mkdir $DIR/$tdir
21294 cnt=$(ls -1 $DIR/$tdir | wc -l)
21295 [ $cnt != 1 ] && error "unexpected #files: $cnt"
21297 FID=$(lfs path2fid $DIR/$tdir/f)
21298 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
21299 # rmfid should fail
21300 cnt=$(ls -1 $DIR/$tdir | wc -l)
21301 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
21303 chmod a+rw $DIR/$tdir
21305 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
21306 # rmfid should fail
21307 cnt=$(ls -1 $DIR/$tdir | wc -l)
21308 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
21311 $RUNAS touch $DIR/$tdir/f
21312 FID=$(lfs path2fid $DIR/$tdir/f)
21313 echo "rmfid as root"
21314 $LFS rmfid $DIR $FID || error "rmfid as root failed"
21315 cnt=$(ls -1 $DIR/$tdir | wc -l)
21316 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
21319 $RUNAS touch $DIR/$tdir/f
21320 cnt=$(ls -1 $DIR/$tdir | wc -l)
21321 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
21322 FID=$(lfs path2fid $DIR/$tdir/f)
21323 # rmfid w/o user_fid2path mount option should fail
21324 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
21325 cnt=$(ls -1 $DIR/$tdir | wc -l)
21326 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
21328 umount_client $MOUNT || error "failed to umount client"
21329 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
21330 error "failed to mount client'"
21332 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
21333 # rmfid should succeed
21334 cnt=$(ls -1 $DIR/$tdir | wc -l)
21335 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
21337 # rmfid shouldn't allow to remove files due to dir's permission
21338 chmod a+rwx $DIR/$tdir
21341 FID=$(lfs path2fid $DIR/$tdir/f)
21342 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
21344 umount_client $MOUNT || error "failed to umount client"
21345 mount_client $MOUNT "$MOUNT_OPTS" ||
21346 error "failed to mount client'"
21349 run_test 421f "rmfid checks permissions"
21355 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21356 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21357 skip "Need MDS version at least 2.12.54"
21359 mkdir -p $DIR/$tdir
21360 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
21361 createmany -o $DIR/$tdir/striped_dir/f 512
21362 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21363 [ $cnt != 512 ] && error "unexpected #files: $cnt"
21365 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
21366 sed "s/[/][^:]*://g")
21368 rm -f $DIR/$tdir/striped_dir/f1*
21369 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21370 removed=$((512 - cnt))
21372 # few files have been just removed, so we expect
21373 # rmfid to fail on their fids
21374 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
21375 [ $removed != $errors ] && error "$errors != $removed"
21377 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21379 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21381 run_test 421g "rmfid to return errors properly"
21384 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
21385 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
21386 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
21387 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
21388 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
21390 local amc=$(at_max_get client)
21391 local amo=$(at_max_get mds1)
21392 local timeout=`lctl get_param -n timeout`
21394 at_max_set 0 client
21397 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
21398 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
21399 fail_val=$(((2*timeout + 10)*1000))
21400 touch $DIR/$tdir/d3/file &
21402 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
21403 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
21404 fail_val=$((2*timeout + 5))
21405 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
21409 sleep $((2 * timeout))
21413 touch $DIR/$tdir/d2/file3
21414 touch $DIR/$tdir/d2/file4
21415 touch $DIR/$tdir/d2/file5
21418 at_max_set $amc client
21419 at_max_set $amo mds1
21421 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
21422 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
21423 error "Watchdog is always throttled"
21425 run_test 422 "kill a process with RPC in progress"
21428 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21429 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
21430 skip "Need server version at least 2.9.55"
21432 start_full_debug_logging
21436 stop_full_debug_logging
21440 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
21441 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
21442 awk '/The barrier for/ { print $7 }')
21445 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
21450 barrier_expired() {
21453 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
21454 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
21455 awk '/will be expired/ { print $7 }')
21457 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
21466 echo "Start barrier_freeze at: $(date)"
21467 #define OBD_FAIL_BARRIER_DELAY 0x2202
21468 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
21469 # Do not reduce barrier time - See LU-11873
21470 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
21473 local b_status=$(barrier_stat)
21474 echo "Got barrier status at: $(date)"
21475 [ "$b_status" = "'freezing_p1'" ] ||
21476 error "(1) unexpected barrier status $b_status"
21478 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
21480 b_status=$(barrier_stat)
21481 [ "$b_status" = "'frozen'" ] ||
21482 error "(2) unexpected barrier status $b_status"
21484 local expired=$(barrier_expired)
21485 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
21486 sleep $((expired + 3))
21488 b_status=$(barrier_stat)
21489 [ "$b_status" = "'expired'" ] ||
21490 error "(3) unexpected barrier status $b_status"
21492 # Do not reduce barrier time - See LU-11873
21493 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
21494 error "(4) fail to freeze barrier"
21496 b_status=$(barrier_stat)
21497 [ "$b_status" = "'frozen'" ] ||
21498 error "(5) unexpected barrier status $b_status"
21500 echo "Start barrier_thaw at: $(date)"
21501 #define OBD_FAIL_BARRIER_DELAY 0x2202
21502 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
21503 do_facet mgs $LCTL barrier_thaw $FSNAME &
21506 b_status=$(barrier_stat)
21507 echo "Got barrier status at: $(date)"
21508 [ "$b_status" = "'thawing'" ] ||
21509 error "(6) unexpected barrier status $b_status"
21511 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
21513 b_status=$(barrier_stat)
21514 [ "$b_status" = "'thawed'" ] ||
21515 error "(7) unexpected barrier status $b_status"
21517 #define OBD_FAIL_BARRIER_FAILURE 0x2203
21518 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
21519 do_facet mgs $LCTL barrier_freeze $FSNAME
21521 b_status=$(barrier_stat)
21522 [ "$b_status" = "'failed'" ] ||
21523 error "(8) unexpected barrier status $b_status"
21525 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21526 do_facet mgs $LCTL barrier_thaw $FSNAME
21530 run_test 801a "write barrier user interfaces and stat machine"
21535 mkdir $DIR/$tdir || error "(1) fail to mkdir"
21536 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
21537 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
21538 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
21539 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
21541 cancel_lru_locks mdc
21543 # 180 seconds should be long enough
21544 do_facet mgs $LCTL barrier_freeze $FSNAME 180
21546 local b_status=$(barrier_stat)
21547 [ "$b_status" = "'frozen'" ] ||
21548 error "(6) unexpected barrier status $b_status"
21550 mkdir $DIR/$tdir/d0/d10 &
21553 touch $DIR/$tdir/d1/f13 &
21556 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
21559 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
21562 rm -f $DIR/$tdir/d4/f12 &
21565 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
21567 # To guarantee taht the 'stat' is not blocked
21568 b_status=$(barrier_stat)
21569 [ "$b_status" = "'frozen'" ] ||
21570 error "(8) unexpected barrier status $b_status"
21572 # let above commands to run at background
21575 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
21576 ps -p $touch_pid || error "(10) touch should be blocked"
21577 ps -p $ln_pid || error "(11) link should be blocked"
21578 ps -p $mv_pid || error "(12) rename should be blocked"
21579 ps -p $rm_pid || error "(13) unlink should be blocked"
21581 b_status=$(barrier_stat)
21582 [ "$b_status" = "'frozen'" ] ||
21583 error "(14) unexpected barrier status $b_status"
21585 do_facet mgs $LCTL barrier_thaw $FSNAME
21586 b_status=$(barrier_stat)
21587 [ "$b_status" = "'thawed'" ] ||
21588 error "(15) unexpected barrier status $b_status"
21590 wait $mkdir_pid || error "(16) mkdir should succeed"
21591 wait $touch_pid || error "(17) touch should succeed"
21592 wait $ln_pid || error "(18) link should succeed"
21593 wait $mv_pid || error "(19) rename should succeed"
21594 wait $rm_pid || error "(20) unlink should succeed"
21598 run_test 801b "modification will be blocked by write barrier"
21601 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21605 stop mds2 || error "(1) Fail to stop mds2"
21607 do_facet mgs $LCTL barrier_freeze $FSNAME 30
21609 local b_status=$(barrier_stat)
21610 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
21611 do_facet mgs $LCTL barrier_thaw $FSNAME
21612 error "(2) unexpected barrier status $b_status"
21615 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21616 error "(3) Fail to rescan barrier bitmap"
21618 # Do not reduce barrier time - See LU-11873
21619 do_facet mgs $LCTL barrier_freeze $FSNAME 20
21621 b_status=$(barrier_stat)
21622 [ "$b_status" = "'frozen'" ] ||
21623 error "(4) unexpected barrier status $b_status"
21625 do_facet mgs $LCTL barrier_thaw $FSNAME
21626 b_status=$(barrier_stat)
21627 [ "$b_status" = "'thawed'" ] ||
21628 error "(5) unexpected barrier status $b_status"
21630 local devname=$(mdsdevname 2)
21632 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
21634 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21635 error "(7) Fail to rescan barrier bitmap"
21639 run_test 801c "rescan barrier bitmap"
21641 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
21642 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
21643 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
21644 saved_MOUNT_OPTS=$MOUNT_OPTS
21650 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
21651 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
21652 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
21653 MOUNT_OPTS=$saved_MOUNT_OPTS
21658 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
21659 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21660 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
21661 skip "Need server version at least 2.9.55"
21663 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
21665 mkdir $DIR/$tdir || error "(1) fail to mkdir"
21667 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
21668 error "(2) Fail to copy"
21670 trap cleanup_802a EXIT
21672 # sync by force before remount as readonly
21673 sync; sync_all_data; sleep 3; sync_all_data
21677 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
21678 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
21679 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
21681 echo "Mount the server as read only"
21682 setupall server_only || error "(3) Fail to start servers"
21684 echo "Mount client without ro should fail"
21685 mount_client $MOUNT &&
21686 error "(4) Mount client without 'ro' should fail"
21688 echo "Mount client with ro should succeed"
21689 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
21690 mount_client $MOUNT ||
21691 error "(5) Mount client with 'ro' should succeed"
21693 echo "Modify should be refused"
21694 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
21696 echo "Read should be allowed"
21697 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
21698 error "(7) Read should succeed under ro mode"
21702 run_test 802a "simulate readonly device"
21705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21706 remote_mds_nodsh && skip "remote MDS with nodsh"
21708 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
21709 skip "readonly option not available"
21711 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
21713 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
21714 error "(2) Fail to copy"
21716 # write back all cached data before setting MDT to readonly
21720 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
21721 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
21723 echo "Modify should be refused"
21724 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
21726 echo "Read should be allowed"
21727 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
21728 error "(7) Read should succeed under ro mode"
21731 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
21733 run_test 802b "be able to set MDTs to readonly"
21736 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21737 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21738 skip "MDS needs to be newer than 2.10.54"
21740 mkdir -p $DIR/$tdir
21741 # Create some objects on all MDTs to trigger related logs objects
21742 for idx in $(seq $MDSCOUNT); do
21743 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
21744 $DIR/$tdir/dir${idx} ||
21745 error "Fail to create $DIR/$tdir/dir${idx}"
21749 wait_delete_completed # ensure old test cleanups are finished
21750 echo "before create:"
21752 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21754 for i in {1..10}; do
21755 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
21756 error "Fail to create $DIR/$tdir/foo$i"
21760 echo "after create:"
21762 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21764 # allow for an llog to be cleaned up during the test
21765 [ $after_used -ge $((before_used + 10 - 1)) ] ||
21766 error "before ($before_used) + 10 > after ($after_used)"
21768 for i in {1..10}; do
21769 rm -rf $DIR/$tdir/foo$i ||
21770 error "Fail to remove $DIR/$tdir/foo$i"
21773 sleep 3 # avoid MDT return cached statfs
21774 wait_delete_completed
21775 echo "after unlink:"
21777 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21779 # allow for an llog to be created during the test
21780 [ $after_used -le $((before_used + 1)) ] ||
21781 error "after ($after_used) > before ($before_used) + 1"
21783 run_test 803 "verify agent object for remote object"
21786 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21787 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21788 skip "MDS needs to be newer than 2.10.54"
21789 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21791 mkdir -p $DIR/$tdir
21792 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
21793 error "Fail to create $DIR/$tdir/dir0"
21795 local fid=$($LFS path2fid $DIR/$tdir/dir0)
21796 local dev=$(mdsdevname 2)
21798 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21799 grep ${fid} || error "NOT found agent entry for dir0"
21801 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
21802 error "Fail to create $DIR/$tdir/dir1"
21804 touch $DIR/$tdir/dir1/foo0 ||
21805 error "Fail to create $DIR/$tdir/dir1/foo0"
21806 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
21809 for idx in $(seq $MDSCOUNT); do
21810 dev=$(mdsdevname $idx)
21811 do_facet mds${idx} \
21812 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21813 grep ${fid} && rc=$idx
21816 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
21817 error "Fail to rename foo0 to foo1"
21818 if [ $rc -eq 0 ]; then
21819 for idx in $(seq $MDSCOUNT); do
21820 dev=$(mdsdevname $idx)
21821 do_facet mds${idx} \
21822 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21823 grep ${fid} && rc=$idx
21827 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
21828 error "Fail to rename foo1 to foo2"
21829 if [ $rc -eq 0 ]; then
21830 for idx in $(seq $MDSCOUNT); do
21831 dev=$(mdsdevname $idx)
21832 do_facet mds${idx} \
21833 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21834 grep ${fid} && rc=$idx
21838 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
21840 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
21841 error "Fail to link to $DIR/$tdir/dir1/foo2"
21842 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
21843 error "Fail to rename foo2 to foo0"
21844 unlink $DIR/$tdir/dir1/foo0 ||
21845 error "Fail to unlink $DIR/$tdir/dir1/foo0"
21846 rm -rf $DIR/$tdir/dir0 ||
21847 error "Fail to rm $DIR/$tdir/dir0"
21849 for idx in $(seq $MDSCOUNT); do
21850 dev=$(mdsdevname $idx)
21854 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
21856 start mds${idx} $dev $MDS_MOUNT_OPTS ||
21857 error "mount mds$idx failed"
21858 df $MOUNT > /dev/null 2>&1
21860 # e2fsck should not return error
21862 error "e2fsck detected error on MDT${idx}: rc=$rc"
21865 run_test 804 "verify agent entry for remote entry"
21868 do_facet $SINGLEMDS zfs set quota=$old $fsset
21869 unlinkmany $DIR/$tdir/f- 1000000
21874 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
21875 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
21876 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
21877 skip "netfree not implemented before 0.7"
21878 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
21879 skip "Need MDS version at least 2.10.57"
21886 local pref="osd-zfs.lustre-MDT0000."
21888 # limit available space on MDS dataset to meet nospace issue
21889 # quickly. then ZFS 0.7.2 can use reserved space if asked
21890 # properly (using netfree flag in osd_declare_destroy()
21891 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
21892 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
21894 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
21895 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
21896 let "usedkb=usedkb-freekb"
21897 let "freekb=freekb/2"
21898 if let "freekb > 5000"; then
21901 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
21902 trap cleanup_805 EXIT
21904 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
21905 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
21906 rm -rf $DIR/$tdir || error "not able to remove"
21907 do_facet $SINGLEMDS zfs set quota=$old $fsset
21910 run_test 805 "ZFS can remove from full fs"
21916 local size=$($LFS getsom -s $file)
21917 local expect=$(stat -c %s $file)
21919 [[ $size == $expect ]] ||
21920 error "$file expected size: $expect, got: $size"
21922 local blocks=$($LFS getsom -b $file)
21923 expect=$(stat -c %b $file)
21924 [[ $blocks == $expect ]] ||
21925 error "$file expected blocks: $expect, got: $blocks"
21930 local size=$($LFS getsom -s $1)
21933 [[ $size == $expect ]] ||
21934 error "$file expected size: $expect, got: $size"
21938 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21939 skip "Need MDS version at least 2.11.52"
21943 touch $DIR/$tfile || error "touch $tfile failed"
21945 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21946 save_lustre_params client "llite.*.xattr_cache" > $save
21947 lctl set_param llite.*.xattr_cache=0
21948 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
21950 # single-threaded write
21951 echo "Test SOM for single-threaded write"
21952 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
21953 error "write $tfile failed"
21954 check_lsom_size $DIR/$tfile $bs
21957 local size=$(($num * $bs))
21961 echo "Test SOM for single client multi-threaded($num) write"
21962 $TRUNCATE $DIR/$tfile 0
21963 for ((i = 0; i < $num; i++)); do
21964 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21966 offset=$((offset + $bs))
21968 for (( i=0; i < $num; i++ )); do
21971 check_lsom_size $DIR/$tfile $size
21973 $TRUNCATE $DIR/$tfile 0
21974 for ((i = 0; i < $num; i++)); do
21975 offset=$((offset - $bs))
21976 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21979 for (( i=0; i < $num; i++ )); do
21982 check_lsom_size $DIR/$tfile $size
21984 # multi-client writes
21985 num=$(get_node_count ${CLIENTS//,/ })
21986 size=$(($num * $bs))
21990 echo "Test SOM for multi-client ($num) writes"
21991 $TRUNCATE $DIR/$tfile 0
21992 for client in ${CLIENTS//,/ }; do
21993 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21996 offset=$((offset + $bs))
21998 for (( i=0; i < $num; i++ )); do
22001 check_lsom_size $DIR/$tfile $offset
22004 $TRUNCATE $DIR/$tfile 0
22005 for client in ${CLIENTS//,/ }; do
22006 offset=$((offset - $bs))
22007 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22011 for (( i=0; i < $num; i++ )); do
22014 check_lsom_size $DIR/$tfile $size
22017 echo "Test SOM for truncate"
22018 $TRUNCATE $DIR/$tfile 1048576
22019 check_lsom_size $DIR/$tfile 1048576
22020 $TRUNCATE $DIR/$tfile 1234
22021 check_lsom_size $DIR/$tfile 1234
22023 # verify SOM blocks count
22024 echo "Verify SOM block count"
22025 $TRUNCATE $DIR/$tfile 0
22026 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
22027 error "failed to write file $tfile"
22028 check_lsom_data $DIR/$tfile
22030 run_test 806 "Verify Lazy Size on MDS"
22033 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
22034 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22035 skip "Need MDS version at least 2.11.52"
22037 # Registration step
22038 changelog_register || error "changelog_register failed"
22039 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
22040 changelog_users $SINGLEMDS | grep -q $cl_user ||
22041 error "User $cl_user not found in changelog_users"
22043 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22044 save_lustre_params client "llite.*.xattr_cache" > $save
22045 lctl set_param llite.*.xattr_cache=0
22046 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22048 rm -rf $DIR/$tdir || error "rm $tdir failed"
22049 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
22050 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
22051 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
22052 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
22053 error "truncate $tdir/trunc failed"
22056 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
22057 error "write $tfile failed"
22059 # multi-client wirtes
22060 local num=$(get_node_count ${CLIENTS//,/ })
22064 echo "Test SOM for multi-client ($num) writes"
22065 touch $DIR/$tfile || error "touch $tfile failed"
22066 $TRUNCATE $DIR/$tfile 0
22067 for client in ${CLIENTS//,/ }; do
22068 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22071 offset=$((offset + $bs))
22073 for (( i=0; i < $num; i++ )); do
22078 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
22079 check_lsom_data $DIR/$tdir/trunc
22080 check_lsom_data $DIR/$tdir/single_dd
22081 check_lsom_data $DIR/$tfile
22084 # Deregistration step
22085 changelog_deregister || error "changelog_deregister failed"
22087 run_test 807 "verify LSOM syncing tool"
22089 check_som_nologged()
22091 local lines=$($LFS changelog $FSNAME-MDT0000 |
22092 grep 'x=trusted.som' | wc -l)
22093 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
22097 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
22098 skip "Need MDS version at least 2.11.55"
22100 # Registration step
22101 changelog_register || error "changelog_register failed"
22103 touch $DIR/$tfile || error "touch $tfile failed"
22106 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
22107 error "write $tfile failed"
22110 $TRUNCATE $DIR/$tfile 1234
22113 $TRUNCATE $DIR/$tfile 1048576
22116 # Deregistration step
22117 changelog_deregister || error "changelog_deregister failed"
22119 run_test 808 "Check trusted.som xattr not logged in Changelogs"
22124 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
22128 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22129 skip "Need MDS version at least 2.11.56"
22131 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
22132 error "failed to create DoM-only file $DIR/$tfile"
22133 touch $DIR/$tfile || error "touch $tfile failed"
22134 check_som_nodata $DIR/$tfile
22136 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
22137 error "write $tfile failed"
22138 check_som_nodata $DIR/$tfile
22140 $TRUNCATE $DIR/$tfile 1234
22141 check_som_nodata $DIR/$tfile
22143 $TRUNCATE $DIR/$tfile 4097
22144 check_som_nodata $DIR/$file
22146 run_test 809 "Verify no SOM xattr store for DoM-only files"
22149 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22150 $GSS && skip_env "could not run with gss"
22151 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
22152 skip "OST < 2.12.58 doesn't align checksum"
22155 stack_trap "set_checksums $ORIG_CSUM" EXIT
22156 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
22161 for csum in $CKSUM_TYPES; do
22162 #define OBD_FAIL_OSC_NO_GRANT 0x411
22163 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
22164 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
22166 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
22167 before=$(md5sum $DIR/$tfile)
22168 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
22169 after=$(md5sum $DIR/$tfile)
22170 [ "$before" == "$after" ] ||
22171 error "$csum: $before != $after bs=$1 seek=$2"
22175 run_test 810 "partial page writes on ZFS (LU-11663)"
22178 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
22179 skip "Need MDS version at least 2.11.56"
22181 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
22182 do_facet mds1 $LCTL set_param fail_loc=0x165
22183 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
22186 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
22189 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) -eq 0 ]] ||
22190 error "MDD orphan cleanup thread not quit"
22192 run_test 811 "orphan name stub can be cleaned up in startup"
22195 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
22196 skip "OST < 2.12.51 doesn't support this fail_loc"
22197 [ "$SHARED_KEY" = true ] &&
22198 skip "OSC connections never go IDLE with Shared-Keys enabled"
22200 $LFS setstripe -c 1 -i 0 $DIR/$tfile
22201 # ensure ost1 is connected
22202 stat $DIR/$tfile >/dev/null || error "can't stat"
22203 wait_osc_import_state client ost1 FULL
22204 # no locks, no reqs to let the connection idle
22205 cancel_lru_locks osc
22207 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
22208 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
22209 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
22210 wait_osc_import_state client ost1 CONNECTING
22211 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
22213 stat $DIR/$tfile >/dev/null || error "can't stat file"
22215 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
22218 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
22219 [ -z "$file_heat_sav" ] && skip "no file heat support"
22230 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
22231 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
22233 $LCTL set_param -n llite.*.file_heat=1
22234 echo "Turn on file heat"
22235 echo "Period second: $period_second, Decay percentage: $decay_pct"
22237 echo "QQQQ" > $DIR/$tfile
22238 echo "QQQQ" > $DIR/$tfile
22239 echo "QQQQ" > $DIR/$tfile
22240 cat $DIR/$tfile > /dev/null
22241 cat $DIR/$tfile > /dev/null
22242 cat $DIR/$tfile > /dev/null
22243 cat $DIR/$tfile > /dev/null
22245 local out=$($LFS heat_get $DIR/$tfile)
22247 $LFS heat_get $DIR/$tfile
22248 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22249 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22250 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22251 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22253 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
22254 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
22255 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
22256 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
22258 sleep $((period_second + 3))
22259 echo "Sleep $((period_second + 3)) seconds..."
22260 # The recursion formula to calculate the heat of the file f is as
22262 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
22263 # Where Hi is the heat value in the period between time points i*I and
22264 # (i+1)*I; Ci is the access count in the period; the symbol P refers
22265 # to the weight of Ci.
22266 out=$($LFS heat_get $DIR/$tfile)
22267 $LFS heat_get $DIR/$tfile
22268 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22269 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22270 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22271 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22273 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
22274 error "read sample ($readsample) is wrong"
22275 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
22276 error "write sample ($writesample) is wrong"
22277 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
22278 error "read bytes ($readbyte) is wrong"
22279 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
22280 error "write bytes ($writebyte) is wrong"
22282 echo "QQQQ" > $DIR/$tfile
22283 echo "QQQQ" > $DIR/$tfile
22284 echo "QQQQ" > $DIR/$tfile
22285 cat $DIR/$tfile > /dev/null
22286 cat $DIR/$tfile > /dev/null
22287 cat $DIR/$tfile > /dev/null
22288 cat $DIR/$tfile > /dev/null
22290 sleep $((period_second + 3))
22291 echo "Sleep $((period_second + 3)) seconds..."
22293 out=$($LFS heat_get $DIR/$tfile)
22294 $LFS heat_get $DIR/$tfile
22295 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22296 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22297 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22298 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22300 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
22301 4 * $decay_pct) / 100") -eq 1 ] ||
22302 error "read sample ($readsample1) is wrong"
22303 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
22304 3 * $decay_pct) / 100") -eq 1 ] ||
22305 error "write sample ($writesample1) is wrong"
22306 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
22307 20 * $decay_pct) / 100") -eq 1 ] ||
22308 error "read bytes ($readbyte1) is wrong"
22309 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
22310 15 * $decay_pct) / 100") -eq 1 ] ||
22311 error "write bytes ($writebyte1) is wrong"
22313 echo "Turn off file heat for the file $DIR/$tfile"
22314 $LFS heat_set -o $DIR/$tfile
22316 echo "QQQQ" > $DIR/$tfile
22317 echo "QQQQ" > $DIR/$tfile
22318 echo "QQQQ" > $DIR/$tfile
22319 cat $DIR/$tfile > /dev/null
22320 cat $DIR/$tfile > /dev/null
22321 cat $DIR/$tfile > /dev/null
22322 cat $DIR/$tfile > /dev/null
22324 out=$($LFS heat_get $DIR/$tfile)
22325 $LFS heat_get $DIR/$tfile
22326 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22327 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22328 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22329 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22331 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
22332 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
22333 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
22334 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
22336 echo "Trun on file heat for the file $DIR/$tfile"
22337 $LFS heat_set -O $DIR/$tfile
22339 echo "QQQQ" > $DIR/$tfile
22340 echo "QQQQ" > $DIR/$tfile
22341 echo "QQQQ" > $DIR/$tfile
22342 cat $DIR/$tfile > /dev/null
22343 cat $DIR/$tfile > /dev/null
22344 cat $DIR/$tfile > /dev/null
22345 cat $DIR/$tfile > /dev/null
22347 out=$($LFS heat_get $DIR/$tfile)
22348 $LFS heat_get $DIR/$tfile
22349 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22350 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22351 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22352 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22354 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
22355 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
22356 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
22357 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
22359 $LFS heat_set -c $DIR/$tfile
22360 $LCTL set_param -n llite.*.file_heat=0
22361 echo "Turn off file heat support for the Lustre filesystem"
22363 echo "QQQQ" > $DIR/$tfile
22364 echo "QQQQ" > $DIR/$tfile
22365 echo "QQQQ" > $DIR/$tfile
22366 cat $DIR/$tfile > /dev/null
22367 cat $DIR/$tfile > /dev/null
22368 cat $DIR/$tfile > /dev/null
22369 cat $DIR/$tfile > /dev/null
22371 out=$($LFS heat_get $DIR/$tfile)
22372 $LFS heat_get $DIR/$tfile
22373 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22374 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22375 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22376 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22378 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
22379 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
22380 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
22381 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
22383 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
22386 run_test 813 "File heat verfication"
22390 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
22391 echo -n y >> $DIR/$tfile
22392 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
22393 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
22395 run_test 814 "sparse cp works as expected (LU-12361)"
22399 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
22400 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
22402 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
22405 [ "$SHARED_KEY" = true ] &&
22406 skip "OSC connections never go IDLE with Shared-Keys enabled"
22408 $LFS setstripe -c 1 -i 0 $DIR/$tfile
22409 # ensure ost1 is connected
22410 stat $DIR/$tfile >/dev/null || error "can't stat"
22411 wait_osc_import_state client ost1 FULL
22412 # no locks, no reqs to let the connection idle
22413 cancel_lru_locks osc
22414 lru_resize_disable osc
22417 before=$($LCTL get_param -n \
22418 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
22420 wait_osc_import_state client ost1 IDLE
22421 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
22422 now=$($LCTL get_param -n \
22423 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
22424 [ $before == $now ] || error "lru_size changed $before != $now"
22426 run_test 816 "do not reset lru_resize on idle reconnect"
22430 exportfs -u localhost:$DIR/nfsexp
22435 systemctl restart nfs-server.service || skip "failed to restart nfsd"
22437 mkdir -p $DIR/nfsexp
22438 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
22439 error "failed to export nfs"
22441 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
22442 stack_trap cleanup_817 EXIT
22444 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
22445 error "failed to mount nfs to $tmpdir"
22447 cp /bin/true $tmpdir
22448 $DIR/nfsexp/true || error "failed to execute 'true' command"
22450 run_test 817 "nfsd won't cache write lock for exec file"
22454 $LFS setstripe -c1 -i0 $DIR/$tfile
22455 $LFS setstripe -c1 -i1 $DIR/$tfile
22457 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
22458 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
22459 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
22460 error "start $SINGLEMDS failed"
22463 run_test 818 "unlink with failed llog"
22466 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
22467 cancel_lru_locks osc
22468 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
22469 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
22470 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
22473 run_test 819a "too big niobuf in read"
22476 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
22477 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
22478 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
22479 cancel_lru_locks osc
22483 run_test 819b "too big niobuf in write"
22486 # tests that do cleanup/setup should be run at the end
22490 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22493 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
22494 $LCTL set_param fail_loc=0x903
22496 cancel_lru_locks MGC
22498 FAIL_ON_ERROR=true cleanup
22499 FAIL_ON_ERROR=true setup
22501 run_test 900 "umount should not race with any mgc requeue thread"
22504 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
22505 check_and_cleanup_lustre
22506 if [ "$I_MOUNTED" != "yes" ]; then
22507 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true