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-11729 LU-4398
57 ALWAYS_EXCEPT+=" 45 317 810 817"
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
63 if [ "$mds1_FSTYPE" = "zfs" ]; then
64 # bug number for skipped test: LU-1957
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
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 if ! combined_mgs_mds ; then
2465 test_mkdir $DIR/$tdir
2466 pool_add $POOL || error "pool_add failed"
2467 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2470 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2472 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2473 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2474 skip27D+=" -s 30,31"
2475 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
2477 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2478 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2479 skip27D+=" -s 32,33"
2480 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2481 error "llapi_layout_test failed"
2483 destroy_test_pools || error "destroy test pools failed"
2485 if ! combined_mgs_mds ; then
2489 run_test 27D "validate llapi_layout API"
2491 # Verify that default_easize is increased from its initial value after
2492 # accessing a widely striped file.
2494 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2495 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2496 skip "client does not have LU-3338 fix"
2498 # 72 bytes is the minimum space required to store striping
2499 # information for a file striped across one OST:
2500 # (sizeof(struct lov_user_md_v3) +
2501 # sizeof(struct lov_user_ost_data_v1))
2503 $LCTL set_param -n llite.*.default_easize $min_easize ||
2504 error "lctl set_param failed"
2505 local easize=$($LCTL get_param -n llite.*.default_easize)
2507 [ $easize -eq $min_easize ] ||
2508 error "failed to set default_easize"
2510 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2511 error "setstripe failed"
2512 # In order to ensure stat() call actually talks to MDS we need to
2513 # do something drastic to this file to shake off all lock, e.g.
2514 # rename it (kills lookup lock forcing cache cleaning)
2515 mv $DIR/$tfile $DIR/${tfile}-1
2516 ls -l $DIR/${tfile}-1
2519 easize=$($LCTL get_param -n llite.*.default_easize)
2521 [ $easize -gt $min_easize ] ||
2522 error "default_easize not updated"
2524 run_test 27E "check that default extended attribute size properly increases"
2526 test_27F() { # LU-5346/LU-7975
2527 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2528 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2529 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2530 skip "Need MDS version at least 2.8.51"
2531 remote_ost_nodsh && skip "remote OST with nodsh"
2533 test_mkdir $DIR/$tdir
2535 $LFS setstripe -c 2 $DIR/$tdir
2537 # stop all OSTs to reproduce situation for LU-7975 ticket
2538 for num in $(seq $OSTCOUNT); do
2542 # open/create f0 with O_LOV_DELAY_CREATE
2543 # truncate f0 to a non-0 size
2545 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2547 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2548 # open/write it again to force delayed layout creation
2549 cat /etc/hosts > $DIR/$tdir/f0 &
2553 for num in $(seq $OSTCOUNT); do
2554 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2555 error "ost$num failed to start"
2558 wait $catpid || error "cat failed"
2560 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2561 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2562 error "wrong stripecount"
2565 run_test 27F "Client resend delayed layout creation with non-zero size"
2567 test_27G() { #LU-10629
2568 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2569 skip "Need MDS version at least 2.11.51"
2570 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2571 remote_mds_nodsh && skip "remote MDS with nodsh"
2572 local POOL=${POOL:-testpool}
2573 local ostrange="0 0 1"
2575 test_mkdir $DIR/$tdir
2576 pool_add $POOL || error "pool_add failed"
2577 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2578 $LFS setstripe -p $POOL $DIR/$tdir
2580 local pool=$($LFS getstripe -p $DIR/$tdir)
2582 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2584 $LFS setstripe -d $DIR/$tdir
2586 pool=$($LFS getstripe -p $DIR/$tdir)
2590 [ -z "$pool" ] || error "'$pool' is not empty"
2592 run_test 27G "Clear OST pool from stripe"
2595 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2596 skip "Need MDS version newer than 2.11.54"
2597 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2598 test_mkdir $DIR/$tdir
2599 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2600 touch $DIR/$tdir/$tfile
2601 $LFS getstripe -c $DIR/$tdir/$tfile
2602 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2603 error "two-stripe file doesn't have two stripes"
2605 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2606 $LFS getstripe -y $DIR/$tdir/$tfile
2607 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2608 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2609 error "expected l_ost_idx: [02]$ not matched"
2611 # make sure ost list has been cleared
2612 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2613 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2614 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2616 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2618 run_test 27H "Set specific OSTs stripe"
2621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2622 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2623 local pool=$TESTNAME
2624 local ostrange="1 1 1"
2626 save_layout_restore_at_exit $MOUNT
2627 $LFS setstripe -c 2 -i 0 $MOUNT
2628 pool_add $pool || error "pool_add failed"
2629 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2630 test_mkdir $DIR/$tdir
2631 $LFS setstripe -p $pool $DIR/$tdir
2632 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2633 $LFS getstripe $DIR/$tdir/$tfile
2635 run_test 27I "check that root dir striping does not break parent dir one"
2638 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
2639 skip "Need MDS version newer than 2.12.51"
2641 test_mkdir $DIR/$tdir
2642 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2643 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2645 # create foreign file (raw way)
2646 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2647 -t 1 -F 0xda08 || error "create_foreign_file failed"
2649 # verify foreign file (raw way)
2650 parse_foreign_file -f $DIR/$tdir/$tfile |
2651 grep "lov_foreign_magic: 0x0BD70BD0" ||
2652 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2653 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2654 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2655 parse_foreign_file -f $DIR/$tdir/$tfile |
2656 grep "lov_foreign_size: 73" ||
2657 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2658 parse_foreign_file -f $DIR/$tdir/$tfile |
2659 grep "lov_foreign_type: 1" ||
2660 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2661 parse_foreign_file -f $DIR/$tdir/$tfile |
2662 grep "lov_foreign_flags: 0x0000DA08" ||
2663 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2664 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2665 grep "lov_foreign_value: 0x" |
2666 sed -e 's/lov_foreign_value: 0x//')
2667 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2668 [[ $lov = ${lov2// /} ]] ||
2669 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2671 # create foreign file (lfs + API)
2672 $LFS setstripe --foreign=daos --flags 0xda08 \
2673 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2674 error "$DIR/$tdir/${tfile}2: create failed"
2676 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2677 grep "lfm_magic:.*0x0BD70BD0" ||
2678 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2679 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2680 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2681 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2682 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2683 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2684 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2685 grep "lfm_flags:.*0x0000DA08" ||
2686 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2687 $LFS getstripe $DIR/$tdir/${tfile}2 |
2688 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2689 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2691 # modify striping should fail
2692 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2693 error "$DIR/$tdir/$tfile: setstripe should fail"
2694 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2695 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2698 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2699 cat $DIR/$tdir/${tfile}2 &&
2700 error "$DIR/$tdir/${tfile}2: read should fail"
2701 cat /etc/passwd > $DIR/$tdir/$tfile &&
2702 error "$DIR/$tdir/$tfile: write should fail"
2703 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2704 error "$DIR/$tdir/${tfile}2: write should fail"
2707 chmod 222 $DIR/$tdir/$tfile ||
2708 error "$DIR/$tdir/$tfile: chmod failed"
2709 chmod 222 $DIR/$tdir/${tfile}2 ||
2710 error "$DIR/$tdir/${tfile}2: chmod failed"
2713 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2714 error "$DIR/$tdir/$tfile: chown failed"
2715 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2716 error "$DIR/$tdir/${tfile}2: chown failed"
2718 # rename should work
2719 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2720 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2721 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2722 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2724 #remove foreign file
2725 rm $DIR/$tdir/${tfile}.new ||
2726 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2727 rm $DIR/$tdir/${tfile}2.new ||
2728 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2730 run_test 27J "basic ops on file with foreign LOV"
2733 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
2734 skip "Need MDS version newer than 2.12.49"
2736 test_mkdir $DIR/$tdir
2737 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2738 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2740 # create foreign dir (raw way)
2741 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2742 error "create_foreign_dir FAILED"
2744 # verify foreign dir (raw way)
2745 parse_foreign_dir -d $DIR/$tdir/$tdir |
2746 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2747 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2748 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2749 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2750 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2751 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2752 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2753 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2754 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2755 grep "lmv_foreign_value: 0x" |
2756 sed 's/lmv_foreign_value: 0x//')
2757 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2759 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2761 # create foreign dir (lfs + API)
2762 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2763 $DIR/$tdir/${tdir}2 ||
2764 error "$DIR/$tdir/${tdir}2: create failed"
2766 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2767 grep "lfm_magic:.*0x0CD50CD0" ||
2768 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2769 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2770 # - sizeof(lfm_type) - sizeof(lfm_flags)
2771 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2772 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2773 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2774 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2775 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2776 grep "lfm_flags:.*0x0000DA05" ||
2777 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2778 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2779 grep "lfm_value.*${uuid1}@${uuid2}" ||
2780 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2782 # file create in dir should fail
2783 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2784 touch $DIR/$tdir/${tdir}2/$tfile &&
2785 "$DIR/${tdir}2: file create should fail"
2788 chmod 777 $DIR/$tdir/$tdir ||
2789 error "$DIR/$tdir: chmod failed"
2790 chmod 777 $DIR/$tdir/${tdir}2 ||
2791 error "$DIR/${tdir}2: chmod failed"
2794 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2795 error "$DIR/$tdir: chown failed"
2796 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2797 error "$DIR/${tdir}2: chown failed"
2799 # rename should work
2800 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2801 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2802 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2803 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2806 rmdir $DIR/$tdir/${tdir}.new ||
2807 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2808 rmdir $DIR/$tdir/${tdir}2.new ||
2809 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2811 run_test 27K "basic ops on dir with foreign LMV"
2814 remote_mds_nodsh && skip "remote MDS with nodsh"
2816 local POOL=${POOL:-$TESTNAME}
2818 if ! combined_mgs_mds ; then
2820 trap umount_mgs_client EXIT
2823 pool_add $POOL || error "pool_add failed"
2825 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2826 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2827 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2829 run_test 27L "lfs pool_list gives correct pool name"
2831 # createtest also checks that device nodes are created and
2832 # then visible correctly (#2091)
2833 test_28() { # bug 2091
2835 $CREATETEST $DIR/d28/ct || error "createtest failed"
2837 run_test 28 "create/mknod/mkdir with bad file types ============"
2840 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2842 sync; sleep 1; sync # flush out any dirty pages from previous tests
2849 declare -i LOCKCOUNTORIG=0
2850 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2851 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2853 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2855 declare -i LOCKUNUSEDCOUNTORIG=0
2856 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2857 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2864 declare -i LOCKCOUNTCURRENT=0
2865 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2866 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2869 declare -i LOCKUNUSEDCOUNTCURRENT=0
2870 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2871 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2874 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2875 $LCTL set_param -n ldlm.dump_namespaces ""
2876 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2877 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2878 log "dumped log to $TMP/test_29.dk (bug 5793)"
2881 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2882 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2883 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2884 log "dumped log to $TMP/test_29.dk (bug 5793)"
2888 run_test 29 "IT_GETATTR regression ============================"
2890 test_30a() { # was test_30
2891 cp $(which ls) $DIR || cp /bin/ls $DIR
2892 $DIR/ls / || error "Can't execute binary from lustre"
2895 run_test 30a "execute binary from Lustre (execve) =============="
2898 cp `which ls` $DIR || cp /bin/ls $DIR
2900 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2903 run_test 30b "execute binary from Lustre as non-root ==========="
2905 test_30c() { # b=22376
2906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2908 cp `which ls` $DIR || cp /bin/ls $DIR
2910 cancel_lru_locks mdc
2911 cancel_lru_locks osc
2912 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2915 run_test 30c "execute binary from Lustre without read perms ===="
2918 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2919 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2921 run_test 31a "open-unlink file =================================="
2924 touch $DIR/f31 || error "touch $DIR/f31 failed"
2925 ln $DIR/f31 $DIR/f31b || error "ln failed"
2926 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2927 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2929 run_test 31b "unlink file with multiple links while open ======="
2932 touch $DIR/f31 || error "touch $DIR/f31 failed"
2933 ln $DIR/f31 $DIR/f31c || error "ln failed"
2934 multiop_bg_pause $DIR/f31 O_uc ||
2935 error "multiop_bg_pause for $DIR/f31 failed"
2937 $MULTIOP $DIR/f31c Ouc
2938 kill -USR1 $MULTIPID
2941 run_test 31c "open-unlink file with multiple links ============="
2944 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2945 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2947 run_test 31d "remove of open directory ========================="
2949 test_31e() { # bug 2904
2950 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2952 run_test 31e "remove of open non-empty directory ==============="
2954 test_31f() { # bug 4554
2955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2958 test_mkdir $DIR/d31f
2959 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2960 cp /etc/hosts $DIR/d31f
2962 $LFS getstripe $DIR/d31f/hosts
2963 multiop_bg_pause $DIR/d31f D_c || return 1
2966 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2967 test_mkdir $DIR/d31f
2968 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2969 cp /etc/hosts $DIR/d31f
2971 $LFS getstripe $DIR/d31f/hosts
2972 multiop_bg_pause $DIR/d31f D_c || return 1
2975 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2976 wait $MULTIPID || error "first opendir $MULTIPID failed"
2980 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2981 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2984 run_test 31f "remove of open directory with open-unlink file ==="
2987 echo "-- cross directory link --"
2988 test_mkdir -c1 $DIR/${tdir}ga
2989 test_mkdir -c1 $DIR/${tdir}gb
2990 touch $DIR/${tdir}ga/f
2991 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2992 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2993 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2994 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2995 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2997 run_test 31g "cross directory link==============="
3000 echo "-- cross directory link --"
3001 test_mkdir -c1 $DIR/${tdir}
3002 test_mkdir -c1 $DIR/${tdir}/dir
3003 touch $DIR/${tdir}/f
3004 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3005 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3006 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3007 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3008 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3010 run_test 31h "cross directory link under child==============="
3013 echo "-- cross directory link --"
3014 test_mkdir -c1 $DIR/$tdir
3015 test_mkdir -c1 $DIR/$tdir/dir
3016 touch $DIR/$tdir/dir/f
3017 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3018 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3019 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3020 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3021 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3023 run_test 31i "cross directory link under parent==============="
3026 test_mkdir -c1 -p $DIR/$tdir
3027 test_mkdir -c1 -p $DIR/$tdir/dir1
3028 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3029 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3030 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3031 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3034 run_test 31j "link for directory==============="
3037 test_mkdir -c1 -p $DIR/$tdir
3039 touch $DIR/$tdir/exist
3040 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3041 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3042 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3043 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3044 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3045 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3046 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3049 run_test 31k "link to file: the same, non-existing, dir==============="
3055 touch $DIR/d31m2/exist
3056 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3057 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3058 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3059 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3060 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3061 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3064 run_test 31m "link to file: the same, non-existing, dir==============="
3067 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3068 nlink=$(stat --format=%h $DIR/$tfile)
3069 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3071 local cmd="exec $fd<$DIR/$tfile"
3074 trap "eval $cmd" EXIT
3075 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3076 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3077 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3078 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3079 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3082 run_test 31n "check link count of unlinked file"
3085 local tempfile=$(mktemp $1_XXXXXX)
3086 mlink $tempfile $1 2> /dev/null &&
3087 echo "$BASHPID: link $tempfile to $1 succeeded"
3091 test_31o() { # LU-2901
3092 test_mkdir $DIR/$tdir
3093 for LOOP in $(seq 100); do
3094 rm -f $DIR/$tdir/$tfile*
3095 for THREAD in $(seq 8); do
3096 link_one $DIR/$tdir/$tfile.$LOOP &
3099 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3100 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3101 error "$LINKS duplicate links to $tfile.$LOOP" &&
3105 run_test 31o "duplicate hard links with same filename"
3108 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3110 test_mkdir $DIR/$tdir
3111 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3112 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3114 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3115 error "open unlink test1 failed"
3116 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3117 error "open unlink test2 failed"
3119 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3120 error "test1 still exists"
3121 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3122 error "test2 still exists"
3124 run_test 31p "remove of open striped directory"
3126 cleanup_test32_mount() {
3129 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3130 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3131 losetup -d $loopdev || true
3137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3139 echo "== more mountpoints and symlinks ================="
3140 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3141 trap cleanup_test32_mount EXIT
3142 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3143 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3144 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3145 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3146 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3147 cleanup_test32_mount
3149 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3152 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3154 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3155 trap cleanup_test32_mount EXIT
3156 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3157 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3158 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3159 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3160 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3161 cleanup_test32_mount
3163 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3166 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3168 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3169 trap cleanup_test32_mount EXIT
3170 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3171 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3172 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3173 test_mkdir -p $DIR/$tdir/d2/test_dir
3174 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3175 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3176 cleanup_test32_mount
3178 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3183 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3184 trap cleanup_test32_mount EXIT
3185 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3186 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3187 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3188 test_mkdir -p $DIR/$tdir/d2/test_dir
3189 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3190 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3191 cleanup_test32_mount
3193 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3197 test_mkdir -p $DIR/$tdir/tmp
3198 local tmp_dir=$DIR/$tdir/tmp
3199 ln -s $DIR/$tdir $tmp_dir/symlink11
3200 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3201 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3202 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3204 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3208 test_mkdir -p $DIR/$tdir/tmp
3209 local tmp_dir=$DIR/$tdir/tmp
3210 ln -s $DIR/$tdir $tmp_dir/symlink11
3211 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3212 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3213 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3215 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3218 local tmp_dir=$DIR/$tdir/tmp
3219 test_mkdir -p $tmp_dir
3220 test_mkdir $DIR/${tdir}2
3221 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3222 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3223 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3224 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3225 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3226 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3228 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3231 rm -fr $DIR/$tdir $DIR/${tdir}2
3232 tmp_dir=$DIR/$tdir/tmp
3233 test_mkdir -p $tmp_dir
3234 test_mkdir $DIR/${tdir}2
3235 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3236 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3237 ls $tmp_dir/symlink12 || error "listing symlink12"
3238 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3240 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3243 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3245 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3246 trap cleanup_test32_mount EXIT
3247 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3248 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3249 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3250 touch $DIR/$tdir/test_file
3251 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3252 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3253 cleanup_test32_mount
3255 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3260 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3261 trap cleanup_test32_mount EXIT
3262 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3263 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3264 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3265 touch $DIR/$tdir/test_file
3266 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3267 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3268 cleanup_test32_mount
3270 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3273 [ $PARALLEL == "yes" ] && skip "skip parallel run"
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 test_mkdir -p $DIR/$tdir/d2
3281 touch $DIR/$tdir/d2/test_file || error "touch failed"
3282 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3283 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3284 cleanup_test32_mount
3286 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3289 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3292 trap cleanup_test32_mount EXIT
3293 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3294 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3295 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3296 test_mkdir -p $DIR/$tdir/d2
3297 touch $DIR/$tdir/d2/test_file || error "touch failed"
3298 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3299 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3300 cleanup_test32_mount
3302 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3306 test_mkdir -p $DIR/d32m/tmp
3307 TMP_DIR=$DIR/d32m/tmp
3308 ln -s $DIR $TMP_DIR/symlink11
3309 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3310 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3311 error "symlink11 not a link"
3312 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3313 error "symlink01 not a link"
3315 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3319 test_mkdir -p $DIR/d32n/tmp
3320 TMP_DIR=$DIR/d32n/tmp
3321 ln -s $DIR $TMP_DIR/symlink11
3322 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3323 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3324 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3326 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3330 test_mkdir -p $DIR/d32o/tmp
3331 TMP_DIR=$DIR/d32o/tmp
3332 ln -s $DIR/$tfile $TMP_DIR/symlink12
3333 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3334 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3335 error "symlink12 not a link"
3336 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3337 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3338 error "$DIR/d32o/tmp/symlink12 not file type"
3339 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3340 error "$DIR/d32o/symlink02 not file type"
3342 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3352 test_mkdir -p $DIR/d32p/tmp
3354 TMP_DIR=$DIR/d32p/tmp
3356 ln -s $DIR/$tfile $TMP_DIR/symlink12
3358 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3360 cat $DIR/d32p/tmp/symlink12 ||
3361 error "Can't open $DIR/d32p/tmp/symlink12"
3363 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3366 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3369 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3371 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3372 trap cleanup_test32_mount EXIT
3373 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3374 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3375 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3376 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3377 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3378 cleanup_test32_mount
3380 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3383 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3385 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3386 trap cleanup_test32_mount EXIT
3387 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3388 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3389 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3390 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3391 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3392 cleanup_test32_mount
3394 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3399 chmod 444 $DIR/$tfile
3400 chown $RUNAS_ID $DIR/$tfile
3402 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3405 run_test 33aa "write file with mode 444 (should return error)"
3409 test_mkdir $DIR/$tdir
3410 chown $RUNAS_ID $DIR/$tdir
3411 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3412 error "$RUNAS create $tdir/$tfile failed"
3413 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3414 error "open RDWR" || true
3416 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3420 test_mkdir $DIR/$tdir
3421 chown $RUNAS_ID $DIR/$tdir
3422 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3424 run_test 33b "test open file with malformed flags (No panic)"
3427 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3428 remote_ost_nodsh && skip "remote OST with nodsh"
3437 test_mkdir $DIR/$tdir
3438 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3441 for ostnum in $(seq $OSTCOUNT); do
3442 # test-framework's OST numbering is one-based, while Lustre's
3444 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3445 # Parsing llobdstat's output sucks; we could grep the /proc
3446 # path, but that's likely to not be as portable as using the
3447 # llobdstat utility. So we parse lctl output instead.
3448 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3449 obdfilter/$ostname/stats |
3450 awk '/^write_bytes/ {print $7}' )
3451 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3452 if (( ${write_bytes:-0} > 0 ))
3459 $all_zeros || return 0
3462 echo foo > $DIR/$tdir/bar
3466 # Total up write_bytes after writing. We'd better find non-zeros.
3467 for ostnum in $(seq $OSTCOUNT); do
3468 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3469 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3470 obdfilter/$ostname/stats |
3471 awk '/^write_bytes/ {print $7}' )
3472 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3473 if (( ${write_bytes:-0} > 0 ))
3482 for ostnum in $(seq $OSTCOUNT); do
3483 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3484 echo "Check that write_bytes is present in obdfilter/*/stats:"
3485 do_facet ost$ostnum lctl get_param -n \
3486 obdfilter/$ostname/stats
3488 error "OST not keeping write_bytes stats (b22312)"
3491 run_test 33c "test llobdstat and write_bytes"
3494 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3498 local remote_dir=$DIR/$tdir/remote_dir
3500 test_mkdir $DIR/$tdir
3501 $LFS mkdir -i $MDTIDX $remote_dir ||
3502 error "create remote directory failed"
3504 touch $remote_dir/$tfile
3505 chmod 444 $remote_dir/$tfile
3506 chown $RUNAS_ID $remote_dir/$tfile
3508 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3510 chown $RUNAS_ID $remote_dir
3511 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3512 error "create" || true
3513 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3514 error "open RDWR" || true
3515 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3517 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3520 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3524 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3525 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3526 mkdir $DIR/$tdir/local_dir
3528 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3529 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3530 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3532 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3533 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3535 rmdir $DIR/$tdir/* || error "rmdir failed"
3538 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3539 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3540 mkdir $DIR/$tdir/local_dir
3542 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3543 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3544 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3546 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3547 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3549 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3552 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3553 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3554 mkdir $DIR/$tdir/local_dir
3556 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3557 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3558 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3560 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3561 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3563 run_test 33e "mkdir and striped directory should have same mode"
3567 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3571 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3572 remote_mds_nodsh && skip "remote MDS with nodsh"
3575 chmod go+rwx $DIR/$tdir
3576 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3577 trap cleanup_33f EXIT
3579 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3580 error "cannot create striped directory"
3582 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3583 error "cannot create files in striped directory"
3585 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3586 error "cannot remove files in striped directory"
3588 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3589 error "cannot remove striped directory"
3593 run_test 33f "nonroot user can create, access, and remove a striped directory"
3596 mkdir -p $DIR/$tdir/dir2
3598 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3600 [[ $err =~ "exists" ]] || error "Not exists error"
3602 run_test 33g "nonroot user create already existing root created file"
3604 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3607 $MCREATE $DIR/f34 || error "mcreate failed"
3608 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3609 error "getstripe failed"
3610 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3611 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3612 error "getstripe failed"
3613 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3614 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3616 run_test 34a "truncate file that has not been opened ==========="
3619 [ ! -f $DIR/f34 ] && test_34a
3620 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3621 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3622 $OPENFILE -f O_RDONLY $DIR/f34
3623 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3624 error "getstripe failed"
3625 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3626 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3628 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3631 [ ! -f $DIR/f34 ] && test_34a
3632 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3633 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3634 $OPENFILE -f O_RDWR $DIR/f34
3635 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3636 error "$LFS getstripe failed"
3637 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3638 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3640 run_test 34c "O_RDWR opening file-with-size works =============="
3643 [ ! -f $DIR/f34 ] && test_34a
3644 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3646 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3647 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3650 run_test 34d "write to sparse file ============================="
3654 $MCREATE $DIR/f34e || error "mcreate failed"
3655 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3656 $CHECKSTAT -s 1000 $DIR/f34e ||
3657 error "Size of $DIR/f34e not equal to 1000 bytes"
3658 $OPENFILE -f O_RDWR $DIR/f34e
3659 $CHECKSTAT -s 1000 $DIR/f34e ||
3660 error "Size of $DIR/f34e not equal to 1000 bytes"
3662 run_test 34e "create objects, some with size and some without =="
3664 test_34f() { # bug 6242, 6243
3665 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3669 $MCREATE $DIR/f34f || error "mcreate failed"
3670 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3671 dd if=$DIR/f34f of=$TMP/f34f
3672 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3673 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3674 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3675 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3676 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3678 run_test 34f "read from a file with no objects until EOF ======="
3681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3683 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3685 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3686 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3687 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3688 cancel_lru_locks osc
3689 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3690 error "wrong size after lock cancel"
3692 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3693 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3694 error "expanding truncate failed"
3695 cancel_lru_locks osc
3696 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3697 error "wrong expanded size after lock cancel"
3699 run_test 34g "truncate long file ==============================="
3702 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3707 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3708 sync # Flush the cache so that multiop below does not block on cache
3709 # flush when getting the group lock
3710 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3713 # Since just timed wait is not good enough, let's do a sync write
3714 # that way we are sure enough time for a roundtrip + processing
3715 # passed + 2 seconds of extra margin.
3716 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3720 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3721 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3725 local nsz=`stat -c %s $DIR/$tfile`
3726 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3728 run_test 34h "ftruncate file under grouplock should not block"
3731 cp /bin/sh $DIR/f35a
3733 chown $RUNAS_ID $DIR/f35a
3734 $RUNAS $DIR/f35a && error || true
3737 run_test 35a "exec file with mode 444 (should return and not leak)"
3741 utime $DIR/f36 || error "utime failed for MDS"
3743 run_test 36a "MDS utime check (mknod, utime)"
3747 utime $DIR/f36 || error "utime failed for OST"
3749 run_test 36b "OST utime check (open, utime)"
3754 chown $RUNAS_ID $DIR/d36
3755 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3757 run_test 36c "non-root MDS utime check (mknod, utime)"
3760 [ ! -d $DIR/d36 ] && test_36c
3761 echo "" > $DIR/d36/f36
3762 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3764 run_test 36d "non-root OST utime check (open, utime)"
3767 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3769 test_mkdir $DIR/$tdir
3770 touch $DIR/$tdir/$tfile
3771 $RUNAS utime $DIR/$tdir/$tfile &&
3772 error "utime worked, expected failure" || true
3774 run_test 36e "utime on non-owned file (should return error)"
3778 local LANG_SAVE=$LANG
3779 local LC_LANG_SAVE=$LC_LANG
3780 export LANG=C LC_LANG=C # for date language
3782 DATESTR="Dec 20 2000"
3783 test_mkdir $DIR/$tdir
3784 lctl set_param fail_loc=$fl
3786 cp /etc/hosts $DIR/$tdir/$tfile
3787 sync & # write RPC generated with "current" inode timestamp, but delayed
3789 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3790 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3791 cancel_lru_locks $OSC
3792 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3794 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3795 echo "BEFORE: $LS_BEFORE" && \
3796 echo "AFTER : $LS_AFTER" && \
3797 echo "WANT : $DATESTR" && \
3798 error "$DIR/$tdir/$tfile timestamps changed" || true
3800 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3804 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3806 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3807 subr_36fh "0x80000214"
3809 run_test 36f "utime on file racing with OST BRW write =========="
3812 remote_ost_nodsh && skip "remote OST with nodsh"
3813 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3814 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3815 skip "Need MDS version at least 2.12.51"
3820 local tgt="obdfilter"
3822 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3824 test_mkdir $DIR/$tdir
3825 fmd_max_age=$(do_facet $facet \
3826 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3829 echo "FMD max age: ${fmd_max_age}s"
3830 touch $DIR/$tdir/$tfile
3831 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3832 gawk '{cnt=cnt+$1} END{print cnt}')
3833 echo "FMD before: $fmd"
3835 error "FMD wasn't create by touch"
3836 sleep $((fmd_max_age + 12))
3837 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3838 gawk '{cnt=cnt+$1} END{print cnt}')
3839 echo "FMD after: $fmd"
3841 error "FMD wasn't expired by ping"
3843 run_test 36g "FMD cache expiry ====================="
3846 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3848 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3849 subr_36fh "0x80000227"
3851 run_test 36h "utime on file racing with OST BRW write =========="
3854 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3856 test_mkdir $DIR/$tdir
3857 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3859 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3860 local new_mtime=$((mtime + 200))
3862 #change Modify time of striped dir
3863 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3864 error "change mtime failed"
3866 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3868 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3870 run_test 36i "change mtime on striped directory"
3872 # test_37 - duplicate with tests 32q 32r
3875 local file=$DIR/$tfile
3877 openfile -f O_DIRECTORY $file
3880 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3881 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3883 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3885 test_39a() { # was test_39
3887 touch $DIR/${tfile}2
3888 # ls -l $DIR/$tfile $DIR/${tfile}2
3889 # ls -lu $DIR/$tfile $DIR/${tfile}2
3890 # ls -lc $DIR/$tfile $DIR/${tfile}2
3892 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3893 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3895 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3897 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3899 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3900 error "O_TRUNC didn't change timestamps"
3903 run_test 39a "mtime changed on create"
3906 test_mkdir -c1 $DIR/$tdir
3907 cp -p /etc/passwd $DIR/$tdir/fopen
3908 cp -p /etc/passwd $DIR/$tdir/flink
3909 cp -p /etc/passwd $DIR/$tdir/funlink
3910 cp -p /etc/passwd $DIR/$tdir/frename
3911 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3914 echo "aaaaaa" >> $DIR/$tdir/fopen
3915 echo "aaaaaa" >> $DIR/$tdir/flink
3916 echo "aaaaaa" >> $DIR/$tdir/funlink
3917 echo "aaaaaa" >> $DIR/$tdir/frename
3919 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3920 local link_new=`stat -c %Y $DIR/$tdir/flink`
3921 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3922 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3924 cat $DIR/$tdir/fopen > /dev/null
3925 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3926 rm -f $DIR/$tdir/funlink2
3927 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3929 for (( i=0; i < 2; i++ )) ; do
3930 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3931 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3932 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3933 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3935 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3936 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3937 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3938 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3940 cancel_lru_locks $OSC
3941 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3944 run_test 39b "mtime change on open, link, unlink, rename ======"
3946 # this should be set to past
3947 TEST_39_MTIME=`date -d "1 year ago" +%s`
3953 local mtime0=`stat -c %Y $DIR1/$tfile`
3955 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3956 local mtime1=`stat -c %Y $DIR1/$tfile`
3957 [ "$mtime1" = $TEST_39_MTIME ] || \
3958 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3961 echo hello >> $DIR1/$tfile
3963 local mtime2=`stat -c %Y $DIR1/$tfile`
3964 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3965 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3967 mv $DIR1/$tfile $DIR1/$tfile-1
3969 for (( i=0; i < 2; i++ )) ; do
3970 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3971 [ "$mtime2" = "$mtime3" ] || \
3972 error "mtime ($mtime2) changed (to $mtime3) on rename"
3974 cancel_lru_locks $OSC
3975 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3978 run_test 39c "mtime change on rename ==========================="
3982 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3985 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3987 for (( i=0; i < 2; i++ )) ; do
3988 local mtime=`stat -c %Y $DIR1/$tfile`
3989 [ $mtime = $TEST_39_MTIME ] || \
3990 error "mtime($mtime) is not set to $TEST_39_MTIME"
3992 cancel_lru_locks $OSC
3993 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3996 run_test 39d "create, utime, stat =============================="
4000 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4003 local mtime1=`stat -c %Y $DIR1/$tfile`
4005 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4007 for (( i=0; i < 2; i++ )) ; do
4008 local mtime2=`stat -c %Y $DIR1/$tfile`
4009 [ $mtime2 = $TEST_39_MTIME ] || \
4010 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4012 cancel_lru_locks $OSC
4013 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4016 run_test 39e "create, stat, utime, stat ========================"
4020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4023 mtime1=`stat -c %Y $DIR1/$tfile`
4026 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4028 for (( i=0; i < 2; i++ )) ; do
4029 local mtime2=`stat -c %Y $DIR1/$tfile`
4030 [ $mtime2 = $TEST_39_MTIME ] || \
4031 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4033 cancel_lru_locks $OSC
4034 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4037 run_test 39f "create, stat, sleep, utime, stat ================="
4041 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4043 echo hello >> $DIR1/$tfile
4044 local mtime1=`stat -c %Y $DIR1/$tfile`
4047 chmod o+r $DIR1/$tfile
4049 for (( i=0; i < 2; i++ )) ; do
4050 local mtime2=`stat -c %Y $DIR1/$tfile`
4051 [ "$mtime1" = "$mtime2" ] || \
4052 error "lost mtime: $mtime2, should be $mtime1"
4054 cancel_lru_locks $OSC
4055 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4058 run_test 39g "write, chmod, stat ==============================="
4062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4068 echo hello >> $DIR1/$tfile
4069 local mtime1=`stat -c %Y $DIR1/$tfile`
4071 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4073 if [ "$d1" != "$d2" ]; then
4074 echo "write and touch not within one second"
4076 for (( i=0; i < 2; i++ )) ; do
4077 local mtime2=`stat -c %Y $DIR1/$tfile`
4078 [ "$mtime2" = $TEST_39_MTIME ] || \
4079 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4081 cancel_lru_locks $OSC
4082 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4086 run_test 39h "write, utime within one second, stat ============="
4089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4094 echo hello >> $DIR1/$tfile
4095 local mtime1=`stat -c %Y $DIR1/$tfile`
4097 mv $DIR1/$tfile $DIR1/$tfile-1
4099 for (( i=0; i < 2; i++ )) ; do
4100 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4102 [ "$mtime1" = "$mtime2" ] || \
4103 error "lost mtime: $mtime2, should be $mtime1"
4105 cancel_lru_locks $OSC
4106 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4109 run_test 39i "write, rename, stat =============================="
4112 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4114 start_full_debug_logging
4118 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4119 lctl set_param fail_loc=0x80000412
4120 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4121 error "multiop failed"
4123 local mtime1=`stat -c %Y $DIR1/$tfile`
4125 mv $DIR1/$tfile $DIR1/$tfile-1
4127 kill -USR1 $multipid
4128 wait $multipid || error "multiop close failed"
4130 for (( i=0; i < 2; i++ )) ; do
4131 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4132 [ "$mtime1" = "$mtime2" ] ||
4133 error "mtime is lost on close: $mtime2, " \
4136 cancel_lru_locks $OSC
4137 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4139 lctl set_param fail_loc=0
4140 stop_full_debug_logging
4142 run_test 39j "write, rename, close, stat ======================="
4145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4150 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4152 local mtime1=`stat -c %Y $DIR1/$tfile`
4154 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4156 kill -USR1 $multipid
4157 wait $multipid || error "multiop close failed"
4159 for (( i=0; i < 2; i++ )) ; do
4160 local mtime2=`stat -c %Y $DIR1/$tfile`
4162 [ "$mtime2" = $TEST_39_MTIME ] || \
4163 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4165 cancel_lru_locks osc
4166 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4169 run_test 39k "write, utime, close, stat ========================"
4171 # this should be set to future
4172 TEST_39_ATIME=`date -d "1 year" +%s`
4175 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4176 remote_mds_nodsh && skip "remote MDS with nodsh"
4178 local atime_diff=$(do_facet $SINGLEMDS \
4179 lctl get_param -n mdd.*MDT0000*.atime_diff)
4183 # test setting directory atime to future
4184 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4185 local atime=$(stat -c %X $DIR/$tdir)
4186 [ "$atime" = $TEST_39_ATIME ] ||
4187 error "atime is not set to future: $atime, $TEST_39_ATIME"
4189 # test setting directory atime from future to now
4190 local now=$(date +%s)
4191 touch -a -d @$now $DIR/$tdir
4193 atime=$(stat -c %X $DIR/$tdir)
4194 [ "$atime" -eq "$now" ] ||
4195 error "atime is not updated from future: $atime, $now"
4197 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4200 # test setting directory atime when now > dir atime + atime_diff
4201 local d1=$(date +%s)
4203 local d2=$(date +%s)
4204 cancel_lru_locks mdc
4205 atime=$(stat -c %X $DIR/$tdir)
4206 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4207 error "atime is not updated : $atime, should be $d2"
4209 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4212 # test not setting directory atime when now < dir atime + atime_diff
4214 cancel_lru_locks mdc
4215 atime=$(stat -c %X $DIR/$tdir)
4216 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4217 error "atime is updated to $atime, should remain $d1<atime<$d2"
4219 do_facet $SINGLEMDS \
4220 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4222 run_test 39l "directory atime update ==========================="
4225 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4229 local far_past_mtime=$(date -d "May 29 1953" +%s)
4230 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4232 touch -m -d @$far_past_mtime $DIR1/$tfile
4233 touch -a -d @$far_past_atime $DIR1/$tfile
4235 for (( i=0; i < 2; i++ )) ; do
4236 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4237 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4238 error "atime or mtime set incorrectly"
4240 cancel_lru_locks $OSC
4241 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4244 run_test 39m "test atime and mtime before 1970"
4246 test_39n() { # LU-3832
4247 remote_mds_nodsh && skip "remote MDS with nodsh"
4249 local atime_diff=$(do_facet $SINGLEMDS \
4250 lctl get_param -n mdd.*MDT0000*.atime_diff)
4255 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4258 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4259 atime0=$(stat -c %X $DIR/$tfile)
4262 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4263 atime1=$(stat -c %X $DIR/$tfile)
4266 cancel_lru_locks mdc
4267 cancel_lru_locks osc
4268 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4269 atime2=$(stat -c %X $DIR/$tfile)
4271 do_facet $SINGLEMDS \
4272 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4274 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4275 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4277 run_test 39n "check that O_NOATIME is honored"
4280 TESTDIR=$DIR/$tdir/$tfile
4281 [ -e $TESTDIR ] && rm -rf $TESTDIR
4288 links2=$(stat -c %h .)
4289 [ $(($links1 + 2)) != $links2 ] &&
4290 error "wrong links count $(($links1 + 2)) != $links2"
4292 links3=$(stat -c %h .)
4293 [ $(($links1 + 1)) != $links3 ] &&
4294 error "wrong links count $links1 != $links3"
4297 run_test 39o "directory cached attributes updated after create"
4300 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4303 TESTDIR=$DIR/$tdir/$tdir
4304 [ -e $TESTDIR ] && rm -rf $TESTDIR
4305 test_mkdir -p $TESTDIR
4309 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4310 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4312 links2=$(stat -c %h .)
4313 [ $(($links1 + 2)) != $links2 ] &&
4314 error "wrong links count $(($links1 + 2)) != $links2"
4316 links3=$(stat -c %h .)
4317 [ $(($links1 + 1)) != $links3 ] &&
4318 error "wrong links count $links1 != $links3"
4321 run_test 39p "remote directory cached attributes updated after create ========"
4324 test_39q() { # LU-8041
4325 local testdir=$DIR/$tdir
4327 multiop_bg_pause $testdir D_c || error "multiop failed"
4329 cancel_lru_locks mdc
4330 kill -USR1 $multipid
4331 local atime=$(stat -c %X $testdir)
4332 [ "$atime" -ne 0 ] || error "atime is zero"
4334 run_test 39q "close won't zero out atime"
4337 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4338 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4339 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4340 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4341 error "$tfile is not 4096 bytes in size"
4343 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4347 small_write $DIR/f41 18
4349 run_test 41 "test small file write + fstat ====================="
4351 count_ost_writes() {
4352 lctl get_param -n ${OSC}.*.stats |
4353 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4354 END { printf("%0.0f", writes) }'
4361 BG_DIRTY_RATIO_SAVE=10
4362 MAX_BG_DIRTY_RATIO=25
4366 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4367 # dirty_ratio, dirty_background_ratio
4368 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4369 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4370 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4371 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4373 # if file not here, we are a 2.4 kernel
4374 kill -CONT `pidof kupdated`
4379 # setup the trap first, so someone cannot exit the test at the
4380 # exact wrong time and mess up a machine
4381 trap start_writeback EXIT
4382 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4383 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4384 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4385 sysctl -w vm.dirty_writeback_centisecs=0
4386 sysctl -w vm.dirty_writeback_centisecs=0
4387 # save and increase /proc/sys/vm/dirty_ratio
4388 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4389 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4390 # save and increase /proc/sys/vm/dirty_background_ratio
4391 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4392 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4394 # if file not here, we are a 2.4 kernel
4395 kill -STOP `pidof kupdated`
4399 # ensure that all stripes have some grant before we test client-side cache
4401 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4402 dd if=/dev/zero of=$i bs=4k count=1
4407 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4408 # file truncation, and file removal.
4410 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4413 cancel_lru_locks $OSC
4415 sync; sleep 1; sync # just to be safe
4416 BEFOREWRITES=`count_ost_writes`
4417 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4418 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4419 AFTERWRITES=`count_ost_writes`
4420 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4421 error "$BEFOREWRITES < $AFTERWRITES"
4424 run_test 42a "ensure that we don't flush on close"
4427 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4430 cancel_lru_locks $OSC
4433 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4434 BEFOREWRITES=$(count_ost_writes)
4435 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4436 AFTERWRITES=$(count_ost_writes)
4437 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4438 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4440 BEFOREWRITES=$(count_ost_writes)
4441 sync || error "sync: $?"
4442 AFTERWRITES=$(count_ost_writes)
4443 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4444 error "$BEFOREWRITES < $AFTERWRITES on sync"
4446 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4450 run_test 42b "test destroy of file with cached dirty data ======"
4452 # if these tests just want to test the effect of truncation,
4453 # they have to be very careful. consider:
4454 # - the first open gets a {0,EOF}PR lock
4455 # - the first write conflicts and gets a {0, count-1}PW
4456 # - the rest of the writes are under {count,EOF}PW
4457 # - the open for truncate tries to match a {0,EOF}PR
4458 # for the filesize and cancels the PWs.
4459 # any number of fixes (don't get {0,EOF} on open, match
4460 # composite locks, do smarter file size management) fix
4461 # this, but for now we want these tests to verify that
4462 # the cancellation with truncate intent works, so we
4463 # start the file with a full-file pw lock to match against
4464 # until the truncate.
4469 cancel_lru_locks $OSC
4471 # prime the file with 0,EOF PW to match
4475 # now the real test..
4476 dd if=/dev/zero of=$file bs=1024 count=100
4477 BEFOREWRITES=`count_ost_writes`
4478 $TRUNCATE $file $offset
4479 cancel_lru_locks $OSC
4480 AFTERWRITES=`count_ost_writes`
4485 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4488 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4489 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4492 run_test 42c "test partial truncate of file with cached dirty data"
4495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4498 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4499 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4502 run_test 42d "test complete truncate of file with cached dirty data"
4504 test_42e() { # bug22074
4505 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4507 local TDIR=$DIR/${tdir}e
4508 local pages=16 # hardcoded 16 pages, don't change it.
4509 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4510 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4514 test_mkdir $DIR/${tdir}e
4515 $LFS setstripe -c 1 $TDIR
4516 createmany -o $TDIR/f $files
4518 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4520 # we assume that with $OSTCOUNT files, at least one of them will
4521 # be allocated on OST0.
4522 warmup_files=$((OSTCOUNT * max_dirty_mb))
4523 createmany -o $TDIR/w $warmup_files
4525 # write a large amount of data into one file and sync, to get good
4526 # avail_grant number from OST.
4527 for ((i=0; i<$warmup_files; i++)); do
4528 idx=$($LFS getstripe -i $TDIR/w$i)
4529 [ $idx -ne 0 ] && continue
4530 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4533 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4535 $LCTL get_param $proc_osc0/cur_dirty_bytes
4536 $LCTL get_param $proc_osc0/cur_grant_bytes
4538 # create as much dirty pages as we can while not to trigger the actual
4539 # RPCs directly. but depends on the env, VFS may trigger flush during this
4540 # period, hopefully we are good.
4541 for ((i=0; i<$warmup_files; i++)); do
4542 idx=$($LFS getstripe -i $TDIR/w$i)
4543 [ $idx -ne 0 ] && continue
4544 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4546 $LCTL get_param $proc_osc0/cur_dirty_bytes
4547 $LCTL get_param $proc_osc0/cur_grant_bytes
4549 # perform the real test
4550 $LCTL set_param $proc_osc0/rpc_stats 0
4551 for ((;i<$files; i++)); do
4552 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
4553 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4556 $LCTL get_param $proc_osc0/rpc_stats
4559 local have_ppr=false
4560 $LCTL get_param $proc_osc0/rpc_stats |
4561 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4562 # skip lines until we are at the RPC histogram data
4563 [ "$PPR" == "pages" ] && have_ppr=true && continue
4564 $have_ppr || continue
4566 # we only want the percent stat for < 16 pages
4567 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4569 percent=$((percent + WPCT))
4570 if [[ $percent -gt 15 ]]; then
4571 error "less than 16-pages write RPCs" \
4578 run_test 42e "verify sub-RPC writes are not done synchronously"
4580 test_43A() { # was test_43
4581 test_mkdir $DIR/$tdir
4582 cp -p /bin/ls $DIR/$tdir/$tfile
4583 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4585 # give multiop a chance to open
4588 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4591 run_test 43A "execution of file opened for write should return -ETXTBSY"
4594 test_mkdir $DIR/$tdir
4595 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4596 $DIR/$tdir/sleep 60 &
4598 # Make sure exec of $tdir/sleep wins race with truncate
4600 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4603 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4606 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4608 test_mkdir $DIR/$tdir
4609 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4610 $DIR/$tdir/sleep 60 &
4612 # Make sure exec of $tdir/sleep wins race with truncate
4614 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4617 run_test 43b "truncate of file being executed should return -ETXTBSY"
4620 local testdir="$DIR/$tdir"
4623 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4624 ( cd $testdir && md5sum -c )
4626 run_test 43c "md5sum of copy into lustre"
4628 test_44A() { # was test_44
4629 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4631 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4632 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4634 run_test 44A "zero length read from a sparse stripe"
4637 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4639 [ -z "$nstripe" ] && skip "can't get stripe info"
4640 [[ $nstripe -gt $OSTCOUNT ]] &&
4641 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4643 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4645 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4646 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4650 OFFSETS="0 $((stride/2)) $((stride-1))"
4651 for offset in $OFFSETS; do
4652 for i in $(seq 0 $((nstripe-1))); do
4653 local GLOBALOFFSETS=""
4655 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4656 local myfn=$DIR/d44a-$size
4657 echo "--------writing $myfn at $size"
4658 ll_sparseness_write $myfn $size ||
4659 error "ll_sparseness_write"
4660 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4661 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4662 error "ll_sparseness_verify $GLOBALOFFSETS"
4664 for j in $(seq 0 $((nstripe-1))); do
4666 size=$((((j + $nstripe )*$stride + $offset)))
4667 ll_sparseness_write $myfn $size ||
4668 error "ll_sparseness_write"
4669 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4671 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4672 error "ll_sparseness_verify $GLOBALOFFSETS"
4677 run_test 44a "test sparse pwrite ==============================="
4681 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4687 before=`dirty_osc_total`
4688 echo executing "\"$*\""
4690 after=`dirty_osc_total`
4691 echo before $before, after $after
4694 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4697 # Obtain grants from OST if it supports it
4698 echo blah > ${f}_grant
4701 do_dirty_record "echo blah > $f"
4702 [[ $before -eq $after ]] && error "write wasn't cached"
4703 do_dirty_record "> $f"
4704 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4705 do_dirty_record "echo blah > $f"
4706 [[ $before -eq $after ]] && error "write wasn't cached"
4707 do_dirty_record "sync"
4708 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4709 do_dirty_record "echo blah > $f"
4710 [[ $before -eq $after ]] && error "write wasn't cached"
4711 do_dirty_record "cancel_lru_locks osc"
4712 [[ $before -gt $after ]] ||
4713 error "lock cancellation didn't lower dirty count"
4716 run_test 45 "osc io page accounting ============================"
4718 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4719 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4720 # objects offset and an assert hit when an rpc was built with 1023's mapped
4721 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4728 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4730 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4731 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4735 run_test 46 "dirtying a previously written page ================"
4737 # test_47 is removed "Device nodes check" is moved to test_28
4739 test_48a() { # bug 2399
4740 [ "$mds1_FSTYPE" = "zfs" ] &&
4741 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4742 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4744 test_mkdir $DIR/$tdir
4746 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4747 test_mkdir $DIR/$tdir
4748 touch foo || error "'touch foo' failed after recreating cwd"
4750 touch .foo || error "'touch .foo' failed after recreating cwd"
4752 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4753 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4754 cd . || error "'cd .' failed after recreating cwd"
4755 mkdir . && error "'mkdir .' worked after recreating cwd"
4756 rmdir . && error "'rmdir .' worked after recreating cwd"
4757 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4758 cd .. || error "'cd ..' failed after recreating cwd"
4760 run_test 48a "Access renamed working dir (should return errors)="
4762 test_48b() { # bug 2399
4764 test_mkdir $DIR/$tdir
4766 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4767 touch foo && error "'touch foo' worked after removing cwd"
4768 mkdir foo && error "'mkdir foo' worked after removing cwd"
4769 touch .foo && error "'touch .foo' worked after removing cwd"
4770 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4771 ls . > /dev/null && error "'ls .' worked after removing cwd"
4772 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4773 mkdir . && error "'mkdir .' worked after removing cwd"
4774 rmdir . && error "'rmdir .' worked after removing cwd"
4775 ln -s . foo && error "'ln -s .' worked after removing cwd"
4776 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4778 run_test 48b "Access removed working dir (should return errors)="
4780 test_48c() { # bug 2350
4781 #lctl set_param debug=-1
4784 test_mkdir -p $DIR/$tdir/dir
4786 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4787 $TRACE touch foo && error "touch foo worked after removing cwd"
4788 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4789 touch .foo && error "touch .foo worked after removing cwd"
4790 mkdir .foo && error "mkdir .foo worked after removing cwd"
4791 $TRACE ls . && error "'ls .' worked after removing cwd"
4792 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4793 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4794 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4795 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4796 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4798 run_test 48c "Access removed working subdir (should return errors)"
4800 test_48d() { # bug 2350
4801 #lctl set_param debug=-1
4804 test_mkdir -p $DIR/$tdir/dir
4806 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4807 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4808 $TRACE touch foo && error "'touch foo' worked after removing parent"
4809 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4810 touch .foo && error "'touch .foo' worked after removing parent"
4811 mkdir .foo && error "mkdir .foo worked after removing parent"
4812 $TRACE ls . && error "'ls .' worked after removing parent"
4813 $TRACE ls .. && error "'ls ..' worked after removing parent"
4814 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4815 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4816 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4819 run_test 48d "Access removed parent subdir (should return errors)"
4821 test_48e() { # bug 4134
4822 #lctl set_param debug=-1
4825 test_mkdir -p $DIR/$tdir/dir
4827 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4828 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4829 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4830 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4831 # On a buggy kernel addition of "touch foo" after cd .. will
4832 # produce kernel oops in lookup_hash_it
4833 touch ../foo && error "'cd ..' worked after recreate parent"
4835 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4837 run_test 48e "Access to recreated parent subdir (should return errors)"
4839 test_49() { # LU-1030
4840 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4841 remote_ost_nodsh && skip "remote OST with nodsh"
4843 # get ost1 size - lustre-OST0000
4844 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4846 # write 800M at maximum
4847 [[ $ost1_size -lt 2 ]] && ost1_size=2
4848 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4850 $LFS setstripe -c 1 -i 0 $DIR/$tfile
4851 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4854 # change max_pages_per_rpc while writing the file
4855 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4856 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4857 # loop until dd process exits
4858 while ps ax -opid | grep -wq $dd_pid; do
4859 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4860 sleep $((RANDOM % 5 + 1))
4862 # restore original max_pages_per_rpc
4863 $LCTL set_param $osc1_mppc=$orig_mppc
4864 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4866 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4870 test_mkdir $DIR/$tdir
4872 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4874 run_test 50 "special situations: /proc symlinks ==============="
4876 test_51a() { # was test_51
4877 # bug 1516 - create an empty entry right after ".." then split dir
4878 test_mkdir -c1 $DIR/$tdir
4879 touch $DIR/$tdir/foo
4880 $MCREATE $DIR/$tdir/bar
4882 createmany -m $DIR/$tdir/longfile 201
4884 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4885 $MCREATE $DIR/$tdir/longfile$FNUM
4890 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4892 run_test 51a "special situations: split htree with empty entry =="
4894 cleanup_print_lfs_df () {
4901 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4903 local dir=$DIR/$tdir
4904 local nrdirs=$((65536 + 100))
4906 # cleanup the directory
4913 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4914 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4915 [[ $numfree -lt $nrdirs ]] &&
4916 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4918 # need to check free space for the directories as well
4919 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4920 numfree=$(( blkfree / $(fs_inode_ksize) ))
4921 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4923 trap cleanup_print_lfs_df EXIT
4926 createmany -d $dir/d $nrdirs || {
4927 unlinkmany $dir/d $nrdirs
4928 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4932 nrdirs=$(ls -U $dir | wc -l)
4934 # unlink all but 100 subdirectories, then check it still works
4936 local delete=$((nrdirs - left))
4941 # for ldiskfs the nlink count should be 1, but this is OSD specific
4942 # and so this is listed for informational purposes only
4943 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4944 unlinkmany -d $dir/d $delete ||
4945 error "unlink of first $delete subdirs failed"
4947 echo "nlink between: $(stat -c %h $dir)"
4948 local found=$(ls -U $dir | wc -l)
4949 [ $found -ne $left ] &&
4950 error "can't find subdirs: found only $found, expected $left"
4952 unlinkmany -d $dir/d $delete $left ||
4953 error "unlink of second $left subdirs failed"
4954 # regardless of whether the backing filesystem tracks nlink accurately
4955 # or not, the nlink count shouldn't be more than "." and ".." here
4956 local after=$(stat -c %h $dir)
4957 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4958 echo "nlink after: $after"
4960 cleanup_print_lfs_df
4962 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4965 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4966 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4968 test_mkdir $DIR/$tdir
4969 createmany -o $DIR/$tdir/t- 1000
4970 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4971 for N in $(seq 0 $((OSTCOUNT - 1))); do
4972 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4973 END { printf("%0.0f", objs) }' $TMP/$tfile)
4974 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4975 '($1 == '$N') { objs += 1 } \
4976 END { printf("%0.0f", objs) }')
4977 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4979 unlinkmany $DIR/$tdir/t- 1000
4982 for N in $(seq 1 $((OSTCOUNT - 1))); do
4983 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4984 error "OST $N has less objects vs OST $NLAST" \
4985 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4986 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4987 error "OST $N has less objects vs OST $NLAST" \
4988 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4990 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4991 error "OST $N has less #0 objects vs OST $NLAST" \
4992 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4993 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4994 error "OST $N has less #0 objects vs OST $NLAST" \
4995 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5000 run_test 51d "check object distribution"
5003 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5004 skip_env "ldiskfs only test"
5007 test_mkdir -c1 $DIR/$tdir
5008 test_mkdir -c1 $DIR/$tdir/d0
5010 touch $DIR/$tdir/d0/foo
5011 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5012 error "file exceed 65000 nlink limit!"
5013 unlinkmany $DIR/$tdir/d0/f- 65001
5016 run_test 51e "check file nlink limit"
5019 test_mkdir $DIR/$tdir
5022 local ulimit_old=$(ulimit -n)
5023 local spare=20 # number of spare fd's for scripts/libraries, etc.
5024 local mdt=$($LFS getstripe -m $DIR/$tdir)
5025 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5027 echo "MDT$mdt numfree=$numfree, max=$max"
5028 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5029 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5030 while ! ulimit -n $((numfree + spare)); do
5031 numfree=$((numfree * 3 / 4))
5033 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5035 echo "left ulimit at $ulimit_old"
5038 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5039 unlinkmany $DIR/$tdir/f $numfree
5040 error "create+open $numfree files in $DIR/$tdir failed"
5042 ulimit -n $ulimit_old
5044 # if createmany exits at 120s there will be fewer than $numfree files
5045 unlinkmany $DIR/$tdir/f $numfree || true
5047 run_test 51f "check many open files limit"
5050 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5051 test_mkdir $DIR/$tdir
5052 touch $DIR/$tdir/foo
5053 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5054 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5055 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5056 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5057 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5059 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5060 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5061 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5063 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5064 cp -r $DIR/$tdir $TMP/
5065 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5067 run_test 52a "append-only flag test (should return errors)"
5070 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5071 test_mkdir $DIR/$tdir
5072 touch $DIR/$tdir/foo
5073 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5074 cat test > $DIR/$tdir/foo && error "cat test worked"
5075 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5076 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5077 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5079 echo foo >> $DIR/$tdir/foo && error "echo worked"
5080 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5081 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5082 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5083 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5085 chattr -i $DIR/$tdir/foo || error "chattr failed"
5087 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5089 run_test 52b "immutable flag test (should return errors) ======="
5092 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5093 remote_mds_nodsh && skip "remote MDS with nodsh"
5094 remote_ost_nodsh && skip "remote OST with nodsh"
5107 local support_last_seq=true
5109 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5110 support_last_seq=false
5113 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5115 for value in $(do_facet $SINGLEMDS \
5116 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5117 param=$(echo ${value[0]} | cut -d "=" -f1)
5118 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5120 if $support_last_seq; then
5121 param_seq=$(echo $param |
5122 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5123 mds_last_seq=$(do_facet $SINGLEMDS \
5124 $LCTL get_param -n $param_seq)
5126 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5128 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5129 node=$(facet_active_host ost$((ostnum+1)))
5130 param="obdfilter.$ostname.last_id"
5131 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5132 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5133 ost_last_id=$ost_last
5135 if $support_last_seq; then
5136 ost_last_id=$(echo $ost_last |
5137 awk -F':' '{print $2}' |
5139 ost_last_seq=$(echo $ost_last |
5140 awk -F':' '{print $1}')
5141 [[ $ost_last_seq = $mds_last_seq ]] || continue
5144 if [[ $ost_last_id != $mds_last ]]; then
5145 error "$ost_last_id != $mds_last"
5152 $found || error "can not match last_seq/last_id for $mdtosc"
5155 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5158 perl -MSocket -e ';' || skip "no Socket perl module installed"
5160 $SOCKETSERVER $DIR/socket ||
5161 error "$SOCKETSERVER $DIR/socket failed: $?"
5162 $SOCKETCLIENT $DIR/socket ||
5163 error "$SOCKETCLIENT $DIR/socket failed: $?"
5164 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5166 run_test 54a "unix domain socket test =========================="
5172 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5174 run_test 54b "char device works in lustre ======================"
5177 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5178 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5179 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5181 for i in $(seq 3 7); do
5182 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5191 loopdev="$DIR/loop54c"
5194 $UMOUNT $DIR/$tdir || rc=$?
5195 losetup -d $loopdev || true
5196 losetup -d $LOOPDEV || true
5197 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5202 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5204 loopdev="$DIR/loop54c"
5207 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5208 trap cleanup_54c EXIT
5209 mknod $loopdev b 7 $LOOPNUM
5210 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5211 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5212 losetup $loopdev $DIR/$tfile ||
5213 error "can't set up $loopdev for $DIR/$tfile"
5214 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5215 test_mkdir $DIR/$tdir
5216 mount -t ext2 $loopdev $DIR/$tdir ||
5217 error "error mounting $loopdev on $DIR/$tdir"
5218 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5221 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5225 run_test 54c "block device works in lustre ====================="
5231 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5233 run_test 54d "fifo device works in lustre ======================"
5238 cp -aL /dev/console $f
5239 echo $string > $f || error "echo $string to $f failed"
5241 run_test 54e "console/tty device works in lustre ======================"
5245 local dir=$DIR/$tdir
5248 test_mkdir -p $dir/dir
5249 for i in $(seq $numfiles); do
5251 touch $dir/dir/file$i
5254 local numcomp=$($LFS getstripe --component-count $dir)
5256 [[ $numcomp == 0 ]] && numcomp=1
5258 # test lfs getstripe with --recursive
5259 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5261 [[ $filenum -eq $((numfiles * 2)) ]] ||
5262 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5263 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5264 [[ $filenum -eq $numfiles ]] ||
5265 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5266 echo "$LFS getstripe showed obdidx or l_ost_idx"
5268 # test lfs getstripe with file instead of dir
5269 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5270 [[ $filenum -eq 1 ]] ||
5271 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5272 echo "$LFS getstripe file1 passed"
5274 #test lfs getstripe with --verbose
5275 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5276 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5277 error "$LFS getstripe --verbose $dir: "\
5278 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5279 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5280 error "$LFS getstripe $dir: showed lmm_magic"
5282 #test lfs getstripe with -v prints lmm_fid
5283 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5284 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5285 error "$LFS getstripe -v $dir: "\
5286 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5287 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5288 error "$LFS getstripe $dir: showed lmm_fid by default"
5289 echo "$LFS getstripe --verbose passed"
5291 #check for FID information
5292 local fid1=$($LFS getstripe --fid $dir/file1)
5293 local fid2=$($LFS getstripe --verbose $dir/file1 |
5294 awk '/lmm_fid: / { print $2; exit; }')
5295 local fid3=$($LFS path2fid $dir/file1)
5297 [ "$fid1" != "$fid2" ] &&
5298 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5299 [ "$fid1" != "$fid3" ] &&
5300 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5301 echo "$LFS getstripe --fid passed"
5303 #test lfs getstripe with --obd
5304 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5305 error "$LFS getstripe --obd wrong_uuid: should return error"
5307 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5310 local obduuid=$(ostuuid_from_index $ostidx)
5311 local found=$($LFS getstripe -r --obd $obduuid $dir |
5312 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5314 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5315 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5317 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5320 [[ $found -eq $filenum ]] ||
5321 error "$LFS getstripe --obd: found $found expect $filenum"
5322 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5323 sed '/^[ ]*'${ostidx}'[ ]/d' |
5324 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5325 error "$LFS getstripe --obd: should not show file on other obd"
5326 echo "$LFS getstripe --obd passed"
5328 run_test 56a "check $LFS getstripe"
5331 local dir=$DIR/$tdir
5335 for i in $(seq $numdirs); do
5336 test_mkdir $dir/dir$i
5339 # test lfs getdirstripe default mode is non-recursion, which is
5340 # different from lfs getstripe
5341 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5343 [[ $dircnt -eq 1 ]] ||
5344 error "$LFS getdirstripe: found $dircnt, not 1"
5345 dircnt=$($LFS getdirstripe --recursive $dir |
5346 grep -c lmv_stripe_count)
5347 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5348 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5350 run_test 56b "check $LFS getdirstripe"
5353 remote_ost_nodsh && skip "remote OST with nodsh"
5356 local ost_name=$(ostname_from_index $ost_idx)
5357 local old_status=$(ost_dev_status $ost_idx)
5359 [[ -z "$old_status" ]] ||
5360 skip_env "OST $ost_name is in $old_status status"
5362 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5365 local new_status=$(ost_dev_status $ost_idx)
5367 [[ "$new_status" = "D" ]] ||
5368 error "OST $ost_name is in status of '$new_status', not 'D'"
5370 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5373 new_status=$(ost_dev_status $ost_idx)
5374 [[ -z "$new_status" ]] ||
5375 error "OST $ost_name is in status of '$new_status', not ''"
5377 run_test 56c "check 'lfs df' showing device status"
5382 local local_tdir="$1"
5383 local local_numfiles="$2"
5384 local local_numdirs="$3"
5385 local dir_params="$4"
5386 local dir_stripe_params="$5"
5388 if [ ! -d "$local_tdir" ] ; then
5389 test_mkdir -p $dir_stripe_params $local_tdir
5390 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5391 for i in $(seq $local_numfiles) ; do
5392 touch $local_tdir/file$i
5394 for i in $(seq $local_numdirs) ; do
5395 test_mkdir $dir_stripe_params $local_tdir/dir$i
5396 for j in $(seq $local_numfiles) ; do
5397 touch $local_tdir/dir$i/file$j
5403 setup_56_special() {
5405 local local_numfiles=$2
5406 local local_numdirs=$3
5408 setup_56 $local_tdir $local_numfiles $local_numdirs
5410 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5411 for i in $(seq $local_numfiles) ; do
5412 mknod $local_tdir/loop${i}b b 7 $i
5413 mknod $local_tdir/null${i}c c 1 3
5414 ln -s $local_tdir/file1 $local_tdir/link${i}
5416 for i in $(seq $local_numdirs) ; do
5417 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5418 mknod $local_tdir/dir$i/null${i}c c 1 3
5419 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5425 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5426 local expected=$(($NUMDIRS + 2))
5428 setup_56 $dir $NUMFILES $NUMDIRS
5430 # test lfs find with -name
5431 for i in $(seq $NUMFILES) ; do
5432 local nums=$($LFS find -name "*$i" $dir | wc -l)
5434 [ $nums -eq $expected ] ||
5435 error "lfs find -name '*$i' $dir wrong: "\
5436 "found $nums, expected $expected"
5439 run_test 56g "check lfs find -name"
5442 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5443 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5445 setup_56 $dir $NUMFILES $NUMDIRS
5447 # test lfs find with ! -name
5448 for i in $(seq $NUMFILES) ; do
5449 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5451 [ $nums -eq $expected ] ||
5452 error "lfs find ! -name '*$i' $dir wrong: "\
5453 "found $nums, expected $expected"
5456 run_test 56h "check lfs find ! -name"
5459 local dir=$DIR/$tdir
5463 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5466 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5468 run_test 56i "check 'lfs find -ost UUID' skips directories"
5471 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5473 setup_56_special $dir $NUMFILES $NUMDIRS
5475 local expected=$((NUMDIRS + 1))
5476 local cmd="$LFS find -type d $dir"
5477 local nums=$($cmd | wc -l)
5479 [ $nums -eq $expected ] ||
5480 error "'$cmd' wrong: found $nums, expected $expected"
5482 run_test 56j "check lfs find -type d"
5485 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5487 setup_56_special $dir $NUMFILES $NUMDIRS
5489 local expected=$(((NUMDIRS + 1) * NUMFILES))
5490 local cmd="$LFS find -type f $dir"
5491 local nums=$($cmd | wc -l)
5493 [ $nums -eq $expected ] ||
5494 error "'$cmd' wrong: found $nums, expected $expected"
5496 run_test 56k "check lfs find -type f"
5499 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5501 setup_56_special $dir $NUMFILES $NUMDIRS
5503 local expected=$((NUMDIRS + NUMFILES))
5504 local cmd="$LFS find -type b $dir"
5505 local nums=$($cmd | wc -l)
5507 [ $nums -eq $expected ] ||
5508 error "'$cmd' wrong: found $nums, expected $expected"
5510 run_test 56l "check lfs find -type b"
5513 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5515 setup_56_special $dir $NUMFILES $NUMDIRS
5517 local expected=$((NUMDIRS + NUMFILES))
5518 local cmd="$LFS find -type c $dir"
5519 local nums=$($cmd | wc -l)
5520 [ $nums -eq $expected ] ||
5521 error "'$cmd' wrong: found $nums, expected $expected"
5523 run_test 56m "check lfs find -type c"
5526 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5527 setup_56_special $dir $NUMFILES $NUMDIRS
5529 local expected=$((NUMDIRS + NUMFILES))
5530 local cmd="$LFS find -type l $dir"
5531 local nums=$($cmd | wc -l)
5533 [ $nums -eq $expected ] ||
5534 error "'$cmd' wrong: found $nums, expected $expected"
5536 run_test 56n "check lfs find -type l"
5539 local dir=$DIR/$tdir
5541 setup_56 $dir $NUMFILES $NUMDIRS
5542 utime $dir/file1 > /dev/null || error "utime (1)"
5543 utime $dir/file2 > /dev/null || error "utime (2)"
5544 utime $dir/dir1 > /dev/null || error "utime (3)"
5545 utime $dir/dir2 > /dev/null || error "utime (4)"
5546 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5547 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5550 local nums=$($LFS find -mtime +0 $dir | wc -l)
5552 [ $nums -eq $expected ] ||
5553 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5556 cmd="$LFS find -mtime 0 $dir"
5557 nums=$($cmd | wc -l)
5558 [ $nums -eq $expected ] ||
5559 error "'$cmd' wrong: found $nums, expected $expected"
5561 run_test 56o "check lfs find -mtime for old files"
5564 local dir=$DIR/$tdir
5568 # just to make sure there is something that won't be found
5570 touch $dir/$tfile.now
5572 for age in year week day hour min; do
5573 count=$((count + 1))
5575 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
5576 touch --date="$count $age ago" -a $dir/$tfile-a.$age
5577 touch --date="$count $age ago" -m $dir/$tfile-m.$age
5579 local cmd="$LFS find $dir -mtime $count${age:0:1}"
5580 local nums=$($cmd | wc -l)
5581 [ $nums -eq $expected ] ||
5582 error "'$cmd' wrong: found $nums, expected $expected"
5584 cmd="$LFS find $dir -atime $count${age:0:1}"
5585 nums=$($cmd | wc -l)
5586 [ $nums -eq $expected ] ||
5587 error "'$cmd' wrong: found $nums, expected $expected"
5591 cmd="$LFS find $dir -ctime +1s -type f"
5592 nums=$($cmd | wc -l)
5593 (( $nums == $count * 2 + 1)) ||
5594 error "'$cmd' wrong: found $nums, expected $((expected*2+1))"
5596 run_test 56ob "check lfs find -atime -mtime -ctime with units"
5599 [ $RUNAS_ID -eq $UID ] &&
5600 skip_env "RUNAS_ID = UID = $UID -- skipping"
5602 local dir=$DIR/$tdir
5604 setup_56 $dir $NUMFILES $NUMDIRS
5605 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5607 local expected=$NUMFILES
5608 local cmd="$LFS find -uid $RUNAS_ID $dir"
5609 local nums=$($cmd | wc -l)
5611 [ $nums -eq $expected ] ||
5612 error "'$cmd' wrong: found $nums, expected $expected"
5614 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5615 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5616 nums=$($cmd | wc -l)
5617 [ $nums -eq $expected ] ||
5618 error "'$cmd' wrong: found $nums, expected $expected"
5620 run_test 56p "check lfs find -uid and ! -uid"
5623 [ $RUNAS_ID -eq $UID ] &&
5624 skip_env "RUNAS_ID = UID = $UID -- skipping"
5626 local dir=$DIR/$tdir
5628 setup_56 $dir $NUMFILES $NUMDIRS
5629 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5631 local expected=$NUMFILES
5632 local cmd="$LFS find -gid $RUNAS_GID $dir"
5633 local nums=$($cmd | wc -l)
5635 [ $nums -eq $expected ] ||
5636 error "'$cmd' wrong: found $nums, expected $expected"
5638 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5639 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5640 nums=$($cmd | wc -l)
5641 [ $nums -eq $expected ] ||
5642 error "'$cmd' wrong: found $nums, expected $expected"
5644 run_test 56q "check lfs find -gid and ! -gid"
5647 local dir=$DIR/$tdir
5649 setup_56 $dir $NUMFILES $NUMDIRS
5652 local cmd="$LFS find -size 0 -type f $dir"
5653 local nums=$($cmd | wc -l)
5655 [ $nums -eq $expected ] ||
5656 error "'$cmd' wrong: found $nums, expected $expected"
5658 cmd="$LFS find ! -size 0 -type f $dir"
5659 nums=$($cmd | wc -l)
5660 [ $nums -eq $expected ] ||
5661 error "'$cmd' wrong: found $nums, expected $expected"
5662 echo "test" > $dir/$tfile
5663 echo "test2" > $dir/$tfile.2 && sync
5665 cmd="$LFS find -size 5 -type f $dir"
5666 nums=$($cmd | wc -l)
5667 [ $nums -eq $expected ] ||
5668 error "'$cmd' wrong: found $nums, expected $expected"
5670 cmd="$LFS find -size +5 -type f $dir"
5671 nums=$($cmd | wc -l)
5672 [ $nums -eq $expected ] ||
5673 error "'$cmd' wrong: found $nums, expected $expected"
5675 cmd="$LFS find -size +0 -type f $dir"
5676 nums=$($cmd | wc -l)
5677 [ $nums -eq $expected ] ||
5678 error "'$cmd' wrong: found $nums, expected $expected"
5680 cmd="$LFS find ! -size -5 -type f $dir"
5681 nums=$($cmd | wc -l)
5682 [ $nums -eq $expected ] ||
5683 error "'$cmd' wrong: found $nums, expected $expected"
5685 cmd="$LFS find -size -5 -type f $dir"
5686 nums=$($cmd | wc -l)
5687 [ $nums -eq $expected ] ||
5688 error "'$cmd' wrong: found $nums, expected $expected"
5690 run_test 56r "check lfs find -size works"
5692 test_56s() { # LU-611 #LU-9369
5693 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5695 local dir=$DIR/$tdir
5696 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5698 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5699 for i in $(seq $NUMDIRS); do
5700 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5703 local expected=$NUMDIRS
5704 local cmd="$LFS find -c $OSTCOUNT $dir"
5705 local nums=$($cmd | wc -l)
5707 [ $nums -eq $expected ] || {
5708 $LFS getstripe -R $dir
5709 error "'$cmd' wrong: found $nums, expected $expected"
5712 expected=$((NUMDIRS + onestripe))
5713 cmd="$LFS find -stripe-count +0 -type f $dir"
5714 nums=$($cmd | wc -l)
5715 [ $nums -eq $expected ] || {
5716 $LFS getstripe -R $dir
5717 error "'$cmd' wrong: found $nums, expected $expected"
5721 cmd="$LFS find -stripe-count 1 -type f $dir"
5722 nums=$($cmd | wc -l)
5723 [ $nums -eq $expected ] || {
5724 $LFS getstripe -R $dir
5725 error "'$cmd' wrong: found $nums, expected $expected"
5728 cmd="$LFS find -stripe-count -2 -type f $dir"
5729 nums=$($cmd | wc -l)
5730 [ $nums -eq $expected ] || {
5731 $LFS getstripe -R $dir
5732 error "'$cmd' wrong: found $nums, expected $expected"
5736 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5737 nums=$($cmd | wc -l)
5738 [ $nums -eq $expected ] || {
5739 $LFS getstripe -R $dir
5740 error "'$cmd' wrong: found $nums, expected $expected"
5743 run_test 56s "check lfs find -stripe-count works"
5745 test_56t() { # LU-611 #LU-9369
5746 local dir=$DIR/$tdir
5748 setup_56 $dir 0 $NUMDIRS
5749 for i in $(seq $NUMDIRS); do
5750 $LFS setstripe -S 8M $dir/dir$i/$tfile
5753 local expected=$NUMDIRS
5754 local cmd="$LFS find -S 8M $dir"
5755 local nums=$($cmd | wc -l)
5757 [ $nums -eq $expected ] || {
5758 $LFS getstripe -R $dir
5759 error "'$cmd' wrong: found $nums, expected $expected"
5763 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5765 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5767 expected=$(((NUMDIRS + 1) * NUMFILES))
5768 cmd="$LFS find -stripe-size 512k -type f $dir"
5769 nums=$($cmd | wc -l)
5770 [ $nums -eq $expected ] ||
5771 error "'$cmd' wrong: found $nums, expected $expected"
5773 cmd="$LFS find -stripe-size +320k -type f $dir"
5774 nums=$($cmd | wc -l)
5775 [ $nums -eq $expected ] ||
5776 error "'$cmd' wrong: found $nums, expected $expected"
5778 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5779 cmd="$LFS find -stripe-size +200k -type f $dir"
5780 nums=$($cmd | wc -l)
5781 [ $nums -eq $expected ] ||
5782 error "'$cmd' wrong: found $nums, expected $expected"
5784 cmd="$LFS find -stripe-size -640k -type f $dir"
5785 nums=$($cmd | wc -l)
5786 [ $nums -eq $expected ] ||
5787 error "'$cmd' wrong: found $nums, expected $expected"
5790 cmd="$LFS find -stripe-size 256k -type f $dir"
5791 nums=$($cmd | wc -l)
5792 [ $nums -eq $expected ] ||
5793 error "'$cmd' wrong: found $nums, expected $expected"
5795 cmd="$LFS find -stripe-size -320k -type f $dir"
5796 nums=$($cmd | wc -l)
5797 [ $nums -eq $expected ] ||
5798 error "'$cmd' wrong: found $nums, expected $expected"
5801 cmd="$LFS find -stripe-size 1024k -type f $dir"
5802 nums=$($cmd | wc -l)
5803 [ $nums -eq $expected ] ||
5804 error "'$cmd' wrong: found $nums, expected $expected"
5806 run_test 56t "check lfs find -stripe-size works"
5808 test_56u() { # LU-611
5809 local dir=$DIR/$tdir
5811 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5813 if [[ $OSTCOUNT -gt 1 ]]; then
5814 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5820 local expected=$(((NUMDIRS + 1) * NUMFILES))
5821 local cmd="$LFS find -stripe-index 0 -type f $dir"
5822 local nums=$($cmd | wc -l)
5824 [ $nums -eq $expected ] ||
5825 error "'$cmd' wrong: found $nums, expected $expected"
5828 cmd="$LFS find -stripe-index 1 -type f $dir"
5829 nums=$($cmd | wc -l)
5830 [ $nums -eq $expected ] ||
5831 error "'$cmd' wrong: found $nums, expected $expected"
5833 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5834 nums=$($cmd | wc -l)
5835 [ $nums -eq $expected ] ||
5836 error "'$cmd' wrong: found $nums, expected $expected"
5839 # This should produce an error and not return any files
5840 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5841 nums=$($cmd 2>/dev/null | wc -l)
5842 [ $nums -eq $expected ] ||
5843 error "'$cmd' wrong: found $nums, expected $expected"
5845 if [[ $OSTCOUNT -gt 1 ]]; then
5846 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5847 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5848 nums=$($cmd | wc -l)
5849 [ $nums -eq $expected ] ||
5850 error "'$cmd' wrong: found $nums, expected $expected"
5853 run_test 56u "check lfs find -stripe-index works"
5857 local dir=$DIR/$tdir
5859 setup_56 $dir $NUMFILES $NUMDIRS
5861 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5862 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5864 for file in $($LFS find -m $UUID $dir); do
5865 file_midx=$($LFS getstripe -m $file)
5866 [ $file_midx -eq $mdt_idx ] ||
5867 error "lfs find -m $UUID != getstripe -m $file_midx"
5870 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5873 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5876 local dir=$DIR/$tdir
5878 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5880 local stripe_size=$($LFS getstripe -S -d $dir) ||
5881 error "$LFS getstripe -S -d $dir failed"
5882 stripe_size=${stripe_size%% *}
5884 local file_size=$((stripe_size * OSTCOUNT))
5885 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5886 local required_space=$((file_num * file_size))
5887 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5889 [[ $free_space -le $((required_space / 1024)) ]] &&
5890 skip_env "need $required_space, have $free_space kbytes"
5893 local dd_count=$((file_size / dd_bs))
5895 # write data into the files
5900 for i in $(seq $NUMFILES); do
5902 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5903 error "write data into $file failed"
5905 for i in $(seq $NUMDIRS); do
5906 for j in $(seq $NUMFILES); do
5907 file=$dir/dir$i/file$j
5908 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5909 error "write data into $file failed"
5913 # $LFS_MIGRATE will fail if hard link migration is unsupported
5914 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5915 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5916 error "creating links to $dir/dir1/file1 failed"
5921 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5924 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5927 eval $cmd || error "$cmd failed"
5929 check_stripe_count $dir/file1 $expected
5931 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
5933 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5934 # OST 1 if it is on OST 0. This file is small enough to
5935 # be on only one stripe.
5936 file=$dir/migr_1_ost
5937 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5938 error "write data into $file failed"
5939 local obdidx=$($LFS getstripe -i $file)
5940 local oldmd5=$(md5sum $file)
5943 [[ $obdidx -eq 0 ]] && newobdidx=1
5944 cmd="$LFS migrate -i $newobdidx $file"
5946 eval $cmd || error "$cmd failed"
5948 local realobdix=$($LFS getstripe -i $file)
5949 local newmd5=$(md5sum $file)
5951 [[ $newobdidx -ne $realobdix ]] &&
5952 error "new OST is different (was=$obdidx, "\
5953 "wanted=$newobdidx, got=$realobdix)"
5954 [[ "$oldmd5" != "$newmd5" ]] &&
5955 error "md5sum differ: $oldmd5, $newmd5"
5959 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5961 eval $cmd || error "$cmd failed"
5963 for j in $(seq $NUMFILES); do
5964 check_stripe_count $dir/dir1/file$j $expected
5967 # lfs_migrate works with lfs find
5968 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5969 $LFS_MIGRATE -y -c $expected"
5971 eval $cmd || error "$cmd failed"
5973 for i in $(seq 2 $NUMFILES); do
5974 check_stripe_count $dir/file$i $expected
5976 for i in $(seq 2 $NUMDIRS); do
5977 for j in $(seq $NUMFILES); do
5978 check_stripe_count $dir/dir$i/file$j $expected
5982 run_test 56w "check lfs_migrate -c stripe_count works"
5985 local file1=$DIR/$tdir/file1
5986 local create_pool=false
5987 local initial_pool=$($LFS getstripe -p $DIR)
5991 echo -n "Creating test dir..."
5992 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5995 echo -n "Creating test file..."
5996 touch $file1 || error "cannot create file"
5999 echo -n "Detecting existing pools..."
6000 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
6002 if [ ${#pool_list[@]} -gt 0 ]; then
6003 echo "${pool_list[@]}"
6004 for thispool in "${pool_list[@]}"; do
6005 if [[ -z "$initial_pool" ||
6006 "$initial_pool" != "$thispool" ]]; then
6008 echo "Using existing pool '$pool'"
6013 echo "none detected."
6015 if [ -z "$pool" ]; then
6016 pool=${POOL:-testpool}
6017 [ "$initial_pool" = "$pool" ] && pool="testpool2"
6018 echo -n "Creating pool '$pool'..."
6020 pool_add $pool &> /dev/null ||
6021 error "pool_add failed"
6024 echo -n "Adding target to pool..."
6025 pool_add_targets $pool 0 0 1 &> /dev/null ||
6026 error "pool_add_targets failed"
6030 echo -n "Setting pool using -p option..."
6031 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
6032 error "migrate failed rc = $?"
6035 echo -n "Verifying test file is in pool after migrating..."
6036 [ "$($LFS getstripe -p $file1)" = $pool ] ||
6037 error "file was not migrated to pool $pool"
6040 echo -n "Removing test file from pool '$pool'..."
6041 $LFS migrate $file1 &> /dev/null ||
6042 error "cannot remove from pool"
6043 [ "$($LFS getstripe -p $file1)" ] &&
6044 error "pool still set"
6047 echo -n "Setting pool using --pool option..."
6048 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
6049 error "migrate failed rc = $?"
6054 if $create_pool; then
6055 destroy_test_pools 2> /dev/null ||
6056 error "destroy test pools failed"
6059 run_test 56wb "check lfs_migrate pool support"
6062 local file1="$DIR/$tdir/file1"
6064 echo -n "Creating test dir..."
6065 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6066 local def_stripe_size=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
6067 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
6068 error "cannot set stripe"
6071 echo -n "Setting initial stripe for test file..."
6072 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
6073 error "cannot set stripe"
6074 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
6075 error "stripe size not set"
6078 # File currently set to -S 512K -c 1
6080 # Ensure -c and -S options are rejected when -R is set
6081 echo -n "Verifying incompatible options are detected..."
6082 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
6083 error "incompatible -c and -R options not detected"
6084 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
6085 error "incompatible -S and -R options not detected"
6088 # Ensure unrecognized options are passed through to 'lfs migrate'
6089 echo -n "Verifying -S option is passed through to lfs migrate..."
6090 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
6091 error "migration failed"
6092 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
6093 error "file was not restriped"
6096 # File currently set to -S 1M -c 1
6098 # Ensure long options are supported
6099 echo -n "Verifying long options supported..."
6100 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
6101 error "long option without argument not supported"
6102 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
6103 error "long option with argument not supported"
6104 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
6105 error "file not restriped with --stripe-size option"
6108 # File currently set to -S 512K -c 1
6110 if [ "$OSTCOUNT" -gt 1 ]; then
6111 echo -n "Verifying explicit stripe count can be set..."
6112 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
6113 error "migrate failed"
6114 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
6115 error "file not restriped to explicit count"
6119 # File currently set to -S 512K -c 1 or -S 512K -c 2
6121 # Ensure parent striping is used if -R is set, and no stripe
6122 # count or size is specified
6123 echo -n "Setting stripe for parent directory..."
6124 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
6125 error "cannot set stripe"
6128 echo -n "Verifying restripe option uses parent stripe settings..."
6129 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
6130 error "migrate failed"
6131 [ $($LFS getstripe -S "$file1") -eq $def_stripe_size ] ||
6132 error "file not restriped to parent settings"
6133 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
6134 error "file not restriped to parent settings"
6137 # File currently set to -S 1M -c 1
6139 # Ensure striping is preserved if -R is not set, and no stripe
6140 # count or size is specified
6141 echo -n "Verifying striping size preserved when not specified..."
6142 local orig_stripe_size=$($LFS getstripe -S "$file1" 2>/dev/null)
6143 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6144 error "cannot set stripe on parent directory"
6145 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6146 error "migrate failed"
6147 [ $($LFS getstripe -S "$file1") -eq $orig_stripe_size ] ||
6148 error "file was restriped"
6151 # Ensure file name properly detected when final option has no argument
6152 echo -n "Verifying file name properly detected..."
6153 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6154 error "file name interpreted as option argument"
6160 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
6163 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6165 local file1=$DIR/$tdir/file1
6167 echo -n "Creating test dir..."
6168 test_mkdir $DIR/$tdir || error "cannot create dir"
6171 echo -n "Creating test file..."
6175 # Ensure 'lfs migrate' will fail by using a non-existent option,
6176 # and make sure rsync is not called to recover
6177 echo -n "Make sure --no-rsync option works..."
6178 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
6179 grep -q 'refusing to fall back to rsync' ||
6180 error "rsync was called with --no-rsync set"
6183 # Ensure rsync is called without trying 'lfs migrate' first
6184 echo -n "Make sure --rsync option works..."
6185 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
6186 grep -q 'falling back to rsync' &&
6187 error "lfs migrate was called with --rsync set"
6190 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6191 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6192 grep -q 'at the same time' ||
6193 error "--rsync and --no-rsync accepted concurrently"
6199 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6202 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6203 check_swap_layouts_support
6205 local dir=$DIR/$tdir
6206 local ref1=/etc/passwd
6207 local file1=$dir/file1
6209 test_mkdir $dir || error "creating dir $dir"
6210 $LFS setstripe -c 2 $file1
6212 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6213 stripe=$($LFS getstripe -c $file1)
6214 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6215 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6220 run_test 56x "lfs migration support"
6223 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6224 check_swap_layouts_support
6226 local dir=$DIR/$tdir/$testnum
6230 local ref1=/etc/passwd
6231 local file1=$dir/file1
6233 $LFS setstripe -c 2 $file1
6235 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6237 local stripe=$($LFS getstripe -c $file1)
6239 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6240 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6245 run_test 56xa "lfs migration --block support"
6247 check_migrate_links() {
6249 local file1="$dir/file1"
6252 local total_count=$(($begin + $count - 1))
6253 local symlink_count=10
6256 if [ ! -f "$file1" ]; then
6257 echo -n "creating initial file..."
6258 $LFS setstripe -c 1 -S "512k" "$file1" ||
6259 error "cannot setstripe initial file"
6262 echo -n "creating symlinks..."
6263 for s in $(seq 1 $symlink_count); do
6264 ln -s "$file1" "$dir/slink$s" ||
6265 error "cannot create symlinks"
6269 echo -n "creating nonlinked files..."
6270 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6271 error "cannot create nonlinked files"
6276 if [ ! -f "$dir/file$total_count" ]; then
6277 echo -n "creating hard links $begin:$total_count..."
6278 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6279 /dev/null || error "cannot create hard links"
6283 echo -n "checking number of hard links listed in xattrs..."
6284 local fid=$($LFS getstripe -F "$file1")
6285 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6288 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6289 skip "hard link list has unexpected size, skipping test"
6291 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6292 error "link names should exceed xattrs size"
6295 echo -n "migrating files..."
6296 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
6298 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6301 # make sure all links have been properly migrated
6302 echo -n "verifying files..."
6303 fid=$($LFS getstripe -F "$file1") ||
6304 error "cannot get fid for file $file1"
6305 for i in $(seq 2 $total_count); do
6306 local fid2=$($LFS getstripe -F $dir/file$i)
6308 [ "$fid2" == "$fid" ] ||
6309 error "migrated hard link has mismatched FID"
6312 # make sure hard links were properly detected, and migration was
6313 # performed only once for the entire link set; nonlinked files should
6315 local actual=$(grep -c 'done' <<< "$migrate_out")
6316 local expected=$(($uniq_count + 1))
6318 [ "$actual" -eq "$expected" ] ||
6319 error "hard links individually migrated ($actual != $expected)"
6321 # make sure the correct number of hard links are present
6322 local hardlinks=$(stat -c '%h' "$file1")
6324 [ $hardlinks -eq $total_count ] ||
6325 error "num hard links $hardlinks != $total_count"
6332 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6333 skip "Need MDS version at least 2.10.55"
6335 local dir="$DIR/$tdir"
6337 test_mkdir "$dir" || error "cannot create dir $dir"
6339 echo "testing lfs migrate mode when all links fit within xattrs"
6340 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6342 echo "testing rsync mode when all links fit within xattrs"
6343 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6345 echo "testing lfs migrate mode when all links do not fit within xattrs"
6346 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6348 echo "testing rsync mode when all links do not fit within xattrs"
6349 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6355 run_test 56xb "lfs migration hard link support"
6358 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6360 local dir="$DIR/$tdir"
6362 test_mkdir "$dir" || error "cannot create dir $dir"
6364 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6365 echo -n "Setting initial stripe for 20MB test file..."
6366 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6367 error "cannot setstripe 20MB file"
6369 echo -n "Sizing 20MB test file..."
6370 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6372 echo -n "Verifying small file autostripe count is 1..."
6373 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6374 error "cannot migrate 20MB file"
6375 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6376 error "cannot get stripe for $dir/20mb"
6377 [ $stripe_count -eq 1 ] ||
6378 error "unexpected stripe count $stripe_count for 20MB file"
6382 # Test 2: File is small enough to fit within the available space on
6383 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6384 # have at least an additional 1KB for each desired stripe for test 3
6385 echo -n "Setting stripe for 1GB test file..."
6386 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
6388 echo -n "Sizing 1GB test file..."
6389 # File size is 1GB + 3KB
6390 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
6393 # need at least 512MB per OST for 1GB file to fit in 2 stripes
6394 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
6395 if (( avail > 524288 * OSTCOUNT )); then
6396 echo -n "Migrating 1GB file..."
6397 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
6398 error "cannot migrate 1GB file"
6400 echo -n "Verifying autostripe count is sqrt(n) + 1..."
6401 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
6402 error "cannot getstripe for 1GB file"
6403 [ $stripe_count -eq 2 ] ||
6404 error "unexpected stripe count $stripe_count != 2"
6408 # Test 3: File is too large to fit within the available space on
6409 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
6410 if [ $OSTCOUNT -ge 3 ]; then
6411 # The required available space is calculated as
6412 # file size (1GB + 3KB) / OST count (3).
6413 local kb_per_ost=349526
6415 echo -n "Migrating 1GB file with limit..."
6416 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
6417 error "cannot migrate 1GB file with limit"
6420 stripe_count=$($LFS getstripe -c "$dir/1gb")
6421 echo -n "Verifying 1GB autostripe count with limited space..."
6422 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
6423 error "unexpected stripe count $stripe_count (min 3)"
6430 run_test 56xc "lfs migration autostripe"
6433 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
6434 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
6437 local dir=$DIR/$tdir
6441 test_mkdir -p $dir || error "creating dir $dir"
6442 touch $f1 || error "creating std file $f1"
6443 $MULTIOP $f2 H2c || error "creating released file $f2"
6445 # a directory can be raid0, so ask only for files
6446 res=$($LFS find $dir -L raid0 -type f | wc -l)
6447 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
6449 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
6450 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
6452 # only files can be released, so no need to force file search
6453 res=$($LFS find $dir -L released)
6454 [[ $res == $f2 ]] || error "search released: found $res != $f2"
6456 res=$($LFS find $dir -type f \! -L released)
6457 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
6459 run_test 56y "lfs find -L raid0|released"
6461 test_56z() { # LU-4824
6462 # This checks to make sure 'lfs find' continues after errors
6463 # There are two classes of errors that should be caught:
6464 # - If multiple paths are provided, all should be searched even if one
6466 # - If errors are encountered during the search, it should not terminate
6468 local dir=$DIR/$tdir
6472 for i in d{0..9}; do
6474 touch $dir/$i/$tfile
6476 $LFS find $DIR/non_existent_dir $dir &&
6477 error "$LFS find did not return an error"
6478 # Make a directory unsearchable. This should NOT be the last entry in
6479 # directory order. Arbitrarily pick the 6th entry
6480 chmod 700 $($LFS find $dir -type d | sed '6!d')
6482 $RUNAS $LFS find $DIR/non_existent $dir
6483 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
6485 # The user should be able to see 10 directories and 9 files
6486 (( count == 19 )) ||
6487 error "$LFS find found $count != 19 entries after error"
6489 run_test 56z "lfs find should continue after an error"
6491 test_56aa() { # LU-5937
6492 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
6494 local dir=$DIR/$tdir
6497 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
6499 createmany -o $dir/striped_dir/${tfile}- 1024
6500 local dirs=$($LFS find --size +8k $dir/)
6502 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
6504 run_test 56aa "lfs find --size under striped dir"
6506 test_56ab() { # LU-10705
6507 test_mkdir $DIR/$tdir
6508 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
6509 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
6510 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
6511 # Flush writes to ensure valid blocks. Need to be more thorough for
6512 # ZFS, since blocks are not allocated/returned to client immediately.
6514 wait_zfs_commit ost1 2
6515 cancel_lru_locks osc
6518 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
6520 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
6522 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
6523 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
6525 rm -f $DIR/$tdir/$tfile.[123]
6527 run_test 56ab "lfs find --blocks"
6530 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
6531 skip "Need MDS version at least 2.10.50"
6533 # Create composite files with one component
6534 local dir=$DIR/$tdir
6536 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
6537 # Create composite files with three components
6538 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
6539 # Create non-composite files
6540 createmany -o $dir/${tfile}- 10
6542 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
6544 [[ $nfiles == 10 ]] ||
6545 error "lfs find -E 1M found $nfiles != 10 files"
6547 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
6548 [[ $nfiles == 25 ]] ||
6549 error "lfs find ! -E 1M found $nfiles != 25 files"
6551 # All files have a component that starts at 0
6552 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
6553 [[ $nfiles == 35 ]] ||
6554 error "lfs find --component-start 0 - $nfiles != 35 files"
6556 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
6557 [[ $nfiles == 15 ]] ||
6558 error "lfs find --component-start 2M - $nfiles != 15 files"
6560 # All files created here have a componenet that does not starts at 2M
6561 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
6562 [[ $nfiles == 35 ]] ||
6563 error "lfs find ! --component-start 2M - $nfiles != 35 files"
6565 # Find files with a specified number of components
6566 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
6567 [[ $nfiles == 15 ]] ||
6568 error "lfs find --component-count 3 - $nfiles != 15 files"
6570 # Remember non-composite files have a component count of zero
6571 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
6572 [[ $nfiles == 10 ]] ||
6573 error "lfs find --component-count 0 - $nfiles != 10 files"
6575 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
6576 [[ $nfiles == 20 ]] ||
6577 error "lfs find ! --component-count 3 - $nfiles != 20 files"
6579 # All files have a flag called "init"
6580 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
6581 [[ $nfiles == 35 ]] ||
6582 error "lfs find --component-flags init - $nfiles != 35 files"
6584 # Multi-component files will have a component not initialized
6585 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
6586 [[ $nfiles == 15 ]] ||
6587 error "lfs find !--component-flags init - $nfiles != 15 files"
6592 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
6595 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
6596 skip "Need MDS version at least 2.10.57"
6606 # create mirrored directories and mirrored files
6607 mkdir $td || error "mkdir $td failed"
6608 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
6609 createmany -o $tf- 10 || error "create $tf- failed"
6611 for i in $(seq 2); do
6613 mkdir $dir || error "mkdir $dir failed"
6614 $LFS mirror create -N$((3 + i)) $dir ||
6615 error "create mirrored dir $dir failed"
6616 createmany -o $dir/$tfile- 10 ||
6617 error "create $dir/$tfile- failed"
6620 # change the states of some mirrored files
6622 for i in $(seq 2); do
6624 for j in $(seq 4 9); do
6625 echo foo > $dir/$tfile-$j
6629 # find mirrored files with specific mirror count
6630 cmd="$LFS find --mirror-count 3 --type f $td"
6631 nfiles=$($cmd | wc -l)
6632 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
6634 cmd="$LFS find ! --mirror-count 3 --type f $td"
6635 nfiles=$($cmd | wc -l)
6636 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
6638 cmd="$LFS find --mirror-count +2 --type f $td"
6639 nfiles=$($cmd | wc -l)
6640 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6642 cmd="$LFS find --mirror-count -6 --type f $td"
6643 nfiles=$($cmd | wc -l)
6644 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6646 # find mirrored files with specific file state
6647 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
6648 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
6650 cmd="$LFS find --mirror-state=ro --type f $td"
6651 nfiles=$($cmd | wc -l)
6652 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6654 cmd="$LFS find ! --mirror-state=ro --type f $td"
6655 nfiles=$($cmd | wc -l)
6656 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6658 cmd="$LFS find --mirror-state=wp --type f $td"
6659 nfiles=$($cmd | wc -l)
6660 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6662 cmd="$LFS find ! --mirror-state=sp --type f $td"
6663 nfiles=$($cmd | wc -l)
6664 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6666 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6670 # note test will not do anything if MDS is not local
6671 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6672 skip_env "ldiskfs only test"
6674 remote_mds_nodsh && skip "remote MDS with nodsh"
6676 local MNTDEV="osd*.*MDT*.mntdev"
6677 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6678 [ -z "$DEV" ] && error "can't access $MNTDEV"
6679 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6680 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6681 error "can't access $DEV"
6682 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6683 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6687 run_test 57a "verify MDS filesystem created with large inodes =="
6690 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6691 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6692 skip_env "ldiskfs only test"
6694 remote_mds_nodsh && skip "remote MDS with nodsh"
6696 local dir=$DIR/$tdir
6699 local fileN=$dir/f$filecount
6701 rm -rf $dir || error "removing $dir"
6703 local mdtidx=$($LFS getstripe -m $dir)
6704 local mdtname=MDT$(printf %04x $mdtidx)
6705 local facet=mds$((mdtidx + 1))
6707 echo "mcreating $filecount files"
6708 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6710 # verify that files do not have EAs yet
6711 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6712 error "$file1 has an EA"
6713 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6714 error "$fileN has an EA"
6718 df $dir #make sure we get new statfs data
6719 local mdsfree=$(do_facet $facet \
6720 lctl get_param -n osd*.*$mdtname.kbytesfree)
6721 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6724 echo "opening files to create objects/EAs"
6725 for file in $(seq -f $dir/f%g 1 $filecount); do
6726 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6727 error "opening $file"
6730 # verify that files have EAs now
6731 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6732 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6734 sleep 1 #make sure we get new statfs data
6736 local mdsfree2=$(do_facet $facet \
6737 lctl get_param -n osd*.*$mdtname.kbytesfree)
6738 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6740 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6741 if [ "$mdsfree" != "$mdsfree2" ]; then
6742 error "MDC before $mdcfree != after $mdcfree2"
6744 echo "MDC before $mdcfree != after $mdcfree2"
6745 echo "unable to confirm if MDS has large inodes"
6750 run_test 57b "default LOV EAs are stored inside large inodes ==="
6753 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6754 [ -z "$(which wiretest 2>/dev/null)" ] &&
6755 skip_env "could not find wiretest"
6759 run_test 58 "verify cross-platform wire constants =============="
6762 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6764 echo "touch 130 files"
6765 createmany -o $DIR/f59- 130
6767 unlinkmany $DIR/f59- 130
6769 # wait for commitment of removal
6770 wait_delete_completed
6772 run_test 59 "verify cancellation of llog records async ========="
6774 TEST60_HEAD="test_60 run $RANDOM"
6776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6777 remote_mgs_nodsh && skip "remote MGS with nodsh"
6778 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6779 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6780 skip_env "missing subtest run-llog.sh"
6782 log "$TEST60_HEAD - from kernel mode"
6783 do_facet mgs "$LCTL dk > /dev/null"
6784 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6785 do_facet mgs $LCTL dk > $TMP/$tfile
6787 # LU-6388: test llog_reader
6788 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6789 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6790 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6791 skip_env "missing llog_reader"
6792 local fstype=$(facet_fstype mgs)
6793 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6794 skip_env "Only for ldiskfs or zfs type mgs"
6796 local mntpt=$(facet_mntpt mgs)
6797 local mgsdev=$(mgsdevname 1)
6809 #get fid and record list
6810 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6812 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6814 #remount mgs as ldiskfs or zfs type
6815 stop mgs || error "stop mgs failed"
6816 mount_fstype mgs || error "remount mgs failed"
6817 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6820 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6821 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6826 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6828 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6830 echo "obj_file is $obj_file"
6831 do_facet mgs $llog_reader $obj_file
6833 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6834 awk '{ print $3 }' | sed -e "s/^type=//g")
6835 if [ $rec_type != $rec ]; then
6836 echo "FAILED test_60a wrong record type $rec_type," \
6842 #check obj path if record type is LLOG_LOGID_MAGIC
6843 if [ "$rec" == "1064553b" ]; then
6844 path=$(do_facet mgs $llog_reader $obj_file |
6845 grep "path=" | awk '{ print $NF }' |
6846 sed -e "s/^path=//g")
6847 if [ $obj_file != $mntpt/$path ]; then
6848 echo "FAILED test_60a wrong obj path" \
6849 "$montpt/$path, should be $obj_file"
6856 #restart mgs before "error", otherwise it will block the next test
6857 stop mgs || error "stop mgs failed"
6858 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6859 $pass || error "test failed, see FAILED test_60a messages for specifics"
6861 run_test 60a "llog_test run from kernel module and test llog_reader"
6863 test_60b() { # bug 6411
6864 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6867 LLOG_COUNT=$(do_facet mgs dmesg |
6868 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6869 /llog_[a-z]*.c:[0-9]/ {
6881 [[ $LLOG_COUNT -gt 120 ]] &&
6882 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6884 run_test 60b "limit repeated messages from CERROR/CWARN"
6887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6889 echo "create 5000 files"
6890 createmany -o $DIR/f60c- 5000
6891 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6892 lctl set_param fail_loc=0x80000137
6893 unlinkmany $DIR/f60c- 5000
6894 lctl set_param fail_loc=0
6896 run_test 60c "unlink file when mds full"
6899 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6901 SAVEPRINTK=$(lctl get_param -n printk)
6902 # verify "lctl mark" is even working"
6903 MESSAGE="test message ID $RANDOM $$"
6904 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6905 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6907 lctl set_param printk=0 || error "set lnet.printk failed"
6908 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6909 MESSAGE="new test message ID $RANDOM $$"
6910 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6911 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6912 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6914 lctl set_param -n printk="$SAVEPRINTK"
6916 run_test 60d "test printk console message masking"
6919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6920 remote_mds_nodsh && skip "remote MDS with nodsh"
6923 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6924 do_facet mds1 lctl set_param fail_loc=0x15b
6927 run_test 60e "no space while new llog is being created"
6932 test_mkdir -c $MDSCOUNT $DIR/$tdir
6933 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir
6938 mkdir $DIR/$tdir/subdir$index 2>/dev/null
6939 rmdir $DIR/$tdir/subdir$index 2>/dev/null
6940 index=$((index + 1))
6946 for i in $(seq 100); do
6947 # define OBD_FAIL_OSD_TXN_START 0x19a
6948 do_facet mds1 lctl set_param fail_loc=0x8000019a
6954 mkdir $DIR/$tdir/new || error "mkdir failed"
6955 rmdir $DIR/$tdir/new || error "rmdir failed"
6957 run_test 60g "transaction abort won't cause MDT hung"
6960 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
6961 skip "Need MDS version at least 2.12.52"
6962 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
6966 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
6967 #define OBD_FAIL_MDS_STRIPE_FID 0x189
6968 for fail_loc in 0x80000188 0x80000189; do
6969 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
6970 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
6971 error "mkdir $dir-$fail_loc failed"
6972 for i in {0..10}; do
6973 # create may fail on missing stripe
6974 echo $i > $DIR/$tdir-$fail_loc/$i
6976 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6977 error "getdirstripe $tdir-$fail_loc failed"
6978 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
6979 error "migrate $tdir-$fail_loc failed"
6980 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6981 error "getdirstripe $tdir-$fail_loc failed"
6982 pushd $DIR/$tdir-$fail_loc
6984 echo $f | cmp $f - || error "$f data mismatch"
6987 rm -rf $DIR/$tdir-$fail_loc
6990 run_test 60h "striped directory with missing stripes can be accessed"
6993 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6996 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
6997 cancel_lru_locks osc
6998 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
7001 run_test 61a "mmap() writes don't make sync hang ================"
7004 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
7006 run_test 61b "mmap() of unstriped file is successful"
7008 # bug 2330 - insufficient obd_match error checking causes LBUG
7010 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7014 cancel_lru_locks osc
7015 lctl set_param fail_loc=0x405
7016 cat $f && error "cat succeeded, expect -EIO"
7017 lctl set_param fail_loc=0
7019 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
7020 # match every page all of the time.
7021 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
7023 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
7024 # Though this test is irrelevant anymore, it helped to reveal some
7025 # other grant bugs (LU-4482), let's keep it.
7026 test_63a() { # was test_63
7027 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7029 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
7031 for i in `seq 10` ; do
7032 dd if=/dev/zero of=$DIR/f63 bs=8k &
7038 rm -f $DIR/f63 || true
7040 run_test 63a "Verify oig_wait interruption does not crash ======="
7042 # bug 2248 - async write errors didn't return to application on sync
7043 # bug 3677 - async write errors left page locked
7045 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7048 lctl set_param debug=-1
7050 # ensure we have a grant to do async writes
7051 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
7054 sync # sync lest earlier test intercept the fail_loc
7056 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7057 lctl set_param fail_loc=0x80000406
7058 $MULTIOP $DIR/$tfile Owy && \
7059 error "sync didn't return ENOMEM"
7060 sync; sleep 2; sync # do a real sync this time to flush page
7061 lctl get_param -n llite.*.dump_page_cache | grep locked && \
7062 error "locked page left in cache after async error" || true
7065 run_test 63b "async write errors should be returned to fsync ==="
7068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7071 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
7073 run_test 64a "verify filter grant calculations (in kernel) ====="
7076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7078 sh oos.sh $MOUNT || error "oos.sh failed: $?"
7080 run_test 64b "check out-of-space detection on client"
7083 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
7085 run_test 64c "verify grant shrink"
7087 # this does exactly what osc_request.c:osc_announce_cached() does in
7088 # order to calculate max amount of grants to ask from server
7092 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
7093 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
7095 ((rpc_in_flight ++));
7096 nrpages=$((nrpages * rpc_in_flight))
7098 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
7100 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
7102 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
7103 local undirty=$((nrpages * PAGE_SIZE))
7105 local max_extent_pages
7106 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
7107 grep grant_max_extent_size | awk '{print $2}')
7108 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
7109 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
7110 local grant_extent_tax
7111 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7112 grep grant_extent_tax | awk '{print $2}')
7114 undirty=$((undirty + nrextents * grant_extent_tax))
7119 # this is size of unit for grant allocation. It should be equal to
7120 # what tgt_grant.c:tgt_grant_chunk() calculates
7124 local grant_extent_tax
7126 max_brw_size=$($LCTL get_param osc.${tgt}.import |
7127 grep max_brw_size | awk '{print $2}')
7129 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7130 grep grant_extent_tax | awk '{print $2}')
7132 echo $(((max_brw_size + grant_extent_tax) * 2))
7136 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
7137 skip "OST < 2.10.55 doesn't limit grants enough"
7139 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
7140 local file=$DIR/$tfile
7142 [[ $($LCTL get_param osc.${tgt}.import |
7143 grep "connect_flags:.*grant_param") ]] ||
7144 skip "no grant_param connect flag"
7146 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
7148 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
7150 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7151 stack_trap "rm -f $file" EXIT
7153 $LFS setstripe $file -i 0 -c 1
7154 dd if=/dev/zero of=$file bs=1M count=1000 &
7159 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
7160 if [[ $cur_grant -gt $max_cur_granted ]]
7163 error "cur_grant $cur_grant > $max_cur_granted"
7166 [[ $? -ne 0 ]] && break;
7171 wait_delete_completed
7172 $LCTL set_param debug="$olddebug" 2> /dev/null || true
7174 run_test 64d "check grant limit exceed"
7176 # bug 1414 - set/get directories' stripe info
7178 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7180 test_mkdir $DIR/$tdir
7182 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7184 run_test 65a "directory with no stripe info"
7187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7189 test_mkdir $DIR/$tdir
7190 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7192 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7195 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7197 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7201 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7203 test_mkdir $DIR/$tdir
7204 local stripesize=$($LFS getstripe -S $DIR/$tdir)
7206 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7207 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7209 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7211 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7214 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7216 test_mkdir $DIR/$tdir
7217 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
7218 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7220 if [[ $STRIPECOUNT -le 0 ]]; then
7222 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
7223 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
7224 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
7226 sc=$(($STRIPECOUNT - 1))
7228 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7229 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7230 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7231 error "lverify failed"
7233 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7236 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7238 test_mkdir $DIR/$tdir
7240 $LFS setstripe $DIR/$tdir || error "setstripe"
7241 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7242 error "no stripe info failed"
7244 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
7246 run_test 65e "directory setstripe defaults"
7249 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7251 test_mkdir $DIR/${tdir}f
7252 $RUNAS $LFS setstripe $DIR/${tdir}f &&
7253 error "setstripe succeeded" || true
7255 run_test 65f "dir setstripe permission (should return error) ==="
7258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7260 test_mkdir $DIR/$tdir
7261 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7263 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7264 error "setstripe -S failed"
7265 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7266 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7267 error "delete default stripe failed"
7269 run_test 65g "directory setstripe -d"
7272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7274 test_mkdir $DIR/$tdir
7275 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7277 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7278 error "setstripe -S failed"
7279 test_mkdir $DIR/$tdir/dd1
7280 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
7281 error "stripe info inherit failed"
7283 run_test 65h "directory stripe info inherit ===================="
7286 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7288 save_layout_restore_at_exit $MOUNT
7290 # bug6367: set non-default striping on root directory
7291 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7293 # bug12836: getstripe on -1 default directory striping
7294 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7296 # bug12836: getstripe -v on -1 default directory striping
7297 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7299 # bug12836: new find on -1 default directory striping
7300 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7302 run_test 65i "various tests to set root directory striping"
7304 test_65j() { # bug6367
7305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7309 # if we aren't already remounting for each test, do so for this test
7310 if [ "$I_MOUNTED" = "yes" ]; then
7311 cleanup || error "failed to unmount"
7315 save_layout_restore_at_exit $MOUNT
7317 $LFS setstripe -d $MOUNT || error "setstripe failed"
7319 run_test 65j "set default striping on root directory (bug 6367)="
7323 wait_delete_completed
7324 do_facet $SINGLEMDS "lctl set_param -n \
7325 osp.$ost*MDT0000.max_create_count=$max_count"
7326 do_facet $SINGLEMDS "lctl set_param -n \
7327 osp.$ost*MDT0000.create_count=$count"
7328 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7329 echo $INACTIVE_OSC "is Activate"
7331 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7334 test_65k() { # bug11679
7335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7336 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7337 remote_mds_nodsh && skip "remote MDS with nodsh"
7339 local disable_precreate=true
7340 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7341 disable_precreate=false
7343 echo "Check OST status: "
7344 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7345 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7347 for OSC in $MDS_OSCS; do
7348 echo $OSC "is active"
7349 do_facet $SINGLEMDS lctl --device %$OSC activate
7352 for INACTIVE_OSC in $MDS_OSCS; do
7353 local ost=$(osc_to_ost $INACTIVE_OSC)
7354 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7355 lov.*md*.target_obd |
7356 awk -F: /$ost/'{ print $1 }' | head -n 1)
7359 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
7360 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7362 echo "Deactivate: " $INACTIVE_OSC
7363 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7365 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7366 osp.$ost*MDT0000.create_count")
7367 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7368 osp.$ost*MDT0000.max_create_count")
7369 $disable_precreate &&
7370 do_facet $SINGLEMDS "lctl set_param -n \
7371 osp.$ost*MDT0000.max_create_count=0"
7373 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7374 [ -f $DIR/$tdir/$idx ] && continue
7375 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
7376 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
7378 error "setstripe $idx should succeed"; }
7379 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7381 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7384 do_facet $SINGLEMDS "lctl set_param -n \
7385 osp.$ost*MDT0000.max_create_count=$max_count"
7386 do_facet $SINGLEMDS "lctl set_param -n \
7387 osp.$ost*MDT0000.create_count=$count"
7388 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7389 echo $INACTIVE_OSC "is Activate"
7391 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7394 run_test 65k "validate manual striping works properly with deactivated OSCs"
7396 test_65l() { # bug 12836
7397 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7399 test_mkdir -p $DIR/$tdir/test_dir
7400 $LFS setstripe -c -1 $DIR/$tdir/test_dir
7401 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7403 run_test 65l "lfs find on -1 stripe dir ========================"
7406 local layout=$(save_layout $MOUNT)
7407 $RUNAS $LFS setstripe -c 2 $MOUNT && {
7408 restore_layout $MOUNT $layout
7409 error "setstripe should fail by non-root users"
7413 run_test 65m "normal user can't set filesystem default stripe"
7416 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
7417 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.50) ]] ||
7418 skip "Need MDS version at least 2.12.50"
7419 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7421 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7422 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7423 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7425 local root_layout=$(save_layout $MOUNT)
7426 stack_trap "restore_layout $MOUNT $root_layout" EXIT
7428 # new subdirectory under root directory should not inherit
7429 # the default layout from root
7430 local dir1=$MOUNT/$tdir-1
7431 mkdir $dir1 || error "mkdir $dir1 failed"
7432 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7433 error "$dir1 shouldn't have LOV EA"
7435 # delete the default layout on root directory
7436 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7438 local dir2=$MOUNT/$tdir-2
7439 mkdir $dir2 || error "mkdir $dir2 failed"
7440 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7441 error "$dir2 shouldn't have LOV EA"
7443 # set a new striping pattern on root directory
7444 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7445 local new_def_stripe_size=$((def_stripe_size * 2))
7446 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7447 error "set stripe size on $MOUNT failed"
7449 # new file created in $dir2 should inherit the new stripe size from
7450 # the filesystem default
7451 local file2=$dir2/$tfile-2
7452 touch $file2 || error "touch $file2 failed"
7454 local file2_stripe_size=$($LFS getstripe -S $file2)
7455 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
7456 error "$file2 didn't inherit stripe size $new_def_stripe_size"
7458 local dir3=$MOUNT/$tdir-3
7459 mkdir $dir3 || error "mkdir $dir3 failed"
7460 ! getfattr -n trusted.lov $dir3 &> /dev/null ||
7461 error "$dir3 shouldn't have LOV EA"
7463 # set OST pool on root directory
7464 local pool=$TESTNAME
7465 pool_add $pool || error "add $pool failed"
7466 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
7467 error "add targets to $pool failed"
7469 $LFS setstripe -p $pool $MOUNT ||
7470 error "set OST pool on $MOUNT failed"
7472 # new file created in $dir3 should inherit the pool from
7473 # the filesystem default
7474 local file3=$dir3/$tfile-3
7475 touch $file3 || error "touch $file3 failed"
7477 local file3_pool=$($LFS getstripe -p $file3)
7478 [[ "$file3_pool" = "$pool" ]] ||
7479 error "$file3 didn't inherit OST pool $pool"
7481 local dir4=$MOUNT/$tdir-4
7482 mkdir $dir4 || error "mkdir $dir4 failed"
7483 ! getfattr -n trusted.lov $dir4 &> /dev/null ||
7484 error "$dir4 shouldn't have LOV EA"
7486 # new file created in $dir4 should inherit the pool from
7487 # the filesystem default
7488 local file4=$dir4/$tfile-4
7489 touch $file4 || error "touch $file4 failed"
7491 local file4_pool=$($LFS getstripe -p $file4)
7492 [[ "$file4_pool" = "$pool" ]] ||
7493 error "$file4 didn't inherit OST pool $pool"
7495 # new subdirectory under non-root directory should inherit
7496 # the default layout from its parent directory
7497 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
7498 error "set directory layout on $dir4 failed"
7500 local dir5=$dir4/$tdir-5
7501 mkdir $dir5 || error "mkdir $dir5 failed"
7503 local dir4_layout=$(get_layout_param $dir4)
7504 local dir5_layout=$(get_layout_param $dir5)
7505 [[ "$dir4_layout" = "$dir5_layout" ]] ||
7506 error "$dir5 should inherit the default layout from $dir4"
7508 run_test 65n "don't inherit default layout from root for new subdirectories"
7510 # bug 2543 - update blocks count on client
7512 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7515 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
7516 sync; sync_all_data; sync; sync_all_data
7517 cancel_lru_locks osc
7518 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
7519 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
7521 run_test 66 "update inode blocks count on client ==============="
7524 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
7528 swapon -s | awk '($1 == "'$1'") { print $4 }'
7531 # bug5265, obdfilter oa2dentry return -ENOENT
7532 # #define OBD_FAIL_SRV_ENOENT 0x217
7534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7535 remote_ost_nodsh && skip "remote OST with nodsh"
7538 $LFS setstripe -c 1 -i 0 $f
7540 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
7542 do_facet ost1 lctl set_param fail_loc=0x217
7543 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
7544 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
7546 do_facet ost1 lctl set_param fail_loc=0
7547 $DIRECTIO write $f 0 2 || error "write error"
7549 cancel_lru_locks osc
7550 $DIRECTIO read $f 0 1 || error "read error"
7552 do_facet ost1 lctl set_param fail_loc=0x217
7553 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
7555 do_facet ost1 lctl set_param fail_loc=0
7558 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
7561 test_mkdir $DIR/$tdir
7562 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
7563 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
7565 run_test 71 "Running dbench on lustre (don't segment fault) ===="
7567 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
7568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7569 [ "$RUNAS_ID" = "$UID" ] &&
7570 skip_env "RUNAS_ID = UID = $UID -- skipping"
7571 # Check that testing environment is properly set up. Skip if not
7572 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
7573 skip_env "User $RUNAS_ID does not exist - skipping"
7576 chmod 777 $DIR/$tfile
7577 chmod ug+s $DIR/$tfile
7578 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
7579 error "$RUNAS dd $DIR/$tfile failed"
7580 # See if we are still setuid/sgid
7581 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
7582 error "S/gid is not dropped on write"
7583 # Now test that MDS is updated too
7584 cancel_lru_locks mdc
7585 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
7586 error "S/gid is not dropped on MDS"
7589 run_test 72a "Test that remove suid works properly (bug5695) ===="
7591 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7594 [ "$RUNAS_ID" = "$UID" ] &&
7595 skip_env "RUNAS_ID = UID = $UID -- skipping"
7596 [ "$RUNAS_ID" -eq 0 ] &&
7597 skip_env "RUNAS_ID = 0 -- skipping"
7598 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7599 # Check that testing environment is properly set up. Skip if not
7600 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7601 skip_env "User $RUNAS_ID does not exist - skipping"
7603 touch $DIR/${tfile}-f{g,u}
7604 test_mkdir $DIR/${tfile}-dg
7605 test_mkdir $DIR/${tfile}-du
7606 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7607 chmod g+s $DIR/${tfile}-{f,d}g
7608 chmod u+s $DIR/${tfile}-{f,d}u
7609 for perm in 777 2777 4777; do
7610 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7611 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7612 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7613 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7617 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7619 # bug 3462 - multiple simultaneous MDC requests
7621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7623 test_mkdir $DIR/d73-1
7624 test_mkdir $DIR/d73-2
7625 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7628 lctl set_param fail_loc=0x80000129
7629 $MULTIOP $DIR/d73-1/f73-2 Oc &
7631 lctl set_param fail_loc=0
7633 $MULTIOP $DIR/d73-2/f73-3 Oc &
7637 wait $pid1 || return 1
7641 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
7642 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
7643 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
7647 run_test 73 "multiple MDC requests (should not deadlock)"
7649 test_74a() { # bug 6149, 6184
7650 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7653 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7655 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7656 # will spin in a tight reconnection loop
7657 $LCTL set_param fail_loc=0x8000030e
7658 # get any lock that won't be difficult - lookup works.
7660 $LCTL set_param fail_loc=0
7664 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
7666 test_74b() { # bug 13310
7667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7669 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7671 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7672 # will spin in a tight reconnection loop
7673 $LCTL set_param fail_loc=0x8000030e
7674 # get a "difficult" lock
7676 $LCTL set_param fail_loc=0
7680 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
7683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7685 #define OBD_FAIL_LDLM_NEW_LOCK
7686 $LCTL set_param fail_loc=0x319
7687 touch $DIR/$tfile && error "touch successful"
7688 $LCTL set_param fail_loc=0
7691 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
7694 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
7697 test_76() { # Now for bug 20433, added originally in bug 1443
7698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7700 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
7702 cancel_lru_locks osc
7703 BEFORE_INODES=$(num_inodes)
7704 echo "before inodes: $BEFORE_INODES"
7706 [ "$SLOW" = "no" ] && COUNT=100
7707 for i in $(seq $COUNT); do
7711 cancel_lru_locks osc
7712 AFTER_INODES=$(num_inodes)
7713 echo "after inodes: $AFTER_INODES"
7715 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
7717 AFTER_INODES=$(num_inodes)
7719 echo "wait $wait seconds inodes: $AFTER_INODES"
7720 if [ $wait -gt 30 ]; then
7721 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
7725 run_test 76 "confirm clients recycle inodes properly ===="
7731 # Note: in sptlrpc modes which enable its own bulk checksum, the
7732 # original crc32_le bulk checksum will be automatically disabled,
7733 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
7734 # will be checked by sptlrpc code against sptlrpc bulk checksum.
7735 # In this case set_checksums() will not be no-op, because sptlrpc
7736 # bulk checksum will be enabled all through the test.
7738 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
7739 lctl set_param -n osc.*.checksums $1
7743 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7744 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
7745 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7746 tr -d [] | head -n1)}
7749 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
7751 log "set checksum type to $1, rc = $rc"
7755 get_osc_checksum_type()
7757 # arugment 1: OST name, like OST0000
7759 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
7760 sed 's/.*\[\(.*\)\].*/\1/g')
7762 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
7766 F77_TMP=$TMP/f77-temp
7769 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
7770 error "error writing to $F77_TMP"
7773 test_77a() { # bug 10889
7774 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7775 $GSS && skip_env "could not run with gss"
7777 [ ! -f $F77_TMP ] && setup_f77
7779 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
7783 run_test 77a "normal checksum read/write operation"
7785 test_77b() { # bug 10889
7786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7787 $GSS && skip_env "could not run with gss"
7789 [ ! -f $F77_TMP ] && setup_f77
7790 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7791 $LCTL set_param fail_loc=0x80000409
7794 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7795 error "dd error: $?"
7796 $LCTL set_param fail_loc=0
7798 for algo in $CKSUM_TYPES; do
7799 cancel_lru_locks osc
7800 set_checksum_type $algo
7801 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7802 $LCTL set_param fail_loc=0x80000408
7803 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7804 $LCTL set_param fail_loc=0
7807 set_checksum_type $ORIG_CSUM_TYPE
7810 run_test 77b "checksum error on client write, read"
7815 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7817 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7818 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7819 $check_ost && [ -n "$ost_file_prefix" ] &&
7820 do_facet ost1 rm -f ${ost_file_prefix}\*
7824 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7825 $GSS && skip_env "could not run with gss"
7826 remote_ost_nodsh && skip "remote OST with nodsh"
7829 local osc_file_prefix
7831 local check_ost=false
7832 local ost_file_prefix
7838 # ensure corruption will occur on first OSS/OST
7839 $LFS setstripe -i 0 $DIR/$tfile
7841 [ ! -f $F77_TMP ] && setup_f77
7842 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7843 error "dd write error: $?"
7844 fid=$($LFS path2fid $DIR/$tfile)
7846 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
7849 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7850 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7852 echo "OSS do not support bulk pages dump upon error"
7855 osc_file_prefix=$($LCTL get_param -n debug_path)
7856 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7858 trap cleanup_77c EXIT
7861 # enable bulk pages dump upon error on Client
7862 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7863 # enable bulk pages dump upon error on OSS
7865 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7867 # flush Client cache to allow next read to reach OSS
7868 cancel_lru_locks osc
7870 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7871 $LCTL set_param fail_loc=0x80000408
7872 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7873 $LCTL set_param fail_loc=0
7877 # check cksum dump on Client
7878 osc_file=$(ls ${osc_file_prefix}*)
7879 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7880 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7881 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7882 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7883 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7885 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7886 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7887 error "dump content does not match on Client"
7889 $check_ost || skip "No need to check cksum dump on OSS"
7891 # check cksum dump on OSS
7892 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7893 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7894 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7895 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7896 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7897 error "dump content does not match on OSS"
7901 run_test 77c "checksum error on client read with debug"
7903 test_77d() { # bug 10889
7904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7905 $GSS && skip_env "could not run with gss"
7907 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7908 $LCTL set_param fail_loc=0x80000409
7910 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7911 error "direct write: rc=$?"
7912 $LCTL set_param fail_loc=0
7915 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7916 $LCTL set_param fail_loc=0x80000408
7918 cancel_lru_locks osc
7919 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7920 error "direct read: rc=$?"
7921 $LCTL set_param fail_loc=0
7924 run_test 77d "checksum error on OST direct write, read"
7926 test_77f() { # bug 10889
7927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7928 $GSS && skip_env "could not run with gss"
7931 for algo in $CKSUM_TYPES; do
7932 cancel_lru_locks osc
7933 set_checksum_type $algo
7934 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7935 $LCTL set_param fail_loc=0x409
7936 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
7937 error "direct write succeeded"
7938 $LCTL set_param fail_loc=0
7940 set_checksum_type $ORIG_CSUM_TYPE
7943 run_test 77f "repeat checksum error on write (expect error)"
7945 test_77g() { # bug 10889
7946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7947 $GSS && skip_env "could not run with gss"
7948 remote_ost_nodsh && skip "remote OST with nodsh"
7950 [ ! -f $F77_TMP ] && setup_f77
7952 local file=$DIR/$tfile
7953 stack_trap "rm -f $file" EXIT
7955 $LFS setstripe -c 1 -i 0 $file
7956 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
7957 do_facet ost1 lctl set_param fail_loc=0x8000021a
7959 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
7960 error "write error: rc=$?"
7961 do_facet ost1 lctl set_param fail_loc=0
7964 cancel_lru_locks osc
7965 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
7966 do_facet ost1 lctl set_param fail_loc=0x8000021b
7968 cmp $F77_TMP $file || error "file compare failed"
7969 do_facet ost1 lctl set_param fail_loc=0
7972 run_test 77g "checksum error on OST write, read"
7974 test_77k() { # LU-10906
7975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7976 $GSS && skip_env "could not run with gss"
7978 local cksum_param="osc.$FSNAME*.checksums"
7979 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
7983 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
7984 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
7985 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
7989 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
7990 error "failed to set checksum=$i on MGS"
7991 wait_update $HOSTNAME "$get_checksum" $i
7993 echo "remount client, checksum should be $i"
7994 remount_client $MOUNT || "failed to remount client"
7995 checksum=$(eval $get_checksum)
7996 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7998 # remove persistent param to avoid races with checksum mountopt below
7999 do_facet mgs $LCTL set_param -P -d $cksum_param ||
8000 error "failed to delete checksum on MGS"
8002 for opt in "checksum" "nochecksum"; do
8003 #remount with mount option
8004 echo "remount client with option $opt, checksum should be $i"
8005 umount_client $MOUNT || "failed to umount client"
8006 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8007 "failed to mount client with option '$opt'"
8008 checksum=$(eval $get_checksum)
8009 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8013 remount_client $MOUNT || "failed to remount client"
8015 run_test 77k "enable/disable checksum correctly"
8018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8019 $GSS && skip_env "could not run with gss"
8022 stack_trap "set_checksums $ORIG_CSUM" EXIT
8023 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
8025 set_checksum_type invalid && error "unexpected success of invalid checksum type"
8027 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8028 for algo in $CKSUM_TYPES; do
8029 set_checksum_type $algo || error "fail to set checksum type $algo"
8030 osc_algo=$(get_osc_checksum_type OST0000)
8031 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
8033 # no locks, no reqs to let the connection idle
8034 cancel_lru_locks osc
8035 lru_resize_disable osc
8036 wait_osc_import_state client ost1 IDLE
8038 # ensure ost1 is connected
8039 stat $DIR/$tfile >/dev/null || error "can't stat"
8040 wait_osc_import_state client ost1 FULL
8042 osc_algo=$(get_osc_checksum_type OST0000)
8043 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
8047 run_test 77l "preferred checksum type is remembered after reconnected"
8049 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8058 test_78() { # bug 10901
8059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8060 remote_ost || skip_env "local OST"
8063 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8064 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8065 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8066 echo "MemTotal: $MEMTOTAL"
8068 # reserve 256MB of memory for the kernel and other running processes,
8069 # and then take 1/2 of the remaining memory for the read/write buffers.
8070 if [ $MEMTOTAL -gt 512 ] ;then
8071 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8073 # for those poor memory-starved high-end clusters...
8074 MEMTOTAL=$((MEMTOTAL / 2))
8076 echo "Mem to use for directio: $MEMTOTAL"
8078 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8079 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8080 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8081 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8083 echo "Smallest OST: $SMALLESTOST"
8084 [[ $SMALLESTOST -lt 10240 ]] &&
8085 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8087 trap cleanup_test_78 EXIT
8089 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8090 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8092 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8093 echo "File size: $F78SIZE"
8094 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8095 for i in $(seq 1 $NSEQ); do
8096 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8097 echo directIO rdwr round $i of $NSEQ
8098 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8103 run_test 78 "handle large O_DIRECT writes correctly ============"
8105 test_79() { # bug 12743
8106 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8108 wait_delete_completed
8110 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8111 BKFREE=$(calc_osc_kbytes kbytesfree)
8112 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8114 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8115 DFTOTAL=`echo $STRING | cut -d, -f1`
8116 DFUSED=`echo $STRING | cut -d, -f2`
8117 DFAVAIL=`echo $STRING | cut -d, -f3`
8118 DFFREE=$(($DFTOTAL - $DFUSED))
8120 ALLOWANCE=$((64 * $OSTCOUNT))
8122 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8123 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8124 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8126 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8127 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8128 error "df free($DFFREE) mismatch OST free($BKFREE)"
8130 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8131 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8132 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8135 run_test 79 "df report consistency check ======================="
8137 test_80() { # bug 10718
8138 remote_ost_nodsh && skip "remote OST with nodsh"
8139 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8141 # relax strong synchronous semantics for slow backends like ZFS
8142 local soc="obdfilter.*.sync_on_lock_cancel"
8143 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
8145 if [ "$soc_old" != "never" ] &&
8146 [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8147 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
8148 facet_active_host $host; done | sort -u)
8149 do_nodes $hosts lctl set_param $soc=never
8152 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
8154 local BEFORE=`date +%s`
8155 cancel_lru_locks osc
8156 local AFTER=`date +%s`
8157 local DIFF=$((AFTER-BEFORE))
8158 if [ $DIFF -gt 1 ] ; then
8159 error "elapsed for 1M@1T = $DIFF"
8162 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
8166 run_test 80 "Page eviction is equally fast at high offsets too ===="
8168 test_81a() { # LU-456
8169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8170 remote_ost_nodsh && skip "remote OST with nodsh"
8172 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8173 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8174 do_facet ost1 lctl set_param fail_loc=0x80000228
8176 # write should trigger a retry and success
8177 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8178 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8180 if [ $RC -ne 0 ] ; then
8181 error "write should success, but failed for $RC"
8184 run_test 81a "OST should retry write when get -ENOSPC ==============="
8186 test_81b() { # LU-456
8187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8188 remote_ost_nodsh && skip "remote OST with nodsh"
8190 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8191 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8192 do_facet ost1 lctl set_param fail_loc=0x228
8194 # write should retry several times and return -ENOSPC finally
8195 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8196 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8199 if [ $RC -ne $ENOSPC ] ; then
8200 error "dd should fail for -ENOSPC, but succeed."
8203 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8205 test_82() { # LU-1031
8206 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
8210 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
8212 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
8214 kill -USR1 $MULTIPID2
8216 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
8217 error "First grouplock does not block second one"
8219 echo "Second grouplock blocks first one"
8221 kill -USR1 $MULTIPID1
8225 run_test 82 "Basic grouplock test"
8228 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
8230 test_mkdir $DIR/$tdir.cvsroot
8231 chown $RUNAS_ID $DIR/$tdir.cvsroot
8234 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
8237 # some versions of cvs import exit(1) when asked to import links or
8238 # files they can't read. ignore those files.
8239 local toignore=$(find . -type l -printf '-I %f\n' -o \
8240 ! -perm /4 -printf '-I %f\n')
8241 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
8242 $tdir.reposname vtag rtag
8245 test_mkdir $DIR/$tdir.reposname
8246 chown $RUNAS_ID $DIR/$tdir.reposname
8247 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
8249 cd $DIR/$tdir.reposname
8251 $RUNAS cvs add -m 'addmsg' foo99
8253 $RUNAS cvs commit -m 'nomsg' foo99
8254 rm -fr $DIR/$tdir.cvsroot
8256 run_test 99 "cvs strange file/directory operations"
8259 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8260 [[ "$NETTYPE" =~ tcp ]] ||
8261 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
8262 remote_ost_nodsh && skip "remote OST with nodsh"
8263 remote_mds_nodsh && skip "remote MDS with nodsh"
8265 skip "useless for local single node setup"
8267 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
8268 [ "$PROT" != "tcp" ] && continue
8269 RPORT=$(echo $REMOTE | cut -d: -f2)
8270 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
8273 LPORT=`echo $LOCAL | cut -d: -f2`
8274 if [ $LPORT -ge 1024 ]; then
8275 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
8277 error_exit "local: $LPORT > 1024, remote: $RPORT"
8280 [ "$rc" = 0 ] || error_exit "privileged port not found" )
8282 run_test 100 "check local port using privileged port ==========="
8284 function get_named_value()
8293 echo $line | sed "s/^$tag[ ]*//"
8300 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
8301 awk '/^max_cached_mb/ { print $2 }')
8304 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
8309 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8310 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
8315 local cache_limit=32
8317 $LCTL set_param -n osc.*-osc*.rpc_stats 0
8318 trap cleanup_101a EXIT
8319 $LCTL set_param -n llite.*.read_ahead_stats 0
8320 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
8323 # randomly read 10000 of 64K chunks from file 3x 32MB in size
8325 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
8326 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
8329 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
8330 get_named_value 'read but discarded' | cut -d" " -f1); do
8331 discard=$(($discard + $s))
8335 if [[ $(($discard * 10)) -gt $nreads ]]; then
8336 $LCTL get_param osc.*-osc*.rpc_stats
8337 $LCTL get_param llite.*.read_ahead_stats
8338 error "too many ($discard) discarded pages"
8340 rm -f $DIR/$tfile || true
8342 run_test 101a "check read-ahead for random reads"
8345 test_mkdir $DIR/$tdir
8347 local FILE_LENGTH=$2
8350 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
8352 local list=$(comma_list $(osts_nodes))
8353 set_osd_param $list '' read_cache_enable 0
8354 set_osd_param $list '' writethrough_cache_enable 0
8356 trap cleanup_test101bc EXIT
8357 # prepare the read-ahead file
8358 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8360 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
8361 count=$FILE_SIZE_MB 2> /dev/null
8365 cleanup_test101bc() {
8370 local list=$(comma_list $(osts_nodes))
8371 set_osd_param $list '' read_cache_enable 1
8372 set_osd_param $list '' writethrough_cache_enable 1
8376 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8381 local STRIPE_SIZE=$2
8382 local FILE_LENGTH=$3
8383 local RA_INC=1048576
8384 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8385 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8386 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8387 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8388 get_named_value 'read but discarded' |
8389 cut -d" " -f1 | calc_total)
8390 if [[ $DISCARD -gt $discard_limit ]]; then
8391 $LCTL get_param llite.*.read_ahead_stats
8392 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8394 echo "Read-ahead success for size ${READ_SIZE}"
8399 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8400 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8402 local STRIPE_SIZE=1048576
8403 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8405 if [ $SLOW == "yes" ]; then
8406 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8408 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8411 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8413 # prepare the read-ahead file
8414 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8415 cancel_lru_locks osc
8416 for BIDX in 2 4 8 16 32 64 128 256
8418 local BSIZE=$((BIDX*4096))
8419 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
8420 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
8421 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
8422 $LCTL set_param -n llite.*.read_ahead_stats 0
8423 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
8424 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
8425 cancel_lru_locks osc
8426 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
8431 run_test 101b "check stride-io mode read-ahead ================="
8434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8436 local STRIPE_SIZE=1048576
8437 local FILE_LENGTH=$((STRIPE_SIZE*100))
8442 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8444 cancel_lru_locks osc
8445 $LCTL set_param osc.*.rpc_stats 0
8446 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
8447 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
8448 local stats=$($LCTL get_param -n $osc_rpc_stats)
8449 local lines=$(echo "$stats" | awk 'END {print NR;}')
8452 if [ $lines -le 20 ]; then
8455 for size in 1 2 4 8; do
8456 local rpc=$(echo "$stats" |
8457 awk '($1 == "'$size':") {print $2; exit; }')
8458 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
8459 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
8461 echo "$osc_rpc_stats check passed!"
8466 run_test 101c "check stripe_size aligned read-ahead ================="
8469 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
8470 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
8474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8476 local file=$DIR/$tfile
8477 local sz_MB=${FILESIZE_101d:-500}
8478 local ra_MB=${READAHEAD_MB:-40}
8480 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
8481 [ $free_MB -lt $sz_MB ] &&
8482 skip "Need free space ${sz_MB}M, have ${free_MB}M"
8484 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
8485 $LFS setstripe -c -1 $file || error "setstripe failed"
8487 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
8488 echo Cancel LRU locks on lustre client to flush the client cache
8489 cancel_lru_locks osc
8491 echo Disable read-ahead
8492 local old_READAHEAD=$(set_read_ahead 0)
8494 echo Reading the test file $file with read-ahead disabled
8495 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8497 echo Cancel LRU locks on lustre client to flush the client cache
8498 cancel_lru_locks osc
8499 echo Enable read-ahead with ${ra_MB}MB
8500 set_read_ahead $ra_MB
8502 echo Reading the test file $file with read-ahead enabled
8503 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8505 echo "read-ahead disabled time read $raOFF"
8506 echo "read-ahead enabled time read $raON"
8508 set_read_ahead $old_READAHEAD
8510 wait_delete_completed
8512 [ $raOFF -le 1 ] || [ $raON -lt $raOFF ] ||
8513 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
8515 run_test 101d "file read with and without read-ahead enabled"
8518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8520 local file=$DIR/$tfile
8521 local size_KB=500 #KB
8525 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
8526 local need_KB=$((count * size_KB))
8527 [[ $free_KB -le $need_KB ]] &&
8528 skip_env "Need free space $need_KB, have $free_KB"
8530 echo "Creating $count ${size_KB}K test files"
8531 for ((i = 0; i < $count; i++)); do
8532 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
8535 echo "Cancel LRU locks on lustre client to flush the client cache"
8536 cancel_lru_locks $OSC
8538 echo "Reset readahead stats"
8539 $LCTL set_param -n llite.*.read_ahead_stats 0
8541 for ((i = 0; i < $count; i++)); do
8542 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
8545 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8546 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8548 for ((i = 0; i < $count; i++)); do
8549 rm -rf $file.$i 2>/dev/null
8552 #10000 means 20% reads are missing in readahead
8553 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
8555 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
8558 which iozone || skip_env "no iozone installed"
8560 local old_debug=$($LCTL get_param debug)
8561 old_debug=${old_debug#*=}
8562 $LCTL set_param debug="reada mmap"
8564 # create a test file
8565 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
8567 echo Cancel LRU locks on lustre client to flush the client cache
8568 cancel_lru_locks osc
8570 echo Reset readahead stats
8571 $LCTL set_param -n llite.*.read_ahead_stats 0
8573 echo mmap read the file with small block size
8574 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
8577 echo checking missing pages
8578 $LCTL get_param llite.*.read_ahead_stats
8579 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8580 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8582 $LCTL set_param debug="$old_debug"
8583 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
8586 run_test 101f "check mmap read performance"
8588 test_101g_brw_size_test() {
8590 local pages=$((mb * 1048576 / PAGE_SIZE))
8591 local file=$DIR/$tfile
8593 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
8594 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
8595 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
8596 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
8600 stack_trap "rm -f $file" EXIT
8601 $LCTL set_param -n osc.*.rpc_stats=0
8603 # 10 RPCs should be enough for the test
8605 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
8606 { error "dd write ${mb} MB blocks failed"; return 3; }
8607 cancel_lru_locks osc
8608 dd of=/dev/null if=$file bs=${mb}M count=$count ||
8609 { error "dd write ${mb} MB blocks failed"; return 4; }
8611 # calculate number of full-sized read and write RPCs
8612 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
8613 sed -n '/pages per rpc/,/^$/p' |
8614 awk '/'$pages':/ { reads += $2; writes += $6 }; \
8615 END { print reads,writes }'))
8616 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
8618 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
8625 remote_ost_nodsh && skip "remote OST with nodsh"
8628 local osts=$(get_facets OST)
8629 local list=$(comma_list $(osts_nodes))
8630 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8631 local brw_size="obdfilter.*.brw_size"
8633 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8635 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
8637 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
8638 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
8639 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
8640 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
8641 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
8642 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
8644 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
8647 if [[ $orig_mb -lt 16 ]]; then
8648 save_lustre_params $osts "$brw_size" > $p
8649 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
8650 error "set 16MB RPC size failed"
8652 echo "remount client to enable new RPC size"
8653 remount_client $MOUNT || error "remount_client failed"
8656 test_101g_brw_size_test 16 || error "16MB RPC test failed"
8657 # should be able to set brw_size=12, but no rpc_stats for that
8658 test_101g_brw_size_test 8 || error "8MB RPC test failed"
8661 test_101g_brw_size_test 4 || error "4MB RPC test failed"
8663 if [[ $orig_mb -lt 16 ]]; then
8664 restore_lustre_params < $p
8665 remount_client $MOUNT || error "remount_client restore failed"
8668 rm -f $p $DIR/$tfile
8670 run_test 101g "Big bulk(4/16 MiB) readahead"
8673 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8675 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
8676 error "dd 70M file failed"
8677 echo Cancel LRU locks on lustre client to flush the client cache
8678 cancel_lru_locks osc
8680 echo "Reset readahead stats"
8681 $LCTL set_param -n llite.*.read_ahead_stats 0
8683 echo "Read 10M of data but cross 64M bundary"
8684 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
8685 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8686 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8687 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
8688 rm -f $p $DIR/$tfile
8690 run_test 101h "Readahead should cover current read window"
8693 test_mkdir $DIR/$tdir
8694 chown $RUNAS_ID $DIR/$tdir
8697 STRIPE_COUNT=$OSTCOUNT
8698 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
8700 trap cleanup_test102 EXIT
8702 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
8704 for num in 1 2 3 4; do
8705 for count in $(seq 1 $STRIPE_COUNT); do
8706 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
8707 local size=`expr $STRIPE_SIZE \* $num`
8708 local file=file"$num-$idx-$count"
8709 $1 $LFS setstripe -S $size -i $idx -c $count $file
8715 $1 tar cf $TMP/f102.tar $tdir --xattrs
8721 rm -rf $DIR/d0.sanity/d102
8725 [ "$UID" != 0 ] && skip "must run as root"
8726 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
8727 skip_env "must have user_xattr"
8729 [ -z "$(which setfattr 2>/dev/null)" ] &&
8730 skip_env "could not find setfattr"
8732 local testfile=$DIR/$tfile
8735 echo "set/get xattr..."
8736 setfattr -n trusted.name1 -v value1 $testfile ||
8737 error "setfattr -n trusted.name1=value1 $testfile failed"
8738 getfattr -n trusted.name1 $testfile 2> /dev/null |
8739 grep "trusted.name1=.value1" ||
8740 error "$testfile missing trusted.name1=value1"
8742 setfattr -n user.author1 -v author1 $testfile ||
8743 error "setfattr -n user.author1=author1 $testfile failed"
8744 getfattr -n user.author1 $testfile 2> /dev/null |
8745 grep "user.author1=.author1" ||
8746 error "$testfile missing trusted.author1=author1"
8749 setfattr -n trusted.name2 -v value2 $testfile ||
8750 error "$testfile unable to set trusted.name2"
8751 setfattr -n trusted.name3 -v value3 $testfile ||
8752 error "$testfile unable to set trusted.name3"
8753 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
8754 grep "trusted.name" | wc -l) -eq 3 ] ||
8755 error "$testfile missing 3 trusted.name xattrs"
8757 setfattr -n user.author2 -v author2 $testfile ||
8758 error "$testfile unable to set user.author2"
8759 setfattr -n user.author3 -v author3 $testfile ||
8760 error "$testfile unable to set user.author3"
8761 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
8762 grep "user.author" | wc -l) -eq 3 ] ||
8763 error "$testfile missing 3 user.author xattrs"
8765 echo "remove xattr..."
8766 setfattr -x trusted.name1 $testfile ||
8767 error "$testfile error deleting trusted.name1"
8768 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
8769 error "$testfile did not delete trusted.name1 xattr"
8771 setfattr -x user.author1 $testfile ||
8772 error "$testfile error deleting user.author1"
8773 echo "set lustre special xattr ..."
8774 $LFS setstripe -c1 $testfile
8775 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
8776 awk -F "=" '/trusted.lov/ { print $2 }' )
8777 setfattr -n "trusted.lov" -v $lovea $testfile ||
8778 error "$testfile doesn't ignore setting trusted.lov again"
8779 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
8780 error "$testfile allow setting invalid trusted.lov"
8783 run_test 102a "user xattr test =================================="
8786 [ -z "$(which setfattr 2>/dev/null)" ] &&
8787 skip_env "could not find setfattr"
8788 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8790 # b10930: get/set/list trusted.lov xattr
8791 echo "get/set/list trusted.lov xattr ..."
8792 local testfile=$DIR/$tfile
8793 $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8794 error "setstripe failed"
8795 local STRIPECOUNT=$($LFS getstripe -c $testfile) ||
8796 error "getstripe failed"
8797 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
8798 error "can't get trusted.lov from $testfile"
8800 local testfile2=${testfile}2
8801 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
8802 grep "trusted.lov" | sed -e 's/[^=]\+=//')
8805 setfattr -n trusted.lov -v $value $testfile2
8806 local stripe_size=$($LFS getstripe -S $testfile2)
8807 local stripe_count=$($LFS getstripe -c $testfile2)
8808 [[ $stripe_size -eq 65536 ]] ||
8809 error "stripe size $stripe_size != 65536"
8810 [[ $stripe_count -eq $STRIPECOUNT ]] ||
8811 error "stripe count $stripe_count != $STRIPECOUNT"
8814 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
8817 [ -z "$(which setfattr 2>/dev/null)" ] &&
8818 skip_env "could not find setfattr"
8819 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8821 # b10930: get/set/list lustre.lov xattr
8822 echo "get/set/list lustre.lov xattr ..."
8823 test_mkdir $DIR/$tdir
8824 chown $RUNAS_ID $DIR/$tdir
8825 local testfile=$DIR/$tdir/$tfile
8826 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8827 error "setstripe failed"
8828 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
8829 error "getstripe failed"
8830 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
8831 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8833 local testfile2=${testfile}2
8834 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8835 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8837 $RUNAS $MCREATE $testfile2
8838 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8839 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
8840 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
8841 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8842 [ $stripe_count -eq $STRIPECOUNT ] ||
8843 error "stripe count $stripe_count != $STRIPECOUNT"
8845 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8847 compare_stripe_info1() {
8848 local stripe_index_all_zero=true
8850 for num in 1 2 3 4; do
8851 for count in $(seq 1 $STRIPE_COUNT); do
8852 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8853 local size=$((STRIPE_SIZE * num))
8854 local file=file"$num-$offset-$count"
8855 stripe_size=$($LFS getstripe -S $PWD/$file)
8856 [[ $stripe_size -ne $size ]] &&
8857 error "$file: size $stripe_size != $size"
8858 stripe_count=$($LFS getstripe -c $PWD/$file)
8859 # allow fewer stripes to be created, ORI-601
8860 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8861 error "$file: count $stripe_count != $count"
8862 stripe_index=$($LFS getstripe -i $PWD/$file)
8863 [[ $stripe_index -ne 0 ]] &&
8864 stripe_index_all_zero=false
8868 $stripe_index_all_zero &&
8869 error "all files are being extracted starting from OST index 0"
8873 have_xattrs_include() {
8874 tar --help | grep -q xattrs-include &&
8875 echo --xattrs-include="lustre.*"
8879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8880 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8882 XINC=$(have_xattrs_include)
8884 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8886 compare_stripe_info1
8888 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8892 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8894 XINC=$(have_xattrs_include)
8896 test_mkdir $DIR/$tdir.restore
8898 tar cf - --xattrs $tdir | tar xf - \
8899 -C $DIR/$tdir.restore --xattrs $XINC
8900 cd $DIR/$tdir.restore/$tdir
8901 compare_stripe_info1
8903 run_test 102f "tar copy files, not keep osts"
8906 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8907 skip "must have user_xattr"
8908 [ -z "$(which setfattr 2>/dev/null)" ] &&
8909 skip_env "could not find setfattr"
8910 [ -z "$(which getfattr 2>/dev/null)" ] &&
8911 skip_env "could not find getfattr"
8913 local xsize=${1:-1024} # in bytes
8914 local file=$DIR/$tfile
8915 local value="$(generate_string $xsize)"
8916 local xbig=trusted.big
8920 log "save $xbig on $file"
8923 setfattr -n $xbig -v $value $file ||
8924 error "saving $xbig on $file failed"
8926 setfattr -n $xbig -v $value $file &&
8927 error "saving $xbig on $file succeeded"
8931 local orig=$(get_xattr_value $xbig $file)
8932 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8934 local xsml=trusted.sml
8935 log "save $xsml on $file"
8936 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8938 local new=$(get_xattr_value $xbig $file)
8939 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8941 log "grow $xsml on $file"
8942 setfattr -n $xsml -v "$value" $file ||
8943 error "growing $xsml on $file failed"
8945 new=$(get_xattr_value $xbig $file)
8946 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8947 log "$xbig still valid after growing $xsml"
8952 test_102h() { # bug 15777
8955 run_test 102h "grow xattr from inside inode to external block"
8958 large_xattr_enabled || skip_env "ea_inode feature disabled"
8960 echo "setting xattr of max xattr size: $(max_xattr_size)"
8961 grow_xattr $(max_xattr_size)
8963 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
8964 echo "This should fail:"
8965 grow_xattr $(($(max_xattr_size) + 10)) 1
8967 run_test 102ha "grow xattr from inside inode to external inode"
8969 test_102i() { # bug 17038
8970 [ -z "$(which getfattr 2>/dev/null)" ] &&
8971 skip "could not find getfattr"
8974 ln -s $DIR/$tfile $DIR/${tfile}link
8975 getfattr -n trusted.lov $DIR/$tfile ||
8976 error "lgetxattr on $DIR/$tfile failed"
8977 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
8978 grep -i "no such attr" ||
8979 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
8980 rm -f $DIR/$tfile $DIR/${tfile}link
8982 run_test 102i "lgetxattr test on symbolic link ============"
8985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8986 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8988 XINC=$(have_xattrs_include)
8989 setup_test102 "$RUNAS"
8990 chown $RUNAS_ID $DIR/$tdir
8991 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8993 compare_stripe_info1 "$RUNAS"
8995 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
8998 [ -z "$(which setfattr 2>/dev/null)" ] &&
8999 skip "could not find setfattr"
9002 # b22187 just check that does not crash for regular file.
9003 setfattr -n trusted.lov $DIR/$tfile
9004 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9005 local test_kdir=$DIR/$tdir
9006 test_mkdir $test_kdir
9007 local default_size=$($LFS getstripe -S $test_kdir)
9008 local default_count=$($LFS getstripe -c $test_kdir)
9009 local default_offset=$($LFS getstripe -i $test_kdir)
9010 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9011 error 'dir setstripe failed'
9012 setfattr -n trusted.lov $test_kdir
9013 local stripe_size=$($LFS getstripe -S $test_kdir)
9014 local stripe_count=$($LFS getstripe -c $test_kdir)
9015 local stripe_offset=$($LFS getstripe -i $test_kdir)
9016 [ $stripe_size -eq $default_size ] ||
9017 error "stripe size $stripe_size != $default_size"
9018 [ $stripe_count -eq $default_count ] ||
9019 error "stripe count $stripe_count != $default_count"
9020 [ $stripe_offset -eq $default_offset ] ||
9021 error "stripe offset $stripe_offset != $default_offset"
9022 rm -rf $DIR/$tfile $test_kdir
9024 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9027 [ -z "$(which getfattr 2>/dev/null)" ] &&
9028 skip "could not find getfattr"
9030 # LU-532 trusted. xattr is invisible to non-root
9031 local testfile=$DIR/$tfile
9035 echo "listxattr as user..."
9036 chown $RUNAS_ID $testfile
9037 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9038 grep -q "trusted" &&
9039 error "$testfile trusted xattrs are user visible"
9043 run_test 102l "listxattr size test =================================="
9045 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9046 local path=$DIR/$tfile
9049 listxattr_size_check $path || error "listattr_size_check $path failed"
9051 run_test 102m "Ensure listxattr fails on small bufffer ========"
9055 getxattr() { # getxattr path name
9056 # Return the base64 encoding of the value of xattr name on path.
9060 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9062 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9064 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9066 getfattr --absolute-names --encoding=base64 --name=$name $path |
9067 awk -F= -v name=$name '$1 == name {
9068 print substr($0, index($0, "=") + 1);
9072 test_102n() { # LU-4101 mdt: protect internal xattrs
9073 [ -z "$(which setfattr 2>/dev/null)" ] &&
9074 skip "could not find setfattr"
9075 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9077 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
9080 local file0=$DIR/$tfile.0
9081 local file1=$DIR/$tfile.1
9082 local xattr0=$TMP/$tfile.0
9083 local xattr1=$TMP/$tfile.1
9084 local namelist="lov lma lmv link fid version som hsm"
9088 rm -rf $file0 $file1 $xattr0 $xattr1
9091 # Get 'before' xattrs of $file1.
9092 getfattr --absolute-names --dump --match=- $file1 > $xattr0
9094 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
9095 namelist+=" lfsck_namespace"
9096 for name in $namelist; do
9097 # Try to copy xattr from $file0 to $file1.
9098 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9100 setfattr --name=trusted.$name --value="$value" $file1 ||
9101 error "setxattr 'trusted.$name' failed"
9103 # Try to set a garbage xattr.
9104 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9106 if [[ x$name == "xlov" ]]; then
9107 setfattr --name=trusted.lov --value="$value" $file1 &&
9108 error "setxattr invalid 'trusted.lov' success"
9110 setfattr --name=trusted.$name --value="$value" $file1 ||
9111 error "setxattr invalid 'trusted.$name' failed"
9114 # Try to remove the xattr from $file1. We don't care if this
9115 # appears to succeed or fail, we just don't want there to be
9116 # any changes or crashes.
9117 setfattr --remove=$trusted.$name $file1 2> /dev/null
9120 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
9123 # Try to copy xattr from $file0 to $file1.
9124 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9126 setfattr --name=trusted.$name --value="$value" $file1 ||
9127 error "setxattr 'trusted.$name' failed"
9129 # Try to set a garbage xattr.
9130 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9132 setfattr --name=trusted.$name --value="$value" $file1 ||
9133 error "setxattr 'trusted.$name' failed"
9135 # Try to remove the xattr from $file1. We don't care if this
9136 # appears to succeed or fail, we just don't want there to be
9137 # any changes or crashes.
9138 setfattr --remove=$trusted.$name $file1 2> /dev/null
9141 # Get 'after' xattrs of file1.
9142 getfattr --absolute-names --dump --match=- $file1 > $xattr1
9144 if ! diff $xattr0 $xattr1; then
9145 error "before and after xattrs of '$file1' differ"
9148 rm -rf $file0 $file1 $xattr0 $xattr1
9152 run_test 102n "silently ignore setxattr on internal trusted xattrs"
9154 test_102p() { # LU-4703 setxattr did not check ownership
9155 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
9156 skip "MDS needs to be at least 2.5.56"
9158 local testfile=$DIR/$tfile
9162 echo "setfacl as user..."
9163 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
9164 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
9166 echo "setfattr as user..."
9167 setfacl -m "u:$RUNAS_ID:---" $testfile
9168 $RUNAS setfattr -x system.posix_acl_access $testfile
9169 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
9171 run_test 102p "check setxattr(2) correctly fails without permission"
9174 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
9175 skip "MDS needs to be at least 2.6.92"
9177 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
9179 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
9182 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
9183 skip "MDS needs to be at least 2.6.93"
9185 touch $DIR/$tfile || error "touch"
9186 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
9187 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
9188 rm $DIR/$tfile || error "rm"
9191 mkdir -p $DIR/$tdir || error "mkdir"
9192 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9193 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9194 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9195 error "$testfile error deleting user.author1"
9196 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9197 grep "user.$(basename $tdir)" &&
9198 error "$tdir did not delete user.$(basename $tdir)"
9199 rmdir $DIR/$tdir || error "rmdir"
9202 test_mkdir $DIR/$tdir
9203 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9204 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9205 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9206 error "$testfile error deleting user.author1"
9207 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9208 grep "user.$(basename $tdir)" &&
9209 error "$tdir did not delete user.$(basename $tdir)"
9210 rmdir $DIR/$tdir || error "rm striped dir"
9212 run_test 102r "set EAs with empty values"
9215 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9216 skip "MDS needs to be at least 2.11.52"
9218 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9220 save_lustre_params client "llite.*.xattr_cache" > $save
9222 for cache in 0 1; do
9223 lctl set_param llite.*.xattr_cache=$cache
9226 touch $DIR/$tfile || error "touch"
9227 for prefix in lustre security system trusted user; do
9228 # Note getxattr() may fail with 'Operation not
9229 # supported' or 'No such attribute' depending
9230 # on prefix and cache.
9231 getfattr -n $prefix.n102s $DIR/$tfile &&
9232 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
9236 restore_lustre_params < $save
9238 run_test 102s "getting nonexistent xattrs should fail"
9241 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9242 skip "MDS needs to be at least 2.11.52"
9244 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9246 save_lustre_params client "llite.*.xattr_cache" > $save
9248 for cache in 0 1; do
9249 lctl set_param llite.*.xattr_cache=$cache
9251 for buf_size in 0 256; do
9253 touch $DIR/$tfile || error "touch"
9254 setfattr -n user.multiop $DIR/$tfile
9255 $MULTIOP $DIR/$tfile oa$buf_size ||
9256 error "cannot get zero length xattr value (buf_size = $buf_size)"
9260 restore_lustre_params < $save
9262 run_test 102t "zero length xattr values handled correctly"
9266 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
9271 [ "$UID" != 0 ] && skip "must run as root"
9272 $GSS && skip_env "could not run under gss"
9273 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
9274 skip_env "must have acl enabled"
9275 [ -z "$(which setfacl 2>/dev/null)" ] &&
9276 skip_env "could not find setfacl"
9277 remote_mds_nodsh && skip "remote MDS with nodsh"
9279 gpasswd -a daemon bin # LU-5641
9280 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
9282 declare -a identity_old
9284 for num in $(seq $MDSCOUNT); do
9285 switch_identity $num true || identity_old[$num]=$?
9293 echo "performing cp ..."
9294 run_acl_subtest cp || error "run_acl_subtest cp failed"
9295 echo "performing getfacl-noacl..."
9296 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
9297 echo "performing misc..."
9298 run_acl_subtest misc || error "misc test failed"
9299 echo "performing permissions..."
9300 run_acl_subtest permissions || error "permissions failed"
9301 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
9302 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
9303 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
9304 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
9306 echo "performing permissions xattr..."
9307 run_acl_subtest permissions_xattr ||
9308 error "permissions_xattr failed"
9310 echo "performing setfacl..."
9311 run_acl_subtest setfacl || error "setfacl test failed"
9313 # inheritance test got from HP
9314 echo "performing inheritance..."
9315 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
9316 chmod +x make-tree || error "chmod +x failed"
9317 run_acl_subtest inheritance || error "inheritance test failed"
9320 echo "LU-974 ignore umask when acl is enabled..."
9321 run_acl_subtest 974 || error "LU-974 umask test failed"
9322 if [ $MDSCOUNT -ge 2 ]; then
9323 run_acl_subtest 974_remote ||
9324 error "LU-974 umask test failed under remote dir"
9327 echo "LU-2561 newly created file is same size as directory..."
9328 if [ "$mds1_FSTYPE" != "zfs" ]; then
9329 run_acl_subtest 2561 || error "LU-2561 test failed"
9331 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
9334 run_acl_subtest 4924 || error "LU-4924 test failed"
9339 for num in $(seq $MDSCOUNT); do
9340 if [ "${identity_old[$num]}" = 1 ]; then
9341 switch_identity $num false || identity_old[$num]=$?
9345 run_test 103a "acl test"
9351 for U in {0..511}; do
9353 local O=$(printf "%04o" $U)
9355 umask $(printf "%04o" $((511 ^ $O)))
9356 $LFS setstripe -c 1 $DIR/$tfile.s$O
9357 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9359 (( $S == ($O & 0666) )) ||
9360 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9362 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9363 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9364 (( $S == ($O & 0666) )) ||
9365 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9367 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9368 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9369 (( $S == ($O & 0666) )) ||
9370 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9371 rm -f $DIR/$tfile.[smp]$0
9375 # limit the concurrently running threads to 64. LU-11878
9376 local idx=$((U % 64))
9377 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9382 run_test 103b "umask lfs setstripe"
9386 cp -rp $DIR/$tdir $DIR/$tdir.bak
9388 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9389 error "$DIR/$tdir shouldn't contain default ACL"
9390 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9391 error "$DIR/$tdir.bak shouldn't contain default ACL"
9394 run_test 103c "'cp -rp' won't set empty acl"
9397 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9400 lfs df || error "lfs df failed"
9401 lfs df -ih || error "lfs df -ih failed"
9402 lfs df -h $DIR || error "lfs df -h $DIR failed"
9403 lfs df -i $DIR || error "lfs df -i $DIR failed"
9404 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9405 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9407 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9408 lctl --device %$OSC deactivate
9409 lfs df || error "lfs df with deactivated OSC failed"
9410 lctl --device %$OSC activate
9411 # wait the osc back to normal
9412 wait_osc_import_ready client ost
9414 lfs df || error "lfs df with reactivated OSC failed"
9417 run_test 104a "lfs df [-ih] [path] test ========================="
9420 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9421 [ $RUNAS_ID -eq $UID ] &&
9422 skip_env "RUNAS_ID = UID = $UID -- skipping"
9424 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
9425 grep "Permission denied" | wc -l)))
9426 if [ $denied_cnt -ne 0 ]; then
9427 error "lfs check servers test failed"
9430 run_test 104b "$RUNAS lfs check servers test ===================="
9433 # doesn't work on 2.4 kernels
9435 if $(flock_is_enabled); then
9436 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
9438 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
9442 run_test 105a "flock when mounted without -o flock test ========"
9446 if $(flock_is_enabled); then
9447 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
9449 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
9453 run_test 105b "fcntl when mounted without -o flock test ========"
9457 if $(flock_is_enabled); then
9458 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
9460 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
9464 run_test 105c "lockf when mounted without -o flock test"
9466 test_105d() { # bug 15924
9467 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9469 test_mkdir $DIR/$tdir
9470 flock_is_enabled || skip_env "mount w/o flock enabled"
9471 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
9472 $LCTL set_param fail_loc=0x80000315
9473 flocks_test 2 $DIR/$tdir
9475 run_test 105d "flock race (should not freeze) ========"
9477 test_105e() { # bug 22660 && 22040
9478 flock_is_enabled || skip_env "mount w/o flock enabled"
9481 flocks_test 3 $DIR/$tfile
9483 run_test 105e "Two conflicting flocks from same process"
9485 test_106() { #bug 10921
9486 test_mkdir $DIR/$tdir
9487 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
9488 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
9490 run_test 106 "attempt exec of dir followed by chown of that dir"
9493 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9501 local save_pattern=$(sysctl -n kernel.core_pattern)
9502 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
9503 sysctl -w kernel.core_pattern=$file
9504 sysctl -w kernel.core_uses_pid=0
9512 kill -s 11 $SLEEPPID
9514 if [ -e $file ]; then
9515 size=`stat -c%s $file`
9516 [ $size -eq 0 ] && error "Fail to create core file $file"
9518 error "Fail to create core file $file"
9521 sysctl -w kernel.core_pattern=$save_pattern
9522 sysctl -w kernel.core_uses_pid=$save_uses_pid
9525 run_test 107 "Coredump on SIG"
9528 test_mkdir $DIR/$tdir
9529 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
9530 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
9531 error "mkdir with 256 char should fail, but did not"
9532 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
9533 error "create with 255 char failed"
9534 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
9535 error "create with 256 char should fail, but did not"
9540 run_test 110 "filename length checking"
9543 # Purpose: To verify dynamic thread (OSS) creation.
9546 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9547 remote_ost_nodsh && skip "remote OST with nodsh"
9549 # Lustre does not stop service threads once they are started.
9550 # Reset number of running threads to default.
9555 local save_params="$TMP/sanity-$TESTNAME.parameters"
9557 # Get ll_ost_io count before I/O
9558 OSTIO_pre=$(do_facet ost1 \
9559 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9560 # Exit if lustre is not running (ll_ost_io not running).
9561 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9563 echo "Starting with $OSTIO_pre threads"
9564 local thread_max=$((OSTIO_pre * 2))
9565 local rpc_in_flight=$((thread_max * 2))
9566 # Number of I/O Process proposed to be started.
9568 local facets=$(get_facets OST)
9570 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9571 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9573 # Set in_flight to $rpc_in_flight
9574 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9575 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9576 nfiles=${rpc_in_flight}
9577 # Set ost thread_max to $thread_max
9578 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
9580 # 5 Minutes should be sufficient for max number of OSS
9581 # threads(thread_max) to be created.
9585 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
9586 test_mkdir $DIR/$tdir
9587 for i in $(seq $nfiles); do
9588 local file=$DIR/$tdir/${tfile}-$i
9589 $LFS setstripe -c -1 -i 0 $file
9590 ($WTL $file $timeout)&
9593 # I/O Started - Wait for thread_started to reach thread_max or report
9594 # error if thread_started is more than thread_max.
9595 echo "Waiting for thread_started to reach thread_max"
9596 local thread_started=0
9597 local end_time=$((SECONDS + timeout))
9599 while [ $SECONDS -le $end_time ] ; do
9601 # Get ost i/o thread_started count.
9602 thread_started=$(do_facet ost1 \
9604 ost.OSS.ost_io.threads_started | cut -d= -f2")
9605 # Break out if thread_started is equal/greater than thread_max
9606 if [[ $thread_started -ge $thread_max ]]; then
9607 echo ll_ost_io thread_started $thread_started, \
9608 equal/greater than thread_max $thread_max
9614 # Cleanup - We have the numbers, Kill i/o jobs if running.
9615 jobcount=($(jobs -p))
9616 for i in $(seq 0 $((${#jobcount[@]}-1)))
9618 kill -9 ${jobcount[$i]}
9619 if [ $? -ne 0 ] ; then
9621 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
9625 # Cleanup files left by WTL binary.
9626 for i in $(seq $nfiles); do
9627 local file=$DIR/$tdir/${tfile}-$i
9629 if [ $? -ne 0 ] ; then
9630 echo "Warning: Failed to delete file $file"
9634 restore_lustre_params <$save_params
9635 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
9637 # Error out if no new thread has started or Thread started is greater
9639 if [[ $thread_started -le $OSTIO_pre ||
9640 $thread_started -gt $thread_max ]]; then
9641 error "ll_ost_io: thread_started $thread_started" \
9642 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
9643 "No new thread started or thread started greater " \
9647 run_test 115 "verify dynamic thread creation===================="
9650 wait_delete_completed
9651 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
9652 echo "OST kbytes available: ${AVAIL[@]}"
9657 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
9658 #echo OST $i: ${AVAIL[i]}kb
9659 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
9663 if [[ ${AVAIL[i]} -lt $MINV ]]; then
9668 echo "Min free space: OST $MINI: $MINV"
9669 echo "Max free space: OST $MAXI: $MAXV"
9672 test_116a() { # was previously test_116()
9673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9674 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9675 remote_mds_nodsh && skip "remote MDS with nodsh"
9677 echo -n "Free space priority "
9678 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
9683 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
9684 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
9685 trap simple_cleanup_common EXIT
9687 # Check if we need to generate uneven OSTs
9688 test_mkdir -p $DIR/$tdir/OST${MINI}
9689 local FILL=$((MINV / 4))
9690 local DIFF=$((MAXV - MINV))
9691 local DIFF2=$((DIFF * 100 / MINV))
9693 local threshold=$(do_facet $SINGLEMDS \
9694 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
9695 threshold=${threshold%%%}
9696 echo -n "Check for uneven OSTs: "
9697 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
9699 if [[ $DIFF2 -gt $threshold ]]; then
9701 echo "Don't need to fill OST$MINI"
9703 # generate uneven OSTs. Write 2% over the QOS threshold value
9705 DIFF=$((threshold - DIFF2 + 2))
9706 DIFF2=$((MINV * DIFF / 100))
9707 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
9708 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
9709 error "setstripe failed"
9710 DIFF=$((DIFF2 / 2048))
9712 while [ $i -lt $DIFF ]; do
9714 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
9715 bs=2M count=1 2>/dev/null
9724 DIFF=$((MAXV - MINV))
9725 DIFF2=$((DIFF * 100 / MINV))
9726 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
9727 if [ $DIFF2 -gt $threshold ]; then
9730 echo "failed - QOS mode won't be used"
9731 simple_cleanup_common
9732 skip "QOS imbalance criteria not met"
9740 # now fill using QOS
9741 $LFS setstripe -c 1 $DIR/$tdir
9742 FILL=$((FILL / 200))
9743 if [ $FILL -gt 600 ]; then
9746 echo "writing $FILL files to QOS-assigned OSTs"
9748 while [ $i -lt $FILL ]; do
9750 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
9754 echo "wrote $i 200k files"
9758 echo "Note: free space may not be updated, so measurements might be off"
9760 DIFF2=$((MAXV - MINV))
9761 echo "free space delta: orig $DIFF final $DIFF2"
9762 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
9763 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
9764 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
9765 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
9766 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
9767 if [[ $DIFF -gt 0 ]]; then
9768 FILL=$((DIFF2 * 100 / DIFF - 100))
9769 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
9772 # Figure out which files were written where
9773 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9774 awk '/'$MINI1': / {print $2; exit}')
9776 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9777 echo "$MINC files created on smaller OST $MINI1"
9778 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9779 awk '/'$MAXI1': / {print $2; exit}')
9781 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9782 echo "$MAXC files created on larger OST $MAXI1"
9783 if [[ $MINC -gt 0 ]]; then
9784 FILL=$((MAXC * 100 / MINC - 100))
9785 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
9787 [[ $MAXC -gt $MINC ]] ||
9788 error_ignore LU-9 "stripe QOS didn't balance free space"
9789 simple_cleanup_common
9791 run_test 116a "stripe QOS: free space balance ==================="
9793 test_116b() { # LU-2093
9794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9795 remote_mds_nodsh && skip "remote MDS with nodsh"
9797 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
9798 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
9799 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
9800 [ -z "$old_rr" ] && skip "no QOS"
9801 do_facet $SINGLEMDS lctl set_param \
9802 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
9804 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
9805 createmany -o $DIR/$tdir/f- 20 || error "can't create"
9806 do_facet $SINGLEMDS lctl set_param fail_loc=0
9808 do_facet $SINGLEMDS lctl set_param \
9809 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
9811 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
9813 test_117() # bug 10891
9815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9817 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
9818 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
9819 lctl set_param fail_loc=0x21e
9820 > $DIR/$tfile || error "truncate failed"
9821 lctl set_param fail_loc=0
9822 echo "Truncate succeeded."
9825 run_test 117 "verify osd extend =========="
9827 NO_SLOW_RESENDCOUNT=4
9828 export OLD_RESENDCOUNT=""
9829 set_resend_count () {
9830 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
9831 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
9832 lctl set_param -n $PROC_RESENDCOUNT $1
9833 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
9836 # for reduce test_118* time (b=14842)
9837 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9839 # Reset async IO behavior after error case
9841 FILE=$DIR/reset_async
9843 # Ensure all OSCs are cleared
9844 $LFS setstripe -c -1 $FILE
9845 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
9850 test_118a() #bug 11710
9852 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9856 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9857 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9858 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9860 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9861 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9866 run_test 118a "verify O_SYNC works =========="
9870 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9871 remote_ost_nodsh && skip "remote OST with nodsh"
9875 #define OBD_FAIL_SRV_ENOENT 0x217
9876 set_nodes_failloc "$(osts_nodes)" 0x217
9877 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9879 set_nodes_failloc "$(osts_nodes)" 0
9880 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9881 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9884 if [[ $RC -eq 0 ]]; then
9885 error "Must return error due to dropped pages, rc=$RC"
9889 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9890 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9894 echo "Dirty pages not leaked on ENOENT"
9896 # Due to the above error the OSC will issue all RPCs syncronously
9897 # until a subsequent RPC completes successfully without error.
9898 $MULTIOP $DIR/$tfile Ow4096yc
9903 run_test 118b "Reclaim dirty pages on fatal error =========="
9907 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9909 # for 118c, restore the original resend count, LU-1940
9910 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
9911 set_resend_count $OLD_RESENDCOUNT
9912 remote_ost_nodsh && skip "remote OST with nodsh"
9916 #define OBD_FAIL_OST_EROFS 0x216
9917 set_nodes_failloc "$(osts_nodes)" 0x216
9919 # multiop should block due to fsync until pages are written
9920 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9924 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9925 error "Multiop failed to block on fsync, pid=$MULTIPID"
9928 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9930 if [[ $WRITEBACK -eq 0 ]]; then
9931 error "No page in writeback, writeback=$WRITEBACK"
9934 set_nodes_failloc "$(osts_nodes)" 0
9937 if [[ $RC -ne 0 ]]; then
9938 error "Multiop fsync failed, rc=$RC"
9941 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9942 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9944 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9945 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9949 echo "Dirty pages flushed via fsync on EROFS"
9952 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
9954 # continue to use small resend count to reduce test_118* time (b=14842)
9955 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9959 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9960 remote_ost_nodsh && skip "remote OST with nodsh"
9964 #define OBD_FAIL_OST_BRW_PAUSE_BULK
9965 set_nodes_failloc "$(osts_nodes)" 0x214
9966 # multiop should block due to fsync until pages are written
9967 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9971 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9972 error "Multiop failed to block on fsync, pid=$MULTIPID"
9975 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9977 if [[ $WRITEBACK -eq 0 ]]; then
9978 error "No page in writeback, writeback=$WRITEBACK"
9981 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
9982 set_nodes_failloc "$(osts_nodes)" 0
9984 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9985 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9987 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9988 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9992 echo "Dirty pages gaurenteed flushed via fsync"
9995 run_test 118d "Fsync validation inject a delay of the bulk =========="
9998 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10002 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10003 lctl set_param fail_loc=0x8000040a
10005 # Should simulate EINVAL error which is fatal
10006 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10008 if [[ $RC -eq 0 ]]; then
10009 error "Must return error due to dropped pages, rc=$RC"
10012 lctl set_param fail_loc=0x0
10014 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10015 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10016 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10018 if [[ $LOCKED -ne 0 ]]; then
10019 error "Locked pages remain in cache, locked=$LOCKED"
10022 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10023 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10027 echo "No pages locked after fsync"
10032 run_test 118f "Simulate unrecoverable OSC side error =========="
10035 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10039 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10040 lctl set_param fail_loc=0x406
10042 # simulate local -ENOMEM
10043 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10046 lctl set_param fail_loc=0
10047 if [[ $RC -eq 0 ]]; then
10048 error "Must return error due to dropped pages, rc=$RC"
10051 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10052 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10053 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10055 if [[ $LOCKED -ne 0 ]]; then
10056 error "Locked pages remain in cache, locked=$LOCKED"
10059 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10060 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10064 echo "No pages locked after fsync"
10069 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10072 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10073 remote_ost_nodsh && skip "remote OST with nodsh"
10077 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10078 set_nodes_failloc "$(osts_nodes)" 0x20e
10079 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10080 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10083 set_nodes_failloc "$(osts_nodes)" 0
10084 if [[ $RC -eq 0 ]]; then
10085 error "Must return error due to dropped pages, rc=$RC"
10088 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10089 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10090 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10092 if [[ $LOCKED -ne 0 ]]; then
10093 error "Locked pages remain in cache, locked=$LOCKED"
10096 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10097 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10101 echo "No pages locked after fsync"
10105 run_test 118h "Verify timeout in handling recoverables errors =========="
10107 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10111 remote_ost_nodsh && skip "remote OST with nodsh"
10115 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10116 set_nodes_failloc "$(osts_nodes)" 0x20e
10118 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10119 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10122 set_nodes_failloc "$(osts_nodes)" 0
10126 if [[ $RC -ne 0 ]]; then
10127 error "got error, but should be not, rc=$RC"
10130 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10131 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10132 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10133 if [[ $LOCKED -ne 0 ]]; then
10134 error "Locked pages remain in cache, locked=$LOCKED"
10137 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10138 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10142 echo "No pages locked after fsync"
10146 run_test 118i "Fix error before timeout in recoverable error =========="
10148 [ "$SLOW" = "no" ] && set_resend_count 4
10151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10152 remote_ost_nodsh && skip "remote OST with nodsh"
10156 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
10157 set_nodes_failloc "$(osts_nodes)" 0x220
10159 # return -EIO from OST
10160 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10162 set_nodes_failloc "$(osts_nodes)" 0x0
10163 if [[ $RC -eq 0 ]]; then
10164 error "Must return error due to dropped pages, rc=$RC"
10167 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10168 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10169 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10170 if [[ $LOCKED -ne 0 ]]; then
10171 error "Locked pages remain in cache, locked=$LOCKED"
10174 # in recoverable error on OST we want resend and stay until it finished
10175 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10176 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10180 echo "No pages locked after fsync"
10184 run_test 118j "Simulate unrecoverable OST side error =========="
10188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10189 remote_ost_nodsh && skip "remote OSTs with nodsh"
10191 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10192 set_nodes_failloc "$(osts_nodes)" 0x20e
10193 test_mkdir $DIR/$tdir
10195 for ((i=0;i<10;i++)); do
10196 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
10197 error "dd to $DIR/$tdir/$tfile-$i failed" )&
10204 set_nodes_failloc "$(osts_nodes)" 0
10207 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
10209 test_118l() # LU-646
10211 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10213 test_mkdir $DIR/$tdir
10214 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
10217 run_test 118l "fsync dir"
10219 test_118m() # LU-3066
10221 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10223 test_mkdir $DIR/$tdir
10224 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
10227 run_test 118m "fdatasync dir ========="
10229 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10236 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10237 remote_ost_nodsh && skip "remote OSTs with nodsh"
10239 # Sleep to avoid a cached response.
10240 #define OBD_STATFS_CACHE_SECONDS 1
10243 # Inject a 10 second delay in the OST_STATFS handler.
10244 #define OBD_FAIL_OST_STATFS_DELAY 0x242
10245 set_nodes_failloc "$(osts_nodes)" 0x242
10248 stat --file-system $MOUNT > /dev/null
10251 set_nodes_failloc "$(osts_nodes)" 0
10253 if ((end - begin > 20)); then
10254 error "statfs took $((end - begin)) seconds, expected 10"
10257 run_test 118n "statfs() sends OST_STATFS requests in parallel"
10259 test_119a() # bug 11737
10261 BSIZE=$((512 * 1024))
10262 directio write $DIR/$tfile 0 1 $BSIZE
10263 # We ask to read two blocks, which is more than a file size.
10264 # directio will indicate an error when requested and actual
10265 # sizes aren't equeal (a normal situation in this case) and
10266 # print actual read amount.
10267 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
10268 if [ "$NOB" != "$BSIZE" ]; then
10269 error "read $NOB bytes instead of $BSIZE"
10273 run_test 119a "Short directIO read must return actual read amount"
10275 test_119b() # bug 11737
10277 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10279 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
10280 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
10282 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
10283 error "direct read failed"
10286 run_test 119b "Sparse directIO read must return actual read amount"
10288 test_119c() # bug 13099
10291 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
10292 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
10295 run_test 119c "Testing for direct read hitting hole"
10297 test_119d() # bug 15950
10299 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10301 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
10302 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
10304 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
10305 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
10306 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
10307 lctl set_param fail_loc=0x40d
10308 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
10311 cat $DIR/$tfile > /dev/null &
10312 lctl set_param fail_loc=0
10315 log "the DIO writes have completed, now wait for the reads (should not block very long)"
10317 [ -n "`ps h -p $pid_reads -o comm`" ] && \
10318 error "the read rpcs have not completed in 2s"
10320 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
10322 run_test 119d "The DIO path should try to send a new rpc once one is completed"
10325 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10326 remote_mds_nodsh && skip "remote MDS with nodsh"
10327 test_mkdir -i0 -c1 $DIR/$tdir
10328 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10329 skip_env "no early lock cancel on server"
10331 lru_resize_disable mdc
10332 lru_resize_disable osc
10333 cancel_lru_locks mdc
10334 # asynchronous object destroy at MDT could cause bl ast to client
10335 cancel_lru_locks osc
10337 stat $DIR/$tdir > /dev/null
10338 can1=$(do_facet mds1 \
10339 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10340 awk '/ldlm_cancel/ {print $2}')
10341 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10342 awk '/ldlm_bl_callback/ {print $2}')
10343 test_mkdir -i0 -c1 $DIR/$tdir/d1
10344 can2=$(do_facet mds1 \
10345 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10346 awk '/ldlm_cancel/ {print $2}')
10347 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10348 awk '/ldlm_bl_callback/ {print $2}')
10349 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10350 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10351 lru_resize_enable mdc
10352 lru_resize_enable osc
10354 run_test 120a "Early Lock Cancel: mkdir test"
10357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10358 remote_mds_nodsh && skip "remote MDS with nodsh"
10359 test_mkdir $DIR/$tdir
10360 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10361 skip_env "no early lock cancel on server"
10363 lru_resize_disable mdc
10364 lru_resize_disable osc
10365 cancel_lru_locks mdc
10366 stat $DIR/$tdir > /dev/null
10367 can1=$(do_facet $SINGLEMDS \
10368 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10369 awk '/ldlm_cancel/ {print $2}')
10370 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10371 awk '/ldlm_bl_callback/ {print $2}')
10372 touch $DIR/$tdir/f1
10373 can2=$(do_facet $SINGLEMDS \
10374 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10375 awk '/ldlm_cancel/ {print $2}')
10376 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10377 awk '/ldlm_bl_callback/ {print $2}')
10378 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10379 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10380 lru_resize_enable mdc
10381 lru_resize_enable osc
10383 run_test 120b "Early Lock Cancel: create test"
10386 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10387 remote_mds_nodsh && skip "remote MDS with nodsh"
10388 test_mkdir -i0 -c1 $DIR/$tdir
10389 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10390 skip "no early lock cancel on server"
10392 lru_resize_disable mdc
10393 lru_resize_disable osc
10394 test_mkdir -i0 -c1 $DIR/$tdir/d1
10395 test_mkdir -i0 -c1 $DIR/$tdir/d2
10396 touch $DIR/$tdir/d1/f1
10397 cancel_lru_locks mdc
10398 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10399 can1=$(do_facet mds1 \
10400 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10401 awk '/ldlm_cancel/ {print $2}')
10402 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10403 awk '/ldlm_bl_callback/ {print $2}')
10404 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10405 can2=$(do_facet mds1 \
10406 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10407 awk '/ldlm_cancel/ {print $2}')
10408 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10409 awk '/ldlm_bl_callback/ {print $2}')
10410 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10411 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10412 lru_resize_enable mdc
10413 lru_resize_enable osc
10415 run_test 120c "Early Lock Cancel: link test"
10418 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10419 remote_mds_nodsh && skip "remote MDS with nodsh"
10420 test_mkdir -i0 -c1 $DIR/$tdir
10421 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10422 skip_env "no early lock cancel on server"
10424 lru_resize_disable mdc
10425 lru_resize_disable osc
10427 cancel_lru_locks mdc
10428 stat $DIR/$tdir > /dev/null
10429 can1=$(do_facet mds1 \
10430 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10431 awk '/ldlm_cancel/ {print $2}')
10432 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10433 awk '/ldlm_bl_callback/ {print $2}')
10434 chmod a+x $DIR/$tdir
10435 can2=$(do_facet mds1 \
10436 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10437 awk '/ldlm_cancel/ {print $2}')
10438 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10439 awk '/ldlm_bl_callback/ {print $2}')
10440 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10441 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10442 lru_resize_enable mdc
10443 lru_resize_enable osc
10445 run_test 120d "Early Lock Cancel: setattr test"
10448 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10449 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10450 skip_env "no early lock cancel on server"
10451 remote_mds_nodsh && skip "remote MDS with nodsh"
10453 local dlmtrace_set=false
10455 test_mkdir -i0 -c1 $DIR/$tdir
10456 lru_resize_disable mdc
10457 lru_resize_disable osc
10458 ! $LCTL get_param debug | grep -q dlmtrace &&
10459 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
10460 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
10461 cancel_lru_locks mdc
10462 cancel_lru_locks osc
10463 dd if=$DIR/$tdir/f1 of=/dev/null
10464 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
10465 # XXX client can not do early lock cancel of OST lock
10466 # during unlink (LU-4206), so cancel osc lock now.
10468 cancel_lru_locks osc
10469 can1=$(do_facet mds1 \
10470 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10471 awk '/ldlm_cancel/ {print $2}')
10472 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10473 awk '/ldlm_bl_callback/ {print $2}')
10474 unlink $DIR/$tdir/f1
10476 can2=$(do_facet mds1 \
10477 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10478 awk '/ldlm_cancel/ {print $2}')
10479 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10480 awk '/ldlm_bl_callback/ {print $2}')
10481 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
10482 $LCTL dk $TMP/cancel.debug.txt
10483 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
10484 $LCTL dk $TMP/blocking.debug.txt
10485 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
10486 lru_resize_enable mdc
10487 lru_resize_enable osc
10489 run_test 120e "Early Lock Cancel: unlink test"
10492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10493 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10494 skip_env "no early lock cancel on server"
10495 remote_mds_nodsh && skip "remote MDS with nodsh"
10497 test_mkdir -i0 -c1 $DIR/$tdir
10498 lru_resize_disable mdc
10499 lru_resize_disable osc
10500 test_mkdir -i0 -c1 $DIR/$tdir/d1
10501 test_mkdir -i0 -c1 $DIR/$tdir/d2
10502 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
10503 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
10504 cancel_lru_locks mdc
10505 cancel_lru_locks osc
10506 dd if=$DIR/$tdir/d1/f1 of=/dev/null
10507 dd if=$DIR/$tdir/d2/f2 of=/dev/null
10508 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
10509 # XXX client can not do early lock cancel of OST lock
10510 # during rename (LU-4206), so cancel osc lock now.
10512 cancel_lru_locks osc
10513 can1=$(do_facet mds1 \
10514 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10515 awk '/ldlm_cancel/ {print $2}')
10516 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10517 awk '/ldlm_bl_callback/ {print $2}')
10518 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10520 can2=$(do_facet mds1 \
10521 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10522 awk '/ldlm_cancel/ {print $2}')
10523 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10524 awk '/ldlm_bl_callback/ {print $2}')
10525 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10526 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10527 lru_resize_enable mdc
10528 lru_resize_enable osc
10530 run_test 120f "Early Lock Cancel: rename test"
10533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10534 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10535 skip_env "no early lock cancel on server"
10536 remote_mds_nodsh && skip "remote MDS with nodsh"
10538 lru_resize_disable mdc
10539 lru_resize_disable osc
10541 echo create $count files
10542 test_mkdir $DIR/$tdir
10543 cancel_lru_locks mdc
10544 cancel_lru_locks osc
10547 can0=$(do_facet $SINGLEMDS \
10548 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10549 awk '/ldlm_cancel/ {print $2}')
10550 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10551 awk '/ldlm_bl_callback/ {print $2}')
10552 createmany -o $DIR/$tdir/f $count
10554 can1=$(do_facet $SINGLEMDS \
10555 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10556 awk '/ldlm_cancel/ {print $2}')
10557 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10558 awk '/ldlm_bl_callback/ {print $2}')
10560 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
10561 echo rm $count files
10564 can2=$(do_facet $SINGLEMDS \
10565 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10566 awk '/ldlm_cancel/ {print $2}')
10567 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10568 awk '/ldlm_bl_callback/ {print $2}')
10570 echo total: $count removes in $((t2-t1))
10571 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
10573 # wait for commitment of removal
10574 lru_resize_enable mdc
10575 lru_resize_enable osc
10577 run_test 120g "Early Lock Cancel: performance test"
10579 test_121() { #bug #10589
10580 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10583 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
10584 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
10585 lctl set_param fail_loc=0x310
10586 cancel_lru_locks osc > /dev/null
10587 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
10588 lctl set_param fail_loc=0
10589 [[ $reads -eq $writes ]] ||
10590 error "read $reads blocks, must be $writes blocks"
10592 run_test 121 "read cancel race ========="
10594 test_123a() { # was test 123, statahead(bug 11401)
10595 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10598 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
10599 log "testing UP system. Performance may be lower than expected."
10604 test_mkdir $DIR/$tdir
10605 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
10606 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
10608 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
10609 createmany -o $DIR/$tdir/$tfile $j $((i - j))
10611 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10612 lctl set_param -n llite.*.statahead_max 0
10613 lctl get_param llite.*.statahead_max
10614 cancel_lru_locks mdc
10615 cancel_lru_locks osc
10617 time ls -l $DIR/$tdir | wc -l
10619 delta=$((etime - stime))
10620 log "ls $i files without statahead: $delta sec"
10621 lctl set_param llite.*.statahead_max=$max
10623 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10624 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
10625 cancel_lru_locks mdc
10626 cancel_lru_locks osc
10628 time ls -l $DIR/$tdir | wc -l
10630 delta_sa=$((etime - stime))
10631 log "ls $i files with statahead: $delta_sa sec"
10632 lctl get_param -n llite.*.statahead_stats
10633 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10635 [[ $swrong -lt $ewrong ]] &&
10636 log "statahead was stopped, maybe too many locks held!"
10637 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
10639 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10640 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10641 lctl set_param -n llite.*.statahead_max 0
10642 lctl get_param llite.*.statahead_max
10643 cancel_lru_locks mdc
10644 cancel_lru_locks osc
10646 time ls -l $DIR/$tdir | wc -l
10648 delta=$((etime - stime))
10649 log "ls $i files again without statahead: $delta sec"
10650 lctl set_param llite.*.statahead_max=$max
10651 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10652 if [ $SLOWOK -eq 0 ]; then
10653 error "ls $i files is slower with statahead!"
10655 log "ls $i files is slower with statahead!"
10661 [ $delta -gt 20 ] && break
10662 [ $delta -gt 8 ] && MULT=$((50 / delta))
10663 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
10671 delta=$((etime - stime))
10672 log "rm -r $DIR/$tdir/: $delta seconds"
10674 lctl get_param -n llite.*.statahead_stats
10676 run_test 123a "verify statahead work"
10678 test_123b () { # statahead(bug 15027)
10679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10681 test_mkdir $DIR/$tdir
10682 createmany -o $DIR/$tdir/$tfile-%d 1000
10684 cancel_lru_locks mdc
10685 cancel_lru_locks osc
10687 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
10688 lctl set_param fail_loc=0x80000803
10689 ls -lR $DIR/$tdir > /dev/null
10691 lctl set_param fail_loc=0x0
10692 lctl get_param -n llite.*.statahead_stats
10697 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
10700 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10701 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10702 skip_env "no lru resize on server"
10706 test_mkdir $DIR/$tdir
10708 log "create $NR files at $DIR/$tdir"
10709 createmany -o $DIR/$tdir/f $NR ||
10710 error "failed to create $NR files in $DIR/$tdir"
10712 cancel_lru_locks mdc
10713 ls -l $DIR/$tdir > /dev/null
10717 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
10718 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
10719 LRU_SIZE=$($LCTL get_param -n $PARAM)
10720 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
10721 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
10723 log "NS=$(basename $NSDIR)"
10728 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
10729 skip "Not enough cached locks created!"
10731 log "LRU=$LRU_SIZE"
10735 # We know that lru resize allows one client to hold $LIMIT locks
10736 # for 10h. After that locks begin to be killed by client.
10738 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
10740 if [ $LIMIT -lt $LRU_SIZE ]; then
10741 skip "Limit is too small $LIMIT"
10744 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
10745 # killing locks. Some time was spent for creating locks. This means
10746 # that up to the moment of sleep finish we must have killed some of
10747 # them (10-100 locks). This depends on how fast ther were created.
10748 # Many of them were touched in almost the same moment and thus will
10749 # be killed in groups.
10750 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
10752 # Use $LRU_SIZE_B here to take into account real number of locks
10753 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
10754 local LRU_SIZE_B=$LRU_SIZE
10756 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
10757 log "OLD_LVF=$OLD_LVF"
10758 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
10760 # Let's make sure that we really have some margin. Client checks
10761 # cached locks every 10 sec.
10762 SLEEP=$((SLEEP+20))
10763 log "Sleep ${SLEEP} sec"
10765 while ((SEC<$SLEEP)); do
10769 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
10770 echo -n "$LRU_SIZE"
10773 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
10774 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
10776 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
10777 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
10778 unlinkmany $DIR/$tdir/f $NR
10782 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
10783 log "unlink $NR files at $DIR/$tdir"
10784 unlinkmany $DIR/$tdir/f $NR
10786 run_test 124a "lru resize ======================================="
10788 get_max_pool_limit()
10790 local limit=$($LCTL get_param \
10791 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
10793 for l in $limit; do
10794 if [[ $l -gt $max ]]; then
10802 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10803 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10804 skip_env "no lru resize on server"
10806 LIMIT=$(get_max_pool_limit)
10808 NR=$(($(default_lru_size)*20))
10809 if [[ $NR -gt $LIMIT ]]; then
10810 log "Limit lock number by $LIMIT locks"
10814 IFree=$(mdsrate_inodes_available)
10815 if [ $IFree -lt $NR ]; then
10816 log "Limit lock number by $IFree inodes"
10820 lru_resize_disable mdc
10821 test_mkdir -p $DIR/$tdir/disable_lru_resize
10823 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
10824 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
10825 cancel_lru_locks mdc
10828 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10831 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10834 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10838 nolruresize_delta=$((etime-stime))
10839 log "ls -la time: $nolruresize_delta seconds"
10840 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10841 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
10843 lru_resize_enable mdc
10844 test_mkdir -p $DIR/$tdir/enable_lru_resize
10846 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
10847 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
10848 cancel_lru_locks mdc
10851 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10854 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10857 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10861 lruresize_delta=$((etime-stime))
10862 log "ls -la time: $lruresize_delta seconds"
10863 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10865 if [ $lruresize_delta -gt $nolruresize_delta ]; then
10866 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
10867 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
10868 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
10870 log "lru resize performs the same with no lru resize"
10872 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
10874 run_test 124b "lru resize (performance test) ======================="
10877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10878 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10879 skip_env "no lru resize on server"
10881 # cache ununsed locks on client
10883 cancel_lru_locks mdc
10884 test_mkdir $DIR/$tdir
10885 createmany -o $DIR/$tdir/f $nr ||
10886 error "failed to create $nr files in $DIR/$tdir"
10887 ls -l $DIR/$tdir > /dev/null
10889 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10890 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10891 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10892 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10893 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10895 # set lru_max_age to 1 sec
10896 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10897 echo "sleep $((recalc_p * 2)) seconds..."
10898 sleep $((recalc_p * 2))
10900 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10901 # restore lru_max_age
10902 $LCTL set_param -n $nsdir.lru_max_age $max_age
10903 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10904 unlinkmany $DIR/$tdir/f $nr
10906 run_test 124c "LRUR cancel very aged locks"
10909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10910 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10911 skip_env "no lru resize on server"
10913 # cache ununsed locks on client
10916 lru_resize_disable mdc
10917 stack_trap "lru_resize_enable mdc" EXIT
10919 cancel_lru_locks mdc
10921 # asynchronous object destroy at MDT could cause bl ast to client
10922 test_mkdir $DIR/$tdir
10923 createmany -o $DIR/$tdir/f $nr ||
10924 error "failed to create $nr files in $DIR/$tdir"
10925 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
10927 ls -l $DIR/$tdir > /dev/null
10929 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10930 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10931 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10932 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10934 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10936 # set lru_max_age to 1 sec
10937 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10938 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
10940 echo "sleep $((recalc_p * 2)) seconds..."
10941 sleep $((recalc_p * 2))
10943 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10945 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10947 run_test 124d "cancel very aged locks if lru-resize diasbaled"
10949 test_125() { # 13358
10950 $LCTL get_param -n llite.*.client_type | grep -q local ||
10951 skip "must run as local client"
10952 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
10953 skip_env "must have acl enabled"
10954 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
10956 test_mkdir $DIR/$tdir
10957 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
10958 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
10959 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
10961 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
10963 test_126() { # bug 12829/13455
10964 $GSS && skip_env "must run as gss disabled"
10965 $LCTL get_param -n llite.*.client_type | grep -q local ||
10966 skip "must run as local client"
10967 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
10969 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
10970 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
10972 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
10974 run_test 126 "check that the fsgid provided by the client is taken into account"
10976 test_127a() { # bug 15521
10977 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10979 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
10980 $LCTL set_param osc.*.stats=0
10981 FSIZE=$((2048 * 1024))
10982 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10983 cancel_lru_locks osc
10984 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
10986 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
10987 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10988 echo "got $COUNT $NAME"
10989 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
10990 eval $NAME=$COUNT || error "Wrong proc format"
10993 read_bytes|write_bytes)
10994 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
10995 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
10996 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
10997 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
10998 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
10999 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
11000 error "sumsquare is too small: $SUMSQ"
11001 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
11002 error "sumsquare is too big: $SUMSQ"
11006 done < $DIR/${tfile}.tmp
11008 #check that we actually got some stats
11009 [ "$read_bytes" ] || error "Missing read_bytes stats"
11010 [ "$write_bytes" ] || error "Missing write_bytes stats"
11011 [ "$read_bytes" != 0 ] || error "no read done"
11012 [ "$write_bytes" != 0 ] || error "no write done"
11014 run_test 127a "verify the client stats are sane"
11016 test_127b() { # bug LU-333
11017 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11018 local name count samp unit min max sum sumsq
11020 $LCTL set_param llite.*.stats=0
11022 # perform 2 reads and writes so MAX is different from SUM.
11023 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11024 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11025 cancel_lru_locks osc
11026 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11027 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11029 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11030 while read name count samp unit min max sum sumsq; do
11031 echo "got $count $name"
11032 eval $name=$count || error "Wrong proc format"
11036 [ $count -ne 2 ] && error "count is not 2: $count"
11037 [ $min -ne $PAGE_SIZE ] &&
11038 error "min is not $PAGE_SIZE: $min"
11039 [ $max -ne $PAGE_SIZE ] &&
11040 error "max is incorrect: $max"
11041 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11042 error "sum is wrong: $sum"
11045 [ $count -ne 2 ] && error "count is not 2: $count"
11046 [ $min -ne $PAGE_SIZE ] &&
11047 error "min is not $PAGE_SIZE: $min"
11048 [ $max -ne $PAGE_SIZE ] &&
11049 error "max is incorrect: $max"
11050 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11051 error "sum is wrong: $sum"
11055 done < $TMP/$tfile.tmp
11057 #check that we actually got some stats
11058 [ "$read_bytes" ] || error "Missing read_bytes stats"
11059 [ "$write_bytes" ] || error "Missing write_bytes stats"
11060 [ "$read_bytes" != 0 ] || error "no read done"
11061 [ "$write_bytes" != 0 ] || error "no write done"
11063 rm -f $TMP/${tfile}.tmp
11065 run_test 127b "verify the llite client stats are sane"
11067 test_127c() { # LU-12394
11068 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11075 $LCTL set_param llite.*.extents_stats=1
11076 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
11078 # Use two stripes so there is enough space in default config
11079 $LFS setstripe -c 2 $DIR/$tfile
11081 # Extent stats start at 0-4K and go in power of two buckets
11082 # LL_HIST_START = 12 --> 2^12 = 4K
11083 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
11084 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
11086 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
11088 # Write and read, 2x each, second time at a non-zero offset
11089 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
11090 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
11091 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
11092 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
11096 $LCTL get_param llite.*.extents_stats
11099 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
11101 local bucket=$($LCTL get_param -n llite.*.extents_stats |
11103 reads=$(echo $bucket | awk '{print $5}')
11104 writes=$(echo $bucket | awk '{print $9}')
11105 [ "$reads" -eq $count ] ||
11106 error "$reads reads in < $bsize bucket, expect $count"
11107 [ "$writes" -eq $count ] ||
11108 error "$writes writes in < $bsize bucket, expect $count"
11111 # Test mmap write and read
11112 $LCTL set_param llite.*.extents_stats=c
11114 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
11115 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
11116 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
11118 $LCTL get_param llite.*.extents_stats
11120 count=$(((size*1024) / PAGE_SIZE))
11122 bsize=$((2 * PAGE_SIZE / 1024))K
11124 bucket=$($LCTL get_param -n llite.*.extents_stats |
11126 reads=$(echo $bucket | awk '{print $5}')
11127 writes=$(echo $bucket | awk '{print $9}')
11128 # mmap writes fault in the page first, creating an additonal read
11129 [ "$reads" -eq $((2 * count)) ] ||
11130 error "$reads reads in < $bsize bucket, expect $count"
11131 [ "$writes" -eq $count ] ||
11132 error "$writes writes in < $bsize bucket, expect $count"
11134 run_test 127c "test llite extent stats with regular & mmap i/o"
11136 test_128() { # bug 15212
11138 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
11143 result=$(grep error $TMP/$tfile.log)
11144 rm -f $DIR/$tfile $TMP/$tfile.log
11145 [ -z "$result" ] ||
11146 error "consecutive find's under interactive lfs failed"
11148 run_test 128 "interactive lfs for 2 consecutive find's"
11150 set_dir_limits () {
11155 local ldproc=/proc/fs/ldiskfs
11156 local facets=$(get_facets MDS)
11158 for facet in ${facets//,/ }; do
11159 canondev=$(ldiskfs_canon \
11160 *.$(convert_facet2label $facet).mntdev $facet)
11161 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
11162 ldproc=/sys/fs/ldiskfs
11163 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
11164 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
11168 check_mds_dmesg() {
11169 local facets=$(get_facets MDS)
11170 for facet in ${facets//,/ }; do
11171 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
11177 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11178 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
11179 skip "Need MDS version with at least 2.5.56"
11180 if [ "$mds1_FSTYPE" != ldiskfs ]; then
11181 skip_env "ldiskfs only test"
11183 remote_mds_nodsh && skip "remote MDS with nodsh"
11187 local has_warning=false
11190 mkdir -p $DIR/$tdir
11192 # block size of mds1
11193 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
11194 set_dir_limits $maxsize $maxsize
11195 local dirsize=$(stat -c%s "$DIR/$tdir")
11197 while [[ $dirsize -le $maxsize ]]; do
11198 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
11200 if ! $has_warning; then
11201 check_mds_dmesg '"is approaching"' && has_warning=true
11203 # check two errors:
11204 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
11205 # EFBIG for previous versions included in ldiskfs series
11206 if [ $rc -eq $EFBIG ] || [ $rc -eq $ENOSPC ]; then
11208 echo "return code $rc received as expected"
11210 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
11211 error_exit "create failed w/o dir size limit"
11213 check_mds_dmesg '"has reached"' ||
11214 error_exit "reached message should be output"
11216 [ $has_warning = "false" ] &&
11217 error_exit "warning message should be output"
11219 dirsize=$(stat -c%s "$DIR/$tdir")
11221 [[ $dirsize -ge $maxsize ]] && return 0
11222 error_exit "current dir size $dirsize, " \
11223 "previous limit $maxsize"
11224 elif [ $rc -ne 0 ]; then
11226 error_exit "return $rc received instead of expected " \
11227 "$EFBIG or $ENOSPC, files in dir $dirsize"
11229 nfiles=$((nfiles + 1))
11230 dirsize=$(stat -c%s "$DIR/$tdir")
11234 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
11236 run_test 129 "test directory size limit ========================"
11245 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11246 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11248 trap cleanup_130 EXIT RETURN
11250 local fm_file=$DIR/$tfile
11251 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
11252 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
11253 error "dd failed for $fm_file"
11255 # LU-1795: test filefrag/FIEMAP once, even if unsupported
11256 filefrag -ves $fm_file
11258 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11259 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11260 [ $RC != 0 ] && error "filefrag $fm_file failed"
11262 filefrag_op=$(filefrag -ve -k $fm_file |
11263 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11264 lun=$($LFS getstripe -i $fm_file)
11266 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
11269 for line in $filefrag_op
11271 frag_lun=`echo $line | cut -d: -f5`
11272 ext_len=`echo $line | cut -d: -f4`
11273 if (( $frag_lun != $lun )); then
11275 error "FIEMAP on 1-stripe file($fm_file) failed"
11278 (( tot_len += ext_len ))
11281 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
11283 error "FIEMAP on 1-stripe file($fm_file) failed;"
11289 echo "FIEMAP on single striped file succeeded"
11291 run_test 130a "FIEMAP (1-stripe file)"
11294 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11296 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11297 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11299 trap cleanup_130 EXIT RETURN
11301 local fm_file=$DIR/$tfile
11302 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
11303 error "setstripe on $fm_file"
11304 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11305 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11307 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
11308 error "dd failed on $fm_file"
11310 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11311 filefrag_op=$(filefrag -ve -k $fm_file |
11312 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11314 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11315 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11320 for line in $filefrag_op
11322 frag_lun=$(echo $line | cut -d: -f5 |
11323 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11324 ext_len=$(echo $line | cut -d: -f4)
11325 if (( $frag_lun != $last_lun )); then
11326 if (( tot_len != 1024 )); then
11328 error "FIEMAP on $fm_file failed; returned " \
11329 "len $tot_len for OST $last_lun instead of 1024"
11332 (( num_luns += 1 ))
11336 (( tot_len += ext_len ))
11339 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
11341 error "FIEMAP on $fm_file failed; returned wrong number of " \
11342 "luns or wrong len for OST $last_lun"
11348 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
11350 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
11353 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11355 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11356 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11358 trap cleanup_130 EXIT RETURN
11360 local fm_file=$DIR/$tfile
11361 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
11362 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11363 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11365 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
11366 error "dd failed on $fm_file"
11368 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11369 filefrag_op=$(filefrag -ve -k $fm_file |
11370 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11372 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11373 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11378 for line in $filefrag_op
11380 frag_lun=$(echo $line | cut -d: -f5 |
11381 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11382 ext_len=$(echo $line | cut -d: -f4)
11383 if (( $frag_lun != $last_lun )); then
11384 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
11385 if (( logical != 512 )); then
11387 error "FIEMAP on $fm_file failed; returned " \
11388 "logical start for lun $logical instead of 512"
11391 if (( tot_len != 512 )); then
11393 error "FIEMAP on $fm_file failed; returned " \
11394 "len $tot_len for OST $last_lun instead of 1024"
11397 (( num_luns += 1 ))
11401 (( tot_len += ext_len ))
11404 if (( num_luns != 2 || tot_len != 512 )); then
11406 error "FIEMAP on $fm_file failed; returned wrong number of " \
11407 "luns or wrong len for OST $last_lun"
11413 echo "FIEMAP on 2-stripe file with hole succeeded"
11415 run_test 130c "FIEMAP (2-stripe file with hole)"
11418 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
11420 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11421 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11423 trap cleanup_130 EXIT RETURN
11425 local fm_file=$DIR/$tfile
11426 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
11427 error "setstripe on $fm_file"
11428 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11429 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11431 local actual_stripe_count=$($LFS getstripe -c $fm_file)
11432 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
11433 error "dd failed on $fm_file"
11435 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11436 filefrag_op=$(filefrag -ve -k $fm_file |
11437 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11439 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11440 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11445 for line in $filefrag_op
11447 frag_lun=$(echo $line | cut -d: -f5 |
11448 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11449 ext_len=$(echo $line | cut -d: -f4)
11450 if (( $frag_lun != $last_lun )); then
11451 if (( tot_len != 1024 )); then
11453 error "FIEMAP on $fm_file failed; returned " \
11454 "len $tot_len for OST $last_lun instead of 1024"
11457 (( num_luns += 1 ))
11461 (( tot_len += ext_len ))
11464 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
11466 error "FIEMAP on $fm_file failed; returned wrong number of " \
11467 "luns or wrong len for OST $last_lun"
11473 echo "FIEMAP on N-stripe file succeeded"
11475 run_test 130d "FIEMAP (N-stripe file)"
11478 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11480 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11481 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11483 trap cleanup_130 EXIT RETURN
11485 local fm_file=$DIR/$tfile
11486 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
11487 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11488 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11491 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
11492 for ((i = 0; i < $NUM_BLKS; i++))
11494 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
11497 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11498 filefrag_op=$(filefrag -ve -k $fm_file |
11499 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11501 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11502 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11507 for line in $filefrag_op
11509 frag_lun=$(echo $line | cut -d: -f5 |
11510 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11511 ext_len=$(echo $line | cut -d: -f4)
11512 if (( $frag_lun != $last_lun )); then
11513 if (( tot_len != $EXPECTED_LEN )); then
11515 error "FIEMAP on $fm_file failed; returned " \
11516 "len $tot_len for OST $last_lun instead " \
11520 (( num_luns += 1 ))
11524 (( tot_len += ext_len ))
11527 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
11529 error "FIEMAP on $fm_file failed; returned wrong number " \
11530 "of luns or wrong len for OST $last_lun"
11536 echo "FIEMAP with continuation calls succeeded"
11538 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
11541 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11542 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11544 local fm_file=$DIR/$tfile
11545 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
11546 error "multiop create with lov_delay_create on $fm_file"
11548 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11549 filefrag_extents=$(filefrag -vek $fm_file |
11550 awk '/extents? found/ { print $2 }')
11551 if [[ "$filefrag_extents" != "0" ]]; then
11552 error "FIEMAP on $fm_file failed; " \
11553 "returned $filefrag_extents expected 0"
11558 run_test 130f "FIEMAP (unstriped file)"
11560 # Test for writev/readv
11562 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
11563 error "writev test failed"
11564 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
11565 error "readv failed"
11568 run_test 131a "test iov's crossing stripe boundary for writev/readv"
11571 local fsize=$((524288 + 1048576 + 1572864))
11572 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
11573 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11574 error "append writev test failed"
11576 ((fsize += 1572864 + 1048576))
11577 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
11578 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11579 error "append writev test failed"
11582 run_test 131b "test append writev"
11585 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
11588 run_test 131c "test read/write on file w/o objects"
11591 rwv -f $DIR/$tfile -w -n 1 1572864
11592 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
11593 if [ "$NOB" != 1572864 ]; then
11594 error "Short read filed: read $NOB bytes instead of 1572864"
11598 run_test 131d "test short read"
11601 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
11602 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
11603 error "read hitting hole failed"
11606 run_test 131e "test read hitting hole"
11615 mds*) res=$(do_facet $facet \
11616 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
11618 ost*) res=$(do_facet $facet \
11619 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
11621 *) error "Wrong facet '$facet'" ;;
11623 [ "$res" ] || error "The counter for $op on $facet was not incremented"
11624 # if the argument $3 is zero, it means any stat increment is ok.
11625 if [[ $want -gt 0 ]]; then
11626 local count=$(echo $res | awk '{ print $2 }')
11627 [[ $count -ne $want ]] &&
11628 error "The $op counter on $facet is $count, not $want"
11633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11634 remote_ost_nodsh && skip "remote OST with nodsh"
11635 remote_mds_nodsh && skip "remote MDS with nodsh"
11636 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11637 skip_env "MDS doesn't support rename stats"
11639 local testdir=$DIR/${tdir}/stats_testdir
11641 mkdir -p $DIR/${tdir}
11644 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11645 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11647 # verify mdt stats first.
11648 mkdir ${testdir} || error "mkdir failed"
11649 check_stats $SINGLEMDS "mkdir" 1
11650 touch ${testdir}/${tfile} || error "touch failed"
11651 check_stats $SINGLEMDS "open" 1
11652 check_stats $SINGLEMDS "close" 1
11653 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
11654 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
11655 check_stats $SINGLEMDS "mknod" 2
11657 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
11658 check_stats $SINGLEMDS "unlink" 1
11659 rm -f ${testdir}/${tfile} || error "file remove failed"
11660 check_stats $SINGLEMDS "unlink" 2
11662 # remove working dir and check mdt stats again.
11663 rmdir ${testdir} || error "rmdir failed"
11664 check_stats $SINGLEMDS "rmdir" 1
11666 local testdir1=$DIR/${tdir}/stats_testdir1
11667 mkdir -p ${testdir}
11668 mkdir -p ${testdir1}
11669 touch ${testdir1}/test1
11670 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
11671 check_stats $SINGLEMDS "crossdir_rename" 1
11673 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
11674 check_stats $SINGLEMDS "samedir_rename" 1
11676 rm -rf $DIR/${tdir}
11678 run_test 133a "Verifying MDT stats ========================================"
11683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11684 remote_ost_nodsh && skip "remote OST with nodsh"
11685 remote_mds_nodsh && skip "remote MDS with nodsh"
11687 local testdir=$DIR/${tdir}/stats_testdir
11689 mkdir -p ${testdir} || error "mkdir failed"
11690 touch ${testdir}/${tfile} || error "touch failed"
11691 cancel_lru_locks mdc
11694 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11695 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11697 # extra mdt stats verification.
11698 chmod 444 ${testdir}/${tfile} || error "chmod failed"
11699 check_stats $SINGLEMDS "setattr" 1
11700 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11701 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
11703 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
11704 check_stats $SINGLEMDS "getattr" 1
11706 rm -rf $DIR/${tdir}
11708 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
11709 # so the check below is not reliable
11710 [ $MDSCOUNT -eq 1 ] || return 0
11712 # Sleep to avoid a cached response.
11713 #define OBD_STATFS_CACHE_SECONDS 1
11715 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11716 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11717 $LFS df || error "lfs failed"
11718 check_stats $SINGLEMDS "statfs" 1
11720 # check aggregated statfs (LU-10018)
11721 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
11723 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
11726 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11727 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11729 check_stats $SINGLEMDS "statfs" 1
11731 # We want to check that the client didn't send OST_STATFS to
11732 # ost1 but the MDT also uses OST_STATFS for precreate. So some
11733 # extra care is needed here.
11734 if remote_mds; then
11735 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
11736 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
11738 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
11739 [ "$res" ] && error "OST got STATFS"
11744 run_test 133b "Verifying extra MDT stats =================================="
11747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11748 remote_ost_nodsh && skip "remote OST with nodsh"
11749 remote_mds_nodsh && skip "remote MDS with nodsh"
11751 local testdir=$DIR/$tdir/stats_testdir
11753 test_mkdir -p $testdir
11755 # verify obdfilter stats.
11756 $LFS setstripe -c 1 -i 0 $testdir/$tfile
11758 cancel_lru_locks osc
11759 wait_delete_completed
11762 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11763 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11765 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
11768 cancel_lru_locks osc
11769 check_stats ost1 "write" 1
11771 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
11772 check_stats ost1 "read" 1
11774 > $testdir/$tfile || error "truncate failed"
11775 check_stats ost1 "punch" 1
11777 rm -f $testdir/$tfile || error "file remove failed"
11778 wait_delete_completed
11779 check_stats ost1 "destroy" 1
11783 run_test 133c "Verifying OST stats ========================================"
11790 while [ $value -ge 2 ]; do
11795 if [ $orig -gt $order ]; then
11803 local size=('K' 'M' 'G' 'T');
11805 local size_string=$value
11807 while [ $value -ge 1024 ]; do
11808 if [ $i -gt 3 ]; then
11809 #T is the biggest unit we get here, if that is bigger,
11811 size_string=${value}T
11814 value=$((value >> 10))
11815 if [ $value -lt 1024 ]; then
11816 size_string=${value}${size[$i]}
11825 get_rename_size() {
11827 local context=${2:-.}
11828 local sample=$(do_facet $SINGLEMDS $LCTL \
11829 get_param mdt.$FSNAME-MDT0000.rename_stats |
11830 grep -A1 $context |
11831 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
11836 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11837 remote_ost_nodsh && skip "remote OST with nodsh"
11838 remote_mds_nodsh && skip "remote MDS with nodsh"
11839 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11840 skip_env "MDS doesn't support rename stats"
11842 local testdir1=$DIR/${tdir}/stats_testdir1
11843 local testdir2=$DIR/${tdir}/stats_testdir2
11844 mkdir -p $DIR/${tdir}
11846 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11848 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
11849 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
11851 createmany -o $testdir1/test 512 || error "createmany failed"
11853 # check samedir rename size
11854 mv ${testdir1}/test0 ${testdir1}/test_0
11856 local testdir1_size=$(ls -l $DIR/${tdir} |
11857 awk '/stats_testdir1/ {print $5}')
11858 local testdir2_size=$(ls -l $DIR/${tdir} |
11859 awk '/stats_testdir2/ {print $5}')
11861 testdir1_size=$(order_2 $testdir1_size)
11862 testdir2_size=$(order_2 $testdir2_size)
11864 testdir1_size=$(size_in_KMGT $testdir1_size)
11865 testdir2_size=$(size_in_KMGT $testdir2_size)
11867 echo "source rename dir size: ${testdir1_size}"
11868 echo "target rename dir size: ${testdir2_size}"
11870 local cmd="do_facet $SINGLEMDS $LCTL "
11871 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
11873 eval $cmd || error "$cmd failed"
11874 local samedir=$($cmd | grep 'same_dir')
11875 local same_sample=$(get_rename_size $testdir1_size)
11876 [ -z "$samedir" ] && error "samedir_rename_size count error"
11877 [[ $same_sample -eq 1 ]] ||
11878 error "samedir_rename_size error $same_sample"
11879 echo "Check same dir rename stats success"
11881 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11883 # check crossdir rename size
11884 mv ${testdir1}/test_0 ${testdir2}/test_0
11886 testdir1_size=$(ls -l $DIR/${tdir} |
11887 awk '/stats_testdir1/ {print $5}')
11888 testdir2_size=$(ls -l $DIR/${tdir} |
11889 awk '/stats_testdir2/ {print $5}')
11891 testdir1_size=$(order_2 $testdir1_size)
11892 testdir2_size=$(order_2 $testdir2_size)
11894 testdir1_size=$(size_in_KMGT $testdir1_size)
11895 testdir2_size=$(size_in_KMGT $testdir2_size)
11897 echo "source rename dir size: ${testdir1_size}"
11898 echo "target rename dir size: ${testdir2_size}"
11900 eval $cmd || error "$cmd failed"
11901 local crossdir=$($cmd | grep 'crossdir')
11902 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
11903 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
11904 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
11905 [[ $src_sample -eq 1 ]] ||
11906 error "crossdir_rename_size error $src_sample"
11907 [[ $tgt_sample -eq 1 ]] ||
11908 error "crossdir_rename_size error $tgt_sample"
11909 echo "Check cross dir rename stats success"
11910 rm -rf $DIR/${tdir}
11912 run_test 133d "Verifying rename_stats ========================================"
11915 remote_mds_nodsh && skip "remote MDS with nodsh"
11916 remote_ost_nodsh && skip "remote OST with nodsh"
11917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11919 local testdir=$DIR/${tdir}/stats_testdir
11920 local ctr f0 f1 bs=32768 count=42 sum
11922 mkdir -p ${testdir} || error "mkdir failed"
11924 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
11926 for ctr in {write,read}_bytes; do
11928 cancel_lru_locks osc
11930 do_facet ost1 $LCTL set_param -n \
11931 "obdfilter.*.exports.clear=clear"
11933 if [ $ctr = write_bytes ]; then
11935 f1=${testdir}/${tfile}
11937 f0=${testdir}/${tfile}
11941 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
11944 cancel_lru_locks osc
11946 sum=$(do_facet ost1 $LCTL get_param \
11947 "obdfilter.*.exports.*.stats" |
11948 awk -v ctr=$ctr 'BEGIN { sum = 0 }
11949 $1 == ctr { sum += $7 }
11950 END { printf("%0.0f", sum) }')
11952 if ((sum != bs * count)); then
11953 error "Bad $ctr sum, expected $((bs * count)), got $sum"
11957 rm -rf $DIR/${tdir}
11959 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
11961 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
11963 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
11964 # not honor the -ignore_readdir_race option correctly. So we call
11965 # error_ignore() rather than error() in these cases. See LU-11152.
11967 if (find --version; do_facet mds1 find --version) |
11968 grep -q '\b4\.5\.1[1-4]\b'; then
11969 error_ignore LU-11152 "$@"
11976 # First without trusting modes.
11977 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
11978 echo "proc_dirs='$proc_dirs'"
11979 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
11980 find $proc_dirs -exec cat '{}' \; &> /dev/null
11982 # Second verifying readability.
11983 $LCTL get_param -R '*' &> /dev/null
11985 # Verifing writability with badarea_io.
11987 -ignore_readdir_race \
11989 -not -name force_lbug \
11990 -not -name changelog_mask \
11991 -exec badarea_io '{}' \; ||
11992 error_133 "find $proc_dirs failed"
11994 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
11997 remote_mds_nodsh && skip "remote MDS with nodsh"
11998 remote_ost_nodsh && skip "remote OST with nodsh"
12000 # eventually, this can also be replaced with "lctl get_param -R",
12001 # but not until that option is always available on the server
12003 for facet in mds1 ost1; do
12004 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
12005 skip_noexit "Too old lustre on $facet"
12006 local facet_proc_dirs=$(do_facet $facet \
12007 \\\ls -d $proc_regexp 2>/dev/null)
12008 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12009 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12010 do_facet $facet find $facet_proc_dirs \
12011 ! -name req_history \
12012 -exec cat '{}' \\\; &> /dev/null
12014 do_facet $facet find $facet_proc_dirs \
12015 ! -name req_history \
12017 -exec cat '{}' \\\; &> /dev/null ||
12018 error "proc file read failed"
12020 do_facet $facet find $facet_proc_dirs \
12021 -ignore_readdir_race \
12023 -not -name force_lbug \
12024 -not -name changelog_mask \
12025 -exec badarea_io '{}' \\\; ||
12026 error_133 "$facet find $facet_proc_dirs failed"
12029 # remount the FS in case writes/reads /proc break the FS
12030 cleanup || error "failed to unmount"
12031 setup || error "failed to setup"
12034 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12037 remote_mds_nodsh && skip "remote MDS with nodsh"
12038 remote_ost_nodsh && skip "remote OST with nodsh"
12039 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12040 skip "Need MDS version at least 2.9.54"
12044 for facet in client mds1 ost1; do
12045 local facet_proc_dirs=$(do_facet $facet \
12046 \\\ls -d $proc_regexp 2> /dev/null)
12047 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12048 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12049 # Get the list of files that are missing the terminating newline
12050 local missing=($(do_facet $facet \
12051 find ${facet_proc_dirs} -type f \| \
12052 while read F\; do \
12053 awk -v FS='\v' -v RS='\v\v' \
12054 "'END { if(NR>0 && \
12055 \\\$NF !~ /.*\\\n\$/) \
12056 print FILENAME}'" \
12059 [ ${#missing[*]} -eq 0 ] ||
12060 error "files do not end with newline: ${missing[*]}"
12063 run_test 133h "Proc files should end with newlines"
12066 remote_mds_nodsh && skip "remote MDS with nodsh"
12067 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12068 skip "Need MDS version at least 2.7.54"
12070 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12071 cancel_lru_locks mdc
12073 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12074 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12075 [ $unused -eq 0 ] || error "$unused locks are not cleared"
12078 createmany -o $DIR/$tdir/f $nr ||
12079 error "failed to create $nr files in $DIR/$tdir"
12080 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12082 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
12083 do_facet mds1 $LCTL set_param fail_loc=0x327
12084 do_facet mds1 $LCTL set_param fail_val=500
12087 echo "sleep 10 seconds ..."
12089 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
12091 do_facet mds1 $LCTL set_param fail_loc=0
12092 do_facet mds1 $LCTL set_param fail_val=0
12093 [ $lck_cnt -lt $unused ] ||
12094 error "No locks reclaimed, before:$unused, after:$lck_cnt"
12097 unlinkmany $DIR/$tdir/f $nr
12099 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
12102 remote_mds_nodsh && skip "remote MDS with nodsh"
12103 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12104 skip "Need MDS version at least 2.7.54"
12106 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12107 cancel_lru_locks mdc
12109 local low_wm=$(do_facet mds1 $LCTL get_param -n \
12110 ldlm.lock_reclaim_threshold_mb)
12111 # disable reclaim temporarily
12112 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
12114 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
12115 do_facet mds1 $LCTL set_param fail_loc=0x328
12116 do_facet mds1 $LCTL set_param fail_val=500
12118 $LCTL set_param debug=+trace
12121 createmany -o $DIR/$tdir/f $nr &
12122 local create_pid=$!
12124 echo "Sleep $TIMEOUT seconds ..."
12126 if ! ps -p $create_pid > /dev/null 2>&1; then
12127 do_facet mds1 $LCTL set_param fail_loc=0
12128 do_facet mds1 $LCTL set_param fail_val=0
12129 do_facet mds1 $LCTL set_param \
12130 ldlm.lock_reclaim_threshold_mb=${low_wm}m
12131 error "createmany finished incorrectly!"
12133 do_facet mds1 $LCTL set_param fail_loc=0
12134 do_facet mds1 $LCTL set_param fail_val=0
12135 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
12136 wait $create_pid || return 1
12138 unlinkmany $DIR/$tdir/f $nr
12140 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
12142 test_140() { #bug-17379
12143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12145 test_mkdir $DIR/$tdir
12146 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
12147 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
12149 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
12150 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
12152 while i=$((i + 1)); do
12154 cd $i || error "Changing to $i"
12155 ln -s ../stat stat || error "Creating stat symlink"
12156 # Read the symlink until ELOOP present,
12157 # not LBUGing the system is considered success,
12158 # we didn't overrun the stack.
12159 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
12160 if [ $ret -ne 0 ]; then
12161 if [ $ret -eq 40 ]; then
12164 error "Open stat symlink"
12170 echo "The symlink depth = $i"
12171 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
12172 error "Invalid symlink depth"
12174 # Test recursive symlink
12175 ln -s symlink_self symlink_self
12176 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
12177 echo "open symlink_self returns $ret"
12178 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
12180 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
12183 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12185 local TF="$TMP/$tfile"
12187 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12189 cancel_lru_locks $OSC
12190 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
12191 remount_client $MOUNT
12193 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
12196 $TRUNCATE $DIR/$tfile 6000
12197 cancel_lru_locks $OSC
12198 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
12201 echo "12345" >>$DIR/$tfile
12202 cancel_lru_locks $OSC
12203 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
12206 echo "12345" >>$DIR/$tfile
12207 cancel_lru_locks $OSC
12208 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
12213 run_test 150 "truncate/append tests"
12215 #LU-2902 roc_hit was not able to read all values from lproc
12216 function roc_hit_init() {
12217 local list=$(comma_list $(osts_nodes))
12218 local dir=$DIR/$tdir-check
12219 local file=$dir/$tfile
12225 #use setstripe to do a write to every ost
12226 for i in $(seq 0 $((OSTCOUNT-1))); do
12227 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
12228 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
12229 idx=$(printf %04x $i)
12230 BEFORE=$(get_osd_param $list *OST*$idx stats |
12231 awk '$1 == "cache_access" {sum += $7}
12232 END { printf("%0.0f", sum) }')
12234 cancel_lru_locks osc
12235 cat $file >/dev/null
12237 AFTER=$(get_osd_param $list *OST*$idx stats |
12238 awk '$1 == "cache_access" {sum += $7}
12239 END { printf("%0.0f", sum) }')
12241 echo BEFORE:$BEFORE AFTER:$AFTER
12242 if ! let "AFTER - BEFORE == 4"; then
12244 error "roc_hit is not safe to use"
12252 function roc_hit() {
12253 local list=$(comma_list $(osts_nodes))
12254 echo $(get_osd_param $list '' stats |
12255 awk '$1 == "cache_hit" {sum += $7}
12256 END { printf("%0.0f", sum) }')
12259 function set_cache() {
12262 if [ "$2" == "off" ]; then
12265 local list=$(comma_list $(osts_nodes))
12266 set_osd_param $list '' $1_cache_enable $on
12268 cancel_lru_locks osc
12272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12273 remote_ost_nodsh && skip "remote OST with nodsh"
12276 local list=$(comma_list $(osts_nodes))
12278 # check whether obdfilter is cache capable at all
12279 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
12280 skip "not cache-capable obdfilter"
12283 # check cache is enabled on all obdfilters
12284 if get_osd_param $list '' read_cache_enable | grep 0; then
12285 skip "oss cache is disabled"
12288 set_osd_param $list '' writethrough_cache_enable 1
12290 # check write cache is enabled on all obdfilters
12291 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
12292 skip "oss write cache is NOT enabled"
12297 #define OBD_FAIL_OBD_NO_LRU 0x609
12298 do_nodes $list $LCTL set_param fail_loc=0x609
12300 # pages should be in the case right after write
12301 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
12304 local BEFORE=$(roc_hit)
12305 cancel_lru_locks osc
12306 cat $DIR/$tfile >/dev/null
12307 local AFTER=$(roc_hit)
12309 do_nodes $list $LCTL set_param fail_loc=0
12311 if ! let "AFTER - BEFORE == CPAGES"; then
12312 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12315 # the following read invalidates the cache
12316 cancel_lru_locks osc
12317 set_osd_param $list '' read_cache_enable 0
12318 cat $DIR/$tfile >/dev/null
12320 # now data shouldn't be found in the cache
12322 cancel_lru_locks osc
12323 cat $DIR/$tfile >/dev/null
12325 if let "AFTER - BEFORE != 0"; then
12326 error "IN CACHE: before: $BEFORE, after: $AFTER"
12329 set_osd_param $list '' read_cache_enable 1
12332 run_test 151 "test cache on oss and controls ==============================="
12335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12337 local TF="$TMP/$tfile"
12339 # simulate ENOMEM during write
12340 #define OBD_FAIL_OST_NOMEM 0x226
12341 lctl set_param fail_loc=0x80000226
12342 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12344 sync || error "sync failed"
12345 lctl set_param fail_loc=0
12347 # discard client's cache
12348 cancel_lru_locks osc
12350 # simulate ENOMEM during read
12351 lctl set_param fail_loc=0x80000226
12352 cmp $TF $DIR/$tfile || error "cmp failed"
12353 lctl set_param fail_loc=0
12357 run_test 152 "test read/write with enomem ============================"
12360 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
12362 run_test 153 "test if fdatasync does not crash ======================="
12364 dot_lustre_fid_permission_check() {
12366 local ffid=$MOUNT/.lustre/fid/$fid
12369 echo "stat fid $fid"
12370 stat $ffid > /dev/null || error "stat $ffid failed."
12371 echo "touch fid $fid"
12372 touch $ffid || error "touch $ffid failed."
12373 echo "write to fid $fid"
12374 cat /etc/hosts > $ffid || error "write $ffid failed."
12375 echo "read fid $fid"
12376 diff /etc/hosts $ffid || error "read $ffid failed."
12377 echo "append write to fid $fid"
12378 cat /etc/hosts >> $ffid || error "append write $ffid failed."
12379 echo "rename fid $fid"
12380 mv $ffid $test_dir/$tfile.1 &&
12381 error "rename $ffid to $tfile.1 should fail."
12382 touch $test_dir/$tfile.1
12383 mv $test_dir/$tfile.1 $ffid &&
12384 error "rename $tfile.1 to $ffid should fail."
12385 rm -f $test_dir/$tfile.1
12386 echo "truncate fid $fid"
12387 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
12388 echo "link fid $fid"
12389 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
12390 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
12391 echo "setfacl fid $fid"
12392 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
12393 echo "getfacl fid $fid"
12394 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
12396 echo "unlink fid $fid"
12397 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
12398 echo "mknod fid $fid"
12399 mknod $ffid c 1 3 && error "mknod $ffid should fail."
12401 fid=[0xf00000400:0x1:0x0]
12402 ffid=$MOUNT/.lustre/fid/$fid
12404 echo "stat non-exist fid $fid"
12405 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
12406 echo "write to non-exist fid $fid"
12407 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
12408 echo "link new fid $fid"
12409 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
12411 mkdir -p $test_dir/$tdir
12412 touch $test_dir/$tdir/$tfile
12413 fid=$($LFS path2fid $test_dir/$tdir)
12416 error "error: could not get fid for $test_dir/$dir/$tfile."
12418 ffid=$MOUNT/.lustre/fid/$fid
12421 ls $ffid > /dev/null || error "ls $ffid failed."
12422 echo "touch $fid/$tfile.1"
12423 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
12425 echo "touch $MOUNT/.lustre/fid/$tfile"
12426 touch $MOUNT/.lustre/fid/$tfile && \
12427 error "touch $MOUNT/.lustre/fid/$tfile should fail."
12429 echo "setxattr to $MOUNT/.lustre/fid"
12430 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
12432 echo "listxattr for $MOUNT/.lustre/fid"
12433 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
12435 echo "delxattr from $MOUNT/.lustre/fid"
12436 setfattr -x trusted.name1 $MOUNT/.lustre/fid
12438 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
12439 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
12440 error "touch invalid fid should fail."
12442 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
12443 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
12444 error "touch non-normal fid should fail."
12446 echo "rename $tdir to $MOUNT/.lustre/fid"
12447 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
12448 error "rename to $MOUNT/.lustre/fid should fail."
12450 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
12452 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
12453 local new_obf_mode=777
12455 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
12456 chmod $new_obf_mode $DIR/.lustre/fid ||
12457 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
12459 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
12460 [ $obf_mode -eq $new_obf_mode ] ||
12461 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
12463 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
12464 chmod $old_obf_mode $DIR/.lustre/fid ||
12465 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
12468 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
12469 fid=$($LFS path2fid $test_dir/$tfile-2)
12471 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
12473 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
12474 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
12475 error "create lov data thru .lustre failed"
12477 echo "cp /etc/passwd $test_dir/$tfile-2"
12478 cp /etc/passwd $test_dir/$tfile-2 ||
12479 error "copy to $test_dir/$tfile-2 failed."
12480 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
12481 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
12482 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
12484 rm -rf $test_dir/tfile.lnk
12485 rm -rf $test_dir/$tfile-2
12489 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12490 skip "Need MDS version at least 2.4.1"
12492 local tf=$DIR/$tfile
12495 local fid=$($LFS path2fid $tf)
12496 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
12498 # check that we get the same pathname back
12499 local found=$($LFS fid2path $MOUNT "$fid")
12500 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
12501 [ "$found" == "$tf" ] ||
12502 error "fid2path($fid=path2fid($tf)) = $found != $tf"
12504 run_test 154A "lfs path2fid and fid2path basic checks"
12507 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12508 skip "Need MDS version at least 2.4.1"
12510 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
12511 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
12512 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
12513 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
12515 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
12516 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
12518 # check that we get the same pathname
12519 echo "PFID: $PFID, name: $name"
12520 local FOUND=$($LFS fid2path $MOUNT "$PFID")
12521 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
12522 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
12523 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
12525 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
12527 run_test 154B "verify the ll_decode_linkea tool"
12530 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12531 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12532 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12533 skip "Need MDS version at least 2.2.51"
12534 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12536 cp /etc/hosts $DIR/$tfile
12538 fid=$($LFS path2fid $DIR/$tfile)
12540 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
12542 dot_lustre_fid_permission_check "$fid" $DIR ||
12543 error "dot lustre permission check $fid failed"
12545 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
12547 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
12549 touch $MOUNT/.lustre/file &&
12550 error "creation is not allowed under .lustre"
12552 mkdir $MOUNT/.lustre/dir &&
12553 error "mkdir is not allowed under .lustre"
12557 run_test 154a "Open-by-FID"
12560 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12561 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12562 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12563 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12564 skip "Need MDS version at least 2.2.51"
12566 local remote_dir=$DIR/$tdir/remote_dir
12570 mkdir -p $DIR/$tdir
12571 $LFS mkdir -i $MDTIDX $remote_dir ||
12572 error "create remote directory failed"
12574 cp /etc/hosts $remote_dir/$tfile
12576 fid=$($LFS path2fid $remote_dir/$tfile)
12578 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
12580 dot_lustre_fid_permission_check "$fid" $remote_dir ||
12581 error "dot lustre permission check $fid failed"
12584 run_test 154b "Open-by-FID for remote directory"
12587 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12588 skip "Need MDS version at least 2.4.1"
12590 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
12591 local FID1=$($LFS path2fid $DIR/$tfile.1)
12592 local FID2=$($LFS path2fid $DIR/$tfile.2)
12593 local FID3=$($LFS path2fid $DIR/$tfile.3)
12596 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
12597 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
12598 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
12600 [ "$FID" = "${!want}" ] ||
12601 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
12605 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
12607 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
12608 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
12612 run_test 154c "lfs path2fid and fid2path multiple arguments"
12615 remote_mds_nodsh && skip "remote MDS with nodsh"
12616 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
12617 skip "Need MDS version at least 2.5.53"
12619 if remote_mds; then
12620 nid=$($LCTL list_nids | sed "s/\./\\\./g")
12624 local proc_ofile="mdt.*.exports.'$nid'.open_files"
12631 local fid=$($LFS path2fid $DIR/$tfile)
12634 cmd="exec $fd<$DIR/$tfile"
12636 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
12637 echo "$fid_list" | grep "$fid"
12640 cmd="exec $fd>/dev/null"
12642 if [ $rc -ne 0 ]; then
12643 error "FID $fid not found in open files list $fid_list"
12646 run_test 154d "Verify open file fid"
12650 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
12651 skip "Need MDS version at least 2.6.50"
12653 if ls -a $MOUNT | grep -q '^\.lustre$'; then
12654 error ".lustre returned by readdir"
12657 run_test 154e ".lustre is not returned by readdir"
12660 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12662 # create parent directory on a single MDT to avoid cross-MDT hardlinks
12663 test_mkdir -p -c1 $DIR/$tdir/d
12664 # test dirs inherit from its stripe
12665 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
12666 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
12667 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
12668 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
12671 # get fid of parents
12672 local FID0=$($LFS path2fid $DIR/$tdir/d)
12673 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
12674 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
12675 local FID3=$($LFS path2fid $DIR)
12677 # check that path2fid --parents returns expected <parent_fid>/name
12678 # 1) test for a directory (single parent)
12679 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
12680 [ "$parent" == "$FID0/foo1" ] ||
12681 error "expected parent: $FID0/foo1, got: $parent"
12683 # 2) test for a file with nlink > 1 (multiple parents)
12684 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
12685 echo "$parent" | grep -F "$FID1/$tfile" ||
12686 error "$FID1/$tfile not returned in parent list"
12687 echo "$parent" | grep -F "$FID2/link" ||
12688 error "$FID2/link not returned in parent list"
12690 # 3) get parent by fid
12691 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
12692 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12693 echo "$parent" | grep -F "$FID1/$tfile" ||
12694 error "$FID1/$tfile not returned in parent list (by fid)"
12695 echo "$parent" | grep -F "$FID2/link" ||
12696 error "$FID2/link not returned in parent list (by fid)"
12698 # 4) test for entry in root directory
12699 parent=$($LFS path2fid --parents $DIR/f)
12700 echo "$parent" | grep -F "$FID3/f" ||
12701 error "$FID3/f not returned in parent list"
12703 # 5) test it on root directory
12704 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
12705 error "$MOUNT should not have parents"
12707 # enable xattr caching and check that linkea is correctly updated
12708 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12709 save_lustre_params client "llite.*.xattr_cache" > $save
12710 lctl set_param llite.*.xattr_cache 1
12712 # 6.1) linkea update on rename
12713 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
12715 # get parents by fid
12716 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12717 # foo1 should no longer be returned in parent list
12718 echo "$parent" | grep -F "$FID1" &&
12719 error "$FID1 should no longer be in parent list"
12720 # the new path should appear
12721 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
12722 error "$FID2/$tfile.moved is not in parent list"
12724 # 6.2) linkea update on unlink
12725 rm -f $DIR/$tdir/d/foo2/link
12726 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12727 # foo2/link should no longer be returned in parent list
12728 echo "$parent" | grep -F "$FID2/link" &&
12729 error "$FID2/link should no longer be in parent list"
12733 restore_lustre_params < $save
12736 run_test 154f "get parent fids by reading link ea"
12740 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12741 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
12742 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
12743 skip "Need MDS version at least 2.6.92"
12745 mkdir -p $DIR/$tdir
12746 llapi_fid_test -d $DIR/$tdir
12748 run_test 154g "various llapi FID tests"
12750 test_155_small_load() {
12751 local temp=$TMP/$tfile
12752 local file=$DIR/$tfile
12754 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
12755 error "dd of=$temp bs=6096 count=1 failed"
12757 cancel_lru_locks $OSC
12758 cmp $temp $file || error "$temp $file differ"
12760 $TRUNCATE $temp 6000
12761 $TRUNCATE $file 6000
12762 cmp $temp $file || error "$temp $file differ (truncate1)"
12764 echo "12345" >>$temp
12765 echo "12345" >>$file
12766 cmp $temp $file || error "$temp $file differ (append1)"
12768 echo "12345" >>$temp
12769 echo "12345" >>$file
12770 cmp $temp $file || error "$temp $file differ (append2)"
12776 test_155_big_load() {
12777 remote_ost_nodsh && skip "remote OST with nodsh"
12779 local temp=$TMP/$tfile
12780 local file=$DIR/$tfile
12783 local cache_size=$(do_facet ost$((MAXI+1)) \
12784 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
12785 local large_file_size=$((cache_size * 2))
12787 echo "OSS cache size: $cache_size KB"
12788 echo "Large file size: $large_file_size KB"
12790 [ $MAXV -le $large_file_size ] &&
12791 skip_env "max available OST size needs > $large_file_size KB"
12793 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
12795 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
12796 error "dd of=$temp bs=$large_file_size count=1k failed"
12799 cancel_lru_locks osc
12800 cmp $temp $file || error "$temp $file differ"
12806 save_writethrough() {
12807 local facets=$(get_facets OST)
12809 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
12813 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12815 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12817 save_writethrough $p
12820 set_cache writethrough on
12821 test_155_small_load
12822 restore_lustre_params < $p
12825 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
12828 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12830 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12832 save_writethrough $p
12835 set_cache writethrough off
12836 test_155_small_load
12837 restore_lustre_params < $p
12840 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
12843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12845 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12847 save_writethrough $p
12850 set_cache writethrough on
12851 test_155_small_load
12852 restore_lustre_params < $p
12855 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
12858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12860 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12862 save_writethrough $p
12865 set_cache writethrough off
12866 test_155_small_load
12867 restore_lustre_params < $p
12870 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
12873 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12875 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12877 save_writethrough $p
12880 set_cache writethrough on
12882 restore_lustre_params < $p
12885 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
12888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12890 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12892 save_writethrough $p
12895 set_cache writethrough off
12897 restore_lustre_params < $p
12900 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
12903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12905 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12907 save_writethrough $p
12910 set_cache writethrough on
12912 restore_lustre_params < $p
12915 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
12918 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12920 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12922 save_writethrough $p
12925 set_cache writethrough off
12927 restore_lustre_params < $p
12930 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
12933 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12934 remote_ost_nodsh && skip "remote OST with nodsh"
12935 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
12936 skip "stats not implemented on old servers"
12937 [ "$ost1_FSTYPE" = "zfs" ] &&
12938 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
12943 local file="$DIR/$tfile"
12944 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12946 save_writethrough $p
12949 log "Turn on read and write cache"
12951 set_cache writethrough on
12953 log "Write data and read it back."
12954 log "Read should be satisfied from the cache."
12955 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12957 cancel_lru_locks osc
12958 cat $file >/dev/null
12960 if ! let "AFTER - BEFORE == CPAGES"; then
12961 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12963 log "cache hits:: before: $BEFORE, after: $AFTER"
12966 log "Read again; it should be satisfied from the cache."
12968 cancel_lru_locks osc
12969 cat $file >/dev/null
12971 if ! let "AFTER - BEFORE == CPAGES"; then
12972 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12974 log "cache hits:: before: $BEFORE, after: $AFTER"
12977 log "Turn off the read cache and turn on the write cache"
12979 set_cache writethrough on
12981 log "Read again; it should be satisfied from the cache."
12983 cancel_lru_locks osc
12984 cat $file >/dev/null
12986 if ! let "AFTER - BEFORE == CPAGES"; then
12987 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12989 log "cache hits:: before: $BEFORE, after: $AFTER"
12992 log "Read again; it should not be satisfied from the cache."
12994 cancel_lru_locks osc
12995 cat $file >/dev/null
12997 if ! let "AFTER - BEFORE == 0"; then
12998 error "IN CACHE: before: $BEFORE, after: $AFTER"
13000 log "cache hits:: before: $BEFORE, after: $AFTER"
13003 log "Write data and read it back."
13004 log "Read should be satisfied from the cache."
13005 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13007 cancel_lru_locks osc
13008 cat $file >/dev/null
13010 if ! let "AFTER - BEFORE == CPAGES"; then
13011 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13013 log "cache hits:: before: $BEFORE, after: $AFTER"
13016 log "Read again; it should not be satisfied from the cache."
13018 cancel_lru_locks osc
13019 cat $file >/dev/null
13021 if ! let "AFTER - BEFORE == 0"; then
13022 error "IN CACHE: before: $BEFORE, after: $AFTER"
13024 log "cache hits:: before: $BEFORE, after: $AFTER"
13027 log "Turn off read and write cache"
13029 set_cache writethrough off
13031 log "Write data and read it back"
13032 log "It should not be satisfied from the cache."
13034 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13035 cancel_lru_locks osc
13037 cat $file >/dev/null
13039 if ! let "AFTER - BEFORE == 0"; then
13040 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13042 log "cache hits:: before: $BEFORE, after: $AFTER"
13045 log "Turn on the read cache and turn off the write cache"
13047 set_cache writethrough off
13049 log "Write data and read it back"
13050 log "It should not be satisfied from the cache."
13052 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13054 cancel_lru_locks osc
13055 cat $file >/dev/null
13057 if ! let "AFTER - BEFORE == 0"; then
13058 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13060 log "cache hits:: before: $BEFORE, after: $AFTER"
13063 log "Read again; it should be satisfied from the cache."
13065 cancel_lru_locks osc
13066 cat $file >/dev/null
13068 if ! let "AFTER - BEFORE == CPAGES"; then
13069 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13071 log "cache hits:: before: $BEFORE, after: $AFTER"
13074 restore_lustre_params < $p
13077 run_test 156 "Verification of tunables"
13080 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13081 remote_mds_nodsh && skip "remote MDS with nodsh"
13082 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13083 skip "Need MDS version at least 2.2.0"
13085 changelog_register || error "changelog_register failed"
13086 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13087 changelog_users $SINGLEMDS | grep -q $cl_user ||
13088 error "User $cl_user not found in changelog_users"
13091 test_mkdir -p $DIR/$tdir/pics/2008/zachy
13092 changelog_clear 0 || error "changelog_clear failed"
13093 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
13094 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
13095 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
13096 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
13097 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
13098 rm $DIR/$tdir/pics/desktop.jpg
13100 changelog_dump | tail -10
13102 echo "verifying changelog mask"
13103 changelog_chmask "-MKDIR"
13104 changelog_chmask "-CLOSE"
13106 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
13107 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
13109 changelog_chmask "+MKDIR"
13110 changelog_chmask "+CLOSE"
13112 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
13113 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
13115 changelog_dump | tail -10
13116 MKDIRS=$(changelog_dump | grep -c "MKDIR")
13117 CLOSES=$(changelog_dump | grep -c "CLOSE")
13118 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
13119 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
13122 echo "verifying target fid"
13123 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
13124 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
13125 [ "$fidc" == "$fidf" ] ||
13126 error "changelog '$tfile' fid $fidc != file fid $fidf"
13127 echo "verifying parent fid"
13128 # The FID returned from the Changelog may be the directory shard on
13129 # a different MDT, and not the FID returned by path2fid on the parent.
13130 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
13131 # since this is what will matter when recreating this file in the tree.
13132 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
13133 local pathp=$($LFS fid2path $MOUNT "$fidp")
13134 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
13135 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
13137 echo "getting records for $cl_user"
13138 changelog_users $SINGLEMDS
13139 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
13141 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
13142 error "changelog_clear failed"
13143 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
13144 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
13145 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
13146 error "user index expect $user_rec1 + $nclr != $user_rec2"
13148 local min0_rec=$(changelog_users $SINGLEMDS |
13149 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
13150 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
13151 awk '{ print $1; exit; }')
13153 changelog_dump | tail -n 5
13154 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
13155 [ $first_rec == $((min0_rec + 1)) ] ||
13156 error "first index should be $min0_rec + 1 not $first_rec"
13158 # LU-3446 changelog index reset on MDT restart
13159 local cur_rec1=$(changelog_users $SINGLEMDS |
13160 awk '/^current.index:/ { print $NF }')
13161 changelog_clear 0 ||
13162 error "clear all changelog records for $cl_user failed"
13163 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
13164 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
13165 error "Fail to start $SINGLEMDS"
13166 local cur_rec2=$(changelog_users $SINGLEMDS |
13167 awk '/^current.index:/ { print $NF }')
13168 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
13169 [ $cur_rec1 == $cur_rec2 ] ||
13170 error "current index should be $cur_rec1 not $cur_rec2"
13172 echo "verifying users from this test are deregistered"
13173 changelog_deregister || error "changelog_deregister failed"
13174 changelog_users $SINGLEMDS | grep -q $cl_user &&
13175 error "User '$cl_user' still in changelog_users"
13177 # lctl get_param -n mdd.*.changelog_users
13178 # current index: 144
13179 # ID index (idle seconds)
13181 if ! changelog_users $SINGLEMDS | grep "^cl"; then
13182 # this is the normal case where all users were deregistered
13183 # make sure no new records are added when no users are present
13184 local last_rec1=$(changelog_users $SINGLEMDS |
13185 awk '/^current.index:/ { print $NF }')
13186 touch $DIR/$tdir/chloe
13187 local last_rec2=$(changelog_users $SINGLEMDS |
13188 awk '/^current.index:/ { print $NF }')
13189 echo "verify changelogs are off: $last_rec1 == $last_rec2"
13190 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
13192 # any changelog users must be leftovers from a previous test
13193 changelog_users $SINGLEMDS
13194 echo "other changelog users; can't verify off"
13197 run_test 160a "changelog sanity"
13199 test_160b() { # LU-3587
13200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13201 remote_mds_nodsh && skip "remote MDS with nodsh"
13202 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13203 skip "Need MDS version at least 2.2.0"
13205 changelog_register || error "changelog_register failed"
13206 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13207 changelog_users $SINGLEMDS | grep -q $cl_user ||
13208 error "User '$cl_user' not found in changelog_users"
13210 local longname1=$(str_repeat a 255)
13211 local longname2=$(str_repeat b 255)
13214 echo "creating very long named file"
13215 touch $longname1 || error "create of '$longname1' failed"
13216 echo "renaming very long named file"
13217 mv $longname1 $longname2
13219 changelog_dump | grep RENME | tail -n 5
13222 run_test 160b "Verify that very long rename doesn't crash in changelog"
13225 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13226 remote_mds_nodsh && skip "remote MDS with nodsh"
13228 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
13229 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
13230 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
13231 skip "Need MDS version at least 2.5.58 or 2.5.2+"
13235 # Registration step
13236 changelog_register || error "changelog_register failed"
13239 mkdir -p $DIR/$tdir
13240 $MCREATE $DIR/$tdir/foo_160c
13241 changelog_chmask "-TRUNC"
13242 $TRUNCATE $DIR/$tdir/foo_160c 200
13243 changelog_chmask "+TRUNC"
13244 $TRUNCATE $DIR/$tdir/foo_160c 199
13245 changelog_dump | tail -n 5
13246 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
13247 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
13249 run_test 160c "verify that changelog log catch the truncate event"
13252 remote_mds_nodsh && skip "remote MDS with nodsh"
13253 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13254 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13255 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
13256 skip "Need MDS version at least 2.7.60"
13258 # Registration step
13259 changelog_register || error "changelog_register failed"
13261 mkdir -p $DIR/$tdir/migrate_dir
13262 changelog_clear 0 || error "changelog_clear failed"
13264 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
13265 changelog_dump | tail -n 5
13266 local migrates=$(changelog_dump | grep -c "MIGRT")
13267 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
13269 run_test 160d "verify that changelog log catch the migrate event"
13272 remote_mds_nodsh && skip "remote MDS with nodsh"
13275 changelog_register || error "changelog_register failed"
13277 # Delete a future user (expect fail)
13278 local MDT0=$(facet_svc $SINGLEMDS)
13279 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
13282 if [ $rc -eq 0 ]; then
13283 error "Deleted non-existant user cl77"
13284 elif [ $rc -ne 2 ]; then
13285 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
13288 # Clear to a bad index (1 billion should be safe)
13289 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
13292 if [ $rc -eq 0 ]; then
13293 error "Successfully cleared to invalid CL index"
13294 elif [ $rc -ne 22 ]; then
13295 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
13298 run_test 160e "changelog negative testing (should return errors)"
13301 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13302 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13303 skip "Need MDS version at least 2.10.56"
13305 local mdts=$(comma_list $(mdts_nodes))
13308 changelog_register || error "first changelog_register failed"
13309 changelog_register || error "second changelog_register failed"
13311 declare -A cl_user1
13312 declare -A cl_user2
13317 # generate some changelog records to accumulate on each MDT
13318 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13319 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13320 error "create $DIR/$tdir/$tfile failed"
13322 # check changelogs have been generated
13323 local nbcl=$(changelog_dump | wc -l)
13324 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13326 for param in "changelog_max_idle_time=10" \
13328 "changelog_min_gc_interval=2" \
13329 "changelog_min_free_cat_entries=3"; do
13330 local MDT0=$(facet_svc $SINGLEMDS)
13331 local var="${param%=*}"
13332 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13334 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13335 do_nodes $mdts $LCTL set_param mdd.*.$param
13338 # force cl_user2 to be idle (1st part)
13341 # simulate changelog catalog almost full
13342 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13343 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13345 for i in $(seq $MDSCOUNT); do
13346 cl_users=(${CL_USERS[mds$i]})
13347 cl_user1[mds$i]="${cl_users[0]}"
13348 cl_user2[mds$i]="${cl_users[1]}"
13350 [ -n "${cl_user1[mds$i]}" ] ||
13351 error "mds$i: no user registered"
13352 [ -n "${cl_user2[mds$i]}" ] ||
13353 error "mds$i: only ${cl_user2[mds$i]} is registered"
13355 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13356 [ -n "$user_rec1" ] ||
13357 error "mds$i: User ${cl_user1[mds$i]} not registered"
13358 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13359 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13360 [ -n "$user_rec2" ] ||
13361 error "mds$i: User ${cl_user1[mds$i]} not registered"
13362 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13363 "$user_rec1 + 2 == $user_rec2"
13364 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13365 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13366 "$user_rec1 + 2, but is $user_rec2"
13367 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13368 [ -n "$user_rec2" ] ||
13369 error "mds$i: User ${cl_user2[mds$i]} not registered"
13370 [ $user_rec1 == $user_rec2 ] ||
13371 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13372 "$user_rec1, but is $user_rec2"
13375 # force cl_user2 to be idle (2nd part) and to reach
13376 # changelog_max_idle_time
13379 # generate one more changelog to trigger fail_loc
13380 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13381 error "create $DIR/$tdir/${tfile}bis failed"
13383 # ensure gc thread is done
13384 for i in $(mdts_nodes); do
13386 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13387 error "$i: GC-thread not done"
13391 for i in $(seq $MDSCOUNT); do
13392 # check cl_user1 still registered
13393 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13394 error "mds$i: User ${cl_user1[mds$i]} not registered"
13395 # check cl_user2 unregistered
13396 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13397 error "mds$i: User ${cl_user2[mds$i]} still registered"
13399 # check changelogs are present and starting at $user_rec1 + 1
13400 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13401 [ -n "$user_rec1" ] ||
13402 error "mds$i: User ${cl_user1[mds$i]} not registered"
13403 first_rec=$($LFS changelog $(facet_svc mds$i) |
13404 awk '{ print $1; exit; }')
13406 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13407 [ $((user_rec1 + 1)) == $first_rec ] ||
13408 error "mds$i: first index should be $user_rec1 + 1, " \
13409 "but is $first_rec"
13412 run_test 160f "changelog garbage collect (timestamped users)"
13415 remote_mds_nodsh && skip "remote MDS with nodsh"
13416 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13417 skip "Need MDS version at least 2.10.56"
13419 local mdts=$(comma_list $(mdts_nodes))
13421 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
13422 do_nodes $mdts $LCTL set_param fail_loc=0x1314
13425 changelog_register || error "first changelog_register failed"
13426 changelog_register || error "second changelog_register failed"
13428 declare -A cl_user1
13429 declare -A cl_user2
13434 # generate some changelog records to accumulate on each MDT
13435 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13436 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13437 error "create $DIR/$tdir/$tfile failed"
13439 # check changelogs have been generated
13440 local nbcl=$(changelog_dump | wc -l)
13441 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13443 # reduce the max_idle_indexes value to make sure we exceed it
13444 max_ndx=$((nbcl / 2 - 1))
13446 for param in "changelog_max_idle_indexes=$max_ndx" \
13448 "changelog_min_gc_interval=2" \
13449 "changelog_min_free_cat_entries=3"; do
13450 local MDT0=$(facet_svc $SINGLEMDS)
13451 local var="${param%=*}"
13452 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13454 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13455 do_nodes $mdts $LCTL set_param mdd.*.$param ||
13456 error "unable to set mdd.*.$param"
13459 # simulate changelog catalog almost full
13460 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13461 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13463 for i in $(seq $MDSCOUNT); do
13464 cl_users=(${CL_USERS[mds$i]})
13465 cl_user1[mds$i]="${cl_users[0]}"
13466 cl_user2[mds$i]="${cl_users[1]}"
13468 [ -n "${cl_user1[mds$i]}" ] ||
13469 error "mds$i: no user registered"
13470 [ -n "${cl_user2[mds$i]}" ] ||
13471 error "mds$i: only ${cl_user1[mds$i]} is registered"
13473 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13474 [ -n "$user_rec1" ] ||
13475 error "mds$i: User ${cl_user1[mds$i]} not registered"
13476 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13477 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13478 [ -n "$user_rec2" ] ||
13479 error "mds$i: User ${cl_user1[mds$i]} not registered"
13480 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13481 "$user_rec1 + 2 == $user_rec2"
13482 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13483 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13484 "$user_rec1 + 2, but is $user_rec2"
13485 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13486 [ -n "$user_rec2" ] ||
13487 error "mds$i: User ${cl_user2[mds$i]} not registered"
13488 [ $user_rec1 == $user_rec2 ] ||
13489 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13490 "$user_rec1, but is $user_rec2"
13493 # ensure we are past the previous changelog_min_gc_interval set above
13496 # generate one more changelog to trigger fail_loc
13497 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13498 error "create $DIR/$tdir/${tfile}bis failed"
13500 # ensure gc thread is done
13501 for i in $(mdts_nodes); do
13503 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13504 error "$i: GC-thread not done"
13508 for i in $(seq $MDSCOUNT); do
13509 # check cl_user1 still registered
13510 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13511 error "mds$i: User ${cl_user1[mds$i]} not registered"
13512 # check cl_user2 unregistered
13513 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13514 error "mds$i: User ${cl_user2[mds$i]} still registered"
13516 # check changelogs are present and starting at $user_rec1 + 1
13517 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13518 [ -n "$user_rec1" ] ||
13519 error "mds$i: User ${cl_user1[mds$i]} not registered"
13520 first_rec=$($LFS changelog $(facet_svc mds$i) |
13521 awk '{ print $1; exit; }')
13523 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13524 [ $((user_rec1 + 1)) == $first_rec ] ||
13525 error "mds$i: first index should be $user_rec1 + 1, " \
13526 "but is $first_rec"
13529 run_test 160g "changelog garbage collect (old users)"
13532 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13533 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13534 skip "Need MDS version at least 2.10.56"
13536 local mdts=$(comma_list $(mdts_nodes))
13539 changelog_register || error "first changelog_register failed"
13540 changelog_register || error "second changelog_register failed"
13542 declare -A cl_user1
13543 declare -A cl_user2
13548 # generate some changelog records to accumulate on each MDT
13549 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13550 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13551 error "create $DIR/$tdir/$tfile failed"
13553 # check changelogs have been generated
13554 local nbcl=$(changelog_dump | wc -l)
13555 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13557 for param in "changelog_max_idle_time=10" \
13559 "changelog_min_gc_interval=2"; do
13560 local MDT0=$(facet_svc $SINGLEMDS)
13561 local var="${param%=*}"
13562 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13564 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13565 do_nodes $mdts $LCTL set_param mdd.*.$param
13568 # force cl_user2 to be idle (1st part)
13571 for i in $(seq $MDSCOUNT); do
13572 cl_users=(${CL_USERS[mds$i]})
13573 cl_user1[mds$i]="${cl_users[0]}"
13574 cl_user2[mds$i]="${cl_users[1]}"
13576 [ -n "${cl_user1[mds$i]}" ] ||
13577 error "mds$i: no user registered"
13578 [ -n "${cl_user2[mds$i]}" ] ||
13579 error "mds$i: only ${cl_user2[mds$i]} is registered"
13581 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13582 [ -n "$user_rec1" ] ||
13583 error "mds$i: User ${cl_user1[mds$i]} not registered"
13584 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13585 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13586 [ -n "$user_rec2" ] ||
13587 error "mds$i: User ${cl_user1[mds$i]} not registered"
13588 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13589 "$user_rec1 + 2 == $user_rec2"
13590 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13591 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13592 "$user_rec1 + 2, but is $user_rec2"
13593 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13594 [ -n "$user_rec2" ] ||
13595 error "mds$i: User ${cl_user2[mds$i]} not registered"
13596 [ $user_rec1 == $user_rec2 ] ||
13597 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13598 "$user_rec1, but is $user_rec2"
13601 # force cl_user2 to be idle (2nd part) and to reach
13602 # changelog_max_idle_time
13605 # force each GC-thread start and block then
13606 # one per MDT/MDD, set fail_val accordingly
13607 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
13608 do_nodes $mdts $LCTL set_param fail_loc=0x1316
13610 # generate more changelogs to trigger fail_loc
13611 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13612 error "create $DIR/$tdir/${tfile}bis failed"
13614 # stop MDT to stop GC-thread, should be done in back-ground as it will
13615 # block waiting for the thread to be released and exit
13616 declare -A stop_pids
13617 for i in $(seq $MDSCOUNT); do
13619 stop_pids[mds$i]=$!
13622 for i in $(mdts_nodes); do
13625 local facets=$(facets_up_on_host $i)
13627 for facet in ${facets//,/ }; do
13628 if [[ $facet == mds* ]]; then
13632 # ensure each MDS's gc threads are still present and all in "R"
13633 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
13634 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
13635 error "$i: expected $nb GC-thread"
13637 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
13639 error "$i: GC-thread not found in R-state"
13640 # check umounts of each MDT on MDS have reached kthread_stop()
13641 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
13642 error "$i: expected $nb umount"
13644 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
13645 error "$i: umount not found in D-state"
13648 # release all GC-threads
13649 do_nodes $mdts $LCTL set_param fail_loc=0
13651 # wait for MDT stop to complete
13652 for i in $(seq $MDSCOUNT); do
13653 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
13657 # may try to check if any orphan changelog records are present
13658 # via ldiskfs/zfs and llog_reader...
13660 # re-start/mount MDTs
13661 for i in $(seq $MDSCOUNT); do
13662 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
13663 error "Fail to start mds$i"
13667 for i in $(seq $MDSCOUNT); do
13668 # check cl_user1 still registered
13669 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13670 error "mds$i: User ${cl_user1[mds$i]} not registered"
13671 # check cl_user2 unregistered
13672 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13673 error "mds$i: User ${cl_user2[mds$i]} still registered"
13675 # check changelogs are present and starting at $user_rec1 + 1
13676 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13677 [ -n "$user_rec1" ] ||
13678 error "mds$i: User ${cl_user1[mds$i]} not registered"
13679 first_rec=$($LFS changelog $(facet_svc mds$i) |
13680 awk '{ print $1; exit; }')
13682 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13683 [ $((user_rec1 + 1)) == $first_rec ] ||
13684 error "mds$i: first index should be $user_rec1 + 1, " \
13685 "but is $first_rec"
13688 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
13693 local mdts=$(comma_list $(mdts_nodes))
13695 changelog_register || error "first changelog_register failed"
13697 # generate some changelog records to accumulate on each MDT
13698 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13699 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13700 error "create $DIR/$tdir/$tfile failed"
13702 # check changelogs have been generated
13703 local nbcl=$(changelog_dump | wc -l)
13704 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13706 # simulate race between register and unregister
13707 # XXX as fail_loc is set per-MDS, with DNE configs the race
13708 # simulation will only occur for one MDT per MDS and for the
13709 # others the normal race scenario will take place
13710 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
13711 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
13712 do_nodes $mdts $LCTL set_param fail_val=1
13714 # unregister 1st user
13715 changelog_deregister &
13717 # wait some time for deregister work to reach race rdv
13719 # register 2nd user
13720 changelog_register || error "2nd user register failed"
13722 wait $pid1 || error "1st user deregister failed"
13726 declare -A LAST_REC
13727 for i in $(seq $MDSCOUNT); do
13728 if changelog_users mds$i | grep "^cl"; then
13729 # make sure new records are added with one user present
13730 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
13731 awk '/^current.index:/ { print $NF }')
13733 error "mds$i has no user registered"
13737 # generate more changelog records to accumulate on each MDT
13738 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13739 error "create $DIR/$tdir/${tfile}bis failed"
13741 for i in $(seq $MDSCOUNT); do
13742 last_rec=$(changelog_users $SINGLEMDS |
13743 awk '/^current.index:/ { print $NF }')
13744 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
13745 [ $last_rec != ${LAST_REC[mds$i]} ] ||
13746 error "changelogs are off on mds$i"
13749 run_test 160i "changelog user register/unregister race"
13752 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13754 test_mkdir -c1 $DIR/$tdir
13755 cp /etc/hosts $DIR/$tdir/$tfile
13756 test_mkdir -c1 $DIR/$tdir/foo1
13757 test_mkdir -c1 $DIR/$tdir/foo2
13758 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
13759 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
13760 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
13761 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
13762 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
13763 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13764 $LFS fid2path $DIR $FID
13765 error "bad link ea"
13768 rm $DIR/$tdir/foo2/zachary
13770 rm $DIR/$tdir/foo2/thor
13772 rm $DIR/$tdir/$tfile
13774 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
13775 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
13776 { $LFS fid2path $DIR $FID; error "bad link rename"; }
13777 rm $DIR/$tdir/foo2/maggie
13780 local longname=$tfile.avg_len_is_thirty_two_
13781 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
13782 error_noexit 'failed to unlink many hardlinks'" EXIT
13783 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
13784 error "failed to hardlink many files"
13785 links=$($LFS fid2path $DIR $FID | wc -l)
13786 echo -n "${links}/1000 links in link EA"
13787 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
13789 run_test 161a "link ea sanity"
13792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13793 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
13796 local remote_dir=$DIR/$tdir/remote_dir
13798 mkdir -p $DIR/$tdir
13799 $LFS mkdir -i $MDTIDX $remote_dir ||
13800 error "create remote directory failed"
13802 cp /etc/hosts $remote_dir/$tfile
13803 mkdir -p $remote_dir/foo1
13804 mkdir -p $remote_dir/foo2
13805 ln $remote_dir/$tfile $remote_dir/foo1/sofia
13806 ln $remote_dir/$tfile $remote_dir/foo2/zachary
13807 ln $remote_dir/$tfile $remote_dir/foo1/luna
13808 ln $remote_dir/$tfile $remote_dir/foo2/thor
13810 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
13812 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13813 $LFS fid2path $DIR $FID
13814 error "bad link ea"
13817 rm $remote_dir/foo2/zachary
13819 rm $remote_dir/foo2/thor
13821 rm $remote_dir/$tfile
13823 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
13824 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
13825 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
13826 $LFS fid2path $DIR $FID
13827 error "bad link rename"
13829 rm $remote_dir/foo2/maggie
13832 local longname=filename_avg_len_is_thirty_two_
13833 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
13834 error "failed to hardlink many files"
13835 links=$($LFS fid2path $DIR $FID | wc -l)
13836 echo -n "${links}/1000 links in link EA"
13837 [[ ${links} -gt 60 ]] ||
13838 error "expected at least 60 links in link EA"
13839 unlinkmany $remote_dir/foo2/$longname 1000 ||
13840 error "failed to unlink many hardlinks"
13842 run_test 161b "link ea sanity under remote directory"
13845 remote_mds_nodsh && skip "remote MDS with nodsh"
13846 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13847 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
13848 skip "Need MDS version at least 2.1.5"
13850 # define CLF_RENAME_LAST 0x0001
13851 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
13852 changelog_register || error "changelog_register failed"
13855 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
13856 touch $DIR/$tdir/foo_161c
13857 touch $DIR/$tdir/bar_161c
13858 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13859 changelog_dump | grep RENME | tail -n 5
13860 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13861 changelog_clear 0 || error "changelog_clear failed"
13862 if [ x$flags != "x0x1" ]; then
13863 error "flag $flags is not 0x1"
13866 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
13867 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
13868 touch $DIR/$tdir/foo_161c
13869 touch $DIR/$tdir/bar_161c
13870 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13871 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13872 changelog_dump | grep RENME | tail -n 5
13873 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13874 changelog_clear 0 || error "changelog_clear failed"
13875 if [ x$flags != "x0x0" ]; then
13876 error "flag $flags is not 0x0"
13878 echo "rename overwrite a target having nlink > 1," \
13879 "changelog record has flags of $flags"
13881 # rename doesn't overwrite a target (changelog flag 0x0)
13882 touch $DIR/$tdir/foo_161c
13883 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
13884 changelog_dump | grep RENME | tail -n 5
13885 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
13886 changelog_clear 0 || error "changelog_clear failed"
13887 if [ x$flags != "x0x0" ]; then
13888 error "flag $flags is not 0x0"
13890 echo "rename doesn't overwrite a target," \
13891 "changelog record has flags of $flags"
13893 # define CLF_UNLINK_LAST 0x0001
13894 # unlink a file having nlink = 1 (changelog flag 0x1)
13895 rm -f $DIR/$tdir/foo2_161c
13896 changelog_dump | grep UNLNK | tail -n 5
13897 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13898 changelog_clear 0 || error "changelog_clear failed"
13899 if [ x$flags != "x0x1" ]; then
13900 error "flag $flags is not 0x1"
13902 echo "unlink a file having nlink = 1," \
13903 "changelog record has flags of $flags"
13905 # unlink a file having nlink > 1 (changelog flag 0x0)
13906 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13907 rm -f $DIR/$tdir/foobar_161c
13908 changelog_dump | grep UNLNK | tail -n 5
13909 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13910 changelog_clear 0 || error "changelog_clear failed"
13911 if [ x$flags != "x0x0" ]; then
13912 error "flag $flags is not 0x0"
13914 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
13916 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
13919 remote_mds_nodsh && skip "remote MDS with nodsh"
13920 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
13925 changelog_register || error "changelog_register failed"
13927 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
13928 # interfer with $MOUNT/.lustre/fid/ access
13930 [[ $? -eq 0 ]] || error "mkdir failed"
13932 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
13933 $LCTL set_param fail_loc=0x8000140c
13935 $LCTL set_param fail_val=5
13938 echo foofoo > $DIR/$tdir/$tfile &
13941 # wait for create to be delayed
13945 [[ $? -eq 0 ]] || error "create should be blocked"
13947 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
13948 stack_trap "rm -f $tempfile"
13949 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
13950 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
13951 # some delay may occur during ChangeLog publishing and file read just
13952 # above, that could allow file write to happen finally
13953 [[ -s $tempfile ]] && echo "file should be empty"
13955 $LCTL set_param fail_loc=0
13958 [[ $? -eq 0 ]] || error "create failed"
13960 run_test 161d "create with concurrent .lustre/fid access"
13963 local expected="$1"
13968 path=$($LFS fid2path "$@")
13971 if [ $rc -ne 0 ]; then
13972 error "path looked up of '$expected' failed: rc=$rc"
13973 elif [ "$path" != "$expected" ]; then
13974 error "path looked up '$path' instead of '$expected'"
13976 echo "FID '$fid' resolves to path '$path' as expected"
13980 test_162a() { # was test_162
13981 test_mkdir -p -c1 $DIR/$tdir/d2
13982 touch $DIR/$tdir/d2/$tfile
13983 touch $DIR/$tdir/d2/x1
13984 touch $DIR/$tdir/d2/x2
13985 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
13986 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
13988 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
13989 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
13992 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
13993 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
13994 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
13996 # softlink to wrong file
13997 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
13998 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
13999 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
14002 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
14003 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
14004 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
14005 # fid2path dir/fsname should both work
14006 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
14007 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
14009 # hardlink count: check that there are 2 links
14010 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
14011 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
14013 # hardlink indexing: remove the first link
14014 rm $DIR/$tdir/d2/p/q/r/hlink
14015 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
14017 run_test 162a "path lookup sanity"
14020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14021 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14024 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
14025 error "create striped dir failed"
14027 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
14028 tail -n 1 | awk '{print $2}')
14029 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
14031 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
14032 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
14035 for ((i=0;i<5;i++)); do
14036 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
14037 error "get fid for f$i failed"
14038 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
14040 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
14041 error "get fid for d$i failed"
14042 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
14047 run_test 162b "striped directory path lookup sanity"
14049 # LU-4239: Verify fid2path works with paths 100 or more directories deep
14051 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
14052 skip "Need MDS version at least 2.7.51"
14054 local lpath=$tdir.local
14055 local rpath=$tdir.remote
14057 test_mkdir $DIR/$lpath
14058 test_mkdir $DIR/$rpath
14060 for ((i = 0; i <= 101; i++)); do
14063 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
14064 error "get fid for local directory $DIR/$lpath failed"
14065 check_path "$DIR/$lpath" $MOUNT $FID --link 0
14068 test_mkdir $DIR/$rpath
14069 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
14070 error "get fid for remote directory $DIR/$rpath failed"
14071 check_path "$DIR/$rpath" $MOUNT $FID --link 0
14076 run_test 162c "fid2path works with paths 100 or more directories deep"
14079 # do directio so as not to populate the page cache
14080 log "creating a 10 Mb file"
14081 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14082 log "starting reads"
14083 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14084 log "truncating the file"
14085 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14087 kill %+ || true # reads might have finished
14088 echo "wait until dd is finished"
14090 log "removing the temporary file"
14091 rm -rf $DIR/$tfile || error "tmp file removal failed"
14093 run_test 169 "parallel read and truncate should not deadlock"
14096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14098 $LCTL clear # bug 18514
14099 $LCTL debug_daemon start $TMP/${tfile}_log_good
14101 $LCTL debug_daemon stop
14102 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
14103 error "sed failed to read log_good"
14105 $LCTL debug_daemon start $TMP/${tfile}_log_good
14107 $LCTL debug_daemon stop
14109 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
14110 error "lctl df log_bad failed"
14112 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14113 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14115 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
14116 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
14118 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
14119 error "bad_line good_line1 good_line2 are empty"
14121 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14122 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
14123 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14125 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
14126 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14127 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14129 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
14130 error "bad_line_new good_line_new are empty"
14132 local expected_good=$((good_line1 + good_line2*2))
14134 rm -f $TMP/${tfile}*
14135 # LU-231, short malformed line may not be counted into bad lines
14136 if [ $bad_line -ne $bad_line_new ] &&
14137 [ $bad_line -ne $((bad_line_new - 1)) ]; then
14138 error "expected $bad_line bad lines, but got $bad_line_new"
14142 if [ $expected_good -ne $good_line_new ]; then
14143 error "expected $expected_good good lines, but got $good_line_new"
14148 run_test 170 "test lctl df to handle corrupted log ====================="
14150 test_171() { # bug20592
14151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14153 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
14154 $LCTL set_param fail_loc=0x50e
14155 $LCTL set_param fail_val=3000
14156 multiop_bg_pause $DIR/$tfile O_s || true
14158 kill -USR1 $MULTIPID
14162 if dmesg | grep "recursive fault"; then
14163 error "caught a recursive fault"
14165 $LCTL set_param fail_loc=0
14168 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
14170 # it would be good to share it with obdfilter-survey/iokit-libecho code
14171 setup_obdecho_osc () {
14174 local obdfilter_name=$2
14175 echo "Creating new osc for $obdfilter_name on $ost_nid"
14176 # make sure we can find loopback nid
14177 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
14179 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
14180 ${obdfilter_name}_osc_UUID || rc=2; }
14181 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
14182 ${obdfilter_name}_UUID $ost_nid || rc=3; }
14186 cleanup_obdecho_osc () {
14187 local obdfilter_name=$1
14188 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
14189 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
14196 local pages=${3:-64}
14201 local obd_size=$(get_obd_size $node $OBD)
14202 local page_size=$(get_page_size $node)
14203 if [[ -n "$obd_size" ]]; then
14204 local new_count=$((obd_size / (pages * page_size / 1024)))
14205 [[ $new_count -ge $count ]] || count=$new_count
14208 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
14209 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
14211 if [ $rc -eq 0 ]; then
14212 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
14213 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
14215 echo "New object id is $id"
14216 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
14218 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
14219 "test_brw $count w v $pages $id" || rc=4; }
14220 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
14222 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
14223 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
14224 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
14225 { do_facet $node "$LCTL --device ec detach" || rc=6; }
14226 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
14231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14233 if ! module_loaded obdecho; then
14234 load_module obdecho/obdecho &&
14235 stack_trap "rmmod obdecho" EXIT ||
14236 error "unable to load obdecho on client"
14239 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
14240 local host=$($LCTL get_param -n osc.$osc.import |
14241 awk '/current_connection:/ { print $2 }' )
14242 local target=$($LCTL get_param -n osc.$osc.import |
14243 awk '/target:/ { print $2 }' )
14244 target=${target%_UUID}
14246 if [ -n "$target" ]; then
14247 setup_obdecho_osc $host $target &&
14248 stack_trap "cleanup_obdecho_osc $target" EXIT ||
14249 { error "obdecho setup failed with $?"; return; }
14251 obdecho_test ${target}_osc client ||
14252 error "obdecho_test failed on ${target}_osc"
14254 $LCTL get_param osc.$osc.import
14255 error "there is no osc.$osc.import target"
14258 run_test 180a "test obdecho on osc"
14261 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14262 remote_ost_nodsh && skip "remote OST with nodsh"
14264 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14265 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14266 error "failed to load module obdecho"
14268 local target=$(do_facet ost1 $LCTL dl |
14269 awk '/obdfilter/ { print $4; exit; }')
14271 if [ -n "$target" ]; then
14272 obdecho_test $target ost1 || error "obdecho_test failed with $?"
14274 do_facet ost1 $LCTL dl
14275 error "there is no obdfilter target on ost1"
14278 run_test 180b "test obdecho directly on obdfilter"
14280 test_180c() { # LU-2598
14281 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14282 remote_ost_nodsh && skip "remote OST with nodsh"
14283 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
14284 skip "Need MDS version at least 2.4.0"
14286 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14287 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14288 error "failed to load module obdecho"
14290 local target=$(do_facet ost1 $LCTL dl |
14291 awk '/obdfilter/ { print $4; exit; }')
14293 if [ -n "$target" ]; then
14294 local pages=16384 # 64MB bulk I/O RPC size
14296 obdecho_test "$target" ost1 "$pages" ||
14297 error "obdecho_test with pages=$pages failed with $?"
14299 do_facet ost1 $LCTL dl
14300 error "there is no obdfilter target on ost1"
14303 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
14305 test_181() { # bug 22177
14306 test_mkdir $DIR/$tdir
14307 # create enough files to index the directory
14308 createmany -o $DIR/$tdir/foobar 4000
14309 # print attributes for debug purpose
14312 multiop_bg_pause $DIR/$tdir D_Sc || return 1
14314 # remove the files & current working dir
14315 unlinkmany $DIR/$tdir/foobar 4000
14317 kill -USR1 $MULTIPID
14319 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
14322 run_test 181 "Test open-unlinked dir ========================"
14328 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14330 $LCTL set_param mdc.*.rpc_stats=clear
14332 for (( i = 0; i < $tcount; i++ )) ; do
14333 mkdir $DIR/$tdir/$i
14336 for (( i = 0; i < $tcount; i++ )) ; do
14337 createmany -o $DIR/$tdir/$i/f- $fcount &
14341 for (( i = 0; i < $tcount; i++ )) ; do
14342 unlinkmany $DIR/$tdir/$i/f- $fcount &
14346 $LCTL get_param mdc.*.rpc_stats
14350 run_test 182 "Test parallel modify metadata operations ================"
14352 test_183() { # LU-2275
14353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14354 remote_mds_nodsh && skip "remote MDS with nodsh"
14355 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
14356 skip "Need MDS version at least 2.3.56"
14358 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14359 echo aaa > $DIR/$tdir/$tfile
14361 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
14362 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
14364 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
14365 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
14367 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14369 # Flush negative dentry cache
14370 touch $DIR/$tdir/$tfile
14372 # We are not checking for any leaked references here, they'll
14373 # become evident next time we do cleanup with module unload.
14376 run_test 183 "No crash or request leak in case of strange dispositions ========"
14378 # test suite 184 is for LU-2016, LU-2017
14380 check_swap_layouts_support
14382 dir0=$DIR/$tdir/$testnum
14383 test_mkdir -p -c1 $dir0
14388 $LFS setstripe -c1 $file1
14390 $LFS setstripe -c2 $file2
14392 gen1=$($LFS getstripe -g $file1)
14393 gen2=$($LFS getstripe -g $file2)
14395 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
14396 gen=$($LFS getstripe -g $file1)
14397 [[ $gen1 != $gen ]] ||
14398 "Layout generation on $file1 does not change"
14399 gen=$($LFS getstripe -g $file2)
14400 [[ $gen2 != $gen ]] ||
14401 "Layout generation on $file2 does not change"
14403 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
14404 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14406 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
14408 run_test 184a "Basic layout swap"
14411 check_swap_layouts_support
14413 dir0=$DIR/$tdir/$testnum
14414 mkdir -p $dir0 || error "creating dir $dir0"
14421 $LFS setstripe -c1 $file1
14422 $LFS setstripe -c2 $file2
14423 $LFS setstripe -c1 $file3
14424 chown $RUNAS_ID $file3
14425 gen1=$($LFS getstripe -g $file1)
14426 gen2=$($LFS getstripe -g $file2)
14428 $LFS swap_layouts $dir1 $dir2 &&
14429 error "swap of directories layouts should fail"
14430 $LFS swap_layouts $dir1 $file1 &&
14431 error "swap of directory and file layouts should fail"
14432 $RUNAS $LFS swap_layouts $file1 $file2 &&
14433 error "swap of file we cannot write should fail"
14434 $LFS swap_layouts $file1 $file3 &&
14435 error "swap of file with different owner should fail"
14436 /bin/true # to clear error code
14438 run_test 184b "Forbidden layout swap (will generate errors)"
14441 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
14442 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
14443 check_swap_layouts_support
14445 local dir0=$DIR/$tdir/$testnum
14446 mkdir -p $dir0 || error "creating dir $dir0"
14448 local ref1=$dir0/ref1
14449 local ref2=$dir0/ref2
14450 local file1=$dir0/file1
14451 local file2=$dir0/file2
14452 # create a file large enough for the concurrent test
14453 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
14454 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
14455 echo "ref file size: ref1($(stat -c %s $ref1))," \
14456 "ref2($(stat -c %s $ref2))"
14459 dd if=$ref1 of=$file1 bs=16k &
14462 # Make sure dd starts to copy file
14463 while [ ! -f $file1 ]; do sleep 0.1; done
14465 $LFS swap_layouts $file1 $file2
14468 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
14469 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
14471 # how many bytes copied before swapping layout
14472 local copied=$(stat -c %s $file2)
14473 local remaining=$(stat -c %s $ref1)
14474 remaining=$((remaining - copied))
14475 echo "Copied $copied bytes before swapping layout..."
14477 cmp -n $copied $file1 $ref2 | grep differ &&
14478 error "Content mismatch [0, $copied) of ref2 and file1"
14479 cmp -n $copied $file2 $ref1 ||
14480 error "Content mismatch [0, $copied) of ref1 and file2"
14481 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
14482 error "Content mismatch [$copied, EOF) of ref1 and file1"
14485 rm -f $ref1 $ref2 $file1 $file2
14487 run_test 184c "Concurrent write and layout swap"
14490 check_swap_layouts_support
14491 [ -z "$(which getfattr 2>/dev/null)" ] &&
14492 skip_env "no getfattr command"
14494 local file1=$DIR/$tdir/$tfile-1
14495 local file2=$DIR/$tdir/$tfile-2
14496 local file3=$DIR/$tdir/$tfile-3
14500 mkdir -p $DIR/$tdir
14501 touch $file1 || error "create $file1 failed"
14502 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14503 error "create $file2 failed"
14504 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14505 error "create $file3 failed"
14506 lovea1=$(get_layout_param $file1)
14508 $LFS swap_layouts $file2 $file3 ||
14509 error "swap $file2 $file3 layouts failed"
14510 $LFS swap_layouts $file1 $file2 ||
14511 error "swap $file1 $file2 layouts failed"
14513 lovea2=$(get_layout_param $file2)
14516 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
14518 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14519 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
14521 run_test 184d "allow stripeless layouts swap"
14524 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
14525 skip "Need MDS version at least 2.6.94"
14526 check_swap_layouts_support
14527 [ -z "$(which getfattr 2>/dev/null)" ] &&
14528 skip_env "no getfattr command"
14530 local file1=$DIR/$tdir/$tfile-1
14531 local file2=$DIR/$tdir/$tfile-2
14532 local file3=$DIR/$tdir/$tfile-3
14535 mkdir -p $DIR/$tdir
14536 touch $file1 || error "create $file1 failed"
14537 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14538 error "create $file2 failed"
14539 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14540 error "create $file3 failed"
14542 $LFS swap_layouts $file1 $file2 ||
14543 error "swap $file1 $file2 layouts failed"
14545 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14546 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
14548 echo 123 > $file1 || error "Should be able to write into $file1"
14550 $LFS swap_layouts $file1 $file3 ||
14551 error "swap $file1 $file3 layouts failed"
14553 echo 123 > $file1 || error "Should be able to write into $file1"
14555 rm -rf $file1 $file2 $file3
14557 run_test 184e "Recreate layout after stripeless layout swaps"
14560 # Create a file with name longer than sizeof(struct stat) ==
14561 # 144 to see if we can get chars from the file name to appear
14562 # in the returned striping. Note that 'f' == 0x66.
14563 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
14565 mkdir -p $DIR/$tdir
14566 mcreate $DIR/$tdir/$file
14567 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
14568 error "IOC_MDC_GETFILEINFO returned garbage striping"
14571 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
14573 test_185() { # LU-2441
14574 # LU-3553 - no volatile file support in old servers
14575 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
14576 skip "Need MDS version at least 2.3.60"
14578 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14579 touch $DIR/$tdir/spoo
14580 local mtime1=$(stat -c "%Y" $DIR/$tdir)
14581 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
14582 error "cannot create/write a volatile file"
14583 [ "$FILESET" == "" ] &&
14584 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
14585 error "FID is still valid after close"
14587 multiop_bg_pause $DIR/$tdir vVw4096_c
14594 # assume that the next FID for this client is sequential, since stdout
14595 # is unfortunately eaten by multiop_bg_pause
14596 local n=$((${fidv[1]} + 1))
14597 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
14598 if [ "$FILESET" == "" ]; then
14599 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
14600 error "FID is missing before close"
14602 kill -USR1 $multi_pid
14603 # 1 second delay, so if mtime change we will see it
14605 local mtime2=$(stat -c "%Y" $DIR/$tdir)
14606 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
14608 run_test 185 "Volatile file support"
14610 function create_check_volatile() {
14614 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
14617 local FID=$(cat /tmp/${tfile}.fid)
14618 [ "$FID" == "" ] && error "can't get FID for volatile"
14619 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
14620 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
14621 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
14625 cancel_lru_locks mdc # flush opencache
14626 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
14631 # LU-12516 - volatile creation via .lustre
14632 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
14633 skip "Need MDS version at least 2.3.55"
14635 create_check_volatile 0
14636 [ $MDSCOUNT -lt 2 ] && return 0
14639 create_check_volatile 1
14643 run_test 185a "Volatile file creation in .lustre/fid/"
14646 remote_mds_nodsh && skip "remote MDS with nodsh"
14647 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14648 skip "Need MDS version at least 2.3.0"
14650 local dir0=$DIR/$tdir/$testnum
14651 mkdir -p $dir0 || error "creating dir $dir0"
14653 local file=$dir0/file1
14654 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
14655 local dv1=$($LFS data_version $file)
14656 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
14657 local dv2=$($LFS data_version $file)
14658 [[ $dv1 != $dv2 ]] ||
14659 error "data version did not change on write $dv1 == $dv2"
14664 run_test 187a "Test data version change"
14667 remote_mds_nodsh && skip "remote MDS with nodsh"
14668 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14669 skip "Need MDS version at least 2.3.0"
14671 local dir0=$DIR/$tdir/$testnum
14672 mkdir -p $dir0 || error "creating dir $dir0"
14674 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
14675 [[ ${DV[0]} != ${DV[1]} ]] ||
14676 error "data version did not change on write"\
14677 " ${DV[0]} == ${DV[1]}"
14682 run_test 187b "Test data version change on volatile file"
14685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14686 remote_mgs_nodsh && skip "remote MGS with nodsh"
14687 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14689 local POOL=${POOL:-cea1}
14690 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
14691 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
14694 local last_ost=$(($OSTCOUNT - 1))
14696 local ost_list=$(seq $first_ost $ost_step $last_ost)
14697 local ost_range="$first_ost $last_ost $ost_step"
14698 local test_path=$POOL_ROOT/$POOL_DIR_NAME
14699 local file_dir=$POOL_ROOT/file_tst
14700 local subdir=$test_path/subdir
14703 if ! combined_mgs_mds ; then
14708 # former test_200a test_200b
14709 pool_add $POOL || { rc=$? ; break; }
14710 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
14711 # former test_200c test_200d
14712 mkdir -p $test_path
14713 pool_set_dir $POOL $test_path || { rc=$? ; break; }
14714 pool_check_dir $POOL $test_path || { rc=$? ; break; }
14716 pool_check_dir $POOL $subdir || { rc=$? ; break; }
14717 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
14718 || { rc=$? ; break; }
14719 # former test_200e test_200f
14720 local files=$((OSTCOUNT*3))
14721 pool_alloc_files $POOL $test_path $files "$ost_list" \
14722 || { rc=$? ; break; }
14723 pool_create_files $POOL $file_dir $files "$ost_list" \
14724 || { rc=$? ; break; }
14725 # former test_200g test_200h
14726 pool_lfs_df $POOL || { rc=$? ; break; }
14727 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
14729 # former test_201a test_201b test_201c
14730 pool_remove_first_target $POOL || { rc=$? ; break; }
14732 local f=$test_path/$tfile
14733 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
14734 pool_remove $POOL $f || { rc=$? ; break; }
14740 if ! combined_mgs_mds ; then
14745 run_test 200 "OST pools"
14747 # usage: default_attr <count | size | offset>
14749 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
14752 # usage: check_default_stripe_attr
14753 check_default_stripe_attr() {
14754 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
14757 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
14759 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
14763 error "unknown getstripe attr '$1'"
14766 [ $ACTUAL == $EXPECTED ] ||
14767 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
14771 test_mkdir $DIR/$tdir
14772 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
14774 check_default_stripe_attr --stripe-count
14775 check_default_stripe_attr --stripe-size
14776 check_default_stripe_attr --stripe-index
14778 run_test 204a "Print default stripe attributes"
14781 test_mkdir $DIR/$tdir
14782 $LFS setstripe --stripe-count 1 $DIR/$tdir
14784 check_default_stripe_attr --stripe-size
14785 check_default_stripe_attr --stripe-index
14787 run_test 204b "Print default stripe size and offset"
14790 test_mkdir $DIR/$tdir
14791 $LFS setstripe --stripe-size 65536 $DIR/$tdir
14793 check_default_stripe_attr --stripe-count
14794 check_default_stripe_attr --stripe-index
14796 run_test 204c "Print default stripe count and offset"
14799 test_mkdir $DIR/$tdir
14800 $LFS setstripe --stripe-index 0 $DIR/$tdir
14802 check_default_stripe_attr --stripe-count
14803 check_default_stripe_attr --stripe-size
14805 run_test 204d "Print default stripe count and size"
14808 test_mkdir $DIR/$tdir
14809 $LFS setstripe -d $DIR/$tdir
14811 check_default_stripe_attr --stripe-count --raw
14812 check_default_stripe_attr --stripe-size --raw
14813 check_default_stripe_attr --stripe-index --raw
14815 run_test 204e "Print raw stripe attributes"
14818 test_mkdir $DIR/$tdir
14819 $LFS setstripe --stripe-count 1 $DIR/$tdir
14821 check_default_stripe_attr --stripe-size --raw
14822 check_default_stripe_attr --stripe-index --raw
14824 run_test 204f "Print raw stripe size and offset"
14827 test_mkdir $DIR/$tdir
14828 $LFS setstripe --stripe-size 65536 $DIR/$tdir
14830 check_default_stripe_attr --stripe-count --raw
14831 check_default_stripe_attr --stripe-index --raw
14833 run_test 204g "Print raw stripe count and offset"
14836 test_mkdir $DIR/$tdir
14837 $LFS setstripe --stripe-index 0 $DIR/$tdir
14839 check_default_stripe_attr --stripe-count --raw
14840 check_default_stripe_attr --stripe-size --raw
14842 run_test 204h "Print raw stripe count and size"
14844 # Figure out which job scheduler is being used, if any,
14845 # or use a fake one
14846 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
14847 JOBENV=SLURM_JOB_ID
14848 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
14850 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
14852 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
14853 JOBENV=LOADL_STEP_ID
14854 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
14857 $LCTL list_param jobid_name > /dev/null 2>&1
14858 if [ $? -eq 0 ]; then
14864 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
14866 verify_jobstats() {
14871 # we don't really need to clear the stats for this test to work, since each
14872 # command has a unique jobid, but it makes debugging easier if needed.
14873 # for facet in $facets; do
14874 # local dev=$(convert_facet2label $facet)
14875 # # clear old jobstats
14876 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
14879 # use a new JobID for each test, or we might see an old one
14880 [ "$JOBENV" = "FAKE_JOBID" ] &&
14881 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
14883 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
14885 [ "$JOBENV" = "nodelocal" ] && {
14886 FAKE_JOBID=id.$testnum.%e.$RANDOM
14887 $LCTL set_param jobid_name=$FAKE_JOBID
14888 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
14891 log "Test: ${cmd[*]}"
14892 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
14894 if [ $JOBENV = "FAKE_JOBID" ]; then
14895 FAKE_JOBID=$JOBVAL ${cmd[*]}
14900 # all files are created on OST0000
14901 for facet in $facets; do
14902 local stats="*.$(convert_facet2label $facet).job_stats"
14904 # strip out libtool wrappers for in-tree executables
14905 if [ $(do_facet $facet lctl get_param $stats |
14906 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
14907 do_facet $facet lctl get_param $stats
14908 error "No jobstats for $JOBVAL found on $facet::$stats"
14914 local new_jobenv=$1
14916 set_persistent_param_and_check client "jobid_var" \
14917 "$FSNAME.sys.jobid_var" $new_jobenv
14920 test_205() { # Job stats
14921 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14922 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
14923 skip "Need MDS version with at least 2.7.1"
14924 remote_mgs_nodsh && skip "remote MGS with nodsh"
14925 remote_mds_nodsh && skip "remote MDS with nodsh"
14926 remote_ost_nodsh && skip "remote OST with nodsh"
14927 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
14928 skip "Server doesn't support jobstats"
14929 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
14931 local old_jobenv=$($LCTL get_param -n jobid_var)
14932 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
14934 if [[ $PERM_CMD == *"set_param -P"* ]]; then
14935 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
14937 stack_trap "do_facet mgs $PERM_CMD \
14938 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
14942 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
14943 mdt.*.job_cleanup_interval | head -n 1)
14944 local new_interval=5
14945 do_facet $SINGLEMDS \
14946 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
14947 stack_trap "do_facet $SINGLEMDS \
14948 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
14949 local start=$SECONDS
14953 cmd="mkdir $DIR/$tdir"
14954 verify_jobstats "$cmd" "$SINGLEMDS"
14956 cmd="rmdir $DIR/$tdir"
14957 verify_jobstats "$cmd" "$SINGLEMDS"
14958 # mkdir on secondary MDT
14959 if [ $MDSCOUNT -gt 1 ]; then
14960 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
14961 verify_jobstats "$cmd" "mds2"
14964 cmd="mknod $DIR/$tfile c 1 3"
14965 verify_jobstats "$cmd" "$SINGLEMDS"
14967 cmd="rm -f $DIR/$tfile"
14968 verify_jobstats "$cmd" "$SINGLEMDS"
14969 # create all files on OST0000 so verify_jobstats can find OST stats
14971 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
14972 verify_jobstats "$cmd" "$SINGLEMDS"
14974 cmd="touch $DIR/$tfile"
14975 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14977 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
14978 verify_jobstats "$cmd" "ost1"
14980 cancel_lru_locks osc
14981 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
14982 verify_jobstats "$cmd" "ost1"
14984 cmd="$TRUNCATE $DIR/$tfile 0"
14985 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14987 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
14988 verify_jobstats "$cmd" "$SINGLEMDS"
14989 # jobstats expiry - sleep until old stats should be expired
14990 local left=$((new_interval + 5 - (SECONDS - start)))
14991 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
14992 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
14994 cmd="mkdir $DIR/$tdir.expire"
14995 verify_jobstats "$cmd" "$SINGLEMDS"
14996 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
14997 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
14999 # Ensure that jobid are present in changelog (if supported by MDS)
15000 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
15001 changelog_dump | tail -10
15002 jobids=$(changelog_dump | tail -9 | grep -c "j=")
15003 [ $jobids -eq 9 ] ||
15004 error "Wrong changelog jobid count $jobids != 9"
15008 jobstats_set $JOBENV
15010 changelog_dump | grep $tfile
15011 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
15012 [ $jobids -eq 0 ] ||
15013 error "Unexpected jobids when jobid_var=$JOBENV"
15016 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
15017 JOBENV="JOBCOMPLEX"
15018 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
15020 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
15022 run_test 205 "Verify job stats"
15024 # LU-1480, LU-1773 and LU-1657
15026 mkdir -p $DIR/$tdir
15027 $LFS setstripe -c -1 $DIR/$tdir
15028 #define OBD_FAIL_LOV_INIT 0x1403
15029 $LCTL set_param fail_loc=0xa0001403
15030 $LCTL set_param fail_val=1
15031 touch $DIR/$tdir/$tfile || true
15033 run_test 206 "fail lov_init_raid0() doesn't lbug"
15036 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15037 local fsz=`stat -c %s $DIR/$tfile`
15038 cancel_lru_locks mdc
15040 # do not return layout in getattr intent
15041 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
15042 $LCTL set_param fail_loc=0x170
15043 local sz=`stat -c %s $DIR/$tfile`
15045 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
15049 run_test 207a "can refresh layout at glimpse"
15052 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15053 local cksum=`md5sum $DIR/$tfile`
15054 local fsz=`stat -c %s $DIR/$tfile`
15055 cancel_lru_locks mdc
15056 cancel_lru_locks osc
15058 # do not return layout in getattr intent
15059 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
15060 $LCTL set_param fail_loc=0x171
15062 # it will refresh layout after the file is opened but before read issues
15063 echo checksum is "$cksum"
15064 echo "$cksum" |md5sum -c --quiet || error "file differs"
15068 run_test 207b "can refresh layout at open"
15071 # FIXME: in this test suite, only RD lease is used. This is okay
15072 # for now as only exclusive open is supported. After generic lease
15073 # is done, this test suite should be revised. - Jinshan
15075 remote_mds_nodsh && skip "remote MDS with nodsh"
15076 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
15077 skip "Need MDS version at least 2.4.52"
15079 echo "==== test 1: verify get lease work"
15080 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
15082 echo "==== test 2: verify lease can be broken by upcoming open"
15083 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15087 $MULTIOP $DIR/$tfile oO_RDONLY:c
15088 kill -USR1 $PID && wait $PID || error "break lease error"
15090 echo "==== test 3: verify lease can't be granted if an open already exists"
15091 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
15095 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
15096 kill -USR1 $PID && wait $PID || error "open file error"
15098 echo "==== test 4: lease can sustain over recovery"
15099 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
15105 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
15107 echo "==== test 5: lease broken can't be regained by replay"
15108 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15112 # open file to break lease and then recovery
15113 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
15116 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
15120 run_test 208 "Exclusive open"
15123 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
15124 skip_env "must have disp_stripe"
15127 sync; sleep 5; sync;
15129 echo 3 > /proc/sys/vm/drop_caches
15130 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15132 # open/close 500 times
15133 for i in $(seq 500); do
15137 echo 3 > /proc/sys/vm/drop_caches
15138 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15140 echo "before: $req_before, after: $req_after"
15141 [ $((req_after - req_before)) -ge 300 ] &&
15142 error "open/close requests are not freed"
15145 run_test 209 "read-only open/close requests should be freed promptly"
15149 size=$((size % 8192 + 1))
15150 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
15151 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
15152 rm -f $DIR/f212 $DIR/f212.xyz
15154 run_test 212 "Sendfile test ============================================"
15157 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
15158 cancel_lru_locks osc
15159 lctl set_param fail_loc=0x8000040f
15160 # generate a read lock
15161 cat $DIR/$tfile > /dev/null
15162 # write to the file, it will try to cancel the above read lock.
15163 cat /etc/hosts >> $DIR/$tfile
15165 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
15167 test_214() { # for bug 20133
15168 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
15169 for (( i=0; i < 340; i++ )) ; do
15170 touch $DIR/$tdir/d214c/a$i
15173 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
15174 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
15175 ls $DIR/d214c || error "ls $DIR/d214c failed"
15176 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
15177 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
15179 run_test 214 "hash-indexed directory test - bug 20133"
15181 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
15182 create_lnet_proc_files() {
15183 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
15186 # counterpart of create_lnet_proc_files
15187 remove_lnet_proc_files() {
15188 rm -f $TMP/lnet_$1.sys
15191 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15192 # 3rd arg as regexp for body
15193 check_lnet_proc_stats() {
15194 local l=$(cat "$TMP/lnet_$1" |wc -l)
15195 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
15197 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
15200 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15201 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
15202 # optional and can be regexp for 2nd line (lnet.routes case)
15203 check_lnet_proc_entry() {
15204 local blp=2 # blp stands for 'position of 1st line of body'
15205 [ -z "$5" ] || blp=3 # lnet.routes case
15207 local l=$(cat "$TMP/lnet_$1" |wc -l)
15208 # subtracting one from $blp because the body can be empty
15209 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
15211 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
15212 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
15214 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
15215 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
15217 # bail out if any unexpected line happened
15218 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
15219 [ "$?" != 0 ] || error "$2 misformatted"
15222 test_215() { # for bugs 18102, 21079, 21517
15223 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15225 local N='(0|[1-9][0-9]*)' # non-negative numeric
15226 local P='[1-9][0-9]*' # positive numeric
15227 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
15228 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
15229 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
15230 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
15232 local L1 # regexp for 1st line
15233 local L2 # regexp for 2nd line (optional)
15234 local BR # regexp for the rest (body)
15236 # lnet.stats should look as 11 space-separated non-negative numerics
15237 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
15238 create_lnet_proc_files "stats"
15239 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
15240 remove_lnet_proc_files "stats"
15242 # lnet.routes should look like this:
15243 # Routing disabled/enabled
15244 # net hops priority state router
15245 # where net is a string like tcp0, hops > 0, priority >= 0,
15246 # state is up/down,
15247 # router is a string like 192.168.1.1@tcp2
15248 L1="^Routing (disabled|enabled)$"
15249 L2="^net +hops +priority +state +router$"
15250 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
15251 create_lnet_proc_files "routes"
15252 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
15253 remove_lnet_proc_files "routes"
15255 # lnet.routers should look like this:
15256 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
15257 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
15258 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
15259 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
15260 L1="^ref +rtr_ref +alive +router$"
15261 BR="^$P +$P +(up|down) +$NID$"
15262 create_lnet_proc_files "routers"
15263 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
15264 remove_lnet_proc_files "routers"
15266 # lnet.peers should look like this:
15267 # nid refs state last max rtr min tx min queue
15268 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
15269 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
15270 # numeric (0 or >0 or <0), queue >= 0.
15271 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
15272 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
15273 create_lnet_proc_files "peers"
15274 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
15275 remove_lnet_proc_files "peers"
15277 # lnet.buffers should look like this:
15278 # pages count credits min
15279 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
15280 L1="^pages +count +credits +min$"
15281 BR="^ +$N +$N +$I +$I$"
15282 create_lnet_proc_files "buffers"
15283 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
15284 remove_lnet_proc_files "buffers"
15286 # lnet.nis should look like this:
15287 # nid status alive refs peer rtr max tx min
15288 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
15289 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
15290 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
15291 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
15292 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
15293 create_lnet_proc_files "nis"
15294 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
15295 remove_lnet_proc_files "nis"
15297 # can we successfully write to lnet.stats?
15298 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
15300 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
15302 test_216() { # bug 20317
15303 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15304 remote_ost_nodsh && skip "remote OST with nodsh"
15307 local facets=$(get_facets OST)
15308 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15310 save_lustre_params client "osc.*.contention_seconds" > $p
15311 save_lustre_params $facets \
15312 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
15313 save_lustre_params $facets \
15314 "ldlm.namespaces.filter-*.contended_locks" >> $p
15315 save_lustre_params $facets \
15316 "ldlm.namespaces.filter-*.contention_seconds" >> $p
15317 clear_stats osc.*.osc_stats
15319 # agressive lockless i/o settings
15320 do_nodes $(comma_list $(osts_nodes)) \
15321 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
15322 ldlm.namespaces.filter-*.contended_locks=0 \
15323 ldlm.namespaces.filter-*.contention_seconds=60"
15324 lctl set_param -n osc.*.contention_seconds=60
15326 $DIRECTIO write $DIR/$tfile 0 10 4096
15327 $CHECKSTAT -s 40960 $DIR/$tfile
15329 # disable lockless i/o
15330 do_nodes $(comma_list $(osts_nodes)) \
15331 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
15332 ldlm.namespaces.filter-*.contended_locks=32 \
15333 ldlm.namespaces.filter-*.contention_seconds=0"
15334 lctl set_param -n osc.*.contention_seconds=0
15335 clear_stats osc.*.osc_stats
15337 dd if=/dev/zero of=$DIR/$tfile count=0
15338 $CHECKSTAT -s 0 $DIR/$tfile
15340 restore_lustre_params <$p
15344 run_test 216 "check lockless direct write updates file size and kms correctly"
15346 test_217() { # bug 22430
15347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15352 for node in $(nodes_list); do
15353 nid=$(host_nids_address $node $NETTYPE)
15354 if [[ $nid = *-* ]] ; then
15355 echo "lctl ping $(h2nettype $nid)"
15356 lctl ping $(h2nettype $nid)
15358 echo "skipping $node (no hyphen detected)"
15362 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
15365 # do directio so as not to populate the page cache
15366 log "creating a 10 Mb file"
15367 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
15368 log "starting reads"
15369 dd if=$DIR/$tfile of=/dev/null bs=4096 &
15370 log "truncating the file"
15371 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
15373 kill %+ || true # reads might have finished
15374 echo "wait until dd is finished"
15376 log "removing the temporary file"
15377 rm -rf $DIR/$tfile || error "tmp file removal failed"
15379 run_test 218 "parallel read and truncate should not deadlock"
15382 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15384 # write one partial page
15385 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
15386 # set no grant so vvp_io_commit_write will do sync write
15387 $LCTL set_param fail_loc=0x411
15388 # write a full page at the end of file
15389 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
15391 $LCTL set_param fail_loc=0
15392 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
15393 $LCTL set_param fail_loc=0x411
15394 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
15397 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
15398 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
15400 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
15402 test_220() { #LU-325
15403 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15404 remote_ost_nodsh && skip "remote OST with nodsh"
15405 remote_mds_nodsh && skip "remote MDS with nodsh"
15406 remote_mgs_nodsh && skip "remote MGS with nodsh"
15410 # create on MDT0000 so the last_id and next_id are correct
15412 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
15416 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
15417 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
15418 osp.$mdtosc_proc1.prealloc_last_id)
15419 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
15420 osp.$mdtosc_proc1.prealloc_next_id)
15424 if ! combined_mgs_mds ; then
15428 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
15429 #define OBD_FAIL_OST_ENOINO 0x229
15430 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
15431 create_pool $FSNAME.$TESTNAME || return 1
15432 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
15434 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
15436 MDSOBJS=$((last_id - next_id))
15437 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
15439 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
15440 echo "OST still has $count kbytes free"
15442 echo "create $MDSOBJS files @next_id..."
15443 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
15445 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15446 osp.$mdtosc_proc1.prealloc_last_id)
15447 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15448 osp.$mdtosc_proc1.prealloc_next_id)
15450 echo "after creation, last_id=$last_id2, next_id=$next_id2"
15455 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
15456 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
15458 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
15459 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
15460 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15461 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
15462 echo "unlink $MDSOBJS files @$next_id..."
15463 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
15465 if ! combined_mgs_mds ; then
15469 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
15472 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15474 dd if=`which date` of=$MOUNT/date oflag=sync
15475 chmod +x $MOUNT/date
15477 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
15478 $LCTL set_param fail_loc=0x80001401
15480 $MOUNT/date > /dev/null
15483 run_test 221 "make sure fault and truncate race to not cause OOM"
15486 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15489 test_mkdir $DIR/$tdir
15490 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15491 createmany -o $DIR/$tdir/$tfile 10
15492 cancel_lru_locks mdc
15493 cancel_lru_locks osc
15494 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15495 $LCTL set_param fail_loc=0x31a
15496 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
15497 $LCTL set_param fail_loc=0
15500 run_test 222a "AGL for ls should not trigger CLIO lock failure"
15503 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15506 test_mkdir $DIR/$tdir
15507 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15508 createmany -o $DIR/$tdir/$tfile 10
15509 cancel_lru_locks mdc
15510 cancel_lru_locks osc
15511 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15512 $LCTL set_param fail_loc=0x31a
15513 rm -r $DIR/$tdir || error "AGL for rmdir failed"
15514 $LCTL set_param fail_loc=0
15516 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
15519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15522 test_mkdir $DIR/$tdir
15523 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15524 createmany -o $DIR/$tdir/$tfile 10
15525 cancel_lru_locks mdc
15526 cancel_lru_locks osc
15527 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
15528 $LCTL set_param fail_loc=0x31b
15529 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
15530 $LCTL set_param fail_loc=0
15533 run_test 223 "osc reenqueue if without AGL lock granted ======================="
15535 test_224a() { # LU-1039, MRP-303
15536 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15538 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
15539 $LCTL set_param fail_loc=0x508
15540 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
15541 $LCTL set_param fail_loc=0
15544 run_test 224a "Don't panic on bulk IO failure"
15546 test_224b() { # LU-1039, MRP-303
15547 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15549 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
15550 cancel_lru_locks osc
15551 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
15552 $LCTL set_param fail_loc=0x515
15553 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
15554 $LCTL set_param fail_loc=0
15557 run_test 224b "Don't panic on bulk IO failure"
15559 test_224c() { # LU-6441
15560 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15561 remote_mds_nodsh && skip "remote MDS with nodsh"
15563 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15564 save_writethrough $p
15565 set_cache writethrough on
15567 local pages_per_rpc=$($LCTL get_param \
15568 osc.*.max_pages_per_rpc)
15569 local at_max=$($LCTL get_param -n at_max)
15570 local timeout=$($LCTL get_param -n timeout)
15571 local test_at="at_max"
15572 local param_at="$FSNAME.sys.at_max"
15573 local test_timeout="timeout"
15574 local param_timeout="$FSNAME.sys.timeout"
15576 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
15578 set_persistent_param_and_check client "$test_at" "$param_at" 0
15579 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
15581 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
15582 do_facet ost1 "$LCTL set_param fail_loc=0x520"
15583 $LFS setstripe -c 1 -i 0 $DIR/$tfile
15584 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
15586 do_facet ost1 "$LCTL set_param fail_loc=0"
15588 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
15589 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
15592 $LCTL set_param -n $pages_per_rpc
15593 restore_lustre_params < $p
15596 run_test 224c "Don't hang if one of md lost during large bulk RPC"
15598 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
15600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15601 if [ -z ${MDSSURVEY} ]; then
15602 skip_env "mds-survey not found"
15604 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15605 skip "Need MDS version at least 2.2.51"
15607 local mds=$(facet_host $SINGLEMDS)
15608 local target=$(do_nodes $mds 'lctl dl' |
15609 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15611 local cmd1="file_count=1000 thrhi=4"
15612 local cmd2="dir_count=2 layer=mdd stripe_count=0"
15613 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15614 local cmd="$cmd1 $cmd2 $cmd3"
15616 rm -f ${TMP}/mds_survey*
15618 eval $cmd || error "mds-survey with zero-stripe failed"
15619 cat ${TMP}/mds_survey*
15620 rm -f ${TMP}/mds_survey*
15622 run_test 225a "Metadata survey sanity with zero-stripe"
15625 if [ -z ${MDSSURVEY} ]; then
15626 skip_env "mds-survey not found"
15628 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15629 skip "Need MDS version at least 2.2.51"
15630 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15631 remote_mds_nodsh && skip "remote MDS with nodsh"
15632 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
15633 skip_env "Need to mount OST to test"
15636 local mds=$(facet_host $SINGLEMDS)
15637 local target=$(do_nodes $mds 'lctl dl' |
15638 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15640 local cmd1="file_count=1000 thrhi=4"
15641 local cmd2="dir_count=2 layer=mdd stripe_count=1"
15642 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15643 local cmd="$cmd1 $cmd2 $cmd3"
15645 rm -f ${TMP}/mds_survey*
15647 eval $cmd || error "mds-survey with stripe_count failed"
15648 cat ${TMP}/mds_survey*
15649 rm -f ${TMP}/mds_survey*
15651 run_test 225b "Metadata survey sanity with stripe_count = 1"
15653 mcreate_path2fid () {
15659 local path=$DIR/$tdir/$name
15664 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
15665 error "cannot create $desc"
15667 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
15669 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
15671 fid_path=$($LFS fid2path $MOUNT $fid)
15673 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
15675 [ "$path" == "$fid_path" ] ||
15676 error "fid2path returned $fid_path, expected $path"
15678 echo "pass with $path and $fid"
15683 mkdir -p $DIR/$tdir
15685 mcreate_path2fid 0010666 0 0 fifo "FIFO"
15686 mcreate_path2fid 0020666 1 3 null "character special file (null)"
15687 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
15688 mcreate_path2fid 0040666 0 0 dir "directory"
15689 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
15690 mcreate_path2fid 0100666 0 0 file "regular file"
15691 mcreate_path2fid 0120666 0 0 link "symbolic link"
15692 mcreate_path2fid 0140666 0 0 sock "socket"
15694 run_test 226a "call path2fid and fid2path on files of all type"
15697 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15702 mkdir -p $DIR/$tdir
15703 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
15704 error "create remote directory failed"
15705 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
15706 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
15707 "character special file (null)"
15708 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
15709 "character special file (no device)"
15710 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
15711 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
15712 "block special file (loop)"
15713 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
15714 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
15715 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
15717 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
15719 # LU-1299 Executing or running ldd on a truncated executable does not
15720 # cause an out-of-memory condition.
15722 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15723 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
15725 dd if=$(which date) of=$MOUNT/date bs=1k count=1
15726 chmod +x $MOUNT/date
15728 $MOUNT/date > /dev/null
15729 ldd $MOUNT/date > /dev/null
15732 run_test 227 "running truncated executable does not cause OOM"
15734 # LU-1512 try to reuse idle OI blocks
15736 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15737 remote_mds_nodsh && skip "remote MDS with nodsh"
15738 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15740 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15741 local myDIR=$DIR/$tdir
15744 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15745 $LCTL set_param fail_loc=0x80001002
15746 createmany -o $myDIR/t- 10000
15747 $LCTL set_param fail_loc=0
15748 # The guard is current the largest FID holder
15750 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15752 local IDX=$(($SEQ % 64))
15754 do_facet $SINGLEMDS sync
15755 # Make sure journal flushed.
15757 local blk1=$(do_facet $SINGLEMDS \
15758 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15759 grep Blockcount | awk '{print $4}')
15761 # Remove old files, some OI blocks will become idle.
15762 unlinkmany $myDIR/t- 10000
15763 # Create new files, idle OI blocks should be reused.
15764 createmany -o $myDIR/t- 2000
15765 do_facet $SINGLEMDS sync
15766 # Make sure journal flushed.
15768 local blk2=$(do_facet $SINGLEMDS \
15769 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15770 grep Blockcount | awk '{print $4}')
15772 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15774 run_test 228a "try to reuse idle OI blocks"
15777 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15778 remote_mds_nodsh && skip "remote MDS with nodsh"
15779 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15781 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15782 local myDIR=$DIR/$tdir
15785 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15786 $LCTL set_param fail_loc=0x80001002
15787 createmany -o $myDIR/t- 10000
15788 $LCTL set_param fail_loc=0
15789 # The guard is current the largest FID holder
15791 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15793 local IDX=$(($SEQ % 64))
15795 do_facet $SINGLEMDS sync
15796 # Make sure journal flushed.
15798 local blk1=$(do_facet $SINGLEMDS \
15799 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15800 grep Blockcount | awk '{print $4}')
15802 # Remove old files, some OI blocks will become idle.
15803 unlinkmany $myDIR/t- 10000
15806 stop $SINGLEMDS || error "Fail to stop MDT."
15808 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
15810 df $MOUNT || error "Fail to df."
15811 # Create new files, idle OI blocks should be reused.
15812 createmany -o $myDIR/t- 2000
15813 do_facet $SINGLEMDS sync
15814 # Make sure journal flushed.
15816 local blk2=$(do_facet $SINGLEMDS \
15817 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15818 grep Blockcount | awk '{print $4}')
15820 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15822 run_test 228b "idle OI blocks can be reused after MDT restart"
15826 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15827 remote_mds_nodsh && skip "remote MDS with nodsh"
15828 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15830 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15831 local myDIR=$DIR/$tdir
15834 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15835 $LCTL set_param fail_loc=0x80001002
15836 # 20000 files can guarantee there are index nodes in the OI file
15837 createmany -o $myDIR/t- 20000
15838 $LCTL set_param fail_loc=0
15839 # The guard is current the largest FID holder
15841 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15843 local IDX=$(($SEQ % 64))
15845 do_facet $SINGLEMDS sync
15846 # Make sure journal flushed.
15848 local blk1=$(do_facet $SINGLEMDS \
15849 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15850 grep Blockcount | awk '{print $4}')
15852 # Remove old files, some OI blocks will become idle.
15853 unlinkmany $myDIR/t- 20000
15855 # The OI file should become empty now
15857 # Create new files, idle OI blocks should be reused.
15858 createmany -o $myDIR/t- 2000
15859 do_facet $SINGLEMDS sync
15860 # Make sure journal flushed.
15862 local blk2=$(do_facet $SINGLEMDS \
15863 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15864 grep Blockcount | awk '{print $4}')
15866 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15868 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
15870 test_229() { # LU-2482, LU-3448
15871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15872 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
15873 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
15874 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
15878 # Create a file with a released layout and stripe count 2.
15879 $MULTIOP $DIR/$tfile H2c ||
15880 error "failed to create file with released layout"
15882 $LFS getstripe -v $DIR/$tfile
15884 local pattern=$($LFS getstripe -L $DIR/$tfile)
15885 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
15887 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
15889 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
15890 stat $DIR/$tfile || error "failed to stat released file"
15892 chown $RUNAS_ID $DIR/$tfile ||
15893 error "chown $RUNAS_ID $DIR/$tfile failed"
15895 chgrp $RUNAS_ID $DIR/$tfile ||
15896 error "chgrp $RUNAS_ID $DIR/$tfile failed"
15898 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
15899 rm $DIR/$tfile || error "failed to remove released file"
15901 run_test 229 "getstripe/stat/rm/attr changes work on released files"
15904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15905 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15906 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15907 skip "Need MDS version at least 2.11.52"
15911 test_mkdir $DIR/$tdir
15912 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
15913 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
15914 [ $mdt_idx -ne 0 ] &&
15915 error "create local directory on wrong MDT $mdt_idx"
15917 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
15918 error "create remote directory failed"
15919 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
15920 [ $mdt_idx -ne $MDTIDX ] &&
15921 error "create remote directory on wrong MDT $mdt_idx"
15923 createmany -o $DIR/$tdir/test_230/t- 10 ||
15924 error "create files on remote directory failed"
15925 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
15926 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
15927 rm -r $DIR/$tdir || error "unlink remote directory failed"
15929 run_test 230a "Create remote directory and files under the remote directory"
15932 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15933 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15934 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15935 skip "Need MDS version at least 2.11.52"
15943 local migrate_dir=$DIR/$tdir/migrate_dir
15944 local other_dir=$DIR/$tdir/other_dir
15946 test_mkdir $DIR/$tdir
15947 test_mkdir -i0 -c1 $migrate_dir
15948 test_mkdir -i0 -c1 $other_dir
15949 for ((i=0; i<10; i++)); do
15950 mkdir -p $migrate_dir/dir_${i}
15951 createmany -o $migrate_dir/dir_${i}/f 10 ||
15952 error "create files under remote dir failed $i"
15955 cp /etc/passwd $migrate_dir/$tfile
15956 cp /etc/passwd $other_dir/$tfile
15957 chattr +SAD $migrate_dir
15958 chattr +SAD $migrate_dir/$tfile
15960 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15961 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15962 local old_dir_mode=$(stat -c%f $migrate_dir)
15963 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
15965 mkdir -p $migrate_dir/dir_default_stripe2
15966 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
15967 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
15969 mkdir -p $other_dir
15970 ln $migrate_dir/$tfile $other_dir/luna
15971 ln $migrate_dir/$tfile $migrate_dir/sofia
15972 ln $other_dir/$tfile $migrate_dir/david
15973 ln -s $migrate_dir/$tfile $other_dir/zachary
15974 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
15975 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
15977 $LFS migrate -m $MDTIDX $migrate_dir ||
15978 error "fails on migrating remote dir to MDT1"
15980 echo "migratate to MDT1, then checking.."
15981 for ((i = 0; i < 10; i++)); do
15982 for file in $(find $migrate_dir/dir_${i}); do
15983 mdt_index=$($LFS getstripe -m $file)
15984 [ $mdt_index == $MDTIDX ] ||
15985 error "$file is not on MDT${MDTIDX}"
15989 # the multiple link file should still in MDT0
15990 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
15991 [ $mdt_index == 0 ] ||
15992 error "$file is not on MDT${MDTIDX}"
15994 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15995 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15996 error " expect $old_dir_flag get $new_dir_flag"
15998 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15999 [ "$old_file_flag" = "$new_file_flag" ] ||
16000 error " expect $old_file_flag get $new_file_flag"
16002 local new_dir_mode=$(stat -c%f $migrate_dir)
16003 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16004 error "expect mode $old_dir_mode get $new_dir_mode"
16006 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16007 [ "$old_file_mode" = "$new_file_mode" ] ||
16008 error "expect mode $old_file_mode get $new_file_mode"
16010 diff /etc/passwd $migrate_dir/$tfile ||
16011 error "$tfile different after migration"
16013 diff /etc/passwd $other_dir/luna ||
16014 error "luna different after migration"
16016 diff /etc/passwd $migrate_dir/sofia ||
16017 error "sofia different after migration"
16019 diff /etc/passwd $migrate_dir/david ||
16020 error "david different after migration"
16022 diff /etc/passwd $other_dir/zachary ||
16023 error "zachary different after migration"
16025 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16026 error "${tfile}_ln different after migration"
16028 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16029 error "${tfile}_ln_other different after migration"
16031 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
16032 [ $stripe_count = 2 ] ||
16033 error "dir strpe_count $d != 2 after migration."
16035 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
16036 [ $stripe_count = 2 ] ||
16037 error "file strpe_count $d != 2 after migration."
16039 #migrate back to MDT0
16042 $LFS migrate -m $MDTIDX $migrate_dir ||
16043 error "fails on migrating remote dir to MDT0"
16045 echo "migrate back to MDT0, checking.."
16046 for file in $(find $migrate_dir); do
16047 mdt_index=$($LFS getstripe -m $file)
16048 [ $mdt_index == $MDTIDX ] ||
16049 error "$file is not on MDT${MDTIDX}"
16052 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16053 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16054 error " expect $old_dir_flag get $new_dir_flag"
16056 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16057 [ "$old_file_flag" = "$new_file_flag" ] ||
16058 error " expect $old_file_flag get $new_file_flag"
16060 local new_dir_mode=$(stat -c%f $migrate_dir)
16061 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16062 error "expect mode $old_dir_mode get $new_dir_mode"
16064 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16065 [ "$old_file_mode" = "$new_file_mode" ] ||
16066 error "expect mode $old_file_mode get $new_file_mode"
16068 diff /etc/passwd ${migrate_dir}/$tfile ||
16069 error "$tfile different after migration"
16071 diff /etc/passwd ${other_dir}/luna ||
16072 error "luna different after migration"
16074 diff /etc/passwd ${migrate_dir}/sofia ||
16075 error "sofia different after migration"
16077 diff /etc/passwd ${other_dir}/zachary ||
16078 error "zachary different after migration"
16080 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16081 error "${tfile}_ln different after migration"
16083 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16084 error "${tfile}_ln_other different after migration"
16086 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
16087 [ $stripe_count = 2 ] ||
16088 error "dir strpe_count $d != 2 after migration."
16090 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
16091 [ $stripe_count = 2 ] ||
16092 error "file strpe_count $d != 2 after migration."
16094 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16096 run_test 230b "migrate directory"
16099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16100 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16101 remote_mds_nodsh && skip "remote MDS with nodsh"
16102 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16103 skip "Need MDS version at least 2.11.52"
16109 local migrate_dir=$DIR/$tdir/migrate_dir
16111 #If migrating directory fails in the middle, all entries of
16112 #the directory is still accessiable.
16113 test_mkdir $DIR/$tdir
16114 test_mkdir -i0 -c1 $migrate_dir
16115 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
16117 createmany -o $migrate_dir/f $total ||
16118 error "create files under ${migrate_dir} failed"
16120 # fail after migrating top dir, and this will fail only once, so the
16121 # first sub file migration will fail (currently f3), others succeed.
16122 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
16123 do_facet mds1 lctl set_param fail_loc=0x1801
16124 local t=$(ls $migrate_dir | wc -l)
16125 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
16126 error "migrate should fail"
16127 local u=$(ls $migrate_dir | wc -l)
16128 [ "$u" == "$t" ] || error "$u != $t during migration"
16130 # add new dir/file should succeed
16131 mkdir $migrate_dir/dir ||
16132 error "mkdir failed under migrating directory"
16133 touch $migrate_dir/file ||
16134 error "create file failed under migrating directory"
16136 # add file with existing name should fail
16137 for file in $migrate_dir/f*; do
16138 stat $file > /dev/null || error "stat $file failed"
16139 $OPENFILE -f O_CREAT:O_EXCL $file &&
16140 error "open(O_CREAT|O_EXCL) $file should fail"
16141 $MULTIOP $file m && error "create $file should fail"
16142 touch $DIR/$tdir/remote_dir/$tfile ||
16143 error "touch $tfile failed"
16144 ln $DIR/$tdir/remote_dir/$tfile $file &&
16145 error "link $file should fail"
16146 mdt_index=$($LFS getstripe -m $file)
16147 if [ $mdt_index == 0 ]; then
16148 # file failed to migrate is not allowed to rename to
16149 mv $DIR/$tdir/remote_dir/$tfile $file &&
16150 error "rename to $file should fail"
16152 mv $DIR/$tdir/remote_dir/$tfile $file ||
16153 error "rename to $file failed"
16155 echo hello >> $file || error "write $file failed"
16158 # resume migration with different options should fail
16159 $LFS migrate -m 0 $migrate_dir &&
16160 error "migrate -m 0 $migrate_dir should fail"
16162 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
16163 error "migrate -c 2 $migrate_dir should fail"
16165 # resume migration should succeed
16166 $LFS migrate -m $MDTIDX $migrate_dir ||
16167 error "migrate $migrate_dir failed"
16169 echo "Finish migration, then checking.."
16170 for file in $(find $migrate_dir); do
16171 mdt_index=$($LFS getstripe -m $file)
16172 [ $mdt_index == $MDTIDX ] ||
16173 error "$file is not on MDT${MDTIDX}"
16176 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16178 run_test 230c "check directory accessiblity if migration failed"
16181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16182 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16183 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16184 skip "Need MDS version at least 2.11.52"
16186 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
16188 local migrate_dir=$DIR/$tdir/migrate_dir
16198 old_index=$((RANDOM % MDSCOUNT))
16199 old_count=$((MDSCOUNT - old_index))
16200 new_index=$((RANDOM % MDSCOUNT))
16201 new_count=$((MDSCOUNT - new_index))
16202 new_hash="all_char"
16204 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
16205 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
16207 test_mkdir $DIR/$tdir
16208 test_mkdir -i $old_index -c $old_count $migrate_dir
16210 for ((i=0; i<100; i++)); do
16211 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
16212 createmany -o $migrate_dir/dir_${i}/f 100 ||
16213 error "create files under remote dir failed $i"
16216 echo -n "Migrate from MDT$old_index "
16217 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
16218 echo -n "to MDT$new_index"
16219 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
16222 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
16223 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
16224 error "migrate remote dir error"
16226 echo "Finish migration, then checking.."
16227 for file in $(find $migrate_dir); do
16228 mdt_index=$($LFS getstripe -m $file)
16229 if [ $mdt_index -lt $new_index ] ||
16230 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
16231 error "$file is on MDT$mdt_index"
16235 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16237 run_test 230d "check migrate big directory"
16240 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16241 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16242 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16243 skip "Need MDS version at least 2.11.52"
16250 mkdir -p $DIR/$tdir
16251 mkdir $DIR/$tdir/migrate_dir
16252 mkdir $DIR/$tdir/other_dir
16253 touch $DIR/$tdir/migrate_dir/a
16254 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
16255 ls $DIR/$tdir/other_dir
16257 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16258 error "migrate dir fails"
16260 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16261 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16263 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16264 [ $mdt_index == 0 ] || error "a is not on MDT0"
16266 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
16267 error "migrate dir fails"
16269 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
16270 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
16272 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16273 [ $mdt_index == 1 ] || error "a is not on MDT1"
16275 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
16276 [ $mdt_index == 1 ] || error "b is not on MDT1"
16278 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16279 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
16281 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
16283 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16285 run_test 230e "migrate mulitple local link files"
16288 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16289 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16290 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16291 skip "Need MDS version at least 2.11.52"
16296 mkdir -p $DIR/$tdir
16297 mkdir $DIR/$tdir/migrate_dir
16298 $LFS mkdir -i1 $DIR/$tdir/other_dir
16299 touch $DIR/$tdir/migrate_dir/a
16300 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
16301 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
16302 ls $DIR/$tdir/other_dir
16304 # a should be migrated to MDT1, since no other links on MDT0
16305 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16306 error "#1 migrate dir fails"
16307 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16308 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16309 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16310 [ $mdt_index == 1 ] || error "a is not on MDT1"
16312 # a should stay on MDT1, because it is a mulitple link file
16313 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16314 error "#2 migrate dir fails"
16315 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16316 [ $mdt_index == 1 ] || error "a is not on MDT1"
16318 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16319 error "#3 migrate dir fails"
16321 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16322 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
16323 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
16325 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
16326 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
16328 # a should be migrated to MDT0, since no other links on MDT1
16329 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16330 error "#4 migrate dir fails"
16331 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16332 [ $mdt_index == 0 ] || error "a is not on MDT0"
16334 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16336 run_test 230f "migrate mulitple remote link files"
16339 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16340 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16341 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16342 skip "Need MDS version at least 2.11.52"
16344 mkdir -p $DIR/$tdir/migrate_dir
16346 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
16347 error "migrating dir to non-exist MDT succeeds"
16350 run_test 230g "migrate dir to non-exist MDT"
16353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16354 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16355 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16356 skip "Need MDS version at least 2.11.52"
16360 mkdir -p $DIR/$tdir/migrate_dir
16362 $LFS migrate -m1 $DIR &&
16363 error "migrating mountpoint1 should fail"
16365 $LFS migrate -m1 $DIR/$tdir/.. &&
16366 error "migrating mountpoint2 should fail"
16369 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
16370 error "migrating $tdir/migrate_dir/.. should fail"
16374 run_test 230h "migrate .. and root"
16377 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16378 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16379 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16380 skip "Need MDS version at least 2.11.52"
16382 mkdir -p $DIR/$tdir/migrate_dir
16384 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
16385 error "migration fails with a tailing slash"
16387 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
16388 error "migration fails with two tailing slashes"
16390 run_test 230i "lfs migrate -m tolerates trailing slashes"
16393 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16394 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16395 skip "Need MDS version at least 2.11.52"
16397 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
16398 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
16399 error "create $tfile failed"
16400 cat /etc/passwd > $DIR/$tdir/$tfile
16402 $LFS migrate -m 1 $DIR/$tdir
16404 cmp /etc/passwd $DIR/$tdir/$tfile ||
16405 error "DoM file mismatch after migration"
16407 run_test 230j "DoM file data not changed after dir migration"
16410 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
16411 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16412 skip "Need MDS version at least 2.11.56"
16415 local files_on_starting_mdt=0
16417 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
16418 $LFS getdirstripe $DIR/$tdir
16419 for i in $(seq $total); do
16420 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
16421 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16422 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16425 echo "$files_on_starting_mdt files on MDT0"
16427 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
16428 $LFS getdirstripe $DIR/$tdir
16430 files_on_starting_mdt=0
16431 for i in $(seq $total); do
16432 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16433 error "file $tfile.$i mismatch after migration"
16434 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
16435 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16438 echo "$files_on_starting_mdt files on MDT1 after migration"
16439 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
16441 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
16442 $LFS getdirstripe $DIR/$tdir
16444 files_on_starting_mdt=0
16445 for i in $(seq $total); do
16446 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16447 error "file $tfile.$i mismatch after 2nd migration"
16448 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16449 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16452 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
16453 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
16457 run_test 230k "file data not changed after dir migration"
16460 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16461 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16462 skip "Need MDS version at least 2.11.56"
16464 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
16465 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
16466 error "create files under remote dir failed $i"
16467 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
16469 run_test 230l "readdir between MDTs won't crash"
16473 # For simplicity this test assumes that max_pages_per_rpc
16474 # is the same across all OSCs
16475 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
16476 local bulk_size=$((max_pages * PAGE_SIZE))
16477 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
16480 mkdir -p $DIR/$tdir
16481 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
16482 error "failed to set stripe with -S ${brw_size}M option"
16484 # clear the OSC stats
16485 $LCTL set_param osc.*.stats=0 &>/dev/null
16488 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
16489 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
16490 oflag=direct &>/dev/null || error "dd failed"
16492 sync; sleep 1; sync # just to be safe
16493 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
16494 if [ x$nrpcs != "x1" ]; then
16495 $LCTL get_param osc.*.stats
16496 error "found $nrpcs ost_write RPCs, not 1 as expected"
16500 # Drop the OSC cache, otherwise we will read from it
16501 cancel_lru_locks osc
16503 # clear the OSC stats
16504 $LCTL set_param osc.*.stats=0 &>/dev/null
16506 # Client reads $bulk_size.
16507 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
16508 iflag=direct &>/dev/null || error "dd failed"
16510 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
16511 if [ x$nrpcs != "x1" ]; then
16512 $LCTL get_param osc.*.stats
16513 error "found $nrpcs ost_read RPCs, not 1 as expected"
16516 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
16519 mkdir -p $DIR/$tdir
16521 for i in {0..1023}; do
16522 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
16523 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
16524 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
16528 run_test 231b "must not assert on fully utilized OST request buffer"
16531 mkdir -p $DIR/$tdir
16532 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16534 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16535 do_facet ost1 $LCTL set_param fail_loc=0x31c
16537 # ignore dd failure
16538 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
16540 do_facet ost1 $LCTL set_param fail_loc=0
16541 umount_client $MOUNT || error "umount failed"
16542 mount_client $MOUNT || error "mount failed"
16543 stop ost1 || error "cannot stop ost1"
16544 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16546 run_test 232a "failed lock should not block umount"
16549 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
16550 skip "Need MDS version at least 2.10.58"
16552 mkdir -p $DIR/$tdir
16553 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16554 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
16556 cancel_lru_locks osc
16558 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16559 do_facet ost1 $LCTL set_param fail_loc=0x31c
16562 $LFS data_version $DIR/$tdir/$tfile || true
16564 do_facet ost1 $LCTL set_param fail_loc=0
16565 umount_client $MOUNT || error "umount failed"
16566 mount_client $MOUNT || error "mount failed"
16567 stop ost1 || error "cannot stop ost1"
16568 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16570 run_test 232b "failed data version lock should not block umount"
16573 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
16574 skip "Need MDS version at least 2.3.64"
16575 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16577 local fid=$($LFS path2fid $MOUNT)
16579 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16580 error "cannot access $MOUNT using its FID '$fid'"
16582 run_test 233a "checking that OBF of the FS root succeeds"
16585 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
16586 skip "Need MDS version at least 2.5.90"
16587 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16589 local fid=$($LFS path2fid $MOUNT/.lustre)
16591 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16592 error "cannot access $MOUNT/.lustre using its FID '$fid'"
16594 fid=$($LFS path2fid $MOUNT/.lustre/fid)
16595 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16596 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
16598 run_test 233b "checking that OBF of the FS .lustre succeeds"
16601 local p="$TMP/sanityN-$TESTNAME.parameters"
16602 save_lustre_params client "llite.*.xattr_cache" > $p
16603 lctl set_param llite.*.xattr_cache 1 ||
16604 skip_env "xattr cache is not supported"
16606 mkdir -p $DIR/$tdir || error "mkdir failed"
16607 touch $DIR/$tdir/$tfile || error "touch failed"
16608 # OBD_FAIL_LLITE_XATTR_ENOMEM
16609 $LCTL set_param fail_loc=0x1405
16610 getfattr -n user.attr $DIR/$tdir/$tfile &&
16611 error "getfattr should have failed with ENOMEM"
16612 $LCTL set_param fail_loc=0x0
16615 restore_lustre_params < $p
16618 run_test 234 "xattr cache should not crash on ENOMEM"
16621 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
16622 skip "Need MDS version at least 2.4.52"
16624 flock_deadlock $DIR/$tfile
16629 124) error "process hangs on a deadlock"
16631 *) error "error executing flock_deadlock $DIR/$tfile"
16635 run_test 235 "LU-1715: flock deadlock detection does not work properly"
16639 check_swap_layouts_support
16641 local ref1=/etc/passwd
16642 local ref2=/etc/group
16643 local file1=$DIR/$tdir/f1
16644 local file2=$DIR/$tdir/f2
16646 test_mkdir -c1 $DIR/$tdir
16647 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
16648 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
16649 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
16650 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
16651 local fd=$(free_fd)
16652 local cmd="exec $fd<>$file2"
16655 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
16656 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
16659 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
16664 run_test 236 "Layout swap on open unlinked file"
16666 # LU-4659 linkea consistency
16668 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16669 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16670 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16671 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16674 ln $DIR/$tfile $DIR/$tfile.lnk
16675 touch $DIR/$tfile.new
16676 mv $DIR/$tfile.new $DIR/$tfile
16677 local fid1=$($LFS path2fid $DIR/$tfile)
16678 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
16679 local path1=$($LFS fid2path $FSNAME "$fid1")
16680 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
16681 local path2=$($LFS fid2path $FSNAME "$fid2")
16682 [ $tfile.lnk == $path2 ] ||
16683 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
16686 run_test 238 "Verify linkea consistency"
16688 test_239A() { # was test_239
16689 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
16690 skip "Need MDS version at least 2.5.60"
16692 local list=$(comma_list $(mdts_nodes))
16694 mkdir -p $DIR/$tdir
16695 createmany -o $DIR/$tdir/f- 5000
16696 unlinkmany $DIR/$tdir/f- 5000
16697 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
16698 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
16699 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
16700 osp.*MDT*.sync_in_flight" | calc_sum)
16701 [ "$changes" -eq 0 ] || error "$changes not synced"
16703 run_test 239A "osp_sync test"
16705 test_239a() { #LU-5297
16706 remote_mds_nodsh && skip "remote MDS with nodsh"
16709 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
16710 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
16711 chgrp $RUNAS_GID $DIR/$tfile
16712 wait_delete_completed
16714 run_test 239a "process invalid osp sync record correctly"
16716 test_239b() { #LU-5297
16717 remote_mds_nodsh && skip "remote MDS with nodsh"
16720 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
16721 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
16722 chgrp $RUNAS_GID $DIR/$tfile1
16723 wait_delete_completed
16724 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16726 chgrp $RUNAS_GID $DIR/$tfile2
16727 wait_delete_completed
16729 run_test 239b "process osp sync record with ENOMEM error correctly"
16732 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16733 remote_mds_nodsh && skip "remote MDS with nodsh"
16735 mkdir -p $DIR/$tdir
16737 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
16738 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
16739 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
16740 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
16742 umount_client $MOUNT || error "umount failed"
16743 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
16744 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
16745 mount_client $MOUNT || error "failed to mount client"
16747 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
16748 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
16750 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
16756 for LOOP in $(seq $count); do
16757 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
16758 cancel_lru_locks $OSC || true
16766 for LOOP in $(seq $1); do
16767 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
16772 test_241a() { # was test_241
16773 local bsize=$PAGE_SIZE
16775 (( bsize < 40960 )) && bsize=40960
16776 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
16778 cancel_lru_locks $OSC
16779 test_241_bio 1000 $bsize &
16781 test_241_dio 1000 $bsize
16784 run_test 241a "bio vs dio"
16787 local bsize=$PAGE_SIZE
16789 (( bsize < 40960 )) && bsize=40960
16790 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
16792 test_241_dio 1000 $bsize &
16794 test_241_dio 1000 $bsize
16797 run_test 241b "dio vs dio"
16800 remote_mds_nodsh && skip "remote MDS with nodsh"
16802 mkdir -p $DIR/$tdir
16803 touch $DIR/$tdir/$tfile
16805 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
16806 do_facet mds1 lctl set_param fail_loc=0x105
16807 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
16809 do_facet mds1 lctl set_param fail_loc=0
16810 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
16812 run_test 242 "mdt_readpage failure should not cause directory unreadable"
16816 test_mkdir $DIR/$tdir
16817 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
16819 run_test 243 "various group lock tests"
16823 test_mkdir $DIR/$tdir
16824 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
16825 sendfile_grouplock $DIR/$tdir/$tfile || \
16826 error "sendfile+grouplock failed"
16829 run_test 244 "sendfile with group lock tests"
16832 local flagname="multi_mod_rpcs"
16833 local connect_data_name="max_mod_rpcs"
16836 # check if multiple modify RPCs flag is set
16837 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
16838 grep "connect_flags:")
16841 echo "$out" | grep -qw $flagname
16842 if [ $? -ne 0 ]; then
16843 echo "connect flag $flagname is not set"
16847 # check if multiple modify RPCs data is set
16848 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
16851 echo "$out" | grep -qw $connect_data_name ||
16852 error "import should have connect data $connect_data_name"
16854 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
16856 test_246() { # LU-7371
16857 remote_ost_nodsh && skip "remote OST with nodsh"
16858 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
16859 skip "Need OST version >= 2.7.62"
16861 do_facet ost1 $LCTL set_param fail_val=4095
16862 #define OBD_FAIL_OST_READ_SIZE 0x234
16863 do_facet ost1 $LCTL set_param fail_loc=0x234
16864 $LFS setstripe $DIR/$tfile -i 0 -c 1
16865 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
16866 cancel_lru_locks $FSNAME-OST0000
16867 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
16869 run_test 246 "Read file of size 4095 should return right length"
16875 umount_client $submount
16880 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16882 skip_env "Fileset feature is not supported"
16884 local submount=${MOUNT}_$tdir
16887 mkdir -p $submount || error "mkdir $submount failed"
16888 FILESET="$FILESET/$tdir" mount_client $submount ||
16889 error "mount $submount failed"
16890 trap "cleanup_247 $submount" EXIT
16891 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
16892 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
16893 error "read $MOUNT/$tdir/$tfile failed"
16894 cleanup_247 $submount
16896 run_test 247a "mount subdir as fileset"
16899 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16900 skip_env "Fileset feature is not supported"
16902 local submount=${MOUNT}_$tdir
16904 rm -rf $MOUNT/$tdir
16905 mkdir -p $submount || error "mkdir $submount failed"
16907 FILESET="$FILESET/$tdir" mount_client $submount &&
16908 error "mount $submount should fail"
16911 run_test 247b "mount subdir that dose not exist"
16914 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16915 skip_env "Fileset feature is not supported"
16917 local submount=${MOUNT}_$tdir
16919 mkdir -p $MOUNT/$tdir/dir1
16920 mkdir -p $submount || error "mkdir $submount failed"
16921 trap "cleanup_247 $submount" EXIT
16922 FILESET="$FILESET/$tdir" mount_client $submount ||
16923 error "mount $submount failed"
16924 local fid=$($LFS path2fid $MOUNT/)
16925 $LFS fid2path $submount $fid && error "fid2path should fail"
16926 cleanup_247 $submount
16928 run_test 247c "running fid2path outside root"
16931 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16932 skip "Fileset feature is not supported"
16934 local submount=${MOUNT}_$tdir
16936 mkdir -p $MOUNT/$tdir/dir1
16937 mkdir -p $submount || error "mkdir $submount failed"
16938 FILESET="$FILESET/$tdir" mount_client $submount ||
16939 error "mount $submount failed"
16940 trap "cleanup_247 $submount" EXIT
16941 local fid=$($LFS path2fid $submount/dir1)
16942 $LFS fid2path $submount $fid || error "fid2path should succeed"
16943 cleanup_247 $submount
16945 run_test 247d "running fid2path inside root"
16949 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16951 skip "Fileset feature is not supported"
16953 local submount=${MOUNT}_$tdir
16956 mkdir -p $submount || error "mkdir $submount failed"
16957 FILESET="$FILESET/.." mount_client $submount &&
16958 error "mount $submount should fail"
16961 run_test 247e "mount .. as fileset"
16964 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
16965 [ -z "$fast_read_sav" ] && skip "no fast read support"
16967 # create a large file for fast read verification
16968 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
16970 # make sure the file is created correctly
16971 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
16972 { rm -f $DIR/$tfile; skip "file creation error"; }
16974 echo "Test 1: verify that fast read is 4 times faster on cache read"
16976 # small read with fast read enabled
16977 $LCTL set_param -n llite.*.fast_read=1
16978 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16979 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16980 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16981 # small read with fast read disabled
16982 $LCTL set_param -n llite.*.fast_read=0
16983 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16984 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16985 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16987 # verify that fast read is 4 times faster for cache read
16988 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
16989 error_not_in_vm "fast read was not 4 times faster: " \
16990 "$t_fast vs $t_slow"
16992 echo "Test 2: verify the performance between big and small read"
16993 $LCTL set_param -n llite.*.fast_read=1
16995 # 1k non-cache read
16996 cancel_lru_locks osc
16997 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16998 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16999 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17001 # 1M non-cache read
17002 cancel_lru_locks osc
17003 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17004 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17005 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17007 # verify that big IO is not 4 times faster than small IO
17008 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
17009 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
17011 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
17014 run_test 248 "fast read verification"
17016 test_249() { # LU-7890
17017 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
17018 skip "Need at least version 2.8.54"
17021 $LFS setstripe -c 1 $DIR/$tfile
17022 # Offset 2T == 4k * 512M
17023 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
17024 error "dd to 2T offset failed"
17026 run_test 249 "Write above 2T file size"
17029 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
17030 && skip "no 16TB file size limit on ZFS"
17032 $LFS setstripe -c 1 $DIR/$tfile
17033 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
17034 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
17035 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
17036 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
17037 conv=notrunc,fsync && error "append succeeded"
17040 run_test 250 "Write above 16T limit"
17043 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
17045 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
17046 #Skip once - writing the first stripe will succeed
17047 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17048 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
17049 error "short write happened"
17051 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17052 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
17053 error "short read happened"
17057 run_test 251 "Handling short read and write correctly"
17060 remote_mds_nodsh && skip "remote MDS with nodsh"
17061 remote_ost_nodsh && skip "remote OST with nodsh"
17062 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
17063 skip_env "ldiskfs only test"
17073 # check lr_reader on OST0000
17075 dev=$(facet_device $tgt)
17076 out=$(do_facet $tgt $LR_READER $dev)
17077 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17079 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
17080 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
17081 error "Invalid uuid returned by $LR_READER on target $tgt"
17082 echo -e "uuid returned by $LR_READER is '$uuid'\n"
17084 # check lr_reader -c on MDT0000
17086 dev=$(facet_device $tgt)
17087 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
17088 skip "$LR_READER does not support additional options"
17090 out=$(do_facet $tgt $LR_READER -c $dev)
17091 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17093 num=$(echo "$out" | grep -c "mdtlov")
17094 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
17095 error "Invalid number of mdtlov clients returned by $LR_READER"
17096 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
17098 # check lr_reader -cr on MDT0000
17099 out=$(do_facet $tgt $LR_READER -cr $dev)
17100 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17102 echo "$out" | grep -q "^reply_data:$" ||
17103 error "$LR_READER should have returned 'reply_data' section"
17104 num=$(echo "$out" | grep -c "client_generation")
17105 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
17107 run_test 252 "check lr_reader tool"
17110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17111 remote_mds_nodsh && skip "remote MDS with nodsh"
17112 remote_mgs_nodsh && skip "remote MGS with nodsh"
17116 local ost_name=$(ostname_from_index $ostidx)
17119 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
17120 do_facet $SINGLEMDS $LCTL get_param -n \
17121 osp.$mdtosc_proc1.reserved_mb_high ||
17122 skip "remote MDS does not support reserved_mb_high"
17126 wait_delete_completed
17129 if ! combined_mgs_mds ; then
17132 pool_add $TESTNAME || error "Pool creation failed"
17133 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
17135 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
17136 error "Setstripe failed"
17138 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
17140 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
17142 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
17144 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17145 osp.$mdtosc_proc1.prealloc_status)
17146 echo "prealloc_status $oa_status"
17148 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
17149 error "File creation should fail"
17151 #object allocation was stopped, but we still able to append files
17152 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
17153 oflag=append || error "Append failed"
17155 rm -f $DIR/$tdir/$tfile.0
17157 # For this test, we want to delete the files we created to go out of
17158 # space but leave the watermark, so we remain nearly out of space
17159 ost_watermarks_enospc_delete_files $tfile $ostidx
17161 wait_delete_completed
17165 for i in $(seq 10 12); do
17166 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
17167 2>/dev/null || error "File creation failed after rm"
17170 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17171 osp.$mdtosc_proc1.prealloc_status)
17172 echo "prealloc_status $oa_status"
17174 if (( oa_status != 0 )); then
17175 error "Object allocation still disable after rm"
17178 if ! combined_mgs_mds ; then
17182 run_test 253 "Check object allocation limit"
17185 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17186 remote_mds_nodsh && skip "remote MDS with nodsh"
17187 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
17188 skip "MDS does not support changelog_size"
17191 local MDT0=$(facet_svc $SINGLEMDS)
17193 changelog_register || error "changelog_register failed"
17195 changelog_clear 0 || error "changelog_clear failed"
17197 local size1=$(do_facet $SINGLEMDS \
17198 $LCTL get_param -n mdd.$MDT0.changelog_size)
17199 echo "Changelog size $size1"
17202 $LFS mkdir -i 0 $DIR/$tdir
17204 mkdir -p $DIR/$tdir/pics/2008/zachy
17205 touch $DIR/$tdir/pics/2008/zachy/timestamp
17206 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
17207 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
17208 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
17209 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
17210 rm $DIR/$tdir/pics/desktop.jpg
17212 local size2=$(do_facet $SINGLEMDS \
17213 $LCTL get_param -n mdd.$MDT0.changelog_size)
17214 echo "Changelog size after work $size2"
17216 (( $size2 > $size1 )) ||
17217 error "new Changelog size=$size2 less than old size=$size1"
17219 run_test 254 "Check changelog size"
17226 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
17227 awk -F: '{print $2}' | grep $type > /dev/null
17228 if [ $? -ne 0 ]; then
17238 lfs ladvise -a willread $file > /dev/null 2>&1
17239 if [ $? -eq 0 ]; then
17243 lfs ladvise -a willread $file 2>&1 |
17244 grep "Inappropriate ioctl for device" > /dev/null
17245 if [ $? -eq 0 ]; then
17252 bc <<<"scale=2; ($1 - $2) * 100 / $2"
17255 # run a random read IO workload
17256 # usage: random_read_iops <filename> <filesize> <iosize>
17257 random_read_iops() {
17260 local iosize=${3:-4096}
17262 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
17263 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
17266 drop_file_oss_cache() {
17270 $LFS ladvise -a dontneed $file 2>/dev/null ||
17271 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
17274 ladvise_willread_performance()
17277 local average_origin=0
17278 local average_cache=0
17279 local average_ladvise=0
17281 for ((i = 1; i <= $repeat; i++)); do
17282 echo "Iter $i/$repeat: reading without willread hint"
17283 cancel_lru_locks osc
17284 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17285 local speed_origin=$(random_read_iops $DIR/$tfile $size)
17286 echo "Iter $i/$repeat: uncached speed: $speed_origin"
17287 average_origin=$(bc <<<"$average_origin + $speed_origin")
17289 cancel_lru_locks osc
17290 local speed_cache=$(random_read_iops $DIR/$tfile $size)
17291 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
17292 average_cache=$(bc <<<"$average_cache + $speed_cache")
17294 cancel_lru_locks osc
17295 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17296 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
17297 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
17298 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
17299 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
17301 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
17302 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
17303 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
17305 speedup_cache=$(percent $average_cache $average_origin)
17306 speedup_ladvise=$(percent $average_ladvise $average_origin)
17308 echo "Average uncached read: $average_origin"
17309 echo "Average speedup with OSS cached read: " \
17310 "$average_cache = +$speedup_cache%"
17311 echo "Average speedup with ladvise willread: " \
17312 "$average_ladvise = +$speedup_ladvise%"
17314 local lowest_speedup=20
17315 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
17316 echo "Speedup with OSS cached read less than $lowest_speedup%," \
17317 "got $average_cache%. Skipping ladvise willread check."
17321 # the test won't work on ZFS until it supports 'ladvise dontneed', but
17322 # it is still good to run until then to exercise 'ladvise willread'
17323 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17324 [ "$ost1_FSTYPE" = "zfs" ] &&
17325 echo "osd-zfs does not support dontneed or drop_caches" &&
17328 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
17329 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
17330 error_not_in_vm "Speedup with willread is less than " \
17331 "$lowest_speedup%, got $average_ladvise%"
17335 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17336 skip "lustre < 2.8.54 does not support ladvise "
17337 remote_ost_nodsh && skip "remote OST with nodsh"
17339 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
17341 ladvise_no_type willread $DIR/$tfile &&
17342 skip "willread ladvise is not supported"
17344 ladvise_no_ioctl $DIR/$tfile &&
17345 skip "ladvise ioctl is not supported"
17348 local size=$((size_mb * 1048576))
17349 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17350 error "dd to $DIR/$tfile failed"
17352 lfs ladvise -a willread $DIR/$tfile ||
17353 error "Ladvise failed with no range argument"
17355 lfs ladvise -a willread -s 0 $DIR/$tfile ||
17356 error "Ladvise failed with no -l or -e argument"
17358 lfs ladvise -a willread -e 1 $DIR/$tfile ||
17359 error "Ladvise failed with only -e argument"
17361 lfs ladvise -a willread -l 1 $DIR/$tfile ||
17362 error "Ladvise failed with only -l argument"
17364 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
17365 error "End offset should not be smaller than start offset"
17367 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
17368 error "End offset should not be equal to start offset"
17370 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
17371 error "Ladvise failed with overflowing -s argument"
17373 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
17374 error "Ladvise failed with overflowing -e argument"
17376 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
17377 error "Ladvise failed with overflowing -l argument"
17379 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
17380 error "Ladvise succeeded with conflicting -l and -e arguments"
17382 echo "Synchronous ladvise should wait"
17384 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
17385 do_nodes $(comma_list $(osts_nodes)) \
17386 $LCTL set_param fail_val=$delay fail_loc=0x237
17388 local start_ts=$SECONDS
17389 lfs ladvise -a willread $DIR/$tfile ||
17390 error "Ladvise failed with no range argument"
17391 local end_ts=$SECONDS
17392 local inteval_ts=$((end_ts - start_ts))
17394 if [ $inteval_ts -lt $(($delay - 1)) ]; then
17395 error "Synchronous advice didn't wait reply"
17398 echo "Asynchronous ladvise shouldn't wait"
17399 local start_ts=$SECONDS
17400 lfs ladvise -a willread -b $DIR/$tfile ||
17401 error "Ladvise failed with no range argument"
17402 local end_ts=$SECONDS
17403 local inteval_ts=$((end_ts - start_ts))
17405 if [ $inteval_ts -gt $(($delay / 2)) ]; then
17406 error "Asynchronous advice blocked"
17409 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
17410 ladvise_willread_performance
17412 run_test 255a "check 'lfs ladvise -a willread'"
17418 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
17422 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17423 skip "lustre < 2.8.54 does not support ladvise "
17424 remote_ost_nodsh && skip "remote OST with nodsh"
17426 lfs setstripe -c 1 -i 0 $DIR/$tfile
17428 ladvise_no_type dontneed $DIR/$tfile &&
17429 skip "dontneed ladvise is not supported"
17431 ladvise_no_ioctl $DIR/$tfile &&
17432 skip "ladvise ioctl is not supported"
17434 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17435 [ "$ost1_FSTYPE" = "zfs" ] &&
17436 skip "zfs-osd does not support 'ladvise dontneed'"
17439 local size=$((size_mb * 1048576))
17440 # In order to prevent disturbance of other processes, only check 3/4
17441 # of the memory usage
17442 local kibibytes=$((size_mb * 1024 * 3 / 4))
17444 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17445 error "dd to $DIR/$tfile failed"
17447 #force write to complete before dropping OST cache & checking memory
17450 local total=$(facet_meminfo ost1 MemTotal)
17451 echo "Total memory: $total KiB"
17453 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
17454 local before_read=$(facet_meminfo ost1 Cached)
17455 echo "Cache used before read: $before_read KiB"
17457 lfs ladvise -a willread $DIR/$tfile ||
17458 error "Ladvise willread failed"
17459 local after_read=$(facet_meminfo ost1 Cached)
17460 echo "Cache used after read: $after_read KiB"
17462 lfs ladvise -a dontneed $DIR/$tfile ||
17463 error "Ladvise dontneed again failed"
17464 local no_read=$(facet_meminfo ost1 Cached)
17465 echo "Cache used after dontneed ladvise: $no_read KiB"
17467 if [ $total -lt $((before_read + kibibytes)) ]; then
17468 echo "Memory is too small, abort checking"
17472 if [ $((before_read + kibibytes)) -gt $after_read ]; then
17473 error "Ladvise willread should use more memory" \
17474 "than $kibibytes KiB"
17477 if [ $((no_read + kibibytes)) -gt $after_read ]; then
17478 error "Ladvise dontneed should release more memory" \
17479 "than $kibibytes KiB"
17482 run_test 255b "check 'lfs ladvise -a dontneed'"
17485 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
17486 skip "lustre < 2.10.53 does not support lockahead"
17494 test_mkdir -p $DIR/$tdir
17495 $LFS setstripe -i 0 -c 1 $DIR/$tdir
17497 #test 10 returns only success/failure
17499 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17501 if [ $rc -eq 255 ]; then
17502 error "Ladvise test${i} failed, ${rc}"
17505 #test 11 counts lock enqueue requests, all others count new locks
17507 count=$(do_facet ost1 \
17508 $LCTL get_param -n ost.OSS.ost.stats)
17509 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
17511 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17513 if [ $rc -eq 255 ]; then
17514 error "Ladvise test${i} failed, ${rc}"
17517 new_count=$(do_facet ost1 \
17518 $LCTL get_param -n ost.OSS.ost.stats)
17519 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
17520 awk '{ print $2 }')
17522 difference="$((new_count - count))"
17523 if [ $difference -ne $rc ]; then
17524 error "Ladvise test${i}, bad enqueue count, returned " \
17525 "${rc}, actual ${difference}"
17528 for i in $(seq 12 21); do
17529 # If we do not do this, we run the risk of having too many
17530 # locks and starting lock cancellation while we are checking
17532 cancel_lru_locks osc
17534 count=$($LCTL get_param -n \
17535 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17537 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17539 if [ $rc -eq 255 ]; then
17540 error "Ladvise test ${i} failed, ${rc}"
17543 new_count=$($LCTL get_param -n \
17544 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17545 difference="$((new_count - count))"
17547 # Test 15 output is divided by 100 to map down to valid return
17548 if [ $i -eq 15 ]; then
17552 if [ $difference -ne $rc ]; then
17553 error "Ladvise test ${i}, bad lock count, returned " \
17554 "${rc}, actual ${difference}"
17558 #test 22 returns only success/failure
17560 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17562 if [ $rc -eq 255 ]; then
17563 error "Ladvise test${i} failed, ${rc}"
17566 run_test 255c "suite of ladvise lockahead tests"
17569 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17570 remote_mds_nodsh && skip "remote MDS with nodsh"
17571 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
17572 changelog_users $SINGLEMDS | grep "^cl" &&
17573 skip "active changelog user"
17579 mdt_dev=$(mdsdevname 1)
17582 changelog_register || error "changelog_register failed"
17585 mkdir -p $DIR/$tdir
17587 changelog_clear 0 || error "changelog_clear failed"
17590 touch $DIR/$tdir/{1..10}
17593 stop $SINGLEMDS || error "Fail to stop MDT"
17597 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
17599 #after mount new plainllog is used
17600 touch $DIR/$tdir/{11..19}
17601 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
17602 stack_trap "rm -f $tmpfile"
17603 cat_sl=$(do_facet $SINGLEMDS "sync; \
17604 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17605 llog_reader $tmpfile | grep -c type=1064553b")
17606 do_facet $SINGLEMDS llog_reader $tmpfile
17608 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
17610 changelog_clear 0 || error "changelog_clear failed"
17612 cat_sl=$(do_facet $SINGLEMDS "sync; \
17613 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17614 llog_reader $tmpfile | grep -c type=1064553b")
17616 if (( cat_sl == 2 )); then
17617 error "Empty plain llog was not deleted from changelog catalog"
17618 elif (( cat_sl != 1 )); then
17619 error "Active plain llog shouldn't be deleted from catalog"
17622 run_test 256 "Check llog delete for empty and not full state"
17625 remote_mds_nodsh && skip "remote MDS with nodsh"
17626 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
17627 skip "Need MDS version at least 2.8.55"
17629 test_mkdir $DIR/$tdir
17631 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
17632 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
17635 #define OBD_FAIL_MDS_XATTR_REP 0x161
17636 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
17637 local facet=mds$((mdtidx + 1))
17638 set_nodes_failloc $(facet_active_host $facet) 0x80000161
17639 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
17641 stop $facet || error "stop MDS failed"
17642 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
17643 error "start MDS fail"
17644 wait_recovery_complete $facet
17646 run_test 257 "xattr locks are not lost"
17648 # Verify we take the i_mutex when security requires it
17650 #define OBD_FAIL_IMUTEX_SEC 0x141c
17651 $LCTL set_param fail_loc=0x141c
17653 chmod u+s $DIR/$tfile
17654 chmod a+rwx $DIR/$tfile
17655 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
17657 if [ $RC -ne 0 ]; then
17658 error "error, failed to take i_mutex, rc=$?"
17662 run_test 258a "verify i_mutex security behavior when suid attributes is set"
17664 # Verify we do NOT take the i_mutex in the normal case
17666 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
17667 $LCTL set_param fail_loc=0x141d
17670 chmod a+rw $DIR/$tfile
17671 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
17673 if [ $RC -ne 0 ]; then
17674 error "error, took i_mutex unnecessarily, rc=$?"
17679 run_test 258b "verify i_mutex security behavior"
17682 local file=$DIR/$tfile
17686 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
17688 stack_trap "rm -f $file" EXIT
17690 wait_delete_completed
17691 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17692 echo "before: $before"
17694 $LFS setstripe -i 0 -c 1 $file
17695 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
17697 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17698 echo "after write: $after"
17700 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
17701 do_facet ost1 $LCTL set_param fail_loc=0x2301
17703 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17704 echo "after truncate: $after"
17707 do_facet ost1 $LCTL set_param fail_loc=0
17708 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17710 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17711 echo "after restart: $after"
17712 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
17713 error "missing truncate?"
17717 run_test 259 "crash at delayed truncate"
17720 #define OBD_FAIL_MDC_CLOSE 0x806
17721 $LCTL set_param fail_loc=0x80000806
17725 run_test 260 "Check mdc_close fail"
17727 ### Data-on-MDT sanity tests ###
17729 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17730 skip "Need MDS version at least 2.10.55 for DoM"
17733 local dom=$DIR/$tdir/dom_file
17734 local tmp=$DIR/$tdir/tmp_file
17736 mkdir -p $DIR/$tdir
17738 # basic checks for DoM component creation
17739 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
17740 error "Can set MDT layout to non-first entry"
17742 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
17743 error "Can define multiple entries as MDT layout"
17745 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
17747 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
17748 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
17749 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
17751 local mdtidx=$($LFS getstripe -m $dom)
17752 local mdtname=MDT$(printf %04x $mdtidx)
17753 local facet=mds$((mdtidx + 1))
17754 local space_check=1
17756 # Skip free space checks with ZFS
17757 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
17761 local size_tmp=$((65536 * 3))
17762 local mdtfree1=$(do_facet $facet \
17763 lctl get_param -n osd*.*$mdtname.kbytesfree)
17765 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17766 # check also direct IO along write
17767 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
17768 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17770 cmp $tmp $dom || error "file data is different"
17771 [ $(stat -c%s $dom) == $size_tmp ] ||
17772 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17773 if [ $space_check == 1 ]; then
17774 local mdtfree2=$(do_facet $facet \
17775 lctl get_param -n osd*.*$mdtname.kbytesfree)
17777 # increase in usage from by $size_tmp
17778 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17779 error "MDT free space wrong after write: " \
17780 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17784 local size_dom=10000
17786 $TRUNCATE $dom $size_dom
17787 [ $(stat -c%s $dom) == $size_dom ] ||
17788 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
17789 if [ $space_check == 1 ]; then
17790 mdtfree1=$(do_facet $facet \
17791 lctl get_param -n osd*.*$mdtname.kbytesfree)
17792 # decrease in usage from $size_tmp to new $size_dom
17793 [ $(($mdtfree1 - $mdtfree2)) -ge \
17794 $(((size_tmp - size_dom) / 1024)) ] ||
17795 error "MDT free space is wrong after truncate: " \
17796 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
17802 size_dom=$((size_dom + size_tmp))
17803 [ $(stat -c%s $dom) == $size_dom ] ||
17804 error "bad size after append: $(stat -c%s $dom) != $size_dom"
17805 if [ $space_check == 1 ]; then
17806 mdtfree2=$(do_facet $facet \
17807 lctl get_param -n osd*.*$mdtname.kbytesfree)
17808 # increase in usage by $size_tmp from previous
17809 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17810 error "MDT free space is wrong after append: " \
17811 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17816 if [ $space_check == 1 ]; then
17817 mdtfree1=$(do_facet $facet \
17818 lctl get_param -n osd*.*$mdtname.kbytesfree)
17819 # decrease in usage by $size_dom from previous
17820 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
17821 error "MDT free space is wrong after removal: " \
17822 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
17825 # combined striping
17826 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
17827 error "Can't create DoM + OST striping"
17829 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
17830 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17831 # check also direct IO along write
17832 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17834 cmp $tmp $dom || error "file data is different"
17835 [ $(stat -c%s $dom) == $size_tmp ] ||
17836 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17841 run_test 270a "DoM: basic functionality tests"
17844 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17845 skip "Need MDS version at least 2.10.55"
17847 local dom=$DIR/$tdir/dom_file
17848 local max_size=1048576
17850 mkdir -p $DIR/$tdir
17851 $LFS setstripe -E $max_size -L mdt $dom
17853 # truncate over the limit
17854 $TRUNCATE $dom $(($max_size + 1)) &&
17855 error "successful truncate over the maximum size"
17856 # write over the limit
17857 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
17858 error "successful write over the maximum size"
17859 # append over the limit
17860 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
17861 echo "12345" >> $dom && error "successful append over the maximum size"
17866 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
17869 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17870 skip "Need MDS version at least 2.10.55"
17872 mkdir -p $DIR/$tdir
17873 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17875 # check files inherit DoM EA
17876 touch $DIR/$tdir/first
17877 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
17878 error "bad pattern"
17879 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
17880 error "bad stripe count"
17881 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
17882 error "bad stripe size"
17884 # check directory inherits DoM EA and uses it as default
17885 mkdir $DIR/$tdir/subdir
17886 touch $DIR/$tdir/subdir/second
17887 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
17888 error "bad pattern in sub-directory"
17889 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
17890 error "bad stripe count in sub-directory"
17891 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
17892 error "bad stripe size in sub-directory"
17895 run_test 270c "DoM: DoM EA inheritance tests"
17898 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17899 skip "Need MDS version at least 2.10.55"
17901 mkdir -p $DIR/$tdir
17902 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17904 # inherit default DoM striping
17905 mkdir $DIR/$tdir/subdir
17906 touch $DIR/$tdir/subdir/f1
17908 # change default directory striping
17909 $LFS setstripe -c 1 $DIR/$tdir/subdir
17910 touch $DIR/$tdir/subdir/f2
17911 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
17912 error "wrong default striping in file 2"
17913 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
17914 error "bad pattern in file 2"
17917 run_test 270d "DoM: change striping from DoM to RAID0"
17920 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17921 skip "Need MDS version at least 2.10.55"
17923 mkdir -p $DIR/$tdir/dom
17924 mkdir -p $DIR/$tdir/norm
17927 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
17928 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
17930 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
17931 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
17933 # find DoM files by layout
17934 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
17935 [ $NUM -eq $DOMFILES ] ||
17936 error "lfs find -L: found $NUM, expected $DOMFILES"
17937 echo "Test 1: lfs find 20 DOM files by layout: OK"
17939 # there should be 1 dir with default DOM striping
17940 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
17942 error "lfs find -L: found $NUM, expected 1 dir"
17943 echo "Test 2: lfs find 1 DOM dir by layout: OK"
17945 # find DoM files by stripe size
17946 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
17947 [ $NUM -eq $DOMFILES ] ||
17948 error "lfs find -S: found $NUM, expected $DOMFILES"
17949 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
17951 # find files by stripe offset except DoM files
17952 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
17953 [ $NUM -eq $NORMFILES ] ||
17954 error "lfs find -i: found $NUM, expected $NORMFILES"
17955 echo "Test 5: lfs find no DOM files by stripe index: OK"
17958 run_test 270e "DoM: lfs find with DoM files test"
17961 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17962 skip "Need MDS version at least 2.10.55"
17964 local mdtname=${FSNAME}-MDT0000-mdtlov
17965 local dom=$DIR/$tdir/dom_file
17966 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
17967 lod.$mdtname.dom_stripesize)
17968 local dom_limit=131072
17970 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
17971 local dom_current=$(do_facet mds1 $LCTL get_param -n \
17972 lod.$mdtname.dom_stripesize)
17973 [ ${dom_limit} -eq ${dom_current} ] ||
17974 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
17976 $LFS mkdir -i 0 -c 1 $DIR/$tdir
17977 $LFS setstripe -d $DIR/$tdir
17978 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
17979 error "Can't set directory default striping"
17981 # exceed maximum stripe size
17982 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17983 error "Can't create file with $((dom_limit * 2)) DoM stripe"
17984 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
17985 error "Able to create DoM component size more than LOD limit"
17987 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
17988 dom_current=$(do_facet mds1 $LCTL get_param -n \
17989 lod.$mdtname.dom_stripesize)
17990 [ 0 -eq ${dom_current} ] ||
17991 error "Can't set zero DoM stripe limit"
17994 # attempt to create DoM file on server with disabled DoM should
17995 # remove DoM entry from layout and be succeed
17996 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
17997 error "Can't create DoM file (DoM is disabled)"
17998 [ $($LFS getstripe -L $dom) == "mdt" ] &&
17999 error "File has DoM component while DoM is disabled"
18002 # attempt to create DoM file with only DoM stripe should return error
18003 $LFS setstripe -E $dom_limit -L mdt $dom &&
18004 error "Able to create DoM-only file while DoM is disabled"
18006 # too low values to be aligned with smallest stripe size 64K
18007 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
18008 dom_current=$(do_facet mds1 $LCTL get_param -n \
18009 lod.$mdtname.dom_stripesize)
18010 [ 30000 -eq ${dom_current} ] &&
18011 error "Can set too small DoM stripe limit"
18013 # 64K is a minimal stripe size in Lustre, expect limit of that size
18014 [ 65536 -eq ${dom_current} ] ||
18015 error "Limit is not set to 64K but ${dom_current}"
18017 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
18018 dom_current=$(do_facet mds1 $LCTL get_param -n \
18019 lod.$mdtname.dom_stripesize)
18021 [ 2147483648 -eq ${dom_current} ] &&
18022 error "Can set too large DoM stripe limit"
18024 do_facet mds1 $LCTL set_param -n \
18025 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
18026 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18027 error "Can't create DoM component size after limit change"
18028 do_facet mds1 $LCTL set_param -n \
18029 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
18030 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
18031 error "Can't create DoM file after limit decrease"
18032 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
18033 error "Can create big DoM component after limit decrease"
18034 touch ${dom}_def ||
18035 error "Can't create file with old default layout"
18037 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
18040 run_test 270f "DoM: maximum DoM stripe size checks"
18043 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18044 skip "Need MDS version at least 2.10.55"
18046 local dom=$DIR/$tdir/dom
18048 mkdir -p $DIR/$tdir
18050 $LFS setstripe -E 1024K -L mdt $dom
18052 lctl set_param -n mdc.*.stats=clear
18053 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18054 cat $dom > /dev/null
18055 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
18056 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
18060 run_test 271a "DoM: data is cached for read after write"
18063 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18064 skip "Need MDS version at least 2.10.55"
18066 local dom=$DIR/$tdir/dom
18068 mkdir -p $DIR/$tdir
18070 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18072 lctl set_param -n mdc.*.stats=clear
18073 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18074 cancel_lru_locks mdc
18075 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
18076 # second stat to check size is cached on client
18077 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
18078 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18079 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
18082 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
18085 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18086 skip "Need MDS version at least 2.10.55"
18088 local dom=$DIR/$tdir/dom
18090 mkdir -p $DIR/$tdir
18092 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18094 lctl set_param -n mdc.*.stats=clear
18095 lctl set_param -n osc.*.stats=clear
18096 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
18097 cancel_lru_locks mdc
18098 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18099 # second stat to check size is cached on client
18100 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18101 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18102 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
18103 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
18104 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
18107 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
18113 local mdt=MDT$(printf %04x $mdtidx)
18115 if [ -z $param ]; then
18116 lctl get_param -n mdc.*$mdt*.stats
18118 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
18123 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18124 skip "Need MDS version at least 2.10.55"
18126 local dom=$DIR/$tdir/dom
18128 mkdir -p $DIR/$tdir
18130 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18132 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18133 local facet=mds$((mdtidx + 1))
18135 cancel_lru_locks mdc
18136 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
18137 createmany -o $dom 1000
18138 lctl set_param -n mdc.*.stats=clear
18139 smalliomany -w $dom 1000 200
18140 get_mdc_stats $mdtidx
18141 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18142 # Each file has 1 open, 1 IO enqueues, total 2000
18143 # but now we have also +1 getxattr for security.capability, total 3000
18144 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
18145 unlinkmany $dom 1000
18147 cancel_lru_locks mdc
18148 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
18149 createmany -o $dom 1000
18150 lctl set_param -n mdc.*.stats=clear
18151 smalliomany -w $dom 1000 200
18152 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18153 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
18154 # for OPEN and IO lock.
18155 [ $((enq - enq_2)) -ge 1000 ] ||
18156 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
18157 unlinkmany $dom 1000
18160 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
18162 cleanup_271def_tests() {
18168 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18169 skip "Need MDS version at least 2.10.57"
18171 local dom=$DIR/$tdir/dom
18172 local tmp=$TMP/$tfile
18173 trap "cleanup_271def_tests $tmp" EXIT
18175 mkdir -p $DIR/$tdir
18177 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18179 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18181 cancel_lru_locks mdc
18182 dd if=/dev/urandom of=$tmp bs=1000 count=1
18183 dd if=$tmp of=$dom bs=1000 count=1
18184 cancel_lru_locks mdc
18186 cat /etc/hosts >> $tmp
18187 lctl set_param -n mdc.*.stats=clear
18189 # append data to the same file it should update local page
18190 echo "Append to the same page"
18191 cat /etc/hosts >> $dom
18192 local num=$(get_mdc_stats $mdtidx ost_read)
18193 local ra=$(get_mdc_stats $mdtidx req_active)
18194 local rw=$(get_mdc_stats $mdtidx req_waittime)
18196 [ -z $num ] || error "$num READ RPC occured"
18197 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18201 cmp $tmp $dom || error "file miscompare"
18203 cancel_lru_locks mdc
18204 lctl set_param -n mdc.*.stats=clear
18206 echo "Open and read file"
18207 cat $dom > /dev/null
18208 local num=$(get_mdc_stats $mdtidx ost_read)
18209 local ra=$(get_mdc_stats $mdtidx req_active)
18210 local rw=$(get_mdc_stats $mdtidx req_waittime)
18212 [ -z $num ] || error "$num READ RPC occured"
18213 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18217 cmp $tmp $dom || error "file miscompare"
18221 run_test 271d "DoM: read on open (1K file in reply buffer)"
18224 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18225 skip "Need MDS version at least 2.10.57"
18227 local dom=$DIR/$tdir/dom
18228 local tmp=$TMP/$tfile
18229 trap "cleanup_271def_tests $tmp" EXIT
18231 mkdir -p $DIR/$tdir
18233 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18235 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18237 cancel_lru_locks mdc
18238 dd if=/dev/urandom of=$tmp bs=200000 count=1
18239 dd if=$tmp of=$dom bs=200000 count=1
18240 cancel_lru_locks mdc
18241 cat /etc/hosts >> $tmp
18242 lctl set_param -n mdc.*.stats=clear
18244 echo "Append to the same page"
18245 cat /etc/hosts >> $dom
18246 local num=$(get_mdc_stats $mdtidx ost_read)
18247 local ra=$(get_mdc_stats $mdtidx req_active)
18248 local rw=$(get_mdc_stats $mdtidx req_waittime)
18250 [ -z $num ] || error "$num READ RPC occured"
18251 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18255 cmp $tmp $dom || error "file miscompare"
18257 cancel_lru_locks mdc
18258 lctl set_param -n mdc.*.stats=clear
18260 echo "Open and read file"
18261 cat $dom > /dev/null
18262 local num=$(get_mdc_stats $mdtidx ost_read)
18263 local ra=$(get_mdc_stats $mdtidx req_active)
18264 local rw=$(get_mdc_stats $mdtidx req_waittime)
18266 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
18267 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18271 cmp $tmp $dom || error "file miscompare"
18275 run_test 271f "DoM: read on open (200K file and read tail)"
18278 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
18279 skip "Skipping due to old client or server version"
18281 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
18283 $CHECKSTAT -t file $DIR1/$tfile
18285 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
18288 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
18289 $LCTL set_param fail_loc=0x80000314
18290 rm $DIR1/$tfile || error "Unlink fails"
18292 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
18293 [ $RC -eq 0 ] || error "Failed write to stale object"
18295 run_test 271g "Discard DoM data vs client flush race"
18298 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18299 skip "Need MDS version at least 2.11.50"
18301 local dom=$DIR/$tdir/dom
18302 mkdir -p $DIR/$tdir
18304 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
18305 dd if=/dev/urandom of=$dom bs=512K count=1 ||
18306 error "failed to write data into $dom"
18307 local old_md5=$(md5sum $dom)
18309 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
18310 error "failed to migrate to the same DoM component"
18312 local new_md5=$(md5sum $dom)
18314 [ "$old_md5" == "$new_md5" ] ||
18315 error "md5sum differ: $old_md5, $new_md5"
18317 [ $($LFS getstripe -c $dom) -eq 2 ] ||
18318 error "migrate stripe count bad: $(LFS getstripe -c $dom) != 2"
18320 run_test 272a "DoM migration: new layout with the same DOM component"
18323 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18324 skip "Need MDS version at least 2.11.50"
18326 local dom=$DIR/$tdir/dom
18327 mkdir -p $DIR/$tdir
18328 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18330 local mdtidx=$($LFS getstripe -m $dom)
18331 local mdtname=MDT$(printf %04x $mdtidx)
18332 local facet=mds$((mdtidx + 1))
18334 local mdtfree1=$(do_facet $facet \
18335 lctl get_param -n osd*.*$mdtname.kbytesfree)
18336 dd if=/dev/urandom of=$dom bs=2M count=1 ||
18337 error "failed to write data into $dom"
18338 local old_md5=$(md5sum $dom)
18339 cancel_lru_locks mdc
18340 local mdtfree1=$(do_facet $facet \
18341 lctl get_param -n osd*.*$mdtname.kbytesfree)
18343 $LFS migrate -c2 $dom ||
18344 error "failed to migrate to the new composite layout"
18345 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18346 error "MDT stripe was not removed"
18348 cancel_lru_locks mdc
18349 local new_md5=$(md5sum $dom)
18350 [ "$old_md5" != "$new_md5" ] &&
18351 error "$old_md5 != $new_md5"
18353 # Skip free space checks with ZFS
18354 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18355 local mdtfree2=$(do_facet $facet \
18356 lctl get_param -n osd*.*$mdtname.kbytesfree)
18357 [ $mdtfree2 -gt $mdtfree1 ] ||
18358 error "MDT space is not freed after migration"
18362 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
18365 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18366 skip "Need MDS version at least 2.11.50"
18368 local dom=$DIR/$tdir/$tfile
18369 mkdir -p $DIR/$tdir
18370 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18372 local mdtidx=$($LFS getstripe -m $dom)
18373 local mdtname=MDT$(printf %04x $mdtidx)
18374 local facet=mds$((mdtidx + 1))
18376 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
18377 error "failed to write data into $dom"
18378 local old_md5=$(md5sum $dom)
18379 cancel_lru_locks mdc
18380 local mdtfree1=$(do_facet $facet \
18381 lctl get_param -n osd*.*$mdtname.kbytesfree)
18383 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
18384 error "failed to migrate to the new composite layout"
18385 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18386 error "MDT stripe was not removed"
18388 cancel_lru_locks mdc
18389 local new_md5=$(md5sum $dom)
18390 [ "$old_md5" != "$new_md5" ] &&
18391 error "$old_md5 != $new_md5"
18393 # Skip free space checks with ZFS
18394 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18395 local mdtfree2=$(do_facet $facet \
18396 lctl get_param -n osd*.*$mdtname.kbytesfree)
18397 [ $mdtfree2 -gt $mdtfree1 ] ||
18398 error "MDS space is not freed after migration"
18402 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
18405 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18406 skip "Need MDS version at least 2.11.50"
18408 # Layout swap cannot be done if either file has DOM component,
18409 # this will never be supported, migration should be used instead
18411 local dom=$DIR/$tdir/$tfile
18412 mkdir -p $DIR/$tdir
18414 $LFS setstripe -c2 ${dom}_plain
18415 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
18416 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
18417 error "can swap layout with DoM component"
18418 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
18419 error "can swap layout with DoM component"
18421 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
18422 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
18423 error "can swap layout with DoM component"
18424 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
18425 error "can swap layout with DoM component"
18428 run_test 273a "DoM: layout swapping should fail with DOM"
18431 remote_ost_nodsh && skip "remote OST with nodsh"
18432 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
18433 skip "Need OST version >= 2.10.57"
18435 local file=$DIR/$tfile
18438 oss=$(comma_list $(osts_nodes))
18440 dd if=/dev/urandom of=$file bs=1M count=2 ||
18441 error "failed to create a file"
18442 cancel_lru_locks osc
18445 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18446 error "failed to read a file"
18448 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
18449 $LCTL set_param fail_loc=0x8000031f
18451 cancel_lru_locks osc &
18454 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
18455 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
18456 #IO takes another lock, but matches the PENDING one
18457 #and places it to the IO RPC
18458 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18459 error "failed to read a file with PENDING lock"
18461 run_test 275 "Read on a canceled duplicate lock"
18464 remote_ost_nodsh && skip "remote OST with nodsh"
18467 do_facet ost1 "(while true; do \
18468 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
18469 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
18472 for LOOP in $(seq 20); do
18474 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
18477 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
18478 rm $TMP/sanity_276_pid"
18480 run_test 276 "Race between mount and obd_statfs"
18483 $LCTL set_param ldlm.namespaces.*.lru_size=0
18484 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
18485 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
18486 grep ^used_mb | awk '{print $2}')
18487 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
18488 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
18489 oflag=direct conv=notrunc
18490 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
18491 grep ^used_mb | awk '{print $2}')
18492 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
18494 run_test 277 "Direct IO shall drop page cache"
18496 cleanup_test_300() {
18500 test_striped_dir() {
18505 mkdir -p $DIR/$tdir
18507 SAVE_UMASK=$(umask)
18508 trap cleanup_test_300 RETURN EXIT
18510 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
18511 $DIR/$tdir/striped_dir ||
18512 error "set striped dir error"
18514 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
18515 [ "$mode" = "755" ] || error "expect 755 got $mode"
18517 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
18518 error "getdirstripe failed"
18519 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
18520 if [ "$stripe_count" != "2" ]; then
18521 error "1:stripe_count is $stripe_count, expect 2"
18523 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
18524 if [ "$stripe_count" != "2" ]; then
18525 error "2:stripe_count is $stripe_count, expect 2"
18528 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
18529 if [ "$stripe_index" != "$mdt_index" ]; then
18530 error "stripe_index is $stripe_index, expect $mdt_index"
18533 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18534 error "nlink error after create striped dir"
18536 mkdir $DIR/$tdir/striped_dir/a
18537 mkdir $DIR/$tdir/striped_dir/b
18539 stat $DIR/$tdir/striped_dir/a ||
18540 error "create dir under striped dir failed"
18541 stat $DIR/$tdir/striped_dir/b ||
18542 error "create dir under striped dir failed"
18544 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
18545 error "nlink error after mkdir"
18547 rmdir $DIR/$tdir/striped_dir/a
18548 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
18549 error "nlink error after rmdir"
18551 rmdir $DIR/$tdir/striped_dir/b
18552 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18553 error "nlink error after rmdir"
18555 chattr +i $DIR/$tdir/striped_dir
18556 createmany -o $DIR/$tdir/striped_dir/f 10 &&
18557 error "immutable flags not working under striped dir!"
18558 chattr -i $DIR/$tdir/striped_dir
18560 rmdir $DIR/$tdir/striped_dir ||
18561 error "rmdir striped dir error"
18569 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18570 skip "skipped for lustre < 2.7.0"
18571 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18572 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18574 test_striped_dir 0 || error "failed on striped dir on MDT0"
18575 test_striped_dir 1 || error "failed on striped dir on MDT0"
18577 run_test 300a "basic striped dir sanity test"
18580 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18581 skip "skipped for lustre < 2.7.0"
18582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18583 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18590 test_mkdir $DIR/$tdir || error "mkdir fail"
18591 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18592 error "set striped dir error"
18593 for i in {0..9}; do
18594 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
18596 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
18597 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
18598 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
18600 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
18601 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
18602 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
18606 run_test 300b "check ctime/mtime for striped dir"
18609 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18610 skip "skipped for lustre < 2.7.0"
18611 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18612 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18616 mkdir -p $DIR/$tdir
18617 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
18618 error "set striped dir error"
18620 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
18621 error "chown striped dir failed"
18623 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
18624 error "create 5k files failed"
18626 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
18628 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
18632 run_test 300c "chown && check ls under striped directory"
18635 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18636 skip "skipped for lustre < 2.7.0"
18637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18638 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18643 mkdir -p $DIR/$tdir
18644 $LFS setstripe -c 2 $DIR/$tdir
18646 #local striped directory
18647 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18648 error "set striped dir error"
18649 createmany -o $DIR/$tdir/striped_dir/f 10 ||
18650 error "create 10 files failed"
18652 #remote striped directory
18653 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
18654 error "set striped dir error"
18655 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
18656 error "create 10 files failed"
18658 for file in $(find $DIR/$tdir); do
18659 stripe_count=$($LFS getstripe -c $file)
18660 [ $stripe_count -eq 2 ] ||
18661 error "wrong stripe $stripe_count for $file"
18666 run_test 300d "check default stripe under striped directory"
18669 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18670 skip "Need MDS version at least 2.7.55"
18671 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18672 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18677 mkdir -p $DIR/$tdir
18679 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18680 error "set striped dir error"
18682 touch $DIR/$tdir/striped_dir/a
18683 touch $DIR/$tdir/striped_dir/b
18684 touch $DIR/$tdir/striped_dir/c
18686 mkdir $DIR/$tdir/striped_dir/dir_a
18687 mkdir $DIR/$tdir/striped_dir/dir_b
18688 mkdir $DIR/$tdir/striped_dir/dir_c
18690 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
18691 error "set striped adir under striped dir error"
18693 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
18694 error "set striped bdir under striped dir error"
18696 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
18697 error "set striped cdir under striped dir error"
18699 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
18700 error "rename dir under striped dir fails"
18702 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
18703 error "rename dir under different stripes fails"
18705 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
18706 error "rename file under striped dir should succeed"
18708 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
18709 error "rename dir under striped dir should succeed"
18713 run_test 300e "check rename under striped directory"
18716 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18717 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18718 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18719 skip "Need MDS version at least 2.7.55"
18725 mkdir -p $DIR/$tdir
18727 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18728 error "set striped dir error"
18730 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
18731 error "set striped dir error"
18733 touch $DIR/$tdir/striped_dir/a
18734 mkdir $DIR/$tdir/striped_dir/dir_a
18735 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
18736 error "create striped dir under striped dir fails"
18738 touch $DIR/$tdir/striped_dir1/b
18739 mkdir $DIR/$tdir/striped_dir1/dir_b
18740 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
18741 error "create striped dir under striped dir fails"
18743 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
18744 error "rename dir under different striped dir should fail"
18746 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
18747 error "rename striped dir under diff striped dir should fail"
18749 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
18750 error "rename file under diff striped dirs fails"
18754 run_test 300f "check rename cross striped directory"
18756 test_300_check_default_striped_dir()
18759 local default_count=$2
18760 local default_index=$3
18763 local dir_stripe_index
18766 echo "checking $dirname $default_count $default_index"
18767 $LFS setdirstripe -D -c $default_count -i $default_index \
18768 -t all_char $DIR/$tdir/$dirname ||
18769 error "set default stripe on striped dir error"
18770 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
18771 [ $stripe_count -eq $default_count ] ||
18772 error "expect $default_count get $stripe_count for $dirname"
18774 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
18775 [ $stripe_index -eq $default_index ] ||
18776 error "expect $default_index get $stripe_index for $dirname"
18778 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
18779 error "create dirs failed"
18781 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
18782 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
18783 for dir in $(find $DIR/$tdir/$dirname/*); do
18784 stripe_count=$($LFS getdirstripe -c $dir)
18785 [ $stripe_count -eq $default_count ] ||
18786 [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
18787 error "stripe count $default_count != $stripe_count for $dir"
18789 stripe_index=$($LFS getdirstripe -i $dir)
18790 [ $default_index -eq -1 ] ||
18791 [ $stripe_index -eq $default_index ] ||
18792 error "$stripe_index != $default_index for $dir"
18794 #check default stripe
18795 stripe_count=$($LFS getdirstripe -D -c $dir)
18796 [ $stripe_count -eq $default_count ] ||
18797 error "default count $default_count != $stripe_count for $dir"
18799 stripe_index=$($LFS getdirstripe -D -i $dir)
18800 [ $stripe_index -eq $default_index ] ||
18801 error "default index $default_index != $stripe_index for $dir"
18803 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
18807 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18808 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18809 skip "Need MDS version at least 2.7.55"
18816 mkdir $DIR/$tdir/normal_dir
18818 #Checking when client cache stripe index
18819 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
18820 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
18821 error "create striped_dir failed"
18823 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
18824 error "create dir0 fails"
18825 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
18826 [ $stripe_index -eq 0 ] ||
18827 error "dir0 expect index 0 got $stripe_index"
18829 mkdir $DIR/$tdir/striped_dir/dir1 ||
18830 error "create dir1 fails"
18831 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
18832 [ $stripe_index -eq 1 ] ||
18833 error "dir1 expect index 1 got $stripe_index"
18835 #check default stripe count/stripe index
18836 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
18837 test_300_check_default_striped_dir normal_dir 1 0
18838 test_300_check_default_striped_dir normal_dir 2 1
18839 test_300_check_default_striped_dir normal_dir 2 -1
18841 #delete default stripe information
18842 echo "delete default stripeEA"
18843 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
18844 error "set default stripe on striped dir error"
18846 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
18847 for dir in $(find $DIR/$tdir/normal_dir/*); do
18848 stripe_count=$($LFS getdirstripe -c $dir)
18849 [ $stripe_count -eq 0 ] ||
18850 error "expect 1 get $stripe_count for $dir"
18851 stripe_index=$($LFS getdirstripe -i $dir)
18852 [ $stripe_index -eq 0 ] ||
18853 error "expect 0 get $stripe_index for $dir"
18856 run_test 300g "check default striped directory for normal directory"
18859 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18860 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18861 skip "Need MDS version at least 2.7.55"
18867 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18868 error "set striped dir error"
18870 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
18871 test_300_check_default_striped_dir striped_dir 1 0
18872 test_300_check_default_striped_dir striped_dir 2 1
18873 test_300_check_default_striped_dir striped_dir 2 -1
18875 #delete default stripe information
18876 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
18877 error "set default stripe on striped dir error"
18879 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
18880 for dir in $(find $DIR/$tdir/striped_dir/*); do
18881 stripe_count=$($LFS getdirstripe -c $dir)
18882 [ $stripe_count -eq 0 ] ||
18883 error "expect 1 get $stripe_count for $dir"
18886 run_test 300h "check default striped directory for striped directory"
18889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18890 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18891 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18892 skip "Need MDS version at least 2.7.55"
18899 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18900 error "set striped dir error"
18902 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18903 error "create files under striped dir failed"
18905 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
18906 error "set striped hashdir error"
18908 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
18909 error "create dir0 under hash dir failed"
18910 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
18911 error "create dir1 under hash dir failed"
18913 # unfortunately, we need to umount to clear dir layout cache for now
18914 # once we fully implement dir layout, we can drop this
18915 umount_client $MOUNT || error "umount failed"
18916 mount_client $MOUNT || error "mount failed"
18918 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
18919 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
18920 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
18922 #set the stripe to be unknown hash type
18923 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
18924 $LCTL set_param fail_loc=0x1901
18925 for ((i = 0; i < 10; i++)); do
18926 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
18927 error "stat f-$i failed"
18928 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
18931 touch $DIR/$tdir/striped_dir/f0 &&
18932 error "create under striped dir with unknown hash should fail"
18934 $LCTL set_param fail_loc=0
18936 umount_client $MOUNT || error "umount failed"
18937 mount_client $MOUNT || error "mount failed"
18941 run_test 300i "client handle unknown hash type striped directory"
18944 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18946 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18947 skip "Need MDS version at least 2.7.55"
18954 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
18955 $LCTL set_param fail_loc=0x1702
18956 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18957 error "set striped dir error"
18959 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18960 error "create files under striped dir failed"
18962 $LCTL set_param fail_loc=0
18964 rm -rf $DIR/$tdir || error "unlink striped dir fails"
18968 run_test 300j "test large update record"
18971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18972 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18973 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18974 skip "Need MDS version at least 2.7.55"
18976 # this test needs a huge transaction
18978 kb=$(do_facet $SINGLEMDS lctl get_param -n osd*.lustre-MDT0000.kbytestotal)
18979 [ $kb -lt $((1024*1024)) ] && skip "too small mds: $kb"
18986 #define OBD_FAIL_LARGE_STRIPE 0x1703
18987 $LCTL set_param fail_loc=0x1703
18988 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
18989 error "set striped dir error"
18990 $LCTL set_param fail_loc=0
18992 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18993 error "getstripeddir fails"
18994 rm -rf $DIR/$tdir/striped_dir ||
18995 error "unlink striped dir fails"
18999 run_test 300k "test large striped directory"
19002 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19003 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19004 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19005 skip "Need MDS version at least 2.7.55"
19009 test_mkdir -p $DIR/$tdir/striped_dir
19010 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
19011 error "chown $RUNAS_ID failed"
19012 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
19013 error "set default striped dir failed"
19015 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
19016 $LCTL set_param fail_loc=0x80000158
19017 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
19019 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
19020 [ $stripe_index -eq 1 ] ||
19021 error "expect 1 get $stripe_index for $dir"
19023 run_test 300l "non-root user to create dir under striped dir with stale layout"
19026 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19027 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
19028 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19029 skip "Need MDS version at least 2.7.55"
19031 mkdir -p $DIR/$tdir/striped_dir
19032 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
19033 error "set default stripes dir error"
19035 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
19037 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
19038 [ $stripe_count -eq 0 ] ||
19039 error "expect 0 get $stripe_count for a"
19041 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
19042 error "set default stripes dir error"
19044 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
19046 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
19047 [ $stripe_count -eq 0 ] ||
19048 error "expect 0 get $stripe_count for b"
19050 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
19051 error "set default stripes dir error"
19053 mkdir $DIR/$tdir/striped_dir/c &&
19054 error "default stripe_index is invalid, mkdir c should fails"
19056 rm -rf $DIR/$tdir || error "rmdir fails"
19058 run_test 300m "setstriped directory on single MDT FS"
19061 local list=$(comma_list $(mdts_nodes))
19064 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19069 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19070 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19071 skip "Need MDS version at least 2.7.55"
19072 remote_mds_nodsh && skip "remote MDS with nodsh"
19075 local list=$(comma_list $(mdts_nodes))
19077 trap cleanup_300n RETURN EXIT
19078 mkdir -p $DIR/$tdir
19079 chmod 777 $DIR/$tdir
19080 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
19081 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19082 error "create striped dir succeeds with gid=0"
19084 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19085 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
19086 error "create striped dir fails with gid=-1"
19088 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19089 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
19090 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19091 error "set default striped dir succeeds with gid=0"
19094 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19095 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
19096 error "set default striped dir fails with gid=-1"
19099 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19100 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
19101 error "create test_dir fails"
19102 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
19103 error "create test_dir1 fails"
19104 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
19105 error "create test_dir2 fails"
19108 run_test 300n "non-root user to create dir under striped dir with default EA"
19111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19112 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19113 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19114 skip "Need MDS version at least 2.7.55"
19119 mkdir -p $DIR/$tdir
19121 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
19122 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
19123 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
19124 skip "not enough free inodes $numfree1 $numfree2"
19127 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
19128 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
19129 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
19130 skip "not enough free space $numfree1 $numfree2"
19133 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
19134 error "setdirstripe fails"
19136 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
19137 error "create dirs fails"
19139 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
19140 ls $DIR/$tdir/striped_dir > /dev/null ||
19141 error "ls striped dir fails"
19142 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
19143 error "unlink big striped dir fails"
19145 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
19148 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19149 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19150 remote_mds_nodsh && skip "remote MDS with nodsh"
19152 mkdir -p $DIR/$tdir
19154 #define OBD_FAIL_OUT_ENOSPC 0x1704
19155 do_facet mds2 lctl set_param fail_loc=0x80001704
19156 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
19157 && error "create striped directory should fail"
19159 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
19161 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
19164 run_test 300p "create striped directory without space"
19167 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19168 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19170 local fd=$(free_fd)
19171 local cmd="exec $fd<$tdir"
19173 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
19176 trap "eval $cmd" EXIT
19177 cd $tdir || error "cd $tdir fails"
19178 rmdir ../$tdir || error "rmdir $tdir fails"
19179 mkdir local_dir && error "create dir succeeds"
19180 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
19184 run_test 300q "create remote directory under orphan directory"
19187 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
19188 skip "Need MDS version at least 2.7.55" && return
19189 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19193 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
19194 error "set striped dir error"
19196 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19197 error "getstripeddir fails"
19200 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
19201 awk '/lmv_stripe_count:/ { print $2 }')
19203 [ $MDSCOUNT -ne $stripe_count ] &&
19204 error "wrong stripe count $stripe_count expected $MDSCOUNT"
19206 rm -rf $DIR/$tdir/striped_dir ||
19207 error "unlink striped dir fails"
19209 run_test 300r "test -1 striped directory"
19211 prepare_remote_file() {
19212 mkdir $DIR/$tdir/src_dir ||
19213 error "create remote source failed"
19215 cp /etc/hosts $DIR/$tdir/src_dir/a ||
19216 error "cp to remote source failed"
19217 touch $DIR/$tdir/src_dir/a
19219 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
19220 error "create remote target dir failed"
19222 touch $DIR/$tdir/tgt_dir/b
19224 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
19225 error "rename dir cross MDT failed!"
19227 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
19228 error "src_child still exists after rename"
19230 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
19231 error "missing file(a) after rename"
19233 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
19234 error "diff after rename"
19238 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19239 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19241 local remote_file=$DIR/$tdir/tgt_dir/b
19243 mkdir -p $DIR/$tdir
19245 prepare_remote_file || error "prepare remote file failed"
19248 $OPENUNLINK $remote_file $remote_file ||
19249 error "openunlink $remote_file failed"
19250 $CHECKSTAT -a $remote_file || error "$remote_file exists"
19252 run_test 310a "open unlink remote file"
19255 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19258 local remote_file=$DIR/$tdir/tgt_dir/b
19260 mkdir -p $DIR/$tdir
19262 prepare_remote_file || error "prepare remote file failed"
19264 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19265 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
19266 $CHECKSTAT -t file $remote_file || error "check file failed"
19268 run_test 310b "unlink remote file with multiple links while open"
19271 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19272 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
19274 local remote_file=$DIR/$tdir/tgt_dir/b
19276 mkdir -p $DIR/$tdir
19278 prepare_remote_file || error "prepare remote file failed"
19280 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19281 multiop_bg_pause $remote_file O_uc ||
19282 error "mulitop failed for remote file"
19284 $MULTIOP $DIR/$tfile Ouc
19285 kill -USR1 $MULTIPID
19288 run_test 310c "open-unlink remote file with multiple links"
19292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19293 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19294 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
19295 skip "lustre < 2.8.54 does not contain LU-4825 fix"
19296 remote_mds_nodsh && skip "remote MDS with nodsh"
19298 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19299 local mdts=$(comma_list $(mdts_nodes))
19301 mkdir -p $DIR/$tdir
19302 $LFS setstripe -i 0 -c 1 $DIR/$tdir
19303 createmany -o $DIR/$tdir/$tfile. 1000
19305 # statfs data is not real time, let's just calculate it
19306 old_iused=$((old_iused + 1000))
19308 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19309 osp.*OST0000*MDT0000.create_count")
19310 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19311 osp.*OST0000*MDT0000.max_create_count")
19312 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
19314 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
19315 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
19316 [ $index -ne 0 ] || error "$tfile stripe index is 0"
19318 unlinkmany $DIR/$tdir/$tfile. 1000
19320 do_nodes $mdts "$LCTL set_param -n \
19321 osp.*OST0000*.max_create_count=$max_count"
19322 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
19323 do_nodes $mdts "$LCTL set_param -n \
19324 osp.*OST0000*.create_count=$count"
19325 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
19326 grep "=0" && error "create_count is zero"
19329 for i in $(seq 120); do
19330 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19331 # system may be too busy to destroy all objs in time, use
19332 # a somewhat small value to not fail autotest
19333 [ $((old_iused - new_iused)) -gt 400 ] && break
19337 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
19338 [ $((old_iused - new_iused)) -gt 400 ] ||
19339 error "objs not destroyed after unlink"
19341 run_test 311 "disable OSP precreate, and unlink should destroy objs"
19348 local vdevdir=$(dirname $(facet_vdevice $ost))
19349 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
19350 local zfs_zapid=$(do_facet $ost $cmd |
19351 grep -w "/O/0/d$((objid%32))" -C 5 |
19352 awk '/Object/{getline; print $1}')
19353 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
19354 awk "/$objid = /"'{printf $3}')
19359 zfs_object_blksz() {
19363 local vdevdir=$(dirname $(facet_vdevice $ost))
19364 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
19365 local blksz=$(do_facet $ost $cmd $objid |
19366 awk '/dblk/{getline; printf $4}')
19368 case "${blksz: -1}" in
19369 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
19370 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
19377 test_312() { # LU-4856
19378 remote_ost_nodsh && skip "remote OST with nodsh"
19379 [ "$ost1_FSTYPE" = "zfs" ] ||
19380 skip_env "the test only applies to zfs"
19382 local max_blksz=$(do_facet ost1 \
19383 $ZFS get -p recordsize $(facet_device ost1) |
19384 awk '!/VALUE/{print $3}')
19386 # to make life a little bit easier
19387 $LFS mkdir -c 1 -i 0 $DIR/$tdir
19388 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19390 local tf=$DIR/$tdir/$tfile
19392 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19394 # Get ZFS object id
19395 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19396 # block size change by sequential overwrite
19399 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
19400 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
19402 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
19403 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
19407 # block size change by sequential append write
19408 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
19409 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19410 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19413 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
19414 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
19415 oflag=sync conv=notrunc
19417 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19418 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
19419 error "blksz error, actual $blksz, " \
19420 "expected: 2 * $count * $PAGE_SIZE"
19426 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19427 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19429 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
19430 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19431 [ $blksz -eq $PAGE_SIZE ] ||
19432 error "blksz error: $blksz, expected: $PAGE_SIZE"
19434 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
19435 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19436 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
19438 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
19439 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19440 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
19442 run_test 312 "make sure ZFS adjusts its block size by write pattern"
19445 remote_ost_nodsh && skip "remote OST with nodsh"
19447 local file=$DIR/$tfile
19450 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
19452 # define OBD_FAIL_TGT_RCVD_EIO 0x720
19453 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19454 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
19455 error "write should failed"
19456 do_facet ost1 "$LCTL set_param fail_loc=0"
19459 run_test 313 "io should fail after last_rcvd update fail"
19462 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19464 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
19465 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19467 wait_delete_completed
19468 do_facet ost1 "$LCTL set_param fail_loc=0"
19470 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
19472 test_315() { # LU-618
19473 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
19475 local file=$DIR/$tfile
19478 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
19479 error "multiop file write failed"
19480 $MULTIOP $file oO_RDONLY:r4063232_c &
19485 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
19488 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
19491 run_test 315 "read should be accounted"
19494 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19495 large_xattr_enabled || skip_env "ea_inode feature disabled"
19497 rm -rf $DIR/$tdir/d
19498 mkdir -p $DIR/$tdir/d
19499 chown nobody $DIR/$tdir/d
19500 touch $DIR/$tdir/d/file
19502 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
19504 run_test 316 "lfs mv"
19507 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
19508 skip "Need MDS version at least 2.11.53"
19509 if [ "$ost1_FSTYPE" == "zfs" ]; then
19510 skip "LU-10370: no implementation for ZFS"
19514 local grant_blk_size
19516 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
19517 awk '/grant_block_size:/ { print $2; exit; }')
19519 # Create File of size 5M. Truncate it to below size's and verify
19522 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
19523 error "Create file $DIR/$tfile failed"
19524 stack_trap "rm -f $DIR/$tfile" EXIT
19526 for trunc_sz in 2097152 4097 4000 509 0; do
19527 $TRUNCATE $DIR/$tfile $trunc_sz ||
19528 error "truncate $tfile to $trunc_sz failed"
19529 local sz=$(stat --format=%s $DIR/$tfile)
19530 local blk=$(stat --format=%b $DIR/$tfile)
19531 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
19532 grant_blk_size) * 8))
19534 if [[ $blk -ne $trunc_blk ]]; then
19535 $(which stat) $DIR/$tfile
19536 error "Expected Block $trunc_blk got $blk for $tfile"
19539 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19540 error "Expected Size $trunc_sz got $sz for $tfile"
19545 # Create file with a hole and write actual two blocks. Block count
19548 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
19549 conv=fsync || error "Create file : $DIR/$tfile"
19551 # Calculate the final truncate size.
19552 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
19555 # truncate to size $trunc_sz bytes. Strip the last block
19556 # The block count must drop to 8
19558 $TRUNCATE $DIR/$tfile $trunc_sz ||
19559 error "truncate $tfile to $trunc_sz failed"
19561 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
19562 sz=$(stat --format=%s $DIR/$tfile)
19563 blk=$(stat --format=%b $DIR/$tfile)
19565 if [[ $blk -ne $trunc_bsz ]]; then
19566 $(which stat) $DIR/$tfile
19567 error "Expected Block $trunc_bsz got $blk for $tfile"
19570 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19571 error "Expected Size $trunc_sz got $sz for $tfile"
19573 run_test 317 "Verify blocks get correctly update after truncate"
19576 local old_max_active=$($LCTL get_param -n \
19577 llite.*.max_read_ahead_async_active 2>/dev/null)
19579 $LCTL set_param llite.*.max_read_ahead_async_active=256
19580 local max_active=$($LCTL get_param -n \
19581 llite.*.max_read_ahead_async_active 2>/dev/null)
19582 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
19584 # currently reset to 0 is unsupported, leave it 512 for now.
19585 $LCTL set_param llite.*.max_read_ahead_async_active=0 &&
19586 error "set max_read_ahead_async_active should fail"
19588 $LCTL set_param llite.*.max_read_ahead_async_active=512
19589 max_active=$($LCTL get_param -n \
19590 llite.*.max_read_ahead_async_active 2>/dev/null)
19591 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
19593 # restore @max_active
19594 [ $old_max_active -ne 0 ] && $LCTL set_param \
19595 llite.*.max_read_ahead_async_active=$old_max_active
19597 local old_threshold=$($LCTL get_param -n \
19598 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
19599 local max_per_file_mb=$($LCTL get_param -n \
19600 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
19602 local invalid=$(($max_per_file_mb + 1))
19604 llite.*.read_ahead_async_file_threshold_mb=$invalid\
19605 && error "set $invalid should fail"
19607 local valid=$(($invalid - 1))
19609 llite.*.read_ahead_async_file_threshold_mb=$valid ||
19610 error "set $valid should succeed"
19611 local threshold=$($LCTL get_param -n \
19612 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
19613 [ $threshold -eq $valid ] || error \
19614 "expect threshold $valid got $threshold"
19616 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
19618 run_test 318 "Verify async readahead tunables"
19621 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
19623 local before=$(date +%s)
19625 local mdir=$DIR/$tdir
19626 local file=$mdir/xxx
19628 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
19631 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
19632 $LCTL set_param fail_val=5 fail_loc=0x8000032c
19633 $LFS mv -m1 $file &
19636 dd if=$file of=/dev/null
19638 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
19639 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
19641 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
19643 run_test 319 "lost lease lock on migrate error"
19646 local read_write=$1
19647 if [ "$read_write" = "write" ]; then
19648 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
19649 elif [ "$read_write" = "read" ]; then
19650 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
19652 error "argument error"
19655 # turn off debug for performance testing
19656 local saved_debug=$($LCTL get_param -n debug)
19657 $LCTL set_param debug=0
19659 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19661 # get ost1 size - lustre-OST0000
19662 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
19663 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
19664 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
19666 if [ "$read_write" = "read" ]; then
19667 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
19670 local start_time=$(date +%s.%N)
19671 $dd_cmd bs=1M count=$blocks oflag=sync ||
19672 error "real dd $read_write error"
19673 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
19675 if [ "$read_write" = "write" ]; then
19679 # define OBD_FAIL_OST_FAKE_RW 0x238
19680 do_facet ost1 $LCTL set_param fail_loc=0x238
19682 local start_time=$(date +%s.%N)
19683 $dd_cmd bs=1M count=$blocks oflag=sync ||
19684 error "fake dd $read_write error"
19685 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
19687 if [ "$read_write" = "write" ]; then
19689 cancel_lru_locks osc
19690 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
19691 error "$tfile size not $blocks MB"
19693 do_facet ost1 $LCTL set_param fail_loc=0
19695 echo "fake $read_write $duration_fake vs. normal $read_write" \
19696 "$duration in seconds"
19697 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
19698 error_not_in_vm "fake write is slower"
19700 $LCTL set_param -n debug="$saved_debug"
19703 test_399a() { # LU-7655 for OST fake write
19704 remote_ost_nodsh && skip "remote OST with nodsh"
19708 run_test 399a "fake write should not be slower than normal write"
19710 test_399b() { # LU-8726 for OST fake read
19711 remote_ost_nodsh && skip "remote OST with nodsh"
19712 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
19713 skip_env "ldiskfs only test"
19718 run_test 399b "fake read should not be slower than normal read"
19720 test_400a() { # LU-1606, was conf-sanity test_74
19721 if ! which $CC > /dev/null 2>&1; then
19722 skip_env "$CC is not installed"
19725 local extra_flags=''
19726 local out=$TMP/$tfile
19727 local prefix=/usr/include/lustre
19730 if ! [[ -d $prefix ]]; then
19731 # Assume we're running in tree and fixup the include path.
19732 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
19733 extra_flags+=" -L$LUSTRE/utils/.lib"
19736 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
19737 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
19738 error "client api broken"
19742 run_test 400a "Lustre client api program can compile and link"
19744 test_400b() { # LU-1606, LU-5011
19746 local out=$TMP/$tfile
19747 local prefix=/usr/include/linux/lustre
19749 # We use a hard coded prefix so that this test will not fail
19750 # when run in tree. There are headers in lustre/include/lustre/
19751 # that are not packaged (like lustre_idl.h) and have more
19752 # complicated include dependencies (like config.h and lnet/types.h).
19753 # Since this test about correct packaging we just skip them when
19754 # they don't exist (see below) rather than try to fixup cppflags.
19756 if ! which $CC > /dev/null 2>&1; then
19757 skip_env "$CC is not installed"
19760 for header in $prefix/*.h; do
19761 if ! [[ -f "$header" ]]; then
19765 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
19766 continue # lustre_ioctl.h is internal header
19769 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
19770 error "cannot compile '$header'"
19774 run_test 400b "packaged headers can be compiled"
19776 test_401a() { #LU-7437
19777 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
19778 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
19780 #count the number of parameters by "list_param -R"
19781 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
19782 #count the number of parameters by listing proc files
19783 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
19784 echo "proc_dirs='$proc_dirs'"
19785 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
19786 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
19789 [ $params -eq $procs ] ||
19790 error "found $params parameters vs. $procs proc files"
19792 # test the list_param -D option only returns directories
19793 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
19794 #count the number of parameters by listing proc directories
19795 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
19798 [ $params -eq $procs ] ||
19799 error "found $params parameters vs. $procs proc files"
19801 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
19804 local save=$($LCTL get_param -n jobid_var)
19807 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
19808 error "no error returned when setting bad parameters"
19810 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
19811 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
19813 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
19814 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
19815 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
19817 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
19820 local jobid_var_old=$($LCTL get_param -n jobid_var)
19821 local jobid_var_new
19823 $LCTL set_param jobid_var= &&
19824 error "no error returned for 'set_param a='"
19826 jobid_var_new=$($LCTL get_param -n jobid_var)
19827 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19828 error "jobid_var was changed by setting without value"
19830 $LCTL set_param jobid_var &&
19831 error "no error returned for 'set_param a'"
19833 jobid_var_new=$($LCTL get_param -n jobid_var)
19834 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19835 error "jobid_var was changed by setting without value"
19837 run_test 401c "Verify 'lctl set_param' without value fails in either format."
19840 local jobid_var_old=$($LCTL get_param -n jobid_var)
19841 local jobid_var_new
19842 local new_value="foo=bar"
19844 $LCTL set_param jobid_var=$new_value ||
19845 error "'set_param a=b' did not accept a value containing '='"
19847 jobid_var_new=$($LCTL get_param -n jobid_var)
19848 [[ "$jobid_var_new" == "$new_value" ]] ||
19849 error "'set_param a=b' failed on a value containing '='"
19851 # Reset the jobid_var to test the other format
19852 $LCTL set_param jobid_var=$jobid_var_old
19853 jobid_var_new=$($LCTL get_param -n jobid_var)
19854 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19855 error "failed to reset jobid_var"
19857 $LCTL set_param jobid_var $new_value ||
19858 error "'set_param a b' did not accept a value containing '='"
19860 jobid_var_new=$($LCTL get_param -n jobid_var)
19861 [[ "$jobid_var_new" == "$new_value" ]] ||
19862 error "'set_param a b' failed on a value containing '='"
19864 $LCTL set_param jobid_var $jobid_var_old
19865 jobid_var_new=$($LCTL get_param -n jobid_var)
19866 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19867 error "failed to reset jobid_var"
19869 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
19872 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
19873 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
19874 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
19875 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
19876 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
19877 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
19878 remote_mds_nodsh && skip "remote MDS with nodsh"
19880 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
19881 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
19882 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
19883 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
19884 echo "Touch failed - OK"
19886 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
19889 local file1=$DIR/$tfile.1
19890 local file2=$DIR/$tfile.2
19891 local tfile=$TMP/$tfile
19893 rm -f $file1 $file2 $tfile
19898 # 30 sec OBD_TIMEOUT in ll_getattr()
19899 # right before populating st_nlink
19900 $LCTL set_param fail_loc=0x80001409
19901 stat -c %h $file1 > $tfile &
19903 # create an alias, drop all locks and reclaim the dentry
19905 cancel_lru_locks mdc
19906 cancel_lru_locks osc
19907 sysctl -w vm.drop_caches=2
19911 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
19913 rm -f $tfile $file1 $file2
19915 run_test 403 "i_nlink should not drop to zero due to aliasing"
19917 test_404() { # LU-6601
19918 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
19919 skip "Need server version newer than 2.8.52"
19920 remote_mds_nodsh && skip "remote MDS with nodsh"
19922 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
19923 awk '/osp .*-osc-MDT/ { print $4}')
19926 for osp in $mosps; do
19927 echo "Deactivate: " $osp
19928 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
19929 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19930 awk -vp=$osp '$4 == p { print $2 }')
19931 [ $stat = IN ] || {
19932 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19933 error "deactivate error"
19935 echo "Activate: " $osp
19936 do_facet $SINGLEMDS $LCTL --device %$osp activate
19937 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19938 awk -vp=$osp '$4 == p { print $2 }')
19939 [ $stat = UP ] || {
19940 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19941 error "activate error"
19945 run_test 404 "validate manual {de}activated works properly for OSPs"
19948 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
19949 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
19950 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
19951 skip "Layout swap lock is not supported"
19953 check_swap_layouts_support
19955 test_mkdir $DIR/$tdir
19956 swap_lock_test -d $DIR/$tdir ||
19957 error "One layout swap locked test failed"
19959 run_test 405 "Various layout swap lock tests"
19962 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19963 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19964 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19965 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19966 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
19967 skip "Need MDS version at least 2.8.50"
19969 local def_stripe_size=$($LFS getstripe -S $MOUNT)
19970 local test_pool=$TESTNAME
19972 if ! combined_mgs_mds ; then
19975 pool_add $test_pool || error "pool_add failed"
19976 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
19977 error "pool_add_targets failed"
19979 save_layout_restore_at_exit $MOUNT
19981 # parent set default stripe count only, child will stripe from both
19982 # parent and fs default
19983 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
19984 error "setstripe $MOUNT failed"
19985 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
19986 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
19987 for i in $(seq 10); do
19988 local f=$DIR/$tdir/$tfile.$i
19989 touch $f || error "touch failed"
19990 local count=$($LFS getstripe -c $f)
19991 [ $count -eq $OSTCOUNT ] ||
19992 error "$f stripe count $count != $OSTCOUNT"
19993 local offset=$($LFS getstripe -i $f)
19994 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
19995 local size=$($LFS getstripe -S $f)
19996 [ $size -eq $((def_stripe_size * 2)) ] ||
19997 error "$f stripe size $size != $((def_stripe_size * 2))"
19998 local pool=$($LFS getstripe -p $f)
19999 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
20002 # change fs default striping, delete parent default striping, now child
20003 # will stripe from new fs default striping only
20004 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
20005 error "change $MOUNT default stripe failed"
20006 $LFS setstripe -c 0 $DIR/$tdir ||
20007 error "delete $tdir default stripe failed"
20008 for i in $(seq 11 20); do
20009 local f=$DIR/$tdir/$tfile.$i
20010 touch $f || error "touch $f failed"
20011 local count=$($LFS getstripe -c $f)
20012 [ $count -eq 1 ] || error "$f stripe count $count != 1"
20013 local offset=$($LFS getstripe -i $f)
20014 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
20015 local size=$($LFS getstripe -S $f)
20016 [ $size -eq $def_stripe_size ] ||
20017 error "$f stripe size $size != $def_stripe_size"
20018 local pool=$($LFS getstripe -p $f)
20019 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
20022 unlinkmany $DIR/$tdir/$tfile. 1 20
20024 local f=$DIR/$tdir/$tfile
20025 pool_remove_all_targets $test_pool $f
20026 pool_remove $test_pool $f
20028 if ! combined_mgs_mds ; then
20032 run_test 406 "DNE support fs default striping"
20035 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20036 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
20037 skip "Need MDS version at least 2.8.55"
20038 remote_mds_nodsh && skip "remote MDS with nodsh"
20040 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
20041 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
20042 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
20043 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
20044 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
20046 #define OBD_FAIL_DT_TXN_STOP 0x2019
20047 for idx in $(seq $MDSCOUNT); do
20048 do_facet mds$idx "lctl set_param fail_loc=0x2019"
20050 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
20051 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
20052 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
20055 run_test 407 "transaction fail should cause operation fail"
20058 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
20060 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
20061 lctl set_param fail_loc=0x8000040a
20062 # let ll_prepare_partial_page() fail
20063 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
20067 # create at least 100 unused inodes so that
20068 # shrink_icache_memory(0) should not return 0
20069 touch $DIR/$tfile-{0..100}
20070 rm -f $DIR/$tfile-{0..100}
20073 echo 2 > /proc/sys/vm/drop_caches
20075 run_test 408 "drop_caches should not hang due to page leaks"
20079 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20081 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
20082 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
20083 touch $DIR/$tdir/guard || error "(2) Fail to create"
20085 local PREFIX=$(str_repeat 'A' 128)
20086 echo "Create 1K hard links start at $(date)"
20087 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20088 error "(3) Fail to hard link"
20090 echo "Links count should be right although linkEA overflow"
20091 stat $DIR/$tdir/guard || error "(4) Fail to stat"
20092 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
20093 [ $linkcount -eq 1001 ] ||
20094 error "(5) Unexpected hard links count: $linkcount"
20096 echo "List all links start at $(date)"
20097 ls -l $DIR/$tdir/foo > /dev/null ||
20098 error "(6) Fail to list $DIR/$tdir/foo"
20100 echo "Unlink hard links start at $(date)"
20101 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20102 error "(7) Fail to unlink"
20103 echo "Unlink hard links finished at $(date)"
20105 run_test 409 "Large amount of cross-MDTs hard links on the same file"
20109 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
20110 skip "Need client version at least 2.9.59"
20112 # Create a file, and stat it from the kernel
20113 local testfile=$DIR/$tfile
20116 local run_id=$RANDOM
20117 local my_ino=$(stat --format "%i" $testfile)
20119 # Try to insert the module. This will always fail as the
20120 # module is designed to not be inserted.
20121 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
20124 # Anything but success is a test failure
20126 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
20127 error "no inode match"
20129 run_test 410 "Test inode number returned from kernel thread"
20131 cleanup_test411_cgroup() {
20137 local cg_basedir=/sys/fs/cgroup/memory
20139 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
20140 skip "no setup for cgroup"
20142 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
20143 error "test file creation failed"
20144 cancel_lru_locks osc
20146 # Create a very small memory cgroup to force a slab allocation error
20147 local cgdir=$cg_basedir/osc_slab_alloc
20148 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
20149 trap "cleanup_test411_cgroup $cgdir" EXIT
20150 echo 2M > $cgdir/memory.kmem.limit_in_bytes
20151 echo 1M > $cgdir/memory.limit_in_bytes
20153 # Should not LBUG, just be killed by oom-killer
20154 # dd will return 0 even allocation failure in some environment.
20155 # So don't check return value
20156 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
20157 cleanup_test411_cgroup $cgdir
20161 run_test 411 "Slab allocation error with cgroup does not LBUG"
20164 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20165 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20166 skip "Need server version at least 2.10.55"
20169 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
20170 error "mkdir failed"
20171 $LFS getdirstripe $DIR/$tdir
20172 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20173 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
20174 error "expect $((MDSCOUT - 1)) get $stripe_index"
20175 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
20176 [ $stripe_count -eq 2 ] ||
20177 error "expect 2 get $stripe_count"
20179 run_test 412 "mkdir on specific MDTs"
20182 [ $MDSCOUNT -lt 2 ] &&
20183 skip "We need at least 2 MDTs for this test"
20185 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20186 skip "Need server version at least 2.10.55"
20189 mkdir $DIR/$tdir || error "mkdir failed"
20191 # find MDT that is the most full
20192 local max=$($LFS df | grep MDT |
20201 END { split(b, c, ":")
20206 for i in $(seq $((MDSCOUNT - 1))); do
20207 $LFS mkdir -c $i $DIR/$tdir/d$i ||
20208 error "mkdir d$i failed"
20209 $LFS getdirstripe $DIR/$tdir/d$i
20210 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
20211 [ $stripe_index -ne $max ] ||
20212 error "don't expect $max"
20215 run_test 413a "mkdir on less full MDTs"
20218 [ $MDSCOUNT -lt 2 ] &&
20219 skip "We need at least 2 MDTs for this test"
20221 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
20222 skip "Need server version at least 2.12.52"
20224 mkdir $DIR/$tdir || error "mkdir failed"
20225 $LFS setdirstripe -D -i -1 -H space $DIR/$tdir ||
20226 error "setdirstripe failed"
20228 local qos_prio_free
20229 local qos_threshold_rr
20232 qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
20233 qos_prio_free=${qos_prio_free%%%}
20234 qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
20235 qos_threshold_rr=${qos_threshold_rr%%%}
20236 qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
20238 stack_trap "$LCTL set_param lmv.*.qos_prio_free=$qos_prio_free" EXIT
20239 stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$qos_threshold_rr" \
20241 stack_trap "$LCTL set_param lmv.*.qos_maxage=$qos_maxage" EXIT
20243 echo "mkdir with roundrobin"
20245 $LCTL set_param lmv.*.qos_threshold_rr=100
20246 for i in $(seq $((100 * MDSCOUNT))); do
20247 mkdir $DIR/$tdir/subdir$i || error "mkdir subdir$i failed"
20249 for i in $(seq $MDSCOUNT); do
20250 count=$($LFS getdirstripe -i $DIR/$tdir/* | grep ^$((i - 1))$ |
20252 echo "$count directories created on MDT$((i - 1))"
20253 [ $count -eq 100 ] || error "subdirs are not evenly distributed"
20256 rm -rf $DIR/$tdir/*
20258 $LCTL set_param lmv.*.qos_threshold_rr=$qos_threshold_rr
20259 # Shorten statfs result age, so that it can be updated in time
20260 $LCTL set_param lmv.*.qos_maxage=1
20269 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree | uniq))
20270 echo "MDT filesfree available: ${ffree[@]}"
20275 for ((i = 0; i < ${#ffree[@]}; i++)); do
20276 if [[ ${ffree[i]} -gt $max ]]; then
20280 if [[ ${ffree[i]} -lt $min ]]; then
20285 echo "Min free files: MDT$min_index: $min"
20286 echo "Max free files: MDT$max_index: $max"
20288 [ $min -eq 0 ] && skip "no free files in MDT$min_index"
20289 [ $min -gt 10000000 ] && skip "too much free files in MDT$min_index"
20291 # Check if we need to generate uneven MDTs
20292 test_mkdir -i $min_index -c 1 -p $DIR/$tdir-MDT$min_index
20294 local diff=$((max - min))
20295 local diff2=$((diff * 100 / min))
20297 echo -n "Check for uneven MDTs: "
20298 echo -n "diff=$diff files ($diff2%) must be > $threshold% ..."
20300 if [ $diff2 -gt $threshold ]; then
20302 echo "Don't need to fill MDT$min_index"
20304 # generate uneven MDTs, create till 25% diff
20306 diff2=$((threshold - diff2))
20307 diff=$((min * diff2 / 100))
20308 # 50 sec per 10000 files in vm
20309 [ $diff -gt 40000 ] && [ "$SLOW" = "no" ] &&
20310 skip "$diff files to create"
20311 echo "Fill $diff2% diff in MDT$min_index with $diff files"
20313 local value="$(generate_string 1024)"
20314 for i in $(seq $diff); do
20315 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE \
20316 $DIR/$tdir-MDT$min_index/f$i > /dev/null ||
20317 error "create f$i failed"
20318 setfattr -n user.413b -v $value \
20319 $DIR/$tdir-MDT$min_index/f$i ||
20320 error "setfattr f$i failed"
20324 min=$((100 *MDSCOUNT))
20327 echo "mkdir with balanced space usage"
20328 $LCTL set_param lmv.*.qos_prio_free=100
20329 for i in $(seq $((100 * MDSCOUNT))); do
20330 mkdir $DIR/$tdir/subdir$i || error "mkdir subdir$i failed"
20332 for i in $(seq $MDSCOUNT); do
20333 count=$($LFS getdirstripe -i $DIR/$tdir/* | grep ^$((i - 1))$ |
20335 echo "$count directories created on MDT$((i - 1))"
20336 [ $min -gt $count ] && min=$count
20337 [ $max -lt $count ] && max=$count
20339 [ $((max - min)) -gt $MDSCOUNT ] ||
20340 error "subdirs shouldn't be evenly distributed"
20342 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
20344 $LFS setdirstripe -D -d $DIR/$tdir || error "setdirstripe -d failed"
20345 getfattr -n trusted.dmv $DIR/$tdir && error "default dir layout exists"
20348 run_test 413b "mkdir with balanced space usage"
20351 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
20352 $LCTL set_param fail_loc=0x80000521
20353 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
20356 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
20359 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20360 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
20361 skip "Need server version at least 2.11.52"
20371 # this test may be slow on ZFS
20372 [ "$mds1_FSTYPE" == "zfs" ] && total=100
20374 # though this test is designed for striped directory, let's test normal
20375 # directory too since lock is always saved as CoS lock.
20376 test_mkdir $DIR/$tdir || error "mkdir $tdir"
20377 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
20386 start_time=$(date +%s)
20387 for i in $(seq $total); do
20388 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
20391 end_time=$(date +%s)
20392 duration=$((end_time - start_time))
20394 kill -9 $setattr_pid
20396 echo "rename $total files took $duration sec"
20397 [ $duration -lt 100 ] || error "rename took $duration sec"
20399 run_test 415 "lock revoke is not missing"
20402 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
20403 skip "Need server version at least 2.11.55"
20405 # define OBD_FAIL_OSD_TXN_START 0x19a
20406 do_facet mds1 lctl set_param fail_loc=0x19a
20408 lfs mkdir -c $MDSCOUNT $DIR/$tdir
20412 run_test 416 "transaction start failure won't cause system hung"
20416 do_nodes $(comma_list $(mdts_nodes)) \
20417 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
20418 do_nodes $(comma_list $(mdts_nodes)) \
20419 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
20420 do_nodes $(comma_list $(mdts_nodes)) \
20421 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
20425 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20426 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
20427 skip "Need MDS version at least 2.11.56"
20429 trap cleanup_417 RETURN EXIT
20431 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
20432 do_nodes $(comma_list $(mdts_nodes)) \
20433 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
20434 $LFS migrate -m 0 $DIR/$tdir.1 &&
20435 error "migrate dir $tdir.1 should fail"
20437 do_nodes $(comma_list $(mdts_nodes)) \
20438 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
20439 $LFS mkdir -i 1 $DIR/$tdir.2 &&
20440 error "create remote dir $tdir.2 should fail"
20442 do_nodes $(comma_list $(mdts_nodes)) \
20443 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
20444 $LFS mkdir -c 2 $DIR/$tdir.3 &&
20445 error "create striped dir $tdir.3 should fail"
20448 run_test 417 "disable remote dir, striped dir and dir migration"
20450 # Checks that the outputs of df [-i] and lfs df [-i] match
20452 # usage: check_lfs_df <blocks | inodes> <mountpoint>
20462 [ "$1" == "blocks" ] && inodes= || inodes="-i"
20464 for count in {1..100}; do
20468 # read the lines of interest
20469 df_out=($(df -P $inodes $dir | tail -n +2)) ||
20470 error "df $inodes $dir | tail -n +2 failed"
20471 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
20472 error "lfs df $inodes $dir | grep summary: failed"
20474 # skip first substrings of each output as they are different
20475 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
20476 # compare the two outputs
20478 for i in {1..5}; do
20479 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
20487 lfs df $inodes $dir
20488 error "df and lfs df $1 output mismatch: " \
20489 "df ${inodes}: ${df_out[*]}, " \
20490 "lfs df ${inodes}: ${lfs_df_out[*]}"
20495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20497 local dir=$DIR/$tdir
20498 local numfiles=$((RANDOM % 4096 + 2))
20499 local numblocks=$((RANDOM % 256 + 1))
20501 wait_delete_completed
20504 # check block output
20505 check_lfs_df blocks $dir
20506 # check inode output
20507 check_lfs_df inodes $dir
20509 # create a single file and retest
20510 echo "Creating a single file and testing"
20511 createmany -o $dir/$tfile- 1 &>/dev/null ||
20512 error "creating 1 file in $dir failed"
20513 check_lfs_df blocks $dir
20514 check_lfs_df inodes $dir
20516 # create a random number of files
20517 echo "Creating $((numfiles - 1)) files and testing"
20518 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
20519 error "creating $((numfiles - 1)) files in $dir failed"
20521 # write a random number of blocks to the first test file
20522 echo "Writing $numblocks 4K blocks and testing"
20523 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
20524 count=$numblocks &>/dev/null ||
20525 error "dd to $dir/${tfile}-0 failed"
20528 check_lfs_df blocks $dir
20529 check_lfs_df inodes $dir
20531 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
20532 error "unlinking $numfiles files in $dir failed"
20534 run_test 418 "df and lfs df outputs match"
20538 local dir=$DIR/$tdir
20543 cancel_lru_locks mdc
20545 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
20546 $LCTL set_param fail_loc=0x1410
20548 $LCTL set_param fail_loc=0
20551 run_test 419 "Verify open file by name doesn't crash kernel"
20555 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
20556 skip "Need MDS version at least 2.12.53"
20558 local SAVE_UMASK=$(umask)
20559 local dir=$DIR/$tdir
20560 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
20564 mkdir -m03777 $dir/testdir
20565 ls -dn $dir/testdir
20566 # Need to remove trailing '.' when SELinux is enabled
20567 local dirperms=$(ls -dn $dir/testdir |
20568 awk '{ sub(/\.$/, "", $1); print $1}')
20569 [ $dirperms == "drwxrwsrwt" ] ||
20570 error "incorrect perms on $dir/testdir"
20572 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
20573 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
20574 ls -n $dir/testdir/testfile
20575 local fileperms=$(ls -n $dir/testdir/testfile |
20576 awk '{ sub(/\.$/, "", $1); print $1}')
20577 [ $fileperms == "-rwxr-xr-x" ] ||
20578 error "incorrect perms on $dir/testdir/testfile"
20582 run_test 420 "clear SGID bit on non-directories for non-members"
20589 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
20590 skip "Need MDS version at least 2.12.54"
20592 test_mkdir $DIR/$tdir
20593 createmany -o $DIR/$tdir/f 3
20594 cnt=$(ls -1 $DIR/$tdir | wc -l)
20595 [ $cnt != 3 ] && error "unexpected #files: $cnt"
20597 fid1=$(lfs path2fid $DIR/$tdir/f1)
20598 fid2=$(lfs path2fid $DIR/$tdir/f2)
20599 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
20601 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
20602 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
20604 cnt=$(ls -1 $DIR/$tdir | wc -l)
20605 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
20607 rm -f $DIR/$tdir/f3 || error "can't remove f3"
20608 createmany -o $DIR/$tdir/f 3
20609 cnt=$(ls -1 $DIR/$tdir | wc -l)
20610 [ $cnt != 3 ] && error "unexpected #files: $cnt"
20612 fid1=$(lfs path2fid $DIR/$tdir/f1)
20613 fid2=$(lfs path2fid $DIR/$tdir/f2)
20614 echo "remove using fsname $FSNAME"
20615 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
20617 cnt=$(ls -1 $DIR/$tdir | wc -l)
20618 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
20620 run_test 421a "simple rm by fid"
20627 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
20628 skip "Need MDS version at least 2.12.54"
20630 test_mkdir $DIR/$tdir
20631 createmany -o $DIR/$tdir/f 3
20632 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
20635 FID1=$(lfs path2fid $DIR/$tdir/f1)
20636 FID2=$(lfs path2fid $DIR/$tdir/f2)
20637 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
20639 kill -USR1 $MULTIPID
20642 cnt=$(ls $DIR/$tdir | wc -l)
20643 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
20645 run_test 421b "rm by fid on open file"
20651 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
20652 skip "Need MDS version at least 2.12.54"
20654 test_mkdir $DIR/$tdir
20655 createmany -o $DIR/$tdir/f 3
20656 touch $DIR/$tdir/$tfile
20657 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
20658 cnt=$(ls -1 $DIR/$tdir | wc -l)
20659 [ $cnt != 184 ] && error "unexpected #files: $cnt"
20661 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
20662 $LFS rmfid $DIR $FID1 || error "rmfid failed"
20664 cnt=$(ls $DIR/$tdir | wc -l)
20665 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
20667 run_test 421c "rm by fid against hardlinked files"
20673 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
20674 skip "Need MDS version at least 2.12.54"
20676 test_mkdir $DIR/$tdir
20677 createmany -o $DIR/$tdir/f 4097
20678 cnt=$(ls -1 $DIR/$tdir | wc -l)
20679 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
20681 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
20682 $LFS rmfid $DIR $FIDS || error "rmfid failed"
20684 cnt=$(ls $DIR/$tdir | wc -l)
20686 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
20688 run_test 421d "rmfid en masse"
20694 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20695 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
20696 skip "Need MDS version at least 2.12.54"
20698 mkdir -p $DIR/$tdir
20699 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
20700 createmany -o $DIR/$tdir/striped_dir/f 512
20701 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
20702 [ $cnt != 512 ] && error "unexpected #files: $cnt"
20704 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
20705 sed "s/[/][^:]*://g")
20706 $LFS rmfid $DIR $FIDS || error "rmfid failed"
20708 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
20710 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
20712 run_test 421e "rmfid in DNE"
20718 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
20719 skip "Need MDS version at least 2.12.54"
20721 test_mkdir $DIR/$tdir
20723 cnt=$(ls -1 $DIR/$tdir | wc -l)
20724 [ $cnt != 1 ] && error "unexpected #files: $cnt"
20726 FID=$(lfs path2fid $DIR/$tdir/f)
20727 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
20728 # rmfid should fail
20729 cnt=$(ls -1 $DIR/$tdir | wc -l)
20730 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
20732 chmod a+rw $DIR/$tdir
20734 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
20735 # rmfid should fail
20736 cnt=$(ls -1 $DIR/$tdir | wc -l)
20737 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
20740 $RUNAS touch $DIR/$tdir/f
20741 FID=$(lfs path2fid $DIR/$tdir/f)
20742 echo "rmfid as root"
20743 $LFS rmfid $DIR $FID || error "rmfid as root failed"
20744 cnt=$(ls -1 $DIR/$tdir | wc -l)
20745 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
20748 $RUNAS touch $DIR/$tdir/f
20749 cnt=$(ls -1 $DIR/$tdir | wc -l)
20750 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
20751 FID=$(lfs path2fid $DIR/$tdir/f)
20752 # rmfid w/o user_fid2path mount option should fail
20753 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
20754 cnt=$(ls -1 $DIR/$tdir | wc -l)
20755 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
20757 umount_client $MOUNT || "failed to umount client"
20758 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
20759 "failed to mount client'"
20761 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
20762 # rmfid should succeed
20763 cnt=$(ls -1 $DIR/$tdir | wc -l)
20764 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
20766 # rmfid shouldn't allow to remove files due to dir's permission
20767 chmod a+rwx $DIR/$tdir
20770 FID=$(lfs path2fid $DIR/$tdir/f)
20771 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
20773 umount_client $MOUNT || "failed to umount client"
20774 mount_client $MOUNT "$MOUNT_OPTS" ||
20775 "failed to mount client'"
20778 run_test 421f "rmfid checks permissions"
20784 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20785 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
20786 skip "Need MDS version at least 2.12.54"
20788 mkdir -p $DIR/$tdir
20789 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
20790 createmany -o $DIR/$tdir/striped_dir/f 512
20791 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
20792 [ $cnt != 512 ] && error "unexpected #files: $cnt"
20794 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
20795 sed "s/[/][^:]*://g")
20797 rm -f $DIR/$tdir/striped_dir/f1*
20798 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
20799 removed=$((512 - cnt))
20801 # few files have been just removed, so we expect
20802 # rmfid to fail on their fids
20803 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
20804 [ $removed != $errors ] && error "$errors != $removed"
20806 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
20808 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
20810 run_test 421g "rmfid to return errors properly"
20813 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
20814 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
20815 skip "Need server version at least 2.9.55"
20817 start_full_debug_logging
20821 stop_full_debug_logging
20825 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
20826 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
20827 awk '/The barrier for/ { print $7 }')
20830 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
20835 barrier_expired() {
20838 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
20839 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
20840 awk '/will be expired/ { print $7 }')
20842 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
20851 echo "Start barrier_freeze at: $(date)"
20852 #define OBD_FAIL_BARRIER_DELAY 0x2202
20853 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
20854 # Do not reduce barrier time - See LU-11873
20855 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
20858 local b_status=$(barrier_stat)
20859 echo "Got barrier status at: $(date)"
20860 [ "$b_status" = "'freezing_p1'" ] ||
20861 error "(1) unexpected barrier status $b_status"
20863 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
20865 b_status=$(barrier_stat)
20866 [ "$b_status" = "'frozen'" ] ||
20867 error "(2) unexpected barrier status $b_status"
20869 local expired=$(barrier_expired)
20870 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
20871 sleep $((expired + 3))
20873 b_status=$(barrier_stat)
20874 [ "$b_status" = "'expired'" ] ||
20875 error "(3) unexpected barrier status $b_status"
20877 # Do not reduce barrier time - See LU-11873
20878 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
20879 error "(4) fail to freeze barrier"
20881 b_status=$(barrier_stat)
20882 [ "$b_status" = "'frozen'" ] ||
20883 error "(5) unexpected barrier status $b_status"
20885 echo "Start barrier_thaw at: $(date)"
20886 #define OBD_FAIL_BARRIER_DELAY 0x2202
20887 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
20888 do_facet mgs $LCTL barrier_thaw $FSNAME &
20891 b_status=$(barrier_stat)
20892 echo "Got barrier status at: $(date)"
20893 [ "$b_status" = "'thawing'" ] ||
20894 error "(6) unexpected barrier status $b_status"
20896 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
20898 b_status=$(barrier_stat)
20899 [ "$b_status" = "'thawed'" ] ||
20900 error "(7) unexpected barrier status $b_status"
20902 #define OBD_FAIL_BARRIER_FAILURE 0x2203
20903 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
20904 do_facet mgs $LCTL barrier_freeze $FSNAME
20906 b_status=$(barrier_stat)
20907 [ "$b_status" = "'failed'" ] ||
20908 error "(8) unexpected barrier status $b_status"
20910 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
20911 do_facet mgs $LCTL barrier_thaw $FSNAME
20915 run_test 801a "write barrier user interfaces and stat machine"
20920 mkdir $DIR/$tdir || error "(1) fail to mkdir"
20921 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
20922 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
20923 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
20924 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
20926 cancel_lru_locks mdc
20928 # 180 seconds should be long enough
20929 do_facet mgs $LCTL barrier_freeze $FSNAME 180
20931 local b_status=$(barrier_stat)
20932 [ "$b_status" = "'frozen'" ] ||
20933 error "(6) unexpected barrier status $b_status"
20935 mkdir $DIR/$tdir/d0/d10 &
20938 touch $DIR/$tdir/d1/f13 &
20941 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
20944 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
20947 rm -f $DIR/$tdir/d4/f12 &
20950 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
20952 # To guarantee taht the 'stat' is not blocked
20953 b_status=$(barrier_stat)
20954 [ "$b_status" = "'frozen'" ] ||
20955 error "(8) unexpected barrier status $b_status"
20957 # let above commands to run at background
20960 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
20961 ps -p $touch_pid || error "(10) touch should be blocked"
20962 ps -p $ln_pid || error "(11) link should be blocked"
20963 ps -p $mv_pid || error "(12) rename should be blocked"
20964 ps -p $rm_pid || error "(13) unlink should be blocked"
20966 b_status=$(barrier_stat)
20967 [ "$b_status" = "'frozen'" ] ||
20968 error "(14) unexpected barrier status $b_status"
20970 do_facet mgs $LCTL barrier_thaw $FSNAME
20971 b_status=$(barrier_stat)
20972 [ "$b_status" = "'thawed'" ] ||
20973 error "(15) unexpected barrier status $b_status"
20975 wait $mkdir_pid || error "(16) mkdir should succeed"
20976 wait $touch_pid || error "(17) touch should succeed"
20977 wait $ln_pid || error "(18) link should succeed"
20978 wait $mv_pid || error "(19) rename should succeed"
20979 wait $rm_pid || error "(20) unlink should succeed"
20983 run_test 801b "modification will be blocked by write barrier"
20986 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20990 stop mds2 || error "(1) Fail to stop mds2"
20992 do_facet mgs $LCTL barrier_freeze $FSNAME 30
20994 local b_status=$(barrier_stat)
20995 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
20996 do_facet mgs $LCTL barrier_thaw $FSNAME
20997 error "(2) unexpected barrier status $b_status"
21000 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21001 error "(3) Fail to rescan barrier bitmap"
21003 # Do not reduce barrier time - See LU-11873
21004 do_facet mgs $LCTL barrier_freeze $FSNAME 20
21006 b_status=$(barrier_stat)
21007 [ "$b_status" = "'frozen'" ] ||
21008 error "(4) unexpected barrier status $b_status"
21010 do_facet mgs $LCTL barrier_thaw $FSNAME
21011 b_status=$(barrier_stat)
21012 [ "$b_status" = "'thawed'" ] ||
21013 error "(5) unexpected barrier status $b_status"
21015 local devname=$(mdsdevname 2)
21017 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
21019 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21020 error "(7) Fail to rescan barrier bitmap"
21024 run_test 801c "rescan barrier bitmap"
21026 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
21027 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
21028 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
21029 saved_MOUNT_OPTS=$MOUNT_OPTS
21035 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
21036 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
21037 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
21038 MOUNT_OPTS=$saved_MOUNT_OPTS
21044 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21045 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
21046 skip "Need server version at least 2.9.55"
21048 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
21050 mkdir $DIR/$tdir || error "(1) fail to mkdir"
21052 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
21053 error "(2) Fail to copy"
21055 trap cleanup_802a EXIT
21057 # sync by force before remount as readonly
21058 sync; sync_all_data; sleep 3; sync_all_data
21062 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
21063 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
21064 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
21066 echo "Mount the server as read only"
21067 setupall server_only || error "(3) Fail to start servers"
21069 echo "Mount client without ro should fail"
21070 mount_client $MOUNT &&
21071 error "(4) Mount client without 'ro' should fail"
21073 echo "Mount client with ro should succeed"
21074 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
21075 mount_client $MOUNT ||
21076 error "(5) Mount client with 'ro' should succeed"
21078 echo "Modify should be refused"
21079 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
21081 echo "Read should be allowed"
21082 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
21083 error "(7) Read should succeed under ro mode"
21087 run_test 802a "simulate readonly device"
21090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21091 remote_mds_nodsh && skip "remote MDS with nodsh"
21093 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
21094 skip "readonly option not available"
21096 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
21098 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
21099 error "(2) Fail to copy"
21101 # write back all cached data before setting MDT to readonly
21105 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
21106 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
21108 echo "Modify should be refused"
21109 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
21111 echo "Read should be allowed"
21112 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
21113 error "(7) Read should succeed under ro mode"
21116 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
21118 run_test 802b "be able to set MDTs to readonly"
21121 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21122 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21123 skip "MDS needs to be newer than 2.10.54"
21125 mkdir -p $DIR/$tdir
21126 # Create some objects on all MDTs to trigger related logs objects
21127 for idx in $(seq $MDSCOUNT); do
21128 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
21129 $DIR/$tdir/dir${idx} ||
21130 error "Fail to create $DIR/$tdir/dir${idx}"
21134 wait_delete_completed # ensure old test cleanups are finished
21135 echo "before create:"
21137 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21139 for i in {1..10}; do
21140 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
21141 error "Fail to create $DIR/$tdir/foo$i"
21145 echo "after create:"
21147 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21149 # allow for an llog to be cleaned up during the test
21150 [ $after_used -ge $((before_used + 10 - 1)) ] ||
21151 error "before ($before_used) + 10 > after ($after_used)"
21153 for i in {1..10}; do
21154 rm -rf $DIR/$tdir/foo$i ||
21155 error "Fail to remove $DIR/$tdir/foo$i"
21158 sleep 3 # avoid MDT return cached statfs
21159 wait_delete_completed
21160 echo "after unlink:"
21162 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21164 # allow for an llog to be created during the test
21165 [ $after_used -le $((before_used + 1)) ] ||
21166 error "after ($after_used) > before ($before_used) + 1"
21168 run_test 803 "verify agent object for remote object"
21171 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21172 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21173 skip "MDS needs to be newer than 2.10.54"
21174 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21176 mkdir -p $DIR/$tdir
21177 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
21178 error "Fail to create $DIR/$tdir/dir0"
21180 local fid=$($LFS path2fid $DIR/$tdir/dir0)
21181 local dev=$(mdsdevname 2)
21183 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21184 grep ${fid} || error "NOT found agent entry for dir0"
21186 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
21187 error "Fail to create $DIR/$tdir/dir1"
21189 touch $DIR/$tdir/dir1/foo0 ||
21190 error "Fail to create $DIR/$tdir/dir1/foo0"
21191 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
21194 for idx in $(seq $MDSCOUNT); do
21195 dev=$(mdsdevname $idx)
21196 do_facet mds${idx} \
21197 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21198 grep ${fid} && rc=$idx
21201 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
21202 error "Fail to rename foo0 to foo1"
21203 if [ $rc -eq 0 ]; then
21204 for idx in $(seq $MDSCOUNT); do
21205 dev=$(mdsdevname $idx)
21206 do_facet mds${idx} \
21207 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21208 grep ${fid} && rc=$idx
21212 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
21213 error "Fail to rename foo1 to foo2"
21214 if [ $rc -eq 0 ]; then
21215 for idx in $(seq $MDSCOUNT); do
21216 dev=$(mdsdevname $idx)
21217 do_facet mds${idx} \
21218 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21219 grep ${fid} && rc=$idx
21223 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
21225 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
21226 error "Fail to link to $DIR/$tdir/dir1/foo2"
21227 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
21228 error "Fail to rename foo2 to foo0"
21229 unlink $DIR/$tdir/dir1/foo0 ||
21230 error "Fail to unlink $DIR/$tdir/dir1/foo0"
21231 rm -rf $DIR/$tdir/dir0 ||
21232 error "Fail to rm $DIR/$tdir/dir0"
21234 for idx in $(seq $MDSCOUNT); do
21235 dev=$(mdsdevname $idx)
21239 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
21241 start mds${idx} $dev $MDS_MOUNT_OPTS ||
21242 error "mount mds$idx failed"
21243 df $MOUNT > /dev/null 2>&1
21245 # e2fsck should not return error
21247 error "e2fsck detected error on MDT${idx}: rc=$rc"
21250 run_test 804 "verify agent entry for remote entry"
21253 do_facet $SINGLEMDS zfs set quota=$old $fsset
21254 unlinkmany $DIR/$tdir/f- 1000000
21259 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
21260 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
21261 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
21262 skip "netfree not implemented before 0.7"
21263 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
21264 skip "Need MDS version at least 2.10.57"
21271 local pref="osd-zfs.lustre-MDT0000."
21273 # limit available space on MDS dataset to meet nospace issue
21274 # quickly. then ZFS 0.7.2 can use reserved space if asked
21275 # properly (using netfree flag in osd_declare_destroy()
21276 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
21277 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
21279 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
21280 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
21281 let "usedkb=usedkb-freekb"
21282 let "freekb=freekb/2"
21283 if let "freekb > 5000"; then
21286 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
21287 trap cleanup_805 EXIT
21289 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
21290 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
21291 rm -rf $DIR/$tdir || error "not able to remove"
21292 do_facet $SINGLEMDS zfs set quota=$old $fsset
21295 run_test 805 "ZFS can remove from full fs"
21301 local size=$($LFS getsom -s $file)
21302 local expect=$(stat -c %s $file)
21304 [[ $size == $expect ]] ||
21305 error "$file expected size: $expect, got: $size"
21307 local blocks=$($LFS getsom -b $file)
21308 expect=$(stat -c %b $file)
21309 [[ $blocks == $expect ]] ||
21310 error "$file expected blocks: $expect, got: $blocks"
21315 local size=$($LFS getsom -s $1)
21318 [[ $size == $expect ]] ||
21319 error "$file expected size: $expect, got: $size"
21323 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21324 skip "Need MDS version at least 2.11.52"
21328 touch $DIR/$tfile || error "touch $tfile failed"
21330 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21331 save_lustre_params client "llite.*.xattr_cache" > $save
21332 lctl set_param llite.*.xattr_cache=0
21333 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
21335 # single-threaded write
21336 echo "Test SOM for single-threaded write"
21337 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
21338 error "write $tfile failed"
21339 check_lsom_size $DIR/$tfile $bs
21342 local size=$(($num * $bs))
21346 echo "Test SOM for single client multi-threaded($num) write"
21347 $TRUNCATE $DIR/$tfile 0
21348 for ((i = 0; i < $num; i++)); do
21349 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21351 offset=$((offset + $bs))
21353 for (( i=0; i < $num; i++ )); do
21356 check_lsom_size $DIR/$tfile $size
21358 $TRUNCATE $DIR/$tfile 0
21359 for ((i = 0; i < $num; i++)); do
21360 offset=$((offset - $bs))
21361 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21364 for (( i=0; i < $num; i++ )); do
21367 check_lsom_size $DIR/$tfile $size
21369 # multi-client wirtes
21370 num=$(get_node_count ${CLIENTS//,/ })
21371 size=$(($num * $bs))
21375 echo "Test SOM for multi-client ($num) writes"
21376 $TRUNCATE $DIR/$tfile 0
21377 for client in ${CLIENTS//,/ }; do
21378 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21381 offset=$((offset + $bs))
21383 for (( i=0; i < $num; i++ )); do
21386 check_lsom_size $DIR/$tfile $offset
21389 $TRUNCATE $DIR/$tfile 0
21390 for client in ${CLIENTS//,/ }; do
21391 offset=$((offset - $bs))
21392 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21396 for (( i=0; i < $num; i++ )); do
21399 check_lsom_size $DIR/$tfile $size
21402 echo "Test SOM for truncate"
21403 $TRUNCATE $DIR/$tfile 1048576
21404 check_lsom_size $DIR/$tfile 1048576
21405 $TRUNCATE $DIR/$tfile 1234
21406 check_lsom_size $DIR/$tfile 1234
21408 # verify SOM blocks count
21409 echo "Verify SOM block count"
21410 $TRUNCATE $DIR/$tfile 0
21411 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
21412 error "failed to write file $tfile"
21413 check_lsom_data $DIR/$tfile
21415 run_test 806 "Verify Lazy Size on MDS"
21418 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
21419 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21420 skip "Need MDS version at least 2.11.52"
21422 # Registration step
21423 changelog_register || error "changelog_register failed"
21424 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
21425 changelog_users $SINGLEMDS | grep -q $cl_user ||
21426 error "User $cl_user not found in changelog_users"
21428 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21429 save_lustre_params client "llite.*.xattr_cache" > $save
21430 lctl set_param llite.*.xattr_cache=0
21431 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
21433 rm -rf $DIR/$tdir || error "rm $tdir failed"
21434 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
21435 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
21436 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
21437 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
21438 error "truncate $tdir/trunc failed"
21441 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
21442 error "write $tfile failed"
21444 # multi-client wirtes
21445 local num=$(get_node_count ${CLIENTS//,/ })
21449 echo "Test SOM for multi-client ($num) writes"
21450 touch $DIR/$tfile || error "touch $tfile failed"
21451 $TRUNCATE $DIR/$tfile 0
21452 for client in ${CLIENTS//,/ }; do
21453 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21456 offset=$((offset + $bs))
21458 for (( i=0; i < $num; i++ )); do
21463 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
21464 check_lsom_data $DIR/$tdir/trunc
21465 check_lsom_data $DIR/$tdir/single_dd
21466 check_lsom_data $DIR/$tfile
21469 # Deregistration step
21470 changelog_deregister || error "changelog_deregister failed"
21472 run_test 807 "verify LSOM syncing tool"
21474 check_som_nologged()
21476 local lines=$($LFS changelog $FSNAME-MDT0000 |
21477 grep 'x=trusted.som' | wc -l)
21478 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
21482 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
21483 skip "Need MDS version at least 2.11.55"
21485 # Registration step
21486 changelog_register || error "changelog_register failed"
21488 touch $DIR/$tfile || error "touch $tfile failed"
21491 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
21492 error "write $tfile failed"
21495 $TRUNCATE $DIR/$tfile 1234
21498 $TRUNCATE $DIR/$tfile 1048576
21501 # Deregistration step
21502 changelog_deregister || error "changelog_deregister failed"
21504 run_test 808 "Check trusted.som xattr not logged in Changelogs"
21509 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
21513 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
21514 skip "Need MDS version at least 2.11.56"
21516 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
21517 error "failed to create DoM-only file $DIR/$tfile"
21518 touch $DIR/$tfile || error "touch $tfile failed"
21519 check_som_nodata $DIR/$tfile
21521 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
21522 error "write $tfile failed"
21523 check_som_nodata $DIR/$tfile
21525 $TRUNCATE $DIR/$tfile 1234
21526 check_som_nodata $DIR/$tfile
21528 $TRUNCATE $DIR/$tfile 4097
21529 check_som_nodata $DIR/$file
21531 run_test 809 "Verify no SOM xattr store for DoM-only files"
21537 # t10 seem to dislike partial pages
21538 lctl set_param osc.*.checksum_type=adler
21539 lctl set_param fail_loc=0x411
21540 dd if=/dev/urandom of=$DIR/$tfile bs=10240 count=2
21541 ORIG=$(md5sum $DIR/$tfile)
21542 lctl set_param ldlm.namespaces.*osc*.lru_size=clear
21543 CSUM=$(md5sum $DIR/$tfile)
21544 set_checksum_type adler
21545 if [ "$ORIG" != "$CSUM" ]; then
21546 error "$ORIG != $CSUM"
21549 run_test 810 "partial page writes on ZFS (LU-11663)"
21552 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
21553 skip "Need MDS version at least 2.11.56"
21555 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
21556 do_facet mds1 $LCTL set_param fail_loc=0x165
21557 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
21560 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
21563 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) -eq 0 ]] ||
21564 error "MDD orphan cleanup thread not quit"
21566 run_test 811 "orphan name stub can be cleaned up in startup"
21569 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
21570 skip "OST < 2.12.51 doesn't support this fail_loc"
21571 [ "$SHARED_KEY" = true ] &&
21572 skip "OSC connections never go IDLE with Shared-Keys enabled"
21574 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21575 # ensure ost1 is connected
21576 stat $DIR/$tfile >/dev/null || error "can't stat"
21577 wait_osc_import_state client ost1 FULL
21578 # no locks, no reqs to let the connection idle
21579 cancel_lru_locks osc
21581 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
21582 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
21583 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
21584 wait_osc_import_state client ost1 CONNECTING
21585 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
21587 stat $DIR/$tfile >/dev/null || error "can't stat file"
21589 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
21592 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
21593 [ -z "$file_heat_sav" ] && skip "no file heat support"
21604 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
21605 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
21607 $LCTL set_param -n llite.*.file_heat=1
21608 echo "Turn on file heat"
21609 echo "Period second: $period_second, Decay percentage: $decay_pct"
21611 echo "QQQQ" > $DIR/$tfile
21612 echo "QQQQ" > $DIR/$tfile
21613 echo "QQQQ" > $DIR/$tfile
21614 cat $DIR/$tfile > /dev/null
21615 cat $DIR/$tfile > /dev/null
21616 cat $DIR/$tfile > /dev/null
21617 cat $DIR/$tfile > /dev/null
21619 local out=$($LFS heat_get $DIR/$tfile)
21621 $LFS heat_get $DIR/$tfile
21622 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
21623 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
21624 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
21625 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
21627 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
21628 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
21629 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
21630 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
21632 sleep $((period_second + 3))
21633 echo "Sleep $((period_second + 3)) seconds..."
21634 # The recursion formula to calculate the heat of the file f is as
21636 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
21637 # Where Hi is the heat value in the period between time points i*I and
21638 # (i+1)*I; Ci is the access count in the period; the symbol P refers
21639 # to the weight of Ci.
21640 out=$($LFS heat_get $DIR/$tfile)
21641 $LFS heat_get $DIR/$tfile
21642 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
21643 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
21644 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
21645 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
21647 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
21648 error "read sample ($readsample) is wrong"
21649 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
21650 error "write sample ($writesample) is wrong"
21651 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
21652 error "read bytes ($readbyte) is wrong"
21653 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
21654 error "write bytes ($writebyte) is wrong"
21656 echo "QQQQ" > $DIR/$tfile
21657 echo "QQQQ" > $DIR/$tfile
21658 echo "QQQQ" > $DIR/$tfile
21659 cat $DIR/$tfile > /dev/null
21660 cat $DIR/$tfile > /dev/null
21661 cat $DIR/$tfile > /dev/null
21662 cat $DIR/$tfile > /dev/null
21664 sleep $((period_second + 3))
21665 echo "Sleep $((period_second + 3)) seconds..."
21667 out=$($LFS heat_get $DIR/$tfile)
21668 $LFS heat_get $DIR/$tfile
21669 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
21670 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
21671 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
21672 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
21674 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
21675 4 * $decay_pct) / 100") -eq 1 ] ||
21676 error "read sample ($readsample1) is wrong"
21677 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
21678 3 * $decay_pct) / 100") -eq 1 ] ||
21679 error "write sample ($writesample1) is wrong"
21680 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
21681 20 * $decay_pct) / 100") -eq 1 ] ||
21682 error "read bytes ($readbyte1) is wrong"
21683 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
21684 15 * $decay_pct) / 100") -eq 1 ] ||
21685 error "write bytes ($writebyte1) is wrong"
21687 echo "Turn off file heat for the file $DIR/$tfile"
21688 $LFS heat_set -o $DIR/$tfile
21690 echo "QQQQ" > $DIR/$tfile
21691 echo "QQQQ" > $DIR/$tfile
21692 echo "QQQQ" > $DIR/$tfile
21693 cat $DIR/$tfile > /dev/null
21694 cat $DIR/$tfile > /dev/null
21695 cat $DIR/$tfile > /dev/null
21696 cat $DIR/$tfile > /dev/null
21698 out=$($LFS heat_get $DIR/$tfile)
21699 $LFS heat_get $DIR/$tfile
21700 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
21701 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
21702 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
21703 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
21705 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
21706 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
21707 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
21708 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
21710 echo "Trun on file heat for the file $DIR/$tfile"
21711 $LFS heat_set -O $DIR/$tfile
21713 echo "QQQQ" > $DIR/$tfile
21714 echo "QQQQ" > $DIR/$tfile
21715 echo "QQQQ" > $DIR/$tfile
21716 cat $DIR/$tfile > /dev/null
21717 cat $DIR/$tfile > /dev/null
21718 cat $DIR/$tfile > /dev/null
21719 cat $DIR/$tfile > /dev/null
21721 out=$($LFS heat_get $DIR/$tfile)
21722 $LFS heat_get $DIR/$tfile
21723 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
21724 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
21725 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
21726 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
21728 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
21729 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
21730 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
21731 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
21733 $LFS heat_set -c $DIR/$tfile
21734 $LCTL set_param -n llite.*.file_heat=0
21735 echo "Turn off file heat support for the Lustre filesystem"
21737 echo "QQQQ" > $DIR/$tfile
21738 echo "QQQQ" > $DIR/$tfile
21739 echo "QQQQ" > $DIR/$tfile
21740 cat $DIR/$tfile > /dev/null
21741 cat $DIR/$tfile > /dev/null
21742 cat $DIR/$tfile > /dev/null
21743 cat $DIR/$tfile > /dev/null
21745 out=$($LFS heat_get $DIR/$tfile)
21746 $LFS heat_get $DIR/$tfile
21747 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
21748 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
21749 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
21750 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
21752 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
21753 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
21754 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
21755 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
21757 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
21760 run_test 813 "File heat verfication"
21764 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
21765 echo -n y >> $DIR/$tfile
21766 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
21767 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
21769 run_test 814 "sparse cp works as expected (LU-12361)"
21773 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
21774 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
21776 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
21779 [ "$SHARED_KEY" = true ] &&
21780 skip "OSC connections never go IDLE with Shared-Keys enabled"
21782 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21783 # ensure ost1 is connected
21784 stat $DIR/$tfile >/dev/null || error "can't stat"
21785 wait_osc_import_state client ost1 FULL
21786 # no locks, no reqs to let the connection idle
21787 cancel_lru_locks osc
21788 lru_resize_disable osc
21791 before=$($LCTL get_param -n \
21792 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
21794 wait_osc_import_state client ost1 IDLE
21795 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
21796 now=$($LCTL get_param -n \
21797 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
21798 [ $before == $now ] || error "lru_size changed $before != $now"
21800 run_test 816 "do not reset lru_resize on idle reconnect"
21804 exportfs -u localhost:$DIR/nfsexp
21809 systemctl restart nfs-server.service || skip "failed to restart nfsd"
21811 mkdir -p $DIR/nfsexp
21812 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
21813 error "failed to export nfs"
21815 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
21816 stack_trap cleanup_817 EXIT
21818 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
21819 error "failed to mount nfs to $tmpdir"
21821 cp /bin/true $tmpdir
21822 $DIR/nfsexp/true || error "failed to execute 'true' command"
21824 run_test 817 "nfsd won't cache write lock for exec file"
21827 # tests that do cleanup/setup should be run at the end
21831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21834 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
21835 $LCTL set_param fail_loc=0x903
21837 cancel_lru_locks MGC
21839 FAIL_ON_ERROR=true cleanup
21840 FAIL_ON_ERROR=true setup
21842 run_test 900 "umount should not race with any mgc requeue thread"
21845 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
21846 check_and_cleanup_lustre
21847 if [ "$I_MOUNTED" != "yes" ]; then
21848 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true