3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
16 CREATETEST=${CREATETEST:-createtest}
17 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
18 OPENFILE=${OPENFILE:-openfile}
19 OPENUNLINK=${OPENUNLINK:-openunlink}
20 READS=${READS:-"reads"}
21 MUNLINK=${MUNLINK:-munlink}
22 SOCKETSERVER=${SOCKETSERVER:-socketserver}
23 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
24 MEMHOG=${MEMHOG:-memhog}
25 DIRECTIO=${DIRECTIO:-directio}
26 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
28 CHECK_GRANT=${CHECK_GRANT:-"yes"}
29 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
30 export PARALLEL=${PARALLEL:-"no"}
33 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
34 LUSTRE=${LUSTRE:-$(dirname $0)/..}
35 . $LUSTRE/tests/test-framework.sh
40 ALWAYS_EXCEPT="$SANITY_EXCEPT "
41 # bug number for skipped test: LU-9693 LU-6493 LU-9693 LU-11058
42 ALWAYS_EXCEPT+=" 42a 42b 42c 77k"
43 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
45 # skipped tests: LU-8411 LU-9096 LU-9054 ..
46 ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
49 # bug number for skipped tests: LU-9795 (all below)
50 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 17n 60a 133g 300f"
53 if [[ $(uname -m) = aarch64 ]]; then
54 # bug number: LU-11596 (all below)
55 ALWAYS_EXCEPT+=" 42d 42e 63a 63b 64a 64b 64c"
56 # bug number: LU-11671 LU-11665 LU-11594 LU-11667 LU-11729
57 ALWAYS_EXCEPT+=" 45 101c 103a 317 810"
60 # skip nfs tests on kernels >= 4.14.0 until they are fixed
61 if [ $LINUX_VERSION_CODE -ge $(version_code 4.14.0) ]; then
62 # bug number: LU-12661
66 # skip cgroup tests on RHEL8.1 kernels until they are fixed
67 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
68 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
69 # bug number: LU-13063
74 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
76 if [ "$mds1_FSTYPE" = "zfs" ]; then
77 # bug number for skipped test:
78 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
80 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
83 # Get the SLES distro version
85 # Returns a version string that should only be used in comparing
86 # strings returned by version_code()
89 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
91 # All SuSE Linux versions have one decimal. version_code expects two
92 local sles_version=$version.0
93 version_code $sles_version
96 # Check if we are running on Ubuntu or SLES so we can make decisions on
98 if [ -r /etc/SuSE-release ]; then
99 sles_version=$(sles_version_code)
100 [ $sles_version -lt $(version_code 11.4.0) ] &&
101 # bug number for skipped test: LU-4341
102 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
103 [ $sles_version -lt $(version_code 12.0.0) ] &&
104 # bug number for skipped test: LU-3703
105 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
106 elif [ -r /etc/os-release ]; then
107 if grep -qi ubuntu /etc/os-release; then
108 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
109 -e 's/^VERSION=//p' \
113 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
114 # bug number for skipped test:
116 ALWAYS_EXCEPT+=" 103a 410"
126 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
127 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
136 check_swap_layouts_support()
138 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
139 skip "Does not support layout lock."
142 check_and_setup_lustre
146 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
148 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
149 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
150 rm -rf $DIR/[Rdfs][0-9]*
152 # $RUNAS_ID may get set incorrectly somewhere else
153 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
154 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
156 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
158 if [ "${ONLY}" = "MOUNT" ] ; then
159 echo "Lustre is up, please go on"
163 echo "preparing for tests involving mounts"
164 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
166 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
167 echo # add a newline after mke2fs.
171 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
172 lctl set_param debug=-1 2> /dev/null || true
175 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
177 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
179 run_test 0a "touch; rm ====================="
182 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
183 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
185 run_test 0b "chmod 0755 $DIR ============================="
188 $LCTL get_param mdc.*.import | grep "state: FULL" ||
189 error "import not FULL"
190 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
193 run_test 0c "check import proc"
195 test_0d() { # LU-3397
196 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
197 skip "proc exports not supported before 2.10.57"
199 local mgs_exp="mgs.MGS.exports"
200 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
202 local exp_client_version
205 local temp_imp=$DIR/$tfile.import
206 local temp_exp=$DIR/$tfile.export
208 # save mgc import file to $temp_imp
209 $LCTL get_param mgc.*.import | tee $temp_imp
210 # Check if client uuid is found in MGS export
211 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
212 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
216 # save mgs export file to $temp_exp
217 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
219 # Compare the value of field "connect_flags"
220 imp_val=$(grep "connect_flags" $temp_imp)
221 exp_val=$(grep "connect_flags" $temp_exp)
222 [ "$exp_val" == "$imp_val" ] ||
223 error "export flags '$exp_val' != import flags '$imp_val'"
225 # Compare the value of client version
226 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
227 exp_val=$(version_code $exp_client_version)
228 imp_val=$CLIENT_VERSION
229 [ "$exp_val" == "$imp_val" ] ||
230 error "export client version '$exp_val' != '$imp_val'"
232 run_test 0d "check export proc ============================="
235 test_mkdir $DIR/$tdir
236 test_mkdir $DIR/$tdir/d2
237 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
238 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
241 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
243 run_test 1 "mkdir; remkdir; rmdir"
246 test_mkdir $DIR/$tdir
247 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
248 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
250 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
252 run_test 2 "mkdir; touch; rmdir; check file"
255 test_mkdir $DIR/$tdir
256 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
257 touch $DIR/$tdir/$tfile
258 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
260 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
262 run_test 3 "mkdir; touch; rmdir; check dir"
264 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
266 test_mkdir -i 1 $DIR/$tdir
268 touch $DIR/$tdir/$tfile ||
269 error "Create file under remote directory failed"
272 error "Expect error removing in-use dir $DIR/$tdir"
274 test -d $DIR/$tdir || error "Remote directory disappeared"
276 rm -rf $DIR/$tdir || error "remove remote dir error"
278 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
281 test_mkdir $DIR/$tdir
282 test_mkdir $DIR/$tdir/d2
283 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
284 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
285 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
287 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
290 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
291 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
292 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
293 error "$tfile does not have perm 0666 or UID $UID"
294 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
295 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
296 error "$tfile should be 0666 and owned by UID $UID"
298 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
301 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
304 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
305 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
306 error "$tfile should be owned by UID $RUNAS_ID"
307 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
308 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
309 error "$tfile should be owned by UID $RUNAS_ID"
311 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
314 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
317 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
318 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
319 error "$tfile should be owned by GID $UID"
320 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
321 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
322 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
324 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
327 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
329 test_mkdir $DIR/$tdir
330 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
331 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
332 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
333 test_mkdir $DIR/$tdir/d/subdir
334 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
335 error "$tdir/d/subdir should be GID $RUNAS_GID"
336 if [[ $MDSCOUNT -gt 1 ]]; then
337 # check remote dir sgid inherite
338 $LFS mkdir -i 0 $DIR/$tdir.local ||
339 error "mkdir $tdir.local failed"
340 chmod g+s $DIR/$tdir.local ||
341 error "chmod $tdir.local failed"
342 chgrp $RUNAS_GID $DIR/$tdir.local ||
343 error "chgrp $tdir.local failed"
344 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
345 error "mkdir $tdir.remote failed"
346 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
347 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
348 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
349 error "$tdir.remote should be mode 02755"
352 run_test 6g "verify new dir in sgid dir inherits group"
354 test_6h() { # bug 7331
355 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
357 touch $DIR/$tfile || error "touch failed"
358 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
359 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
360 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
361 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
362 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
364 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
367 test_mkdir $DIR/$tdir
368 $MCREATE $DIR/$tdir/$tfile
369 chmod 0666 $DIR/$tdir/$tfile
370 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
371 error "$tdir/$tfile should be mode 0666"
373 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
376 if [ ! -d $DIR/$tdir ]; then
377 test_mkdir $DIR/$tdir
379 $MCREATE $DIR/$tdir/$tfile
380 echo -n foo > $DIR/$tdir/$tfile
381 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
382 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
384 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
387 test_mkdir $DIR/$tdir
388 touch $DIR/$tdir/$tfile
389 chmod 0666 $DIR/$tdir/$tfile
390 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
391 error "$tfile mode not 0666"
393 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
396 test_mkdir $DIR/$tdir
397 test_mkdir $DIR/$tdir/d2
398 test_mkdir $DIR/$tdir/d2/d3
399 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
401 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
404 test_mkdir $DIR/$tdir
405 test_mkdir $DIR/$tdir/d2
406 touch $DIR/$tdir/d2/$tfile
407 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
408 error "$tdir/d2/$tfile not a file"
410 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
413 test_mkdir $DIR/$tdir
414 test_mkdir $DIR/$tdir/d2
415 chmod 0666 $DIR/$tdir/d2
416 chmod 0705 $DIR/$tdir/d2
417 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
418 error "$tdir/d2 mode not 0705"
420 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
423 test_mkdir $DIR/$tdir
424 touch $DIR/$tdir/$tfile
425 chmod 0666 $DIR/$tdir/$tfile
426 chmod 0654 $DIR/$tdir/$tfile
427 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
428 error "$tdir/d2 mode not 0654"
430 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
433 test_mkdir $DIR/$tdir
434 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
436 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
437 error "$tdir/$tfile size not 0 after truncate"
439 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
442 test_mkdir $DIR/$tdir
443 touch $DIR/$tdir/$tfile
445 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
447 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
450 test_mkdir $DIR/$tdir
451 touch $DIR/$tdir/$tfile
452 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
453 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
454 error "$tdir/${tfile_2} not a file after rename"
455 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
457 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
460 test_mkdir $DIR/$tdir
461 touch $DIR/$tdir/$tfile
462 rm -rf $DIR/$tdir/$tfile
463 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
465 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
468 test_mkdir $DIR/$tdir
469 touch $DIR/$tdir/$tfile
470 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
472 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
473 error "$tdir/l-exist not a symlink"
474 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
475 error "$tdir/l-exist not referencing a file"
476 rm -f $DIR/$tdir/l-exist
477 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
479 run_test 17a "symlinks: create, remove (real)"
482 test_mkdir $DIR/$tdir
483 ln -s no-such-file $DIR/$tdir/l-dangle
485 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
486 error "$tdir/l-dangle not referencing no-such-file"
487 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
488 error "$tdir/l-dangle not referencing non-existent file"
489 rm -f $DIR/$tdir/l-dangle
490 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
492 run_test 17b "symlinks: create, remove (dangling)"
494 test_17c() { # bug 3440 - don't save failed open RPC for replay
495 test_mkdir $DIR/$tdir
496 ln -s foo $DIR/$tdir/$tfile
497 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
499 run_test 17c "symlinks: open dangling (should return error)"
502 test_mkdir $DIR/$tdir
503 ln -s foo $DIR/$tdir/$tfile
504 touch $DIR/$tdir/$tfile || error "creating to new symlink"
506 run_test 17d "symlinks: create dangling"
509 test_mkdir $DIR/$tdir
510 local foo=$DIR/$tdir/$tfile
511 ln -s $foo $foo || error "create symlink failed"
512 ls -l $foo || error "ls -l failed"
513 ls $foo && error "ls not failed" || true
515 run_test 17e "symlinks: create recursive symlink (should return error)"
518 test_mkdir $DIR/$tdir
519 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
520 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
521 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
522 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
523 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
524 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
527 run_test 17f "symlinks: long and very long symlink name"
529 # str_repeat(S, N) generate a string that is string S repeated N times
534 while [ $((n -= 1)) -ge 0 ]; do
540 # Long symlinks and LU-2241
542 test_mkdir $DIR/$tdir
543 local TESTS="59 60 61 4094 4095"
545 # Fix for inode size boundary in 2.1.4
546 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
549 # Patch not applied to 2.2 or 2.3 branches
550 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
551 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
554 # skip long symlink name for rhel6.5.
555 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
556 grep -q '6.5' /etc/redhat-release &>/dev/null &&
557 TESTS="59 60 61 4062 4063"
560 local SYMNAME=$(str_repeat 'x' $i)
561 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
562 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
565 run_test 17g "symlinks: really long symlink name and inode boundaries"
567 test_17h() { #bug 17378
568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
569 remote_mds_nodsh && skip "remote MDS with nodsh"
573 test_mkdir $DIR/$tdir
574 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
575 $LFS setstripe -c -1 $DIR/$tdir
576 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
577 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
578 touch $DIR/$tdir/$tfile || true
580 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
582 test_17i() { #bug 20018
583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
584 remote_mds_nodsh && skip "remote MDS with nodsh"
586 local foo=$DIR/$tdir/$tfile
589 test_mkdir -c1 $DIR/$tdir
590 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
591 ln -s $foo $foo || error "create symlink failed"
592 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
593 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
594 ls -l $foo && error "error not detected"
597 run_test 17i "don't panic on short symlink (should return error)"
599 test_17k() { #bug 22301
600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
601 [[ -z "$(which rsync 2>/dev/null)" ]] &&
602 skip "no rsync command"
603 rsync --help | grep -q xattr ||
604 skip_env "$(rsync --version | head -n1) does not support xattrs"
605 test_mkdir $DIR/$tdir
606 test_mkdir $DIR/$tdir.new
607 touch $DIR/$tdir/$tfile
608 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
609 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
610 error "rsync failed with xattrs enabled"
612 run_test 17k "symlinks: rsync with xattrs enabled"
614 test_17l() { # LU-279
615 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
616 skip "no getfattr command"
618 test_mkdir $DIR/$tdir
619 touch $DIR/$tdir/$tfile
620 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
621 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
622 # -h to not follow symlinks. -m '' to list all the xattrs.
623 # grep to remove first line: '# file: $path'.
624 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
626 lgetxattr_size_check $path $xattr ||
627 error "lgetxattr_size_check $path $xattr failed"
631 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
636 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
637 remote_mds_nodsh && skip "remote MDS with nodsh"
638 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
639 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
640 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
642 local short_sym="0123456789"
643 local wdir=$DIR/$tdir
648 # create a long symlink file
649 for ((i = 0; i < 4; ++i)); do
650 long_sym=${long_sym}${long_sym}
653 echo "create 512 short and long symlink files under $wdir"
654 for ((i = 0; i < 256; ++i)); do
655 ln -sf ${long_sym}"a5a5" $wdir/long-$i
656 ln -sf ${short_sym}"a5a5" $wdir/short-$i
662 wait_delete_completed
664 echo "recreate the 512 symlink files with a shorter string"
665 for ((i = 0; i < 512; ++i)); do
666 # rewrite the symlink file with a shorter string
667 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
668 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
671 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
672 local devname=$(mdsdevname $mds_index)
674 echo "stop and checking mds${mds_index}:"
675 # e2fsck should not return error
677 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
680 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
681 error "start mds${mds_index} failed"
682 df $MOUNT > /dev/null 2>&1
684 error "e2fsck detected error for short/long symlink: rc=$rc"
687 run_test 17m "run e2fsck against MDT which contains short/long symlink"
689 check_fs_consistency_17n() {
693 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
694 # so it only check MDT1/MDT2 instead of all of MDTs.
695 for mdt_index in 1 2; do
696 local devname=$(mdsdevname $mdt_index)
697 # e2fsck should not return error
699 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
702 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
703 error "mount mds$mdt_index failed"
704 df $MOUNT > /dev/null 2>&1
710 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
712 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
713 remote_mds_nodsh && skip "remote MDS with nodsh"
714 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
715 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
716 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
720 test_mkdir $DIR/$tdir
721 for ((i=0; i<10; i++)); do
722 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
723 error "create remote dir error $i"
724 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
725 error "create files under remote dir failed $i"
728 check_fs_consistency_17n ||
729 error "e2fsck report error after create files under remote dir"
731 for ((i = 0; i < 10; i++)); do
732 rm -rf $DIR/$tdir/remote_dir_${i} ||
733 error "destroy remote dir error $i"
736 check_fs_consistency_17n ||
737 error "e2fsck report error after unlink files under remote dir"
739 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
740 skip "lustre < 2.4.50 does not support migrate mv"
742 for ((i = 0; i < 10; i++)); do
743 mkdir -p $DIR/$tdir/remote_dir_${i}
744 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
745 error "create files under remote dir failed $i"
746 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
747 error "migrate remote dir error $i"
749 check_fs_consistency_17n || error "e2fsck report error after migration"
751 for ((i = 0; i < 10; i++)); do
752 rm -rf $DIR/$tdir/remote_dir_${i} ||
753 error "destroy remote dir error $i"
756 check_fs_consistency_17n || error "e2fsck report error after unlink"
758 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
761 remote_mds_nodsh && skip "remote MDS with nodsh"
762 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
763 skip "Need MDS version at least 2.3.64"
765 local wdir=$DIR/${tdir}o
771 mdt_index=$($LFS getstripe -m $wdir/$tfile)
772 mdt_index=$((mdt_index + 1))
775 #fail mds will wait the failover finish then set
776 #following fail_loc to avoid interfer the recovery process.
779 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
780 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
781 ls -l $wdir/$tfile && rc=1
782 do_facet mds${mdt_index} lctl set_param fail_loc=0
783 [[ $rc -eq 0 ]] || error "stat file should fail"
785 run_test 17o "stat file with incompat LMA feature"
788 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
789 ls $DIR || error "Failed to ls $DIR: $?"
791 run_test 18 "touch .../f ; ls ... =============================="
797 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
799 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
802 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
804 run_test 19b "ls -l .../f19 (should return error) =============="
807 [ $RUNAS_ID -eq $UID ] &&
808 skip_env "RUNAS_ID = UID = $UID -- skipping"
810 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
812 run_test 19c "$RUNAS touch .../f19 (should return error) =="
815 cat $DIR/f19 && error || true
817 run_test 19d "cat .../f19 (should return error) =============="
826 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
828 run_test 20 "touch .../f ; ls -l ..."
831 test_mkdir $DIR/$tdir
832 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
833 ln -s dangle $DIR/$tdir/link
834 echo foo >> $DIR/$tdir/link
835 cat $DIR/$tdir/dangle
836 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
837 $CHECKSTAT -f -t file $DIR/$tdir/link ||
838 error "$tdir/link not linked to a file"
840 run_test 21 "write to dangling link"
843 local wdir=$DIR/$tdir
845 chown $RUNAS_ID:$RUNAS_GID $wdir
846 (cd $wdir || error "cd $wdir failed";
847 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
849 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
850 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
851 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
852 error "checkstat -u failed"
854 run_test 22 "unpack tar archive as non-root user"
858 test_mkdir $DIR/$tdir
859 local file=$DIR/$tdir/$tfile
861 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
862 openfile -f O_CREAT:O_EXCL $file &&
863 error "$file recreate succeeded" || true
865 run_test 23a "O_CREAT|O_EXCL in subdir"
867 test_23b() { # bug 18988
868 test_mkdir $DIR/$tdir
869 local file=$DIR/$tdir/$tfile
872 echo foo > $file || error "write filed"
873 echo bar >> $file || error "append filed"
874 $CHECKSTAT -s 8 $file || error "wrong size"
877 run_test 23b "O_APPEND check"
879 # LU-9409, size with O_APPEND and tiny writes
881 local file=$DIR/$tfile
884 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
885 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
889 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
890 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
895 #racing tiny & normal writes
896 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
899 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
902 #racing tiny & normal writes 2, ugly numbers
903 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
904 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
906 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
909 run_test 23c "O_APPEND size checks for tiny writes"
911 # LU-11069 file offset is correct after appending writes
913 local file=$DIR/$tfile
916 echo CentaurHauls > $file
917 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
918 if ((offset != 26)); then
919 error "wrong offset, expected 26, got '$offset'"
922 run_test 23d "file offset is correct after appending writes"
926 echo '-- same directory rename'
927 test_mkdir $DIR/$tdir
928 touch $DIR/$tdir/$tfile.1
929 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
930 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
932 run_test 24a "rename file to non-existent target"
935 test_mkdir $DIR/$tdir
936 touch $DIR/$tdir/$tfile.{1,2}
937 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
938 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
939 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
941 run_test 24b "rename file to existing target"
944 test_mkdir $DIR/$tdir
945 test_mkdir $DIR/$tdir/d$testnum.1
946 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
947 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
948 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
950 run_test 24c "rename directory to non-existent target"
953 test_mkdir -c1 $DIR/$tdir
954 test_mkdir -c1 $DIR/$tdir/d$testnum.1
955 test_mkdir -c1 $DIR/$tdir/d$testnum.2
956 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
957 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
958 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
960 run_test 24d "rename directory to existing target"
963 echo '-- cross directory renames --'
967 mv $DIR/R5a/f $DIR/R5b/g
968 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
969 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
971 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
976 touch $DIR/R6a/f $DIR/R6b/g
977 mv $DIR/R6a/f $DIR/R6b/g
978 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
979 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
981 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
986 test_mkdir $DIR/R7a/d
987 mv $DIR/R7a/d $DIR/R7b/e
988 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
989 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
991 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
994 test_mkdir -c1 $DIR/R8a
995 test_mkdir -c1 $DIR/R8b
996 test_mkdir -c1 $DIR/R8a/d
997 test_mkdir -c1 $DIR/R8b/e
998 mrename $DIR/R8a/d $DIR/R8b/e
999 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1000 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1002 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1005 echo "-- rename error cases"
1007 test_mkdir $DIR/R9/a
1009 mrename $DIR/R9/f $DIR/R9/a
1010 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1011 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1012 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1014 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1018 mrename $DIR/R10/f $DIR/R10/g
1019 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1020 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1021 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1023 run_test 24j "source does not exist ============================"
1026 test_mkdir $DIR/R11a
1027 test_mkdir $DIR/R11a/d
1029 mv $DIR/R11a/f $DIR/R11a/d
1030 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1031 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1033 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1035 # bug 2429 - rename foo foo foo creates invalid file
1038 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1040 run_test 24l "Renaming a file to itself ========================"
1044 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1045 # on ext3 this does not remove either the source or target files
1046 # though the "expected" operation would be to remove the source
1047 $CHECKSTAT -t file ${f} || error "${f} missing"
1048 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1050 run_test 24m "Renaming a file to a hard link to itself ========="
1054 # this stats the old file after it was renamed, so it should fail
1056 $CHECKSTAT ${f} || error "${f} missing"
1058 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1059 $CHECKSTAT -a ${f} || error "${f} exists"
1061 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1064 test_mkdir $DIR/$tdir
1065 rename_many -s random -v -n 10 $DIR/$tdir
1067 run_test 24o "rename of files during htree split"
1070 test_mkdir $DIR/R12a
1071 test_mkdir $DIR/R12b
1072 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1073 mrename $DIR/R12a $DIR/R12b
1074 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1075 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1076 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1077 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1079 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1081 cleanup_multiop_pause() {
1083 kill -USR1 $MULTIPID
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1089 test_mkdir $DIR/R13a
1090 test_mkdir $DIR/R13b
1091 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1092 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1095 trap cleanup_multiop_pause EXIT
1096 mrename $DIR/R13a $DIR/R13b
1097 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1098 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1099 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1100 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1101 cleanup_multiop_pause
1102 wait $MULTIPID || error "multiop close failed"
1104 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1106 test_24r() { #bug 3789
1107 test_mkdir $DIR/R14a
1108 test_mkdir $DIR/R14a/b
1109 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1110 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1111 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1113 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1116 test_mkdir $DIR/R15a
1117 test_mkdir $DIR/R15a/b
1118 test_mkdir $DIR/R15a/b/c
1119 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1120 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1121 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1123 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1125 test_mkdir $DIR/R16a
1126 test_mkdir $DIR/R16a/b
1127 test_mkdir $DIR/R16a/b/c
1128 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1129 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1130 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1132 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1134 test_24u() { # bug12192
1135 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1136 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1138 run_test 24u "create stripe file"
1140 simple_cleanup_common() {
1143 [ -z "$DIR" -o -z "$tdir" ] && return 0
1145 local start=$SECONDS
1148 wait_delete_completed
1149 echo "cleanup time $((SECONDS - start))"
1153 max_pages_per_rpc() {
1154 local mdtname="$(printf "MDT%04x" ${1:-0})"
1155 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1161 local nrfiles=${COUNT:-100000}
1162 local fname="$DIR/$tdir/$tfile"
1164 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1165 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1167 test_mkdir "$(dirname $fname)"
1168 # assume MDT0000 has the fewest inodes
1169 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1170 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1171 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1173 trap simple_cleanup_common EXIT
1175 createmany -m "$fname" $nrfiles
1177 cancel_lru_locks mdc
1178 lctl set_param mdc.*.stats clear
1180 # was previously test_24D: LU-6101
1181 # readdir() returns correct number of entries after cursor reload
1182 local num_ls=$(ls $DIR/$tdir | wc -l)
1183 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1184 local num_all=$(ls -a $DIR/$tdir | wc -l)
1185 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1186 $num_all -ne $((nrfiles + 2)) ]; then
1187 error "Expected $nrfiles files, got $num_ls " \
1188 "($num_uniq unique $num_all .&..)"
1190 # LU-5 large readdir
1191 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1192 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1193 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1194 # take into account of overhead in lu_dirpage header and end mark in
1195 # each page, plus one in rpc_num calculation.
1196 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1197 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1198 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1199 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1200 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1201 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1202 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1203 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1204 error "large readdir doesn't take effect: " \
1205 "$mds_readpage should be about $rpc_max"
1207 simple_cleanup_common
1209 run_test 24v "list large directory (test hash collision, b=17560)"
1211 test_24w() { # bug21506
1213 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1214 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1215 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1216 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1217 [[ "$SZ1" -eq "$SZ2" ]] ||
1218 error "Error reading at the end of the file $tfile"
1220 run_test 24w "Reading a file larger than 4Gb"
1223 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1225 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1226 skip "Need MDS version at least 2.7.56"
1229 local remote_dir=$DIR/$tdir/remote_dir
1231 test_mkdir $DIR/$tdir
1232 $LFS mkdir -i $MDTIDX $remote_dir ||
1233 error "create remote directory failed"
1235 test_mkdir $DIR/$tdir/src_dir
1236 touch $DIR/$tdir/src_file
1237 test_mkdir $remote_dir/tgt_dir
1238 touch $remote_dir/tgt_file
1240 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1241 error "rename dir cross MDT failed!"
1243 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1244 error "rename file cross MDT failed!"
1246 touch $DIR/$tdir/ln_file
1247 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1248 error "ln file cross MDT failed"
1250 rm -rf $DIR/$tdir || error "Can not delete directories"
1252 run_test 24x "cross MDT rename/link"
1255 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1258 local remote_dir=$DIR/$tdir/remote_dir
1261 test_mkdir $DIR/$tdir
1262 $LFS mkdir -i $mdtidx $remote_dir ||
1263 error "create remote directory failed"
1265 test_mkdir $remote_dir/src_dir
1266 touch $remote_dir/src_file
1267 test_mkdir $remote_dir/tgt_dir
1268 touch $remote_dir/tgt_file
1270 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1271 error "rename subdir in the same remote dir failed!"
1273 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1274 error "rename files in the same remote dir failed!"
1276 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1277 error "link files in the same remote dir failed!"
1279 rm -rf $DIR/$tdir || error "Can not delete directories"
1281 run_test 24y "rename/link on the same dir should succeed"
1284 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1285 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1286 skip "Need MDS version at least 2.12.51"
1290 for index in 0 1; do
1291 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1292 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1295 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1297 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1298 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1300 local mdts=$(comma_list $(mdts_nodes))
1302 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1303 stack_trap "do_nodes $mdts $LCTL \
1304 set_param mdt.*.enable_remote_rename=1" EXIT
1306 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1308 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1309 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1311 run_test 24z "cross-MDT rename is done as cp"
1313 test_24A() { # LU-3182
1317 test_mkdir $DIR/$tdir
1318 trap simple_cleanup_common EXIT
1319 createmany -m $DIR/$tdir/$tfile $NFILES
1320 local t=$(ls $DIR/$tdir | wc -l)
1321 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1322 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1323 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1324 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1327 simple_cleanup_common || error "Can not delete directories"
1329 run_test 24A "readdir() returns correct number of entries."
1331 test_24B() { # LU-4805
1332 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1336 test_mkdir $DIR/$tdir
1337 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1338 error "create striped dir failed"
1340 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1341 [ $count -eq 2 ] || error "Expected 2, got $count"
1343 touch $DIR/$tdir/striped_dir/a
1345 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1346 [ $count -eq 3 ] || error "Expected 3, got $count"
1348 touch $DIR/$tdir/striped_dir/.f
1350 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1351 [ $count -eq 4 ] || error "Expected 4, got $count"
1353 rm -rf $DIR/$tdir || error "Can not delete directories"
1355 run_test 24B "readdir for striped dir return correct number of entries"
1358 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1364 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1365 error "create striped dir failed"
1367 cd $DIR/$tdir/d0/striped_dir
1369 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1370 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1371 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1373 [ "$d0_ino" = "$parent_ino" ] ||
1374 error ".. wrong, expect $d0_ino, get $parent_ino"
1376 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1377 error "mv striped dir failed"
1379 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1381 [ "$d1_ino" = "$parent_ino" ] ||
1382 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1384 run_test 24C "check .. in striped dir"
1387 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1388 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1391 mkdir $DIR/$tdir/src_dir
1392 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1393 error "create remote source failed"
1395 touch $DIR/$tdir/src_dir/src_child/a
1397 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1398 error "create remote target dir failed"
1400 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1401 error "create remote target child failed"
1403 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1404 error "rename dir cross MDT failed!"
1408 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1409 error "src_child still exists after rename"
1411 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1412 error "missing file(a) after rename"
1414 rm -rf $DIR/$tdir || error "Can not delete directories"
1416 run_test 24E "cross MDT rename/link"
1419 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1422 [ "$SLOW" = "no" ] && repeats=100
1426 echo "$repeats repeats"
1427 for ((i = 0; i < repeats; i++)); do
1428 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1429 touch $DIR/$tdir/test/a || error "touch fails"
1430 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1431 rm -rf $DIR/$tdir/test || error "rmdir fails"
1436 run_test 24F "hash order vs readdir (LU-11330)"
1439 echo '== symlink sanity ============================================='
1443 touch $DIR/s25/foo ||
1444 error "File creation in symlinked directory failed"
1446 run_test 25a "create file in symlinked directory ==============="
1449 [ ! -d $DIR/d25 ] && test_25a
1450 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1452 run_test 25b "lookup file in symlinked directory ==============="
1456 test_mkdir $DIR/d26/d26-2
1457 ln -s d26/d26-2 $DIR/s26
1458 touch $DIR/s26/foo || error "File creation failed"
1460 run_test 26a "multiple component symlink ======================="
1463 test_mkdir -p $DIR/$tdir/d26-2
1464 ln -s $tdir/d26-2/foo $DIR/s26-2
1465 touch $DIR/s26-2 || error "File creation failed"
1467 run_test 26b "multiple component symlink at end of lookup ======"
1470 test_mkdir $DIR/d26.2
1471 touch $DIR/d26.2/foo
1472 ln -s d26.2 $DIR/s26.2-1
1473 ln -s s26.2-1 $DIR/s26.2-2
1474 ln -s s26.2-2 $DIR/s26.2-3
1475 chmod 0666 $DIR/s26.2-3/foo
1477 run_test 26c "chain of symlinks"
1479 # recursive symlinks (bug 439)
1481 ln -s d26-3/foo $DIR/d26-3
1483 run_test 26d "create multiple component recursive symlink"
1486 [ ! -h $DIR/d26-3 ] && test_26d
1489 run_test 26e "unlink multiple component recursive symlink"
1491 # recursive symlinks (bug 7022)
1493 test_mkdir $DIR/$tdir
1494 test_mkdir $DIR/$tdir/$tfile
1495 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1496 test_mkdir -p lndir/bar1
1497 test_mkdir $DIR/$tdir/$tfile/$tfile
1498 cd $tfile || error "cd $tfile failed"
1499 ln -s .. dotdot || error "ln dotdot failed"
1500 ln -s dotdot/lndir lndir || error "ln lndir failed"
1501 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1502 output=`ls $tfile/$tfile/lndir/bar1`
1503 [ "$output" = bar1 ] && error "unexpected output"
1504 rm -r $tfile || error "rm $tfile failed"
1505 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1507 run_test 26f "rm -r of a directory which has recursive symlink"
1510 test_mkdir $DIR/$tdir
1511 $LFS getstripe $DIR/$tdir
1512 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1513 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1514 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1516 run_test 27a "one stripe file"
1519 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1521 test_mkdir $DIR/$tdir
1522 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1523 $LFS getstripe -c $DIR/$tdir/$tfile
1524 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1525 error "two-stripe file doesn't have two stripes"
1527 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1529 run_test 27b "create and write to two stripe file"
1532 test_mkdir $DIR/$tdir
1533 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1534 error "setstripe failed"
1535 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1536 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1538 run_test 27d "create file with default settings"
1541 # LU-5839 adds check for existed layout before setting it
1542 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1543 skip "Need MDS version at least 2.7.56"
1545 test_mkdir $DIR/$tdir
1546 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1547 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1548 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1550 run_test 27e "setstripe existing file (should return error)"
1553 test_mkdir $DIR/$tdir
1554 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1555 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1556 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1557 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1558 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1559 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1561 run_test 27f "setstripe with bad stripe size (should return error)"
1564 test_mkdir $DIR/$tdir
1565 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1566 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1567 error "$DIR/$tdir/$tfile has object"
1569 run_test 27g "$LFS getstripe with no objects"
1572 test_mkdir $DIR/$tdir
1573 touch $DIR/$tdir/$tfile || error "touch failed"
1574 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1575 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1577 (( rc == 2 )) || error "getstripe did not return ENOENT"
1579 run_test 27ga "$LFS getstripe with missing file (should return error)"
1582 test_mkdir $DIR/$tdir
1583 touch $DIR/$tdir/$tfile || error "touch failed"
1584 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1585 error "missing objects"
1587 run_test 27i "$LFS getstripe with some objects"
1590 test_mkdir $DIR/$tdir
1591 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1592 error "setstripe failed" || true
1594 run_test 27j "setstripe with bad stripe offset (should return error)"
1596 test_27k() { # bug 2844
1597 test_mkdir $DIR/$tdir
1598 local file=$DIR/$tdir/$tfile
1599 local ll_max_blksize=$((4 * 1024 * 1024))
1600 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1601 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1602 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1603 dd if=/dev/zero of=$file bs=4k count=1
1604 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1605 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1607 run_test 27k "limit i_blksize for broken user apps"
1610 mcreate $DIR/$tfile || error "creating file"
1611 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1612 error "setstripe should have failed" || true
1614 run_test 27l "check setstripe permissions (should return error)"
1617 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1619 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1621 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1622 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1624 trap simple_cleanup_common EXIT
1625 test_mkdir $DIR/$tdir
1626 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1627 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1628 error "dd should fill OST0"
1630 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1632 [ $i -gt 256 ] && break
1635 touch $DIR/$tdir/$tfile.$i
1636 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1637 awk '{print $1}'| grep -w "0") ] &&
1638 error "OST0 was full but new created file still use it"
1640 touch $DIR/$tdir/$tfile.$i
1641 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1642 awk '{print $1}'| grep -w "0") ] &&
1643 error "OST0 was full but new created file still use it"
1644 simple_cleanup_common
1646 run_test 27m "create file while OST0 was full"
1649 local delay=$(do_facet $SINGLEMDS lctl get_param -n lo[vd].*.qos_maxage |
1650 awk '{ print $1 * 2; exit; }')
1654 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1655 # if the OST isn't full anymore.
1657 local OSTIDX=${1:-""}
1659 local list=$(comma_list $(osts_nodes))
1660 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1662 do_nodes $list lctl set_param fail_loc=0
1663 sync # initiate all OST_DESTROYs from MDS to OST
1667 exhaust_precreations() {
1670 local FAILIDX=${3:-$OSTIDX}
1671 local ofacet=ost$((OSTIDX + 1))
1673 test_mkdir -p -c1 $DIR/$tdir
1674 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1675 local mfacet=mds$((mdtidx + 1))
1676 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1678 local OST=$(ostname_from_index $OSTIDX)
1681 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1682 local last_id=$(do_facet $mfacet lctl get_param -n \
1683 osp.$mdtosc_proc1.prealloc_last_id)
1684 local next_id=$(do_facet $mfacet lctl get_param -n \
1685 osp.$mdtosc_proc1.prealloc_next_id)
1687 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1688 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1690 test_mkdir -p $DIR/$tdir/${OST}
1691 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1692 #define OBD_FAIL_OST_ENOSPC 0x215
1693 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1694 echo "Creating to objid $last_id on ost $OST..."
1695 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1696 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1697 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1701 exhaust_all_precreations() {
1703 for (( i=0; i < OSTCOUNT; i++ )) ; do
1704 exhaust_precreations $i $1 -1
1709 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1710 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1711 remote_mds_nodsh && skip "remote MDS with nodsh"
1712 remote_ost_nodsh && skip "remote OST with nodsh"
1715 rm -f $DIR/$tdir/$tfile
1716 exhaust_precreations 0 0x80000215
1717 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1718 touch $DIR/$tdir/$tfile || error "touch failed"
1719 $LFS getstripe $DIR/$tdir/$tfile
1722 run_test 27n "create file with some full OSTs"
1725 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1727 remote_mds_nodsh && skip "remote MDS with nodsh"
1728 remote_ost_nodsh && skip "remote OST with nodsh"
1731 rm -f $DIR/$tdir/$tfile
1732 exhaust_all_precreations 0x215
1734 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1739 run_test 27o "create file with all full OSTs (should error)"
1741 function create_and_checktime() {
1746 for ((i=0; i < $loops; i++)); do
1747 local start=$SECONDS
1748 multiop $fname-$i Oc
1749 ((SECONDS-start < TIMEOUT)) ||
1750 error "creation took " $((SECONDS-$start)) && return 1
1755 local mdts=$(comma_list $(mdts_nodes))
1757 [ $MDS1_VERSION -lt $(version_code 2.12.6) ] &&
1758 skip "Need MDS version at least 2.12.6"
1760 local f0=$DIR/${tfile}-0
1761 local f1=$DIR/${tfile}-1
1763 wait_delete_completed
1765 # refill precreated objects
1766 $LFS setstripe -i0 -c1 $f0
1768 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
1769 # force QoS allocation policy
1770 do_nodes $mdts $LCTL set_param lov.*.qos_threshold_rr=0%
1771 stack_trap "do_nodes $mdts $LCTL set_param \
1772 lov.*.qos_threshold_rr=$saved" EXIT
1775 # one OST is unavailable, but still have few objects preallocated
1777 stack_trap "start ost1 $(ostdevname 1) $OST_MOUNT_OPTS; \
1778 rm -rf $f1 $DIR/$tdir*" EXIT
1780 for ((i=0; i < 7; i++)); do
1781 mkdir $DIR/$tdir$i || error "can't create dir"
1782 $LFS setstripe -c$((OSTCOUNT-1)) $DIR/$tdir$i ||
1783 error "can't set striping"
1785 for ((i=0; i < 7; i++)); do
1786 create_and_checktime $DIR/$tdir$i/$tfile 100 &
1790 run_test 27oo "don't let few threads to reserve too many objects"
1793 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1795 remote_mds_nodsh && skip "remote MDS with nodsh"
1796 remote_ost_nodsh && skip "remote OST with nodsh"
1799 rm -f $DIR/$tdir/$tfile
1800 test_mkdir $DIR/$tdir
1802 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1803 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1804 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1806 exhaust_precreations 0 0x80000215
1807 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1808 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1809 $LFS getstripe $DIR/$tdir/$tfile
1813 run_test 27p "append to a truncated file with some full OSTs"
1816 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1817 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1818 remote_mds_nodsh && skip "remote MDS with nodsh"
1819 remote_ost_nodsh && skip "remote OST with nodsh"
1822 rm -f $DIR/$tdir/$tfile
1824 test_mkdir $DIR/$tdir
1825 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1826 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1827 error "truncate $DIR/$tdir/$tfile failed"
1828 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1830 exhaust_all_precreations 0x215
1832 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1833 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1837 run_test 27q "append to truncated file with all OSTs full (should error)"
1840 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1842 remote_mds_nodsh && skip "remote MDS with nodsh"
1843 remote_ost_nodsh && skip "remote OST with nodsh"
1846 rm -f $DIR/$tdir/$tfile
1847 exhaust_precreations 0 0x80000215
1849 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1853 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1855 test_27s() { # bug 10725
1856 test_mkdir $DIR/$tdir
1857 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1858 local stripe_count=0
1859 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1860 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1861 error "stripe width >= 2^32 succeeded" || true
1864 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1866 test_27t() { # bug 10864
1871 $WLFS getstripe $tfile
1874 run_test 27t "check that utils parse path correctly"
1876 test_27u() { # bug 4900
1877 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1878 remote_mds_nodsh && skip "remote MDS with nodsh"
1881 local list=$(comma_list $(mdts_nodes))
1883 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1884 do_nodes $list $LCTL set_param fail_loc=0x139
1885 test_mkdir -p $DIR/$tdir
1886 trap simple_cleanup_common EXIT
1887 createmany -o $DIR/$tdir/t- 1000
1888 do_nodes $list $LCTL set_param fail_loc=0
1890 TLOG=$TMP/$tfile.getstripe
1891 $LFS getstripe $DIR/$tdir > $TLOG
1892 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1893 unlinkmany $DIR/$tdir/t- 1000
1895 [[ $OBJS -gt 0 ]] &&
1896 error "$OBJS objects created on OST-0. See $TLOG" ||
1899 run_test 27u "skip object creation on OSC w/o objects"
1901 test_27v() { # bug 4900
1902 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1904 remote_mds_nodsh && skip "remote MDS with nodsh"
1905 remote_ost_nodsh && skip "remote OST with nodsh"
1907 exhaust_all_precreations 0x215
1910 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1912 touch $DIR/$tdir/$tfile
1913 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1915 for (( i=1; i < OSTCOUNT; i++ )); do
1916 do_facet ost$i lctl set_param fail_loc=0x705
1918 local START=`date +%s`
1919 createmany -o $DIR/$tdir/$tfile 32
1921 local FINISH=`date +%s`
1922 local TIMEOUT=`lctl get_param -n timeout`
1923 local PROCESS=$((FINISH - START))
1924 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1925 error "$FINISH - $START >= $TIMEOUT / 2"
1926 sleep $((TIMEOUT / 2 - PROCESS))
1929 run_test 27v "skip object creation on slow OST"
1931 test_27w() { # bug 10997
1932 test_mkdir $DIR/$tdir
1933 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1934 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1935 error "stripe size $size != 65536" || true
1936 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1937 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1939 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1942 [[ $OSTCOUNT -lt 2 ]] &&
1943 skip_env "skipping multiple stripe count/offset test"
1945 test_mkdir $DIR/$tdir
1946 for i in $(seq 1 $OSTCOUNT); do
1948 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1949 error "setstripe -c $i -i $offset failed"
1950 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1951 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1952 [ $count -ne $i ] && error "stripe count $count != $i" || true
1953 [ $index -ne $offset ] &&
1954 error "stripe offset $index != $offset" || true
1957 run_test 27wa "check $LFS setstripe -c -i options"
1960 remote_ost_nodsh && skip "remote OST with nodsh"
1961 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1964 OFFSET=$(($OSTCOUNT - 1))
1966 local OST=$(ostname_from_index $OSTIDX)
1968 test_mkdir $DIR/$tdir
1969 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1970 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1972 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1973 for i in $(seq 0 $OFFSET); do
1974 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1975 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1976 error "OST0 was degraded but new created file still use it"
1978 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1980 run_test 27x "create files while OST0 is degraded"
1983 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1984 remote_mds_nodsh && skip "remote MDS with nodsh"
1985 remote_ost_nodsh && skip "remote OST with nodsh"
1986 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1988 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1989 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1990 osp.$mdtosc.prealloc_last_id)
1991 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1992 osp.$mdtosc.prealloc_next_id)
1993 local fcount=$((last_id - next_id))
1994 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1995 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1997 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1998 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1999 local OST_DEACTIVE_IDX=-1
2004 for OSC in $MDS_OSCS; do
2005 OST=$(osc_to_ost $OSC)
2006 OSTIDX=$(index_from_ostuuid $OST)
2007 if [ $OST_DEACTIVE_IDX == -1 ]; then
2008 OST_DEACTIVE_IDX=$OSTIDX
2010 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2011 echo $OSC "is Deactivated:"
2012 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2016 OSTIDX=$(index_from_ostuuid $OST)
2017 test_mkdir $DIR/$tdir
2018 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2020 for OSC in $MDS_OSCS; do
2021 OST=$(osc_to_ost $OSC)
2022 OSTIDX=$(index_from_ostuuid $OST)
2023 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2024 echo $OST "is degraded:"
2025 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2026 obdfilter.$OST.degraded=1
2031 createmany -o $DIR/$tdir/$tfile $fcount
2033 for OSC in $MDS_OSCS; do
2034 OST=$(osc_to_ost $OSC)
2035 OSTIDX=$(index_from_ostuuid $OST)
2036 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2037 echo $OST "is recovered from degraded:"
2038 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2039 obdfilter.$OST.degraded=0
2041 do_facet $SINGLEMDS lctl --device %$OSC activate
2045 # all osp devices get activated, hence -1 stripe count restored
2046 local stripe_count=0
2048 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2049 # devices get activated.
2051 $LFS setstripe -c -1 $DIR/$tfile
2052 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2054 [ $stripe_count -ne $OSTCOUNT ] &&
2055 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2058 run_test 27y "create files while OST0 is degraded and the rest inactive"
2064 lmm_count=$($GETSTRIPE -c $1)
2065 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
2066 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
2068 local old_ifs="$IFS"
2070 fid=($($LFS path2fid $1))
2073 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2074 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2076 # compare lmm_seq and lu_fid->f_seq
2077 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2078 # compare lmm_object_id and lu_fid->oid
2079 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2081 # check the trusted.fid attribute of the OST objects of the file
2082 local have_obdidx=false
2084 $GETSTRIPE $1 | while read obdidx oid hex seq; do
2085 # skip lines up to and including "obdidx"
2086 [ -z "$obdidx" ] && break
2087 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2088 $have_obdidx || continue
2090 local ost=$((obdidx + 1))
2091 local dev=$(ostdevname $ost)
2094 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2096 seq=$(echo $seq | sed -e "s/^0x//g")
2097 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2098 oid_hex=$(echo $oid)
2100 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2102 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2106 # Don't unmount/remount the OSTs if we don't need to do that.
2107 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2108 # update too, until that use mount/ll_decode_filter_fid/mount.
2109 # Re-enable when debugfs will understand new filter_fid.
2111 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2112 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2113 $dev 2>/dev/null" | grep "parent=")
2115 if [ -z "$ff" ]; then
2117 mount_fstype ost$ost
2118 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2119 $(facet_mntpt ost$ost)/$obj_file)
2120 unmount_fstype ost$ost
2121 start ost$ost $dev $OST_MOUNT_OPTS
2125 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2127 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2129 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2130 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2132 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2133 # stripe_size=1048576 component_id=1 component_start=0 \
2134 # component_end=33554432
2135 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2136 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2137 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2139 if grep -q 'stripe=' <<<$ff; then
2140 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2142 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2143 # into f_ver in this case. See comment on ff_parent.
2144 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2147 # compare lmm_seq and filter_fid->ff_parent.f_seq
2148 [ $ff_pseq = $lmm_seq ] ||
2149 error "FF parent SEQ $ff_pseq != $lmm_seq"
2150 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2151 [ $ff_poid = $lmm_oid ] ||
2152 error "FF parent OID $ff_poid != $lmm_oid"
2153 (($ff_pstripe == $stripe_nr)) ||
2154 error "FF stripe $ff_pstripe != $stripe_nr"
2156 stripe_nr=$((stripe_nr + 1))
2157 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2159 if grep -q 'stripe_count=' <<<$ff; then
2160 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2161 -e 's/ .*//' <<<$ff)
2162 [ $lmm_count = $ff_scnt ] ||
2163 error "FF stripe count $lmm_count != $ff_scnt"
2169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2170 remote_ost_nodsh && skip "remote OST with nodsh"
2172 test_mkdir $DIR/$tdir
2173 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2174 { error "setstripe -c -1 failed"; return 1; }
2175 # We need to send a write to every object to get parent FID info set.
2176 # This _should_ also work for setattr, but does not currently.
2177 # touch $DIR/$tdir/$tfile-1 ||
2178 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2179 { error "dd $tfile-1 failed"; return 2; }
2180 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2181 { error "setstripe -c -1 failed"; return 3; }
2182 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2183 { error "dd $tfile-2 failed"; return 4; }
2185 # make sure write RPCs have been sent to OSTs
2188 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2189 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2191 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2193 test_27A() { # b=19102
2194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2196 save_layout_restore_at_exit $MOUNT
2197 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2198 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2199 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2200 local default_size=$($GETSTRIPE -S $MOUNT)
2201 local default_offset=$($GETSTRIPE -i $MOUNT)
2202 local dsize=$(do_facet $SINGLEMDS \
2203 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2204 [ $default_size -eq $dsize ] ||
2205 error "stripe size $default_size != $dsize"
2206 [ $default_offset -eq -1 ] ||
2207 error "stripe offset $default_offset != -1"
2209 run_test 27A "check filesystem-wide default LOV EA values"
2211 test_27B() { # LU-2523
2212 test_mkdir $DIR/$tdir
2213 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2215 # open f1 with O_LOV_DELAY_CREATE
2217 # call setstripe ioctl on open file descriptor for f1
2219 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2223 # open f1 with O_LOV_DELAY_CREATE
2225 # call setstripe ioctl on open file descriptor for f1
2227 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2229 # Allow multiop to fail in imitation of NFS's busted semantics.
2232 run_test 27B "call setstripe on open unlinked file/rename victim"
2234 test_27C() { #LU-2871
2235 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2243 test_mkdir $DIR/$tdir
2245 for i in $(seq 0 $((OSTCOUNT - 1))); do
2246 # set stripe across all OSTs starting from OST$i
2247 $SETSTRIPE -i $i -c -1 $tfile$i
2248 # get striping information
2249 ost_idx=($($GETSTRIPE $tfile$i |
2250 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2254 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2255 error "${#ost_idx[@]} != $OSTCOUNT"
2257 for index in $(seq 0 $((OSTCOUNT - 1))); do
2259 for j in $(echo ${ost_idx[@]}); do
2260 if [ $index -eq $j ]; then
2266 error "Can not find $index in ${ost_idx[@]}"
2270 run_test 27C "check full striping across all OSTs"
2273 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2274 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2275 remote_mds_nodsh && skip "remote MDS with nodsh"
2277 local POOL=${POOL:-testpool}
2279 local last_ost=$(($OSTCOUNT - 1))
2281 local ost_list=$(seq $first_ost $ost_step $last_ost)
2282 local ost_range="$first_ost $last_ost $ost_step"
2284 test_mkdir $DIR/$tdir
2285 pool_add $POOL || error "pool_add failed"
2286 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2289 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2291 [ $MDS1_VERSION -lt $(version_code 2.9.55) -o \
2292 $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2293 skip27D+=" -s 30,31"
2294 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2295 error "llapi_layout_test failed"
2297 destroy_test_pools || error "destroy test pools failed"
2299 run_test 27D "validate llapi_layout API"
2301 # Verify that default_easize is increased from its initial value after
2302 # accessing a widely striped file.
2304 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2305 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2306 skip "client does not have LU-3338 fix"
2308 # 72 bytes is the minimum space required to store striping
2309 # information for a file striped across one OST:
2310 # (sizeof(struct lov_user_md_v3) +
2311 # sizeof(struct lov_user_ost_data_v1))
2313 $LCTL set_param -n llite.*.default_easize $min_easize ||
2314 error "lctl set_param failed"
2315 local easize=$($LCTL get_param -n llite.*.default_easize)
2317 [ $easize -eq $min_easize ] ||
2318 error "failed to set default_easize"
2320 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2321 error "setstripe failed"
2325 easize=$($LCTL get_param -n llite.*.default_easize)
2327 [ $easize -gt $min_easize ] ||
2328 error "default_easize not updated"
2330 run_test 27E "check that default extended attribute size properly increases"
2332 test_27F() { # LU-5346/LU-7975
2333 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2334 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2335 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2336 skip "Need MDS version at least 2.8.51"
2337 remote_ost_nodsh && skip "remote OST with nodsh"
2339 test_mkdir $DIR/$tdir
2341 $SETSTRIPE -c 2 $DIR/$tdir
2343 # stop all OSTs to reproduce situation for LU-7975 ticket
2344 for num in $(seq $OSTCOUNT); do
2348 # open/create f0 with O_LOV_DELAY_CREATE
2349 # truncate f0 to a non-0 size
2351 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2353 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2354 # open/write it again to force delayed layout creation
2355 cat /etc/hosts > $DIR/$tdir/f0 &
2359 for num in $(seq $OSTCOUNT); do
2360 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2361 error "ost$num failed to start"
2364 wait $catpid || error "cat failed"
2366 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2367 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2370 run_test 27F "Client resend delayed layout creation with non-zero size"
2372 test_27G() { #LU-10629
2373 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2374 skip "Need MDS version at least 2.11.51"
2375 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2376 remote_mds_nodsh && skip "remote MDS with nodsh"
2377 local POOL=${POOL:-testpool}
2378 local ostrange="0 0 1"
2380 test_mkdir $DIR/$tdir
2381 pool_add $POOL || error "pool_add failed"
2382 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2383 $LFS setstripe -p $POOL $DIR/$tdir
2385 local pool=$($LFS getstripe -p $DIR/$tdir)
2387 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2389 $LFS setstripe -d $DIR/$tdir
2391 pool=$($LFS getstripe -p $DIR/$tdir)
2395 [ -z "$pool" ] || error "'$pool' is not empty"
2397 run_test 27G "Clear OST pool from stripe"
2400 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2401 skip "Need MDS version newer than 2.11.54"
2402 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2403 test_mkdir $DIR/$tdir
2404 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2405 touch $DIR/$tdir/$tfile
2406 $LFS getstripe -c $DIR/$tdir/$tfile
2407 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2408 error "two-stripe file doesn't have two stripes"
2410 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2411 $LFS getstripe -y $DIR/$tdir/$tfile
2412 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2413 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2414 error "expected l_ost_idx: [02]$ not matched"
2416 # make sure ost list have been cleared
2417 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
2418 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2419 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2421 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2423 run_test 27H "Set specific OSTs stripe"
2426 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2427 skip "Need MDS version >= than 2.12.57"
2428 remote_mds_nodsh && skip "remote MDS with nodsh"
2429 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2431 test_mkdir $DIR/$tdir
2433 # Set default striping on directory
2437 # if we run against a 2.12 server which lacks overstring support
2438 # then the connect_flag will not report overstriping, even if client
2440 if [[ $($LCTL get_param mdc.*.connect_flags) =~ overstriping ]]; then
2441 stripe_opt="-C $setcount"
2442 elif (( $OSTCOUNT >= $setcount )); then
2443 stripe_opt="-c $setcount"
2445 skip "server does not support overstriping"
2447 $LFS setstripe $stripe_opt $DIR/$tdir
2449 echo 1 > $DIR/$tdir/${tfile}.1
2450 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2451 [ $count -eq $setcount ] ||
2452 error "(1) stripe count $count, should be $setcount"
2454 # Capture existing append_stripe_count setting for restore
2455 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2456 local mdts=$(comma_list $(mdts_nodes))
2457 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2459 local appendcount=$orig_count
2460 echo 1 >> $DIR/$tdir/${tfile}.2_append
2461 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2462 [ $count -eq $appendcount ] ||
2463 error "(2)stripe count $count, should be $appendcount for append"
2465 # Disable O_APPEND striping, verify it works
2466 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2468 # Should now get the default striping, which is 4
2470 echo 1 >> $DIR/$tdir/${tfile}.3_append
2471 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2472 [ $count -eq $setcount ] ||
2473 error "(3) stripe count $count, should be $setcount"
2475 # Try changing the stripe count for append files
2476 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2478 # Append striping is now 2 (directory default is still 4)
2480 echo 1 >> $DIR/$tdir/${tfile}.4_append
2481 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2482 [ $count -eq $appendcount ] ||
2483 error "(4) stripe count $count, should be $appendcount for append"
2485 # Test append stripe count of -1
2486 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2487 appendcount=$OSTCOUNT
2488 echo 1 >> $DIR/$tdir/${tfile}.5
2489 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2490 [ $count -eq $appendcount ] ||
2491 error "(5) stripe count $count, should be $appendcount for append"
2493 # Set append striping back to default of 1
2494 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2496 # Try a new default striping, PFL + DOM
2497 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2499 # Create normal DOM file, DOM returns stripe count == 0
2501 touch $DIR/$tdir/${tfile}.6
2502 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2503 [ $count -eq $setcount ] ||
2504 error "(6) stripe count $count, should be $setcount"
2508 echo 1 >> $DIR/$tdir/${tfile}.7_append
2509 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2510 [ $count -eq $appendcount ] ||
2511 error "(7) stripe count $count, should be $appendcount for append"
2513 # Clean up DOM layout
2514 $LFS setstripe -d $DIR/$tdir
2516 save_layout_restore_at_exit $MOUNT
2517 # Now test that append striping works when layout is from root
2518 $LFS setstripe -c 2 $MOUNT
2519 # Make a special directory for this
2520 mkdir $DIR/${tdir}/${tdir}.2
2522 # Verify for normal file
2524 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2525 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2526 [ $count -eq $setcount ] ||
2527 error "(8) stripe count $count, should be $setcount"
2530 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2531 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2532 [ $count -eq $appendcount ] ||
2533 error "(9) stripe count $count, should be $appendcount for append"
2535 # Now test O_APPEND striping with pools
2536 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2537 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2540 pool_add $TESTNAME || error "pool creation failed"
2541 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2543 echo 1 >> $DIR/$tdir/${tfile}.10_append
2545 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2546 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2548 # Check that count is still correct
2550 echo 1 >> $DIR/$tdir/${tfile}.11_append
2551 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2552 [ $count -eq $appendcount ] ||
2553 error "(11) stripe count $count, should be $appendcount for append"
2555 # Disable O_APPEND stripe count, verify pool works separately
2556 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2558 echo 1 >> $DIR/$tdir/${tfile}.12_append
2560 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2561 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2563 # Remove pool setting, verify it's not applied
2564 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
2566 echo 1 >> $DIR/$tdir/${tfile}.13_append
2568 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
2569 [ "$pool" = "" ] || error "(13) pool found: $pool"
2571 run_test 27M "test O_APPEND striping"
2573 # createtest also checks that device nodes are created and
2574 # then visible correctly (#2091)
2575 test_28() { # bug 2091
2577 $CREATETEST $DIR/d28/ct || error "createtest failed"
2579 run_test 28 "create/mknod/mkdir with bad file types ============"
2582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2584 sync; sleep 1; sync # flush out any dirty pages from previous tests
2591 declare -i LOCKCOUNTORIG=0
2592 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2593 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2595 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2597 declare -i LOCKUNUSEDCOUNTORIG=0
2598 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2599 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2606 declare -i LOCKCOUNTCURRENT=0
2607 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2608 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2611 declare -i LOCKUNUSEDCOUNTCURRENT=0
2612 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2613 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2616 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2617 $LCTL set_param -n ldlm.dump_namespaces ""
2618 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2619 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2620 log "dumped log to $TMP/test_29.dk (bug 5793)"
2623 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2624 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2625 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2626 log "dumped log to $TMP/test_29.dk (bug 5793)"
2630 run_test 29 "IT_GETATTR regression ============================"
2632 test_30a() { # was test_30
2633 cp $(which ls) $DIR || cp /bin/ls $DIR
2634 $DIR/ls / || error "Can't execute binary from lustre"
2637 run_test 30a "execute binary from Lustre (execve) =============="
2640 cp `which ls` $DIR || cp /bin/ls $DIR
2642 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2645 run_test 30b "execute binary from Lustre as non-root ==========="
2647 test_30c() { # b=22376
2648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2650 cp `which ls` $DIR || cp /bin/ls $DIR
2652 cancel_lru_locks mdc
2653 cancel_lru_locks osc
2654 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2657 run_test 30c "execute binary from Lustre without read perms ===="
2660 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2661 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2663 run_test 31a "open-unlink file =================================="
2666 touch $DIR/f31 || error "touch $DIR/f31 failed"
2667 ln $DIR/f31 $DIR/f31b || error "ln failed"
2668 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2669 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2671 run_test 31b "unlink file with multiple links while open ======="
2674 touch $DIR/f31 || error "touch $DIR/f31 failed"
2675 ln $DIR/f31 $DIR/f31c || error "ln failed"
2676 multiop_bg_pause $DIR/f31 O_uc ||
2677 error "multiop_bg_pause for $DIR/f31 failed"
2679 $MULTIOP $DIR/f31c Ouc
2680 kill -USR1 $MULTIPID
2683 run_test 31c "open-unlink file with multiple links ============="
2686 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2687 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2689 run_test 31d "remove of open directory ========================="
2691 test_31e() { # bug 2904
2692 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2694 run_test 31e "remove of open non-empty directory ==============="
2696 test_31f() { # bug 4554
2697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2700 test_mkdir $DIR/d31f
2701 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2702 cp /etc/hosts $DIR/d31f
2704 $GETSTRIPE $DIR/d31f/hosts
2705 multiop_bg_pause $DIR/d31f D_c || return 1
2708 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2709 test_mkdir $DIR/d31f
2710 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2711 cp /etc/hosts $DIR/d31f
2713 $GETSTRIPE $DIR/d31f/hosts
2714 multiop_bg_pause $DIR/d31f D_c || return 1
2717 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2718 wait $MULTIPID || error "first opendir $MULTIPID failed"
2722 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2723 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2726 run_test 31f "remove of open directory with open-unlink file ==="
2729 echo "-- cross directory link --"
2730 test_mkdir -c1 $DIR/${tdir}ga
2731 test_mkdir -c1 $DIR/${tdir}gb
2732 touch $DIR/${tdir}ga/f
2733 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2734 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2735 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2736 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2737 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2739 run_test 31g "cross directory link==============="
2742 echo "-- cross directory link --"
2743 test_mkdir -c1 $DIR/${tdir}
2744 test_mkdir -c1 $DIR/${tdir}/dir
2745 touch $DIR/${tdir}/f
2746 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2747 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2748 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2749 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2750 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2752 run_test 31h "cross directory link under child==============="
2755 echo "-- cross directory link --"
2756 test_mkdir -c1 $DIR/$tdir
2757 test_mkdir -c1 $DIR/$tdir/dir
2758 touch $DIR/$tdir/dir/f
2759 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2760 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2761 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2762 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2763 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2765 run_test 31i "cross directory link under parent==============="
2768 test_mkdir -c1 -p $DIR/$tdir
2769 test_mkdir -c1 -p $DIR/$tdir/dir1
2770 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2771 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2772 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2773 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2776 run_test 31j "link for directory==============="
2779 test_mkdir -c1 -p $DIR/$tdir
2781 touch $DIR/$tdir/exist
2782 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2783 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2784 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2785 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2786 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2787 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2788 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2791 run_test 31k "link to file: the same, non-existing, dir==============="
2797 touch $DIR/d31m2/exist
2798 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2799 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2800 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2801 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2802 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2803 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2806 run_test 31m "link to file: the same, non-existing, dir==============="
2809 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2810 nlink=$(stat --format=%h $DIR/$tfile)
2811 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2813 local cmd="exec $fd<$DIR/$tfile"
2816 trap "eval $cmd" EXIT
2817 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2818 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2819 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2820 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2821 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2824 run_test 31n "check link count of unlinked file"
2827 local TEMPNAME=$(mktemp $1_XXXXXX)
2828 mlink $TEMPNAME $1 2> /dev/null &&
2829 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2833 test_31o() { # LU-2901
2834 test_mkdir $DIR/$tdir
2835 for LOOP in $(seq 100); do
2836 rm -f $DIR/$tdir/$tfile*
2837 for THREAD in $(seq 8); do
2838 link_one $DIR/$tdir/$tfile.$LOOP &
2841 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2842 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2843 error "$LINKS duplicate links to $tfile.$LOOP" &&
2847 run_test 31o "duplicate hard links with same filename"
2850 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2852 test_mkdir $DIR/$tdir
2853 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2854 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2856 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2857 error "open unlink test1 failed"
2858 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2859 error "open unlink test2 failed"
2861 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2862 error "test1 still exists"
2863 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2864 error "test2 still exists"
2866 run_test 31p "remove of open striped directory"
2868 cleanup_test32_mount() {
2871 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2872 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2873 losetup -d $loopdev || true
2879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2881 echo "== more mountpoints and symlinks ================="
2882 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2883 trap cleanup_test32_mount EXIT
2884 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2885 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2886 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2887 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2888 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2889 cleanup_test32_mount
2891 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2896 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2897 trap cleanup_test32_mount EXIT
2898 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2899 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2900 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2901 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2902 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2903 cleanup_test32_mount
2905 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2910 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2911 trap cleanup_test32_mount EXIT
2912 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2913 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2914 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2915 test_mkdir -p $DIR/$tdir/d2/test_dir
2916 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2917 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2918 cleanup_test32_mount
2920 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2923 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2925 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2926 trap cleanup_test32_mount EXIT
2927 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2928 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2929 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2930 test_mkdir -p $DIR/$tdir/d2/test_dir
2931 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2932 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2933 cleanup_test32_mount
2935 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2939 test_mkdir -p $DIR/$tdir/tmp
2940 local tmp_dir=$DIR/$tdir/tmp
2941 ln -s $DIR/$tdir $tmp_dir/symlink11
2942 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2943 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2944 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2946 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2950 test_mkdir -p $DIR/$tdir/tmp
2951 local tmp_dir=$DIR/$tdir/tmp
2952 ln -s $DIR/$tdir $tmp_dir/symlink11
2953 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2954 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2955 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2957 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2960 local tmp_dir=$DIR/$tdir/tmp
2961 test_mkdir -p $tmp_dir
2962 test_mkdir $DIR/${tdir}2
2963 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2964 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2965 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2966 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2967 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2968 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2970 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2973 rm -fr $DIR/$tdir $DIR/${tdir}2
2974 tmp_dir=$DIR/$tdir/tmp
2975 test_mkdir -p $tmp_dir
2976 test_mkdir $DIR/${tdir}2
2977 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2978 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2979 ls $tmp_dir/symlink12 || error "listing symlink12"
2980 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2982 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2987 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2988 trap cleanup_test32_mount EXIT
2989 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2990 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2991 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2992 touch $DIR/$tdir/test_file
2993 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2994 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2995 cleanup_test32_mount
2997 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3000 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3002 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3003 trap cleanup_test32_mount EXIT
3004 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3005 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3006 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3007 touch $DIR/$tdir/test_file
3008 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3009 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3010 cleanup_test32_mount
3012 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3015 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3018 trap cleanup_test32_mount EXIT
3019 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3020 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3021 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3022 test_mkdir -p $DIR/$tdir/d2
3023 touch $DIR/$tdir/d2/test_file || error "touch failed"
3024 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3025 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3026 cleanup_test32_mount
3028 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3034 trap cleanup_test32_mount EXIT
3035 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3036 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3037 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3038 test_mkdir -p $DIR/$tdir/d2
3039 touch $DIR/$tdir/d2/test_file || error "touch failed"
3040 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3041 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3042 cleanup_test32_mount
3044 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3048 test_mkdir -p $DIR/d32m/tmp
3049 TMP_DIR=$DIR/d32m/tmp
3050 ln -s $DIR $TMP_DIR/symlink11
3051 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3052 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3053 error "symlink11 not a link"
3054 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3055 error "symlink01 not a link"
3057 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3061 test_mkdir -p $DIR/d32n/tmp
3062 TMP_DIR=$DIR/d32n/tmp
3063 ln -s $DIR $TMP_DIR/symlink11
3064 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3065 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3066 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3068 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3072 test_mkdir -p $DIR/d32o/tmp
3073 TMP_DIR=$DIR/d32o/tmp
3074 ln -s $DIR/$tfile $TMP_DIR/symlink12
3075 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3076 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3077 error "symlink12 not a link"
3078 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3079 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3080 error "$DIR/d32o/tmp/symlink12 not file type"
3081 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3082 error "$DIR/d32o/symlink02 not file type"
3084 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3094 test_mkdir -p $DIR/d32p/tmp
3096 TMP_DIR=$DIR/d32p/tmp
3098 ln -s $DIR/$tfile $TMP_DIR/symlink12
3100 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3102 cat $DIR/d32p/tmp/symlink12 ||
3103 error "Can't open $DIR/d32p/tmp/symlink12"
3105 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3108 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3113 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3114 trap cleanup_test32_mount EXIT
3115 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3116 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3117 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3118 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3119 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3120 cleanup_test32_mount
3122 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3125 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3127 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3128 trap cleanup_test32_mount EXIT
3129 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3130 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3131 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3132 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3133 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3134 cleanup_test32_mount
3136 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3141 chmod 444 $DIR/$tfile
3142 chown $RUNAS_ID $DIR/$tfile
3144 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3147 run_test 33aa "write file with mode 444 (should return error)"
3151 test_mkdir $DIR/$tdir
3152 chown $RUNAS_ID $DIR/$tdir
3153 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3154 error "$RUNAS create $tdir/$tfile failed"
3155 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3156 error "open RDWR" || true
3158 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3162 test_mkdir $DIR/$tdir
3163 chown $RUNAS_ID $DIR/$tdir
3164 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3166 run_test 33b "test open file with malformed flags (No panic)"
3169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3170 remote_ost_nodsh && skip "remote OST with nodsh"
3179 test_mkdir $DIR/$tdir
3180 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3183 for ostnum in $(seq $OSTCOUNT); do
3184 # test-framework's OST numbering is one-based, while Lustre's
3186 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3187 # Parsing llobdstat's output sucks; we could grep the /proc
3188 # path, but that's likely to not be as portable as using the
3189 # llobdstat utility. So we parse lctl output instead.
3190 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3191 obdfilter/$ostname/stats |
3192 awk '/^write_bytes/ {print $7}' )
3193 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3194 if (( ${write_bytes:-0} > 0 ))
3201 $all_zeros || return 0
3204 echo foo > $DIR/$tdir/bar
3208 # Total up write_bytes after writing. We'd better find non-zeros.
3209 for ostnum in $(seq $OSTCOUNT); do
3210 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3211 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3212 obdfilter/$ostname/stats |
3213 awk '/^write_bytes/ {print $7}' )
3214 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3215 if (( ${write_bytes:-0} > 0 ))
3224 for ostnum in $(seq $OSTCOUNT); do
3225 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3226 echo "Check that write_bytes is present in obdfilter/*/stats:"
3227 do_facet ost$ostnum lctl get_param -n \
3228 obdfilter/$ostname/stats
3230 error "OST not keeping write_bytes stats (b22312)"
3233 run_test 33c "test llobdstat and write_bytes"
3236 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3237 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3240 local remote_dir=$DIR/$tdir/remote_dir
3242 test_mkdir $DIR/$tdir
3243 $LFS mkdir -i $MDTIDX $remote_dir ||
3244 error "create remote directory failed"
3246 touch $remote_dir/$tfile
3247 chmod 444 $remote_dir/$tfile
3248 chown $RUNAS_ID $remote_dir/$tfile
3250 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3252 chown $RUNAS_ID $remote_dir
3253 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3254 error "create" || true
3255 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3256 error "open RDWR" || true
3257 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3259 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3262 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3266 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3267 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3268 mkdir $DIR/$tdir/local_dir
3270 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3271 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3272 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3274 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3275 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3277 rmdir $DIR/$tdir/* || error "rmdir failed"
3280 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3281 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3282 mkdir $DIR/$tdir/local_dir
3284 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3285 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3286 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3288 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3289 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3291 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3294 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3295 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3296 mkdir $DIR/$tdir/local_dir
3298 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3299 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3300 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3302 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3303 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3305 run_test 33e "mkdir and striped directory should have same mode"
3309 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3313 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3314 remote_mds_nodsh && skip "remote MDS with nodsh"
3317 chmod go+rwx $DIR/$tdir
3318 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3319 trap cleanup_33f EXIT
3321 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3322 error "cannot create striped directory"
3324 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3325 error "cannot create files in striped directory"
3327 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3328 error "cannot remove files in striped directory"
3330 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3331 error "cannot remove striped directory"
3335 run_test 33f "nonroot user can create, access, and remove a striped directory"
3338 mkdir -p $DIR/$tdir/dir2
3340 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3342 [[ $err =~ "exists" ]] || error "Not exists error"
3344 run_test 33g "nonroot user create already existing root created file"
3346 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3349 $MCREATE $DIR/f34 || error "mcreate failed"
3350 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3351 error "getstripe failed"
3352 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3353 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3354 error "getstripe failed"
3355 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3356 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3358 run_test 34a "truncate file that has not been opened ==========="
3361 [ ! -f $DIR/f34 ] && test_34a
3362 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3363 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3364 $OPENFILE -f O_RDONLY $DIR/f34
3365 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3366 error "getstripe failed"
3367 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3368 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3370 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3373 [ ! -f $DIR/f34 ] && test_34a
3374 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3375 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3376 $OPENFILE -f O_RDWR $DIR/f34
3377 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3378 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3379 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3381 run_test 34c "O_RDWR opening file-with-size works =============="
3384 [ ! -f $DIR/f34 ] && test_34a
3385 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3387 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3388 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3391 run_test 34d "write to sparse file ============================="
3395 $MCREATE $DIR/f34e || error "mcreate failed"
3396 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3397 $CHECKSTAT -s 1000 $DIR/f34e ||
3398 error "Size of $DIR/f34e not equal to 1000 bytes"
3399 $OPENFILE -f O_RDWR $DIR/f34e
3400 $CHECKSTAT -s 1000 $DIR/f34e ||
3401 error "Size of $DIR/f34e not equal to 1000 bytes"
3403 run_test 34e "create objects, some with size and some without =="
3405 test_34f() { # bug 6242, 6243
3406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3410 $MCREATE $DIR/f34f || error "mcreate failed"
3411 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3412 dd if=$DIR/f34f of=$TMP/f34f
3413 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3414 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3415 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3416 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3417 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3419 run_test 34f "read from a file with no objects until EOF ======="
3422 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3424 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3426 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3427 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3428 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3429 cancel_lru_locks osc
3430 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3431 error "wrong size after lock cancel"
3433 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3434 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3435 error "expanding truncate failed"
3436 cancel_lru_locks osc
3437 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3438 error "wrong expanded size after lock cancel"
3440 run_test 34g "truncate long file ==============================="
3443 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3448 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3449 sync # Flush the cache so that multiop below does not block on cache
3450 # flush when getting the group lock
3451 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3454 # Since just timed wait is not good enough, let's do a sync write
3455 # that way we are sure enough time for a roundtrip + processing
3456 # passed + 2 seconds of extra margin.
3457 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3461 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3462 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3466 local nsz=`stat -c %s $DIR/$tfile`
3467 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3469 run_test 34h "ftruncate file under grouplock should not block"
3472 cp /bin/sh $DIR/f35a
3474 chown $RUNAS_ID $DIR/f35a
3475 $RUNAS $DIR/f35a && error || true
3478 run_test 35a "exec file with mode 444 (should return and not leak)"
3482 utime $DIR/f36 || error "utime failed for MDS"
3484 run_test 36a "MDS utime check (mknod, utime)"
3488 utime $DIR/f36 || error "utime failed for OST"
3490 run_test 36b "OST utime check (open, utime)"
3495 chown $RUNAS_ID $DIR/d36
3496 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3498 run_test 36c "non-root MDS utime check (mknod, utime)"
3501 [ ! -d $DIR/d36 ] && test_36c
3502 echo "" > $DIR/d36/f36
3503 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3505 run_test 36d "non-root OST utime check (open, utime)"
3508 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3510 test_mkdir $DIR/$tdir
3511 touch $DIR/$tdir/$tfile
3512 $RUNAS utime $DIR/$tdir/$tfile &&
3513 error "utime worked, expected failure" || true
3515 run_test 36e "utime on non-owned file (should return error)"
3519 local LANG_SAVE=$LANG
3520 local LC_LANG_SAVE=$LC_LANG
3521 export LANG=C LC_LANG=C # for date language
3523 DATESTR="Dec 20 2000"
3524 test_mkdir $DIR/$tdir
3525 lctl set_param fail_loc=$fl
3527 cp /etc/hosts $DIR/$tdir/$tfile
3528 sync & # write RPC generated with "current" inode timestamp, but delayed
3530 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3531 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3532 cancel_lru_locks $OSC
3533 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3535 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3536 echo "BEFORE: $LS_BEFORE" && \
3537 echo "AFTER : $LS_AFTER" && \
3538 echo "WANT : $DATESTR" && \
3539 error "$DIR/$tdir/$tfile timestamps changed" || true
3541 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3545 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3547 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3548 subr_36fh "0x80000214"
3550 run_test 36f "utime on file racing with OST BRW write =========="
3553 remote_ost_nodsh && skip "remote OST with nodsh"
3554 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3555 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3556 skip "Need MDS version at least 2.12.51"
3561 local tgt="obdfilter"
3563 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3565 test_mkdir $DIR/$tdir
3566 fmd_max_age=$(do_facet $facet \
3567 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3570 echo "FMD max age: ${fmd_max_age}s"
3571 touch $DIR/$tdir/$tfile
3572 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3573 gawk '{cnt=cnt+$1} END{print cnt}')
3574 echo "FMD before: $fmd"
3576 error "FMD wasn't create by touch"
3577 sleep $((fmd_max_age + 12))
3578 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3579 gawk '{cnt=cnt+$1} END{print cnt}')
3580 echo "FMD after: $fmd"
3582 error "FMD wasn't expired by ping"
3584 run_test 36g "FMD cache expiry ====================="
3587 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3589 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3590 subr_36fh "0x80000227"
3592 run_test 36h "utime on file racing with OST BRW write =========="
3595 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3597 test_mkdir $DIR/$tdir
3598 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3600 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3601 local new_mtime=$((mtime + 200))
3603 #change Modify time of striped dir
3604 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3605 error "change mtime failed"
3607 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3609 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3611 run_test 36i "change mtime on striped directory"
3613 # test_37 - duplicate with tests 32q 32r
3616 local file=$DIR/$tfile
3618 openfile -f O_DIRECTORY $file
3621 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3622 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3624 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3626 test_39a() { # was test_39
3628 touch $DIR/${tfile}2
3629 # ls -l $DIR/$tfile $DIR/${tfile}2
3630 # ls -lu $DIR/$tfile $DIR/${tfile}2
3631 # ls -lc $DIR/$tfile $DIR/${tfile}2
3633 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3634 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3636 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3638 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3640 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3641 error "O_TRUNC didn't change timestamps"
3644 run_test 39a "mtime changed on create"
3647 test_mkdir -c1 $DIR/$tdir
3648 cp -p /etc/passwd $DIR/$tdir/fopen
3649 cp -p /etc/passwd $DIR/$tdir/flink
3650 cp -p /etc/passwd $DIR/$tdir/funlink
3651 cp -p /etc/passwd $DIR/$tdir/frename
3652 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3655 echo "aaaaaa" >> $DIR/$tdir/fopen
3656 echo "aaaaaa" >> $DIR/$tdir/flink
3657 echo "aaaaaa" >> $DIR/$tdir/funlink
3658 echo "aaaaaa" >> $DIR/$tdir/frename
3660 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3661 local link_new=`stat -c %Y $DIR/$tdir/flink`
3662 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3663 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3665 cat $DIR/$tdir/fopen > /dev/null
3666 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3667 rm -f $DIR/$tdir/funlink2
3668 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3670 for (( i=0; i < 2; i++ )) ; do
3671 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3672 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3673 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3674 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3676 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3677 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3678 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3679 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3681 cancel_lru_locks $OSC
3682 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3685 run_test 39b "mtime change on open, link, unlink, rename ======"
3687 # this should be set to past
3688 TEST_39_MTIME=`date -d "1 year ago" +%s`
3694 local mtime0=`stat -c %Y $DIR1/$tfile`
3696 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3697 local mtime1=`stat -c %Y $DIR1/$tfile`
3698 [ "$mtime1" = $TEST_39_MTIME ] || \
3699 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3702 echo hello >> $DIR1/$tfile
3704 local mtime2=`stat -c %Y $DIR1/$tfile`
3705 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3706 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3708 mv $DIR1/$tfile $DIR1/$tfile-1
3710 for (( i=0; i < 2; i++ )) ; do
3711 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3712 [ "$mtime2" = "$mtime3" ] || \
3713 error "mtime ($mtime2) changed (to $mtime3) on rename"
3715 cancel_lru_locks $OSC
3716 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3719 run_test 39c "mtime change on rename ==========================="
3723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3726 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3728 for (( i=0; i < 2; i++ )) ; do
3729 local mtime=`stat -c %Y $DIR1/$tfile`
3730 [ $mtime = $TEST_39_MTIME ] || \
3731 error "mtime($mtime) is not set to $TEST_39_MTIME"
3733 cancel_lru_locks $OSC
3734 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3737 run_test 39d "create, utime, stat =============================="
3741 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3744 local mtime1=`stat -c %Y $DIR1/$tfile`
3746 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3748 for (( i=0; i < 2; i++ )) ; do
3749 local mtime2=`stat -c %Y $DIR1/$tfile`
3750 [ $mtime2 = $TEST_39_MTIME ] || \
3751 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3753 cancel_lru_locks $OSC
3754 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3757 run_test 39e "create, stat, utime, stat ========================"
3761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3764 mtime1=`stat -c %Y $DIR1/$tfile`
3767 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3769 for (( i=0; i < 2; i++ )) ; do
3770 local mtime2=`stat -c %Y $DIR1/$tfile`
3771 [ $mtime2 = $TEST_39_MTIME ] || \
3772 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3774 cancel_lru_locks $OSC
3775 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3778 run_test 39f "create, stat, sleep, utime, stat ================="
3782 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3784 echo hello >> $DIR1/$tfile
3785 local mtime1=`stat -c %Y $DIR1/$tfile`
3788 chmod o+r $DIR1/$tfile
3790 for (( i=0; i < 2; i++ )) ; do
3791 local mtime2=`stat -c %Y $DIR1/$tfile`
3792 [ "$mtime1" = "$mtime2" ] || \
3793 error "lost mtime: $mtime2, should be $mtime1"
3795 cancel_lru_locks $OSC
3796 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3799 run_test 39g "write, chmod, stat ==============================="
3803 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3809 echo hello >> $DIR1/$tfile
3810 local mtime1=`stat -c %Y $DIR1/$tfile`
3812 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3814 if [ "$d1" != "$d2" ]; then
3815 echo "write and touch not within one second"
3817 for (( i=0; i < 2; i++ )) ; do
3818 local mtime2=`stat -c %Y $DIR1/$tfile`
3819 [ "$mtime2" = $TEST_39_MTIME ] || \
3820 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3822 cancel_lru_locks $OSC
3823 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3827 run_test 39h "write, utime within one second, stat ============="
3830 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3835 echo hello >> $DIR1/$tfile
3836 local mtime1=`stat -c %Y $DIR1/$tfile`
3838 mv $DIR1/$tfile $DIR1/$tfile-1
3840 for (( i=0; i < 2; i++ )) ; do
3841 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3843 [ "$mtime1" = "$mtime2" ] || \
3844 error "lost mtime: $mtime2, should be $mtime1"
3846 cancel_lru_locks $OSC
3847 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3850 run_test 39i "write, rename, stat =============================="
3853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3855 start_full_debug_logging
3859 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3860 lctl set_param fail_loc=0x80000412
3861 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3862 error "multiop failed"
3864 local mtime1=`stat -c %Y $DIR1/$tfile`
3866 mv $DIR1/$tfile $DIR1/$tfile-1
3868 kill -USR1 $multipid
3869 wait $multipid || error "multiop close failed"
3871 for (( i=0; i < 2; i++ )) ; do
3872 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3873 [ "$mtime1" = "$mtime2" ] ||
3874 error "mtime is lost on close: $mtime2, " \
3877 cancel_lru_locks $OSC
3878 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3880 lctl set_param fail_loc=0
3881 stop_full_debug_logging
3883 run_test 39j "write, rename, close, stat ======================="
3886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3891 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3893 local mtime1=`stat -c %Y $DIR1/$tfile`
3895 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3897 kill -USR1 $multipid
3898 wait $multipid || error "multiop close failed"
3900 for (( i=0; i < 2; i++ )) ; do
3901 local mtime2=`stat -c %Y $DIR1/$tfile`
3903 [ "$mtime2" = $TEST_39_MTIME ] || \
3904 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3906 cancel_lru_locks osc
3907 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3910 run_test 39k "write, utime, close, stat ========================"
3912 # this should be set to future
3913 TEST_39_ATIME=`date -d "1 year" +%s`
3916 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3917 remote_mds_nodsh && skip "remote MDS with nodsh"
3919 local atime_diff=$(do_facet $SINGLEMDS \
3920 lctl get_param -n mdd.*MDT0000*.atime_diff)
3924 # test setting directory atime to future
3925 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3926 local atime=$(stat -c %X $DIR/$tdir)
3927 [ "$atime" = $TEST_39_ATIME ] ||
3928 error "atime is not set to future: $atime, $TEST_39_ATIME"
3930 # test setting directory atime from future to now
3931 local now=$(date +%s)
3932 touch -a -d @$now $DIR/$tdir
3934 atime=$(stat -c %X $DIR/$tdir)
3935 [ "$atime" -eq "$now" ] ||
3936 error "atime is not updated from future: $atime, $now"
3938 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3941 # test setting directory atime when now > dir atime + atime_diff
3942 local d1=$(date +%s)
3944 local d2=$(date +%s)
3945 cancel_lru_locks mdc
3946 atime=$(stat -c %X $DIR/$tdir)
3947 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3948 error "atime is not updated : $atime, should be $d2"
3950 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3953 # test not setting directory atime when now < dir atime + atime_diff
3955 cancel_lru_locks mdc
3956 atime=$(stat -c %X $DIR/$tdir)
3957 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3958 error "atime is updated to $atime, should remain $d1<atime<$d2"
3960 do_facet $SINGLEMDS \
3961 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3963 run_test 39l "directory atime update ==========================="
3966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3970 local far_past_mtime=$(date -d "May 29 1953" +%s)
3971 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3973 touch -m -d @$far_past_mtime $DIR1/$tfile
3974 touch -a -d @$far_past_atime $DIR1/$tfile
3976 for (( i=0; i < 2; i++ )) ; do
3977 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3978 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3979 error "atime or mtime set incorrectly"
3981 cancel_lru_locks $OSC
3982 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3985 run_test 39m "test atime and mtime before 1970"
3987 test_39n() { # LU-3832
3988 remote_mds_nodsh && skip "remote MDS with nodsh"
3990 local atime_diff=$(do_facet $SINGLEMDS \
3991 lctl get_param -n mdd.*MDT0000*.atime_diff)
3996 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3999 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4000 atime0=$(stat -c %X $DIR/$tfile)
4003 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4004 atime1=$(stat -c %X $DIR/$tfile)
4007 cancel_lru_locks mdc
4008 cancel_lru_locks osc
4009 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4010 atime2=$(stat -c %X $DIR/$tfile)
4012 do_facet $SINGLEMDS \
4013 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4015 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4016 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4018 run_test 39n "check that O_NOATIME is honored"
4021 TESTDIR=$DIR/$tdir/$tfile
4022 [ -e $TESTDIR ] && rm -rf $TESTDIR
4029 links2=$(stat -c %h .)
4030 [ $(($links1 + 2)) != $links2 ] &&
4031 error "wrong links count $(($links1 + 2)) != $links2"
4033 links3=$(stat -c %h .)
4034 [ $(($links1 + 1)) != $links3 ] &&
4035 error "wrong links count $links1 != $links3"
4038 run_test 39o "directory cached attributes updated after create"
4041 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4044 TESTDIR=$DIR/$tdir/$tdir
4045 [ -e $TESTDIR ] && rm -rf $TESTDIR
4046 test_mkdir -p $TESTDIR
4050 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4051 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4053 links2=$(stat -c %h .)
4054 [ $(($links1 + 2)) != $links2 ] &&
4055 error "wrong links count $(($links1 + 2)) != $links2"
4057 links3=$(stat -c %h .)
4058 [ $(($links1 + 1)) != $links3 ] &&
4059 error "wrong links count $links1 != $links3"
4062 run_test 39p "remote directory cached attributes updated after create ========"
4065 test_39q() { # LU-8041
4066 local testdir=$DIR/$tdir
4068 multiop_bg_pause $testdir D_c || error "multiop failed"
4070 cancel_lru_locks mdc
4071 kill -USR1 $multipid
4072 local atime=$(stat -c %X $testdir)
4073 [ "$atime" -ne 0 ] || error "atime is zero"
4075 run_test 39q "close won't zero out atime"
4078 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4079 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4080 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4081 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4082 error "$tfile is not 4096 bytes in size"
4084 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4088 small_write $DIR/f41 18
4090 run_test 41 "test small file write + fstat ====================="
4092 count_ost_writes() {
4093 lctl get_param -n ${OSC}.*.stats |
4094 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4095 END { printf("%0.0f", writes) }'
4102 BG_DIRTY_RATIO_SAVE=10
4103 MAX_BG_DIRTY_RATIO=25
4107 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4108 # dirty_ratio, dirty_background_ratio
4109 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4110 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4111 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4112 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4114 # if file not here, we are a 2.4 kernel
4115 kill -CONT `pidof kupdated`
4120 # setup the trap first, so someone cannot exit the test at the
4121 # exact wrong time and mess up a machine
4122 trap start_writeback EXIT
4123 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4124 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4125 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4126 sysctl -w vm.dirty_writeback_centisecs=0
4127 sysctl -w vm.dirty_writeback_centisecs=0
4128 # save and increase /proc/sys/vm/dirty_ratio
4129 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4130 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4131 # save and increase /proc/sys/vm/dirty_background_ratio
4132 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4133 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4135 # if file not here, we are a 2.4 kernel
4136 kill -STOP `pidof kupdated`
4140 # ensure that all stripes have some grant before we test client-side cache
4142 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4143 dd if=/dev/zero of=$i bs=4k count=1
4148 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4149 # file truncation, and file removal.
4151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4154 cancel_lru_locks $OSC
4156 sync; sleep 1; sync # just to be safe
4157 BEFOREWRITES=`count_ost_writes`
4158 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4159 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4160 AFTERWRITES=`count_ost_writes`
4161 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4162 error "$BEFOREWRITES < $AFTERWRITES"
4165 run_test 42a "ensure that we don't flush on close"
4168 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4171 cancel_lru_locks $OSC
4174 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4175 BEFOREWRITES=$(count_ost_writes)
4176 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4177 AFTERWRITES=$(count_ost_writes)
4178 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4179 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4181 BEFOREWRITES=$(count_ost_writes)
4182 sync || error "sync: $?"
4183 AFTERWRITES=$(count_ost_writes)
4184 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4185 error "$BEFOREWRITES < $AFTERWRITES on sync"
4187 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4191 run_test 42b "test destroy of file with cached dirty data ======"
4193 # if these tests just want to test the effect of truncation,
4194 # they have to be very careful. consider:
4195 # - the first open gets a {0,EOF}PR lock
4196 # - the first write conflicts and gets a {0, count-1}PW
4197 # - the rest of the writes are under {count,EOF}PW
4198 # - the open for truncate tries to match a {0,EOF}PR
4199 # for the filesize and cancels the PWs.
4200 # any number of fixes (don't get {0,EOF} on open, match
4201 # composite locks, do smarter file size management) fix
4202 # this, but for now we want these tests to verify that
4203 # the cancellation with truncate intent works, so we
4204 # start the file with a full-file pw lock to match against
4205 # until the truncate.
4210 cancel_lru_locks $OSC
4212 # prime the file with 0,EOF PW to match
4216 # now the real test..
4217 dd if=/dev/zero of=$file bs=1024 count=100
4218 BEFOREWRITES=`count_ost_writes`
4219 $TRUNCATE $file $offset
4220 cancel_lru_locks $OSC
4221 AFTERWRITES=`count_ost_writes`
4226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4229 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4230 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4233 run_test 42c "test partial truncate of file with cached dirty data"
4236 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4239 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4240 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4243 run_test 42d "test complete truncate of file with cached dirty data"
4245 test_42e() { # bug22074
4246 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4248 local TDIR=$DIR/${tdir}e
4249 local pages=16 # hardcoded 16 pages, don't change it.
4250 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4251 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4255 test_mkdir $DIR/${tdir}e
4256 $SETSTRIPE -c 1 $TDIR
4257 createmany -o $TDIR/f $files
4259 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4261 # we assume that with $OSTCOUNT files, at least one of them will
4262 # be allocated on OST0.
4263 warmup_files=$((OSTCOUNT * max_dirty_mb))
4264 createmany -o $TDIR/w $warmup_files
4266 # write a large amount of data into one file and sync, to get good
4267 # avail_grant number from OST.
4268 for ((i=0; i<$warmup_files; i++)); do
4269 idx=$($GETSTRIPE -i $TDIR/w$i)
4270 [ $idx -ne 0 ] && continue
4271 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4274 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4276 $LCTL get_param $proc_osc0/cur_dirty_bytes
4277 $LCTL get_param $proc_osc0/cur_grant_bytes
4279 # create as much dirty pages as we can while not to trigger the actual
4280 # RPCs directly. but depends on the env, VFS may trigger flush during this
4281 # period, hopefully we are good.
4282 for ((i=0; i<$warmup_files; i++)); do
4283 idx=$($GETSTRIPE -i $TDIR/w$i)
4284 [ $idx -ne 0 ] && continue
4285 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4287 $LCTL get_param $proc_osc0/cur_dirty_bytes
4288 $LCTL get_param $proc_osc0/cur_grant_bytes
4290 # perform the real test
4291 $LCTL set_param $proc_osc0/rpc_stats 0
4292 for ((;i<$files; i++)); do
4293 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
4294 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4297 $LCTL get_param $proc_osc0/rpc_stats
4300 local have_ppr=false
4301 $LCTL get_param $proc_osc0/rpc_stats |
4302 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4303 # skip lines until we are at the RPC histogram data
4304 [ "$PPR" == "pages" ] && have_ppr=true && continue
4305 $have_ppr || continue
4307 # we only want the percent stat for < 16 pages
4308 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4310 percent=$((percent + WPCT))
4311 if [[ $percent -gt 15 ]]; then
4312 error "less than 16-pages write RPCs" \
4319 run_test 42e "verify sub-RPC writes are not done synchronously"
4321 test_43A() { # was test_43
4322 test_mkdir $DIR/$tdir
4323 cp -p /bin/ls $DIR/$tdir/$tfile
4324 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4326 # give multiop a chance to open
4329 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4332 run_test 43A "execution of file opened for write should return -ETXTBSY"
4335 test_mkdir $DIR/$tdir
4336 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4337 $DIR/$tdir/sleep 60 &
4339 # Make sure exec of $tdir/sleep wins race with truncate
4341 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4344 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4349 test_mkdir $DIR/$tdir
4350 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4351 $DIR/$tdir/sleep 60 &
4353 # Make sure exec of $tdir/sleep wins race with truncate
4355 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4358 run_test 43b "truncate of file being executed should return -ETXTBSY"
4361 local testdir="$DIR/$tdir"
4364 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4365 ( cd $testdir && md5sum -c )
4367 run_test 43c "md5sum of copy into lustre"
4369 test_44A() { # was test_44
4370 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4372 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4373 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4375 run_test 44A "zero length read from a sparse stripe"
4378 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4380 [ -z "$nstripe" ] && skip "can't get stripe info"
4381 [[ $nstripe -gt $OSTCOUNT ]] &&
4382 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4384 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4386 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4387 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4391 OFFSETS="0 $((stride/2)) $((stride-1))"
4392 for offset in $OFFSETS; do
4393 for i in $(seq 0 $((nstripe-1))); do
4394 local GLOBALOFFSETS=""
4396 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4397 local myfn=$DIR/d44a-$size
4398 echo "--------writing $myfn at $size"
4399 ll_sparseness_write $myfn $size ||
4400 error "ll_sparseness_write"
4401 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4402 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4403 error "ll_sparseness_verify $GLOBALOFFSETS"
4405 for j in $(seq 0 $((nstripe-1))); do
4407 size=$((((j + $nstripe )*$stride + $offset)))
4408 ll_sparseness_write $myfn $size ||
4409 error "ll_sparseness_write"
4410 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4412 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4413 error "ll_sparseness_verify $GLOBALOFFSETS"
4418 run_test 44a "test sparse pwrite ==============================="
4422 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4428 before=`dirty_osc_total`
4429 echo executing "\"$*\""
4431 after=`dirty_osc_total`
4432 echo before $before, after $after
4435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4438 # Obtain grants from OST if it supports it
4439 echo blah > ${f}_grant
4442 do_dirty_record "echo blah > $f"
4443 [[ $before -eq $after ]] && error "write wasn't cached"
4444 do_dirty_record "> $f"
4445 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4446 do_dirty_record "echo blah > $f"
4447 [[ $before -eq $after ]] && error "write wasn't cached"
4448 do_dirty_record "sync"
4449 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4450 do_dirty_record "echo blah > $f"
4451 [[ $before -eq $after ]] && error "write wasn't cached"
4452 do_dirty_record "cancel_lru_locks osc"
4453 [[ $before -gt $after ]] ||
4454 error "lock cancellation didn't lower dirty count"
4457 run_test 45 "osc io page accounting ============================"
4459 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4460 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4461 # objects offset and an assert hit when an rpc was built with 1023's mapped
4462 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4464 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4469 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4471 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4472 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4476 run_test 46 "dirtying a previously written page ================"
4478 # test_47 is removed "Device nodes check" is moved to test_28
4480 test_48a() { # bug 2399
4481 [ "$mds1_FSTYPE" = "zfs" ] &&
4482 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4483 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4485 test_mkdir $DIR/$tdir
4487 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4488 test_mkdir $DIR/$tdir
4489 touch foo || error "'touch foo' failed after recreating cwd"
4491 touch .foo || error "'touch .foo' failed after recreating cwd"
4493 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4494 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4495 cd . || error "'cd .' failed after recreating cwd"
4496 mkdir . && error "'mkdir .' worked after recreating cwd"
4497 rmdir . && error "'rmdir .' worked after recreating cwd"
4498 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4499 cd .. || error "'cd ..' failed after recreating cwd"
4501 run_test 48a "Access renamed working dir (should return errors)="
4503 test_48b() { # bug 2399
4505 test_mkdir $DIR/$tdir
4507 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4508 touch foo && error "'touch foo' worked after removing cwd"
4509 mkdir foo && error "'mkdir foo' worked after removing cwd"
4510 touch .foo && error "'touch .foo' worked after removing cwd"
4511 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4512 ls . > /dev/null && error "'ls .' worked after removing cwd"
4513 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4514 mkdir . && error "'mkdir .' worked after removing cwd"
4515 rmdir . && error "'rmdir .' worked after removing cwd"
4516 ln -s . foo && error "'ln -s .' worked after removing cwd"
4517 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4519 run_test 48b "Access removed working dir (should return errors)="
4521 test_48c() { # bug 2350
4522 #lctl set_param debug=-1
4525 test_mkdir -p $DIR/$tdir/dir
4527 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4528 $TRACE touch foo && error "touch foo worked after removing cwd"
4529 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4530 touch .foo && error "touch .foo worked after removing cwd"
4531 mkdir .foo && error "mkdir .foo worked after removing cwd"
4532 $TRACE ls . && error "'ls .' worked after removing cwd"
4533 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4534 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4535 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4536 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4537 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4539 run_test 48c "Access removed working subdir (should return errors)"
4541 test_48d() { # bug 2350
4542 #lctl set_param debug=-1
4545 test_mkdir -p $DIR/$tdir/dir
4547 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4548 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4549 $TRACE touch foo && error "'touch foo' worked after removing parent"
4550 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4551 touch .foo && error "'touch .foo' worked after removing parent"
4552 mkdir .foo && error "mkdir .foo worked after removing parent"
4553 $TRACE ls . && error "'ls .' worked after removing parent"
4554 $TRACE ls .. && error "'ls ..' worked after removing parent"
4555 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4556 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4557 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4560 run_test 48d "Access removed parent subdir (should return errors)"
4562 test_48e() { # bug 4134
4563 #lctl set_param debug=-1
4566 test_mkdir -p $DIR/$tdir/dir
4568 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4569 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4570 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4571 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4572 # On a buggy kernel addition of "touch foo" after cd .. will
4573 # produce kernel oops in lookup_hash_it
4574 touch ../foo && error "'cd ..' worked after recreate parent"
4576 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4578 run_test 48e "Access to recreated parent subdir (should return errors)"
4580 test_49() { # LU-1030
4581 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4582 remote_ost_nodsh && skip "remote OST with nodsh"
4584 # get ost1 size - lustre-OST0000
4585 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4587 # write 800M at maximum
4588 [[ $ost1_size -lt 2 ]] && ost1_size=2
4589 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4591 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4592 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4595 # change max_pages_per_rpc while writing the file
4596 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4597 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4598 # loop until dd process exits
4599 while ps ax -opid | grep -wq $dd_pid; do
4600 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4601 sleep $((RANDOM % 5 + 1))
4603 # restore original max_pages_per_rpc
4604 $LCTL set_param $osc1_mppc=$orig_mppc
4605 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4607 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4611 test_mkdir $DIR/$tdir
4613 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4615 run_test 50 "special situations: /proc symlinks ==============="
4617 test_51a() { # was test_51
4618 # bug 1516 - create an empty entry right after ".." then split dir
4619 test_mkdir -c1 $DIR/$tdir
4620 touch $DIR/$tdir/foo
4621 $MCREATE $DIR/$tdir/bar
4623 createmany -m $DIR/$tdir/longfile 201
4625 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4626 $MCREATE $DIR/$tdir/longfile$FNUM
4631 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4633 run_test 51a "special situations: split htree with empty entry =="
4635 cleanup_print_lfs_df () {
4642 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4644 local dir=$DIR/$tdir
4645 local nrdirs=$((65536 + 100))
4647 # cleanup the directory
4654 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4655 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4656 [[ $numfree -lt $nrdirs ]] &&
4657 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4659 # need to check free space for the directories as well
4660 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4661 numfree=$(( blkfree / $(fs_inode_ksize) ))
4662 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4664 trap cleanup_print_lfs_df EXIT
4667 createmany -d $dir/d $nrdirs || {
4668 unlinkmany $dir/d $nrdirs
4669 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4673 nrdirs=$(ls -U $dir | wc -l)
4675 # unlink all but 100 subdirectories, then check it still works
4677 local delete=$((nrdirs - left))
4682 # for ldiskfs the nlink count should be 1, but this is OSD specific
4683 # and so this is listed for informational purposes only
4684 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4685 unlinkmany -d $dir/d $delete ||
4686 error "unlink of first $delete subdirs failed"
4688 echo "nlink between: $(stat -c %h $dir)"
4689 local found=$(ls -U $dir | wc -l)
4690 [ $found -ne $left ] &&
4691 error "can't find subdirs: found only $found, expected $left"
4693 unlinkmany -d $dir/d $delete $left ||
4694 error "unlink of second $left subdirs failed"
4695 # regardless of whether the backing filesystem tracks nlink accurately
4696 # or not, the nlink count shouldn't be more than "." and ".." here
4697 local after=$(stat -c %h $dir)
4698 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4699 echo "nlink after: $after"
4701 cleanup_print_lfs_df
4703 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4706 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4707 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4709 test_mkdir $DIR/$tdir
4710 createmany -o $DIR/$tdir/t- 1000
4711 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4712 for N in $(seq 0 $((OSTCOUNT - 1))); do
4713 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4714 END { printf("%0.0f", objs) }' $TMP/$tfile)
4715 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4716 '($1 == '$N') { objs += 1 } \
4717 END { printf("%0.0f", objs) }')
4718 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4720 unlinkmany $DIR/$tdir/t- 1000
4723 for N in $(seq 1 $((OSTCOUNT - 1))); do
4724 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4725 error "OST $N has less objects vs OST $NLAST" \
4726 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4727 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4728 error "OST $N has less objects vs OST $NLAST" \
4729 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4731 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4732 error "OST $N has less #0 objects vs OST $NLAST" \
4733 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4734 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4735 error "OST $N has less #0 objects vs OST $NLAST" \
4736 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4741 run_test 51d "check object distribution"
4744 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4745 skip_env "ldiskfs only test"
4748 test_mkdir -c1 $DIR/$tdir
4749 test_mkdir -c1 $DIR/$tdir/d0
4751 touch $DIR/$tdir/d0/foo
4752 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4753 error "file exceed 65000 nlink limit!"
4754 unlinkmany $DIR/$tdir/d0/f- 65001
4757 run_test 51e "check file nlink limit"
4760 test_mkdir $DIR/$tdir
4763 local ulimit_old=$(ulimit -n)
4764 local spare=20 # number of spare fd's for scripts/libraries, etc.
4765 local mdt=$($LFS getstripe -m $DIR/$tdir)
4766 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4768 echo "MDT$mdt numfree=$numfree, max=$max"
4769 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4770 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4771 while ! ulimit -n $((numfree + spare)); do
4772 numfree=$((numfree * 3 / 4))
4774 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4776 echo "left ulimit at $ulimit_old"
4779 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4780 unlinkmany $DIR/$tdir/f $numfree
4781 error "create+open $numfree files in $DIR/$tdir failed"
4783 ulimit -n $ulimit_old
4785 # if createmany exits at 120s there will be fewer than $numfree files
4786 unlinkmany $DIR/$tdir/f $numfree || true
4788 run_test 51f "check many open files limit"
4791 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4792 test_mkdir $DIR/$tdir
4793 touch $DIR/$tdir/foo
4794 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4795 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4796 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4797 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4798 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4800 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4801 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4802 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4804 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4805 cp -r $DIR/$tdir $TMP/
4806 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4808 run_test 52a "append-only flag test (should return errors)"
4811 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4812 test_mkdir $DIR/$tdir
4813 touch $DIR/$tdir/foo
4814 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4815 cat test > $DIR/$tdir/foo && error "cat test worked"
4816 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4817 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4818 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4820 echo foo >> $DIR/$tdir/foo && error "echo worked"
4821 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4822 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4823 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4824 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4826 chattr -i $DIR/$tdir/foo || error "chattr failed"
4828 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4830 run_test 52b "immutable flag test (should return errors) ======="
4833 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4834 remote_mds_nodsh && skip "remote MDS with nodsh"
4835 remote_ost_nodsh && skip "remote OST with nodsh"
4848 local support_last_seq=true
4850 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
4851 support_last_seq=false
4854 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4856 for value in $(do_facet $SINGLEMDS \
4857 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
4858 param=$(echo ${value[0]} | cut -d "=" -f1)
4859 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4861 if $support_last_seq; then
4862 param_seq=$(echo $param |
4863 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4864 mds_last_seq=$(do_facet $SINGLEMDS \
4865 $LCTL get_param -n $param_seq)
4867 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4869 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4870 node=$(facet_active_host ost$((ostnum+1)))
4871 param="obdfilter.$ostname.last_id"
4872 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4873 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4874 ost_last_id=$ost_last
4876 if $support_last_seq; then
4877 ost_last_id=$(echo $ost_last |
4878 awk -F':' '{print $2}' |
4880 ost_last_seq=$(echo $ost_last |
4881 awk -F':' '{print $1}')
4882 [[ $ost_last_seq = $mds_last_seq ]] || continue
4885 if [[ $ost_last_id != $mds_last ]]; then
4886 error "$ost_last_id != $mds_last"
4893 $found || error "can not match last_seq/last_id for $mdtosc"
4896 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4899 perl -MSocket -e ';' || skip "no Socket perl module installed"
4901 $SOCKETSERVER $DIR/socket ||
4902 error "$SOCKETSERVER $DIR/socket failed: $?"
4903 $SOCKETCLIENT $DIR/socket ||
4904 error "$SOCKETCLIENT $DIR/socket failed: $?"
4905 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4907 run_test 54a "unix domain socket test =========================="
4913 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
4915 run_test 54b "char device works in lustre ======================"
4918 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4919 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4920 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4922 for i in $(seq 3 7); do
4923 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4932 loopdev="$DIR/loop54c"
4935 $UMOUNT $DIR/$tdir || rc=$?
4936 losetup -d $loopdev || true
4937 losetup -d $LOOPDEV || true
4938 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4945 loopdev="$DIR/loop54c"
4948 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
4949 trap cleanup_54c EXIT
4950 mknod $loopdev b 7 $LOOPNUM
4951 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4952 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
4953 losetup $loopdev $DIR/$tfile ||
4954 error "can't set up $loopdev for $DIR/$tfile"
4955 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4956 test_mkdir $DIR/$tdir
4957 mount -t ext2 $loopdev $DIR/$tdir ||
4958 error "error mounting $loopdev on $DIR/$tdir"
4959 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
4962 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
4966 run_test 54c "block device works in lustre ====================="
4972 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4974 run_test 54d "fifo device works in lustre ======================"
4979 cp -aL /dev/console $f
4980 echo $string > $f || error "echo $string to $f failed"
4982 run_test 54e "console/tty device works in lustre ======================"
4986 local dir=$DIR/$tdir
4989 test_mkdir -p $dir/dir
4990 for i in $(seq $numfiles); do
4992 touch $dir/dir/file$i
4995 local numcomp=$($LFS getstripe --component-count $dir)
4997 [[ $numcomp == 0 ]] && numcomp=1
4999 # test lfs getstripe with --recursive
5000 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5002 [[ $filenum -eq $((numfiles * 2)) ]] ||
5003 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5004 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5005 [[ $filenum -eq $numfiles ]] ||
5006 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5007 echo "$LFS getstripe showed obdidx or l_ost_idx"
5009 # test lfs getstripe with file instead of dir
5010 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5011 [[ $filenum -eq 1 ]] ||
5012 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5013 echo "$LFS getstripe file1 passed"
5015 #test lfs getstripe with --verbose
5016 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5017 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5018 error "$LFS getstripe --verbose $dir: "\
5019 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5020 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5021 error "$LFS getstripe $dir: showed lmm_magic"
5023 #test lfs getstripe with -v prints lmm_fid
5024 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5025 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5026 error "$LFS getstripe -v $dir: "\
5027 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5028 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5029 error "$LFS getstripe $dir: showed lmm_fid by default"
5030 echo "$LFS getstripe --verbose passed"
5032 #check for FID information
5033 local fid1=$($LFS getstripe --fid $dir/file1)
5034 local fid2=$($LFS getstripe --verbose $dir/file1 |
5035 awk '/lmm_fid: / { print $2; exit; }')
5036 local fid3=$($LFS path2fid $dir/file1)
5038 [ "$fid1" != "$fid2" ] &&
5039 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5040 [ "$fid1" != "$fid3" ] &&
5041 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5042 echo "$LFS getstripe --fid passed"
5044 #test lfs getstripe with --obd
5045 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5046 error "$LFS getstripe --obd wrong_uuid: should return error"
5048 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5051 local obduuid=$(ostuuid_from_index $ostidx)
5052 local found=$($LFS getstripe -r --obd $obduuid $dir |
5053 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5055 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5056 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5058 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5061 [[ $found -eq $filenum ]] ||
5062 error "$LFS getstripe --obd: found $found expect $filenum"
5063 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5064 sed '/^[ ]*'${ostidx}'[ ]/d' |
5065 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5066 error "$LFS getstripe --obd: should not show file on other obd"
5067 echo "$LFS getstripe --obd passed"
5069 run_test 56a "check $LFS getstripe"
5072 local dir=$DIR/$tdir
5076 for i in $(seq $numdirs); do
5077 test_mkdir $dir/dir$i
5080 # test lfs getdirstripe default mode is non-recursion, which is
5081 # different from lfs getstripe
5082 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5084 [[ $dircnt -eq 1 ]] ||
5085 error "$LFS getdirstripe: found $dircnt, not 1"
5086 dircnt=$($LFS getdirstripe --recursive $dir |
5087 grep -c lmv_stripe_count)
5088 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5089 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5091 run_test 56b "check $LFS getdirstripe"
5094 remote_ost_nodsh && skip "remote OST with nodsh"
5097 local ost_name=$(ostname_from_index $ost_idx)
5098 local old_status=$(ost_dev_status $ost_idx)
5100 [[ -z "$old_status" ]] ||
5101 skip_env "OST $ost_name is in $old_status status"
5103 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5104 [[ $OST1_VERSION -ge $(version_code 2.12.3) ]] && do_facet ost1 \
5105 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
5108 local new_status=$(ost_dev_status $ost_idx)
5110 [[ "$new_status" =~ "D" ]] ||
5111 error "$ost_name status is '$new_status', missing 'D'"
5112 if [[ $OST1_VERSION -ge $(version_code 2.12.3) ]]; then
5113 [[ "$new_status" =~ "N" ]] ||
5114 error "$ost_name status is '$new_status', missing 'N'"
5117 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5118 [[ $OST1_VERSION -ge $(version_code 2.12.3) ]] && do_facet ost1 \
5119 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
5122 new_status=$(ost_dev_status $ost_idx)
5123 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
5124 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
5126 run_test 56c "check 'lfs df' showing device status"
5131 local local_tdir="$1"
5132 local local_numfiles="$2"
5133 local local_numdirs="$3"
5134 local dir_params="$4"
5135 local dir_stripe_params="$5"
5137 if [ ! -d "$local_tdir" ] ; then
5138 test_mkdir -p $dir_stripe_params $local_tdir
5139 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5140 for i in $(seq $local_numfiles) ; do
5141 touch $local_tdir/file$i
5143 for i in $(seq $local_numdirs) ; do
5144 test_mkdir $dir_stripe_params $local_tdir/dir$i
5145 for j in $(seq $local_numfiles) ; do
5146 touch $local_tdir/dir$i/file$j
5152 setup_56_special() {
5154 local local_numfiles=$2
5155 local local_numdirs=$3
5157 setup_56 $local_tdir $local_numfiles $local_numdirs
5159 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5160 for i in $(seq $local_numfiles) ; do
5161 mknod $local_tdir/loop${i}b b 7 $i
5162 mknod $local_tdir/null${i}c c 1 3
5163 ln -s $local_tdir/file1 $local_tdir/link${i}
5165 for i in $(seq $local_numdirs) ; do
5166 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5167 mknod $local_tdir/dir$i/null${i}c c 1 3
5168 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5174 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5175 local expected=$(($NUMDIRS + 2))
5177 setup_56 $dir $NUMFILES $NUMDIRS
5179 # test lfs find with -name
5180 for i in $(seq $NUMFILES) ; do
5181 local nums=$($LFS find -name "*$i" $dir | wc -l)
5183 [ $nums -eq $expected ] ||
5184 error "lfs find -name '*$i' $dir wrong: "\
5185 "found $nums, expected $expected"
5188 run_test 56g "check lfs find -name"
5191 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5192 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5194 setup_56 $dir $NUMFILES $NUMDIRS
5196 # test lfs find with ! -name
5197 for i in $(seq $NUMFILES) ; do
5198 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5200 [ $nums -eq $expected ] ||
5201 error "lfs find ! -name '*$i' $dir wrong: "\
5202 "found $nums, expected $expected"
5205 run_test 56h "check lfs find ! -name"
5208 local dir=$DIR/$tdir
5212 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5215 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5217 run_test 56i "check 'lfs find -ost UUID' skips directories"
5220 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5222 setup_56_special $dir $NUMFILES $NUMDIRS
5224 local expected=$((NUMDIRS + 1))
5225 local cmd="$LFS find -type d $dir"
5226 local nums=$($cmd | wc -l)
5228 [ $nums -eq $expected ] ||
5229 error "'$cmd' wrong: found $nums, expected $expected"
5231 run_test 56j "check lfs find -type d"
5234 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5236 setup_56_special $dir $NUMFILES $NUMDIRS
5238 local expected=$(((NUMDIRS + 1) * NUMFILES))
5239 local cmd="$LFS find -type f $dir"
5240 local nums=$($cmd | wc -l)
5242 [ $nums -eq $expected ] ||
5243 error "'$cmd' wrong: found $nums, expected $expected"
5245 run_test 56k "check lfs find -type f"
5248 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5250 setup_56_special $dir $NUMFILES $NUMDIRS
5252 local expected=$((NUMDIRS + NUMFILES))
5253 local cmd="$LFS find -type b $dir"
5254 local nums=$($cmd | wc -l)
5256 [ $nums -eq $expected ] ||
5257 error "'$cmd' wrong: found $nums, expected $expected"
5259 run_test 56l "check lfs find -type b"
5262 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5264 setup_56_special $dir $NUMFILES $NUMDIRS
5266 local expected=$((NUMDIRS + NUMFILES))
5267 local cmd="$LFS find -type c $dir"
5268 local nums=$($cmd | wc -l)
5269 [ $nums -eq $expected ] ||
5270 error "'$cmd' wrong: found $nums, expected $expected"
5272 run_test 56m "check lfs find -type c"
5275 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5276 setup_56_special $dir $NUMFILES $NUMDIRS
5278 local expected=$((NUMDIRS + NUMFILES))
5279 local cmd="$LFS find -type l $dir"
5280 local nums=$($cmd | wc -l)
5282 [ $nums -eq $expected ] ||
5283 error "'$cmd' wrong: found $nums, expected $expected"
5285 run_test 56n "check lfs find -type l"
5288 local dir=$DIR/$tdir
5290 setup_56 $dir $NUMFILES $NUMDIRS
5291 utime $dir/file1 > /dev/null || error "utime (1)"
5292 utime $dir/file2 > /dev/null || error "utime (2)"
5293 utime $dir/dir1 > /dev/null || error "utime (3)"
5294 utime $dir/dir2 > /dev/null || error "utime (4)"
5295 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5296 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5299 local nums=$($LFS find -mtime +0 $dir | wc -l)
5301 [ $nums -eq $expected ] ||
5302 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5305 cmd="$LFS find -mtime 0 $dir"
5306 nums=$($cmd | wc -l)
5307 [ $nums -eq $expected ] ||
5308 error "'$cmd' wrong: found $nums, expected $expected"
5310 run_test 56o "check lfs find -mtime for old files"
5313 [ $RUNAS_ID -eq $UID ] &&
5314 skip_env "RUNAS_ID = UID = $UID -- skipping"
5316 local dir=$DIR/$tdir
5318 setup_56 $dir $NUMFILES $NUMDIRS
5319 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5321 local expected=$NUMFILES
5322 local cmd="$LFS find -uid $RUNAS_ID $dir"
5323 local nums=$($cmd | wc -l)
5325 [ $nums -eq $expected ] ||
5326 error "'$cmd' wrong: found $nums, expected $expected"
5328 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5329 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5330 nums=$($cmd | wc -l)
5331 [ $nums -eq $expected ] ||
5332 error "'$cmd' wrong: found $nums, expected $expected"
5334 run_test 56p "check lfs find -uid and ! -uid"
5337 [ $RUNAS_ID -eq $UID ] &&
5338 skip_env "RUNAS_ID = UID = $UID -- skipping"
5340 local dir=$DIR/$tdir
5342 setup_56 $dir $NUMFILES $NUMDIRS
5343 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5345 local expected=$NUMFILES
5346 local cmd="$LFS find -gid $RUNAS_GID $dir"
5347 local nums=$($cmd | wc -l)
5349 [ $nums -eq $expected ] ||
5350 error "'$cmd' wrong: found $nums, expected $expected"
5352 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5353 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5354 nums=$($cmd | wc -l)
5355 [ $nums -eq $expected ] ||
5356 error "'$cmd' wrong: found $nums, expected $expected"
5358 run_test 56q "check lfs find -gid and ! -gid"
5361 local dir=$DIR/$tdir
5363 setup_56 $dir $NUMFILES $NUMDIRS
5366 local cmd="$LFS find -size 0 -type f -lazy $dir"
5367 local nums=$($cmd | wc -l)
5369 [ $nums -eq $expected ] ||
5370 error "'$cmd' wrong: found $nums, expected $expected"
5371 cmd="$LFS find -size 0 -type f $dir"
5372 nums=$($cmd | wc -l)
5373 [ $nums -eq $expected ] ||
5374 error "'$cmd' wrong: found $nums, expected $expected"
5377 cmd="$LFS find ! -size 0 -type f -lazy $dir"
5378 nums=$($cmd | wc -l)
5379 [ $nums -eq $expected ] ||
5380 error "'$cmd' wrong: found $nums, expected $expected"
5381 cmd="$LFS find ! -size 0 -type f $dir"
5382 nums=$($cmd | wc -l)
5383 [ $nums -eq $expected ] ||
5384 error "'$cmd' wrong: found $nums, expected $expected"
5386 echo "test" > $dir/$tfile
5387 echo "test2" > $dir/$tfile.2 && sync
5389 cmd="$LFS find -size 5 -type f -lazy $dir"
5390 nums=$($cmd | wc -l)
5391 [ $nums -eq $expected ] ||
5392 error "'$cmd' wrong: found $nums, expected $expected"
5393 cmd="$LFS find -size 5 -type f $dir"
5394 nums=$($cmd | wc -l)
5395 [ $nums -eq $expected ] ||
5396 error "'$cmd' wrong: found $nums, expected $expected"
5399 cmd="$LFS find -size +5 -type f -lazy $dir"
5400 nums=$($cmd | wc -l)
5401 [ $nums -eq $expected ] ||
5402 error "'$cmd' wrong: found $nums, expected $expected"
5403 cmd="$LFS find -size +5 -type f $dir"
5404 nums=$($cmd | wc -l)
5405 [ $nums -eq $expected ] ||
5406 error "'$cmd' wrong: found $nums, expected $expected"
5409 cmd="$LFS find -size +0 -type f -lazy $dir"
5410 nums=$($cmd | wc -l)
5411 [ $nums -eq $expected ] ||
5412 error "'$cmd' wrong: found $nums, expected $expected"
5413 cmd="$LFS find -size +0 -type f $dir"
5414 nums=$($cmd | wc -l)
5415 [ $nums -eq $expected ] ||
5416 error "'$cmd' wrong: found $nums, expected $expected"
5419 cmd="$LFS find ! -size -5 -type f -lazy $dir"
5420 nums=$($cmd | wc -l)
5421 [ $nums -eq $expected ] ||
5422 error "'$cmd' wrong: found $nums, expected $expected"
5423 cmd="$LFS find ! -size -5 -type f $dir"
5424 nums=$($cmd | wc -l)
5425 [ $nums -eq $expected ] ||
5426 error "'$cmd' wrong: found $nums, expected $expected"
5429 cmd="$LFS find -size -5 -type f -lazy $dir"
5430 nums=$($cmd | wc -l)
5431 [ $nums -eq $expected ] ||
5432 error "'$cmd' wrong: found $nums, expected $expected"
5433 cmd="$LFS find -size -5 -type f $dir"
5434 nums=$($cmd | wc -l)
5435 [ $nums -eq $expected ] ||
5436 error "'$cmd' wrong: found $nums, expected $expected"
5438 run_test 56r "check lfs find -size works"
5445 cancel_lru_locks $OSC
5447 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5448 local nums=$($cmd | wc -l)
5450 [ $nums -eq $expected ] ||
5451 error "'$cmd' wrong: found $nums, expected $expected"
5453 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5455 if (( rpcs_before + glimpses != rpcs_after )); then
5456 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5457 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
5459 if [[ $glimpses == 0 ]]; then
5460 error "'$cmd' should not send glimpse RPCs to OST"
5462 error "'$cmd' should send $glimpses glimpse RPCs to OST"
5468 [[ $MDS1_VERSION -ge $(version_code 2.12.4) ]] ||
5469 skip "MDS < 2.12.4 doesn't return LSOM data"
5470 local dir=$DIR/$tdir
5472 [[ $OSC == "mdc" ]] && skip "DoM files"
5474 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5475 # open and close all files to ensure LSOM is updated
5476 cancel_lru_locks $OSC
5477 find $dir -type f | xargs cat > /dev/null
5479 # expect_found glimpse_rpcs command_to_run
5480 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
5481 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
5482 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
5483 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
5485 echo "test" > $dir/$tfile
5486 echo "test2" > $dir/$tfile.2 && sync
5487 cancel_lru_locks $OSC
5488 cat $dir/$tfile $dir/$tfile.2 > /dev/null
5490 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
5491 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
5492 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
5493 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
5495 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
5496 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
5497 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
5498 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
5499 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
5500 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
5502 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
5504 test_56s() { # LU-611 #LU-9369
5505 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5507 local dir=$DIR/$tdir
5508 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5510 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5511 for i in $(seq $NUMDIRS); do
5512 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5515 local expected=$NUMDIRS
5516 local cmd="$LFS find -c $OSTCOUNT $dir"
5517 local nums=$($cmd | wc -l)
5519 [ $nums -eq $expected ] || {
5520 $LFS getstripe -R $dir
5521 error "'$cmd' wrong: found $nums, expected $expected"
5524 expected=$((NUMDIRS + onestripe))
5525 cmd="$LFS find -stripe-count +0 -type f $dir"
5526 nums=$($cmd | wc -l)
5527 [ $nums -eq $expected ] || {
5528 $LFS getstripe -R $dir
5529 error "'$cmd' wrong: found $nums, expected $expected"
5533 cmd="$LFS find -stripe-count 1 -type f $dir"
5534 nums=$($cmd | wc -l)
5535 [ $nums -eq $expected ] || {
5536 $LFS getstripe -R $dir
5537 error "'$cmd' wrong: found $nums, expected $expected"
5540 cmd="$LFS find -stripe-count -2 -type f $dir"
5541 nums=$($cmd | wc -l)
5542 [ $nums -eq $expected ] || {
5543 $LFS getstripe -R $dir
5544 error "'$cmd' wrong: found $nums, expected $expected"
5548 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5549 nums=$($cmd | wc -l)
5550 [ $nums -eq $expected ] || {
5551 $LFS getstripe -R $dir
5552 error "'$cmd' wrong: found $nums, expected $expected"
5555 run_test 56s "check lfs find -stripe-count works"
5557 test_56t() { # LU-611 #LU-9369
5558 local dir=$DIR/$tdir
5560 setup_56 $dir 0 $NUMDIRS
5561 for i in $(seq $NUMDIRS); do
5562 $LFS setstripe -S 8M $dir/dir$i/$tfile
5565 local expected=$NUMDIRS
5566 local cmd="$LFS find -S 8M $dir"
5567 local nums=$($cmd | wc -l)
5569 [ $nums -eq $expected ] || {
5570 $LFS getstripe -R $dir
5571 error "'$cmd' wrong: found $nums, expected $expected"
5575 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5577 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5579 expected=$(((NUMDIRS + 1) * NUMFILES))
5580 cmd="$LFS find -stripe-size 512k -type f $dir"
5581 nums=$($cmd | wc -l)
5582 [ $nums -eq $expected ] ||
5583 error "'$cmd' wrong: found $nums, expected $expected"
5585 cmd="$LFS find -stripe-size +320k -type f $dir"
5586 nums=$($cmd | wc -l)
5587 [ $nums -eq $expected ] ||
5588 error "'$cmd' wrong: found $nums, expected $expected"
5590 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5591 cmd="$LFS find -stripe-size +200k -type f $dir"
5592 nums=$($cmd | wc -l)
5593 [ $nums -eq $expected ] ||
5594 error "'$cmd' wrong: found $nums, expected $expected"
5596 cmd="$LFS find -stripe-size -640k -type f $dir"
5597 nums=$($cmd | wc -l)
5598 [ $nums -eq $expected ] ||
5599 error "'$cmd' wrong: found $nums, expected $expected"
5602 cmd="$LFS find -stripe-size 256k -type f $dir"
5603 nums=$($cmd | wc -l)
5604 [ $nums -eq $expected ] ||
5605 error "'$cmd' wrong: found $nums, expected $expected"
5607 cmd="$LFS find -stripe-size -320k -type f $dir"
5608 nums=$($cmd | wc -l)
5609 [ $nums -eq $expected ] ||
5610 error "'$cmd' wrong: found $nums, expected $expected"
5613 cmd="$LFS find -stripe-size 1024k -type f $dir"
5614 nums=$($cmd | wc -l)
5615 [ $nums -eq $expected ] ||
5616 error "'$cmd' wrong: found $nums, expected $expected"
5618 run_test 56t "check lfs find -stripe-size works"
5620 test_56u() { # LU-611
5621 local dir=$DIR/$tdir
5623 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5625 if [[ $OSTCOUNT -gt 1 ]]; then
5626 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5632 local expected=$(((NUMDIRS + 1) * NUMFILES))
5633 local cmd="$LFS find -stripe-index 0 -type f $dir"
5634 local nums=$($cmd | wc -l)
5636 [ $nums -eq $expected ] ||
5637 error "'$cmd' wrong: found $nums, expected $expected"
5640 cmd="$LFS find -stripe-index 1 -type f $dir"
5641 nums=$($cmd | wc -l)
5642 [ $nums -eq $expected ] ||
5643 error "'$cmd' wrong: found $nums, expected $expected"
5645 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5646 nums=$($cmd | wc -l)
5647 [ $nums -eq $expected ] ||
5648 error "'$cmd' wrong: found $nums, expected $expected"
5651 # This should produce an error and not return any files
5652 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5653 nums=$($cmd 2>/dev/null | wc -l)
5654 [ $nums -eq $expected ] ||
5655 error "'$cmd' wrong: found $nums, expected $expected"
5657 if [[ $OSTCOUNT -gt 1 ]]; then
5658 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5659 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5660 nums=$($cmd | wc -l)
5661 [ $nums -eq $expected ] ||
5662 error "'$cmd' wrong: found $nums, expected $expected"
5665 run_test 56u "check lfs find -stripe-index works"
5669 local dir=$DIR/$tdir
5671 setup_56 $dir $NUMFILES $NUMDIRS
5673 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5674 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5676 for file in $($LFS find -m $UUID $dir); do
5677 file_midx=$($LFS getstripe -m $file)
5678 [ $file_midx -eq $mdt_idx ] ||
5679 error "lfs find -m $UUID != getstripe -m $file_midx"
5682 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5685 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5686 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5688 local dir=$DIR/$tdir
5690 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5692 local stripe_size=$($LFS getstripe -S -d $dir) ||
5693 error "$LFS getstripe -S -d $dir failed"
5694 stripe_size=${stripe_size%% *}
5696 local file_size=$((stripe_size * OSTCOUNT))
5697 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5698 local required_space=$((file_num * file_size))
5699 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5701 [[ $free_space -le $((required_space / 1024)) ]] &&
5702 skip_env "need $required_space, have $free_space kbytes"
5705 local dd_count=$((file_size / dd_bs))
5707 # write data into the files
5712 for i in $(seq $NUMFILES); do
5714 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5715 error "write data into $file failed"
5717 for i in $(seq $NUMDIRS); do
5718 for j in $(seq $NUMFILES); do
5719 file=$dir/dir$i/file$j
5720 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5721 error "write data into $file failed"
5725 # $LFS_MIGRATE will fail if hard link migration is unsupported
5726 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5727 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5728 error "creating links to $dir/dir1/file1 failed"
5733 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5736 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5739 eval $cmd || error "$cmd failed"
5741 check_stripe_count $dir/file1 $expected
5743 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
5745 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5746 # OST 1 if it is on OST 0. This file is small enough to
5747 # be on only one stripe.
5748 file=$dir/migr_1_ost
5749 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5750 error "write data into $file failed"
5751 local obdidx=$($LFS getstripe -i $file)
5752 local oldmd5=$(md5sum $file)
5755 [[ $obdidx -eq 0 ]] && newobdidx=1
5756 cmd="$LFS migrate -i $newobdidx $file"
5758 eval $cmd || error "$cmd failed"
5760 local realobdix=$($LFS getstripe -i $file)
5761 local newmd5=$(md5sum $file)
5763 [[ $newobdidx -ne $realobdix ]] &&
5764 error "new OST is different (was=$obdidx, "\
5765 "wanted=$newobdidx, got=$realobdix)"
5766 [[ "$oldmd5" != "$newmd5" ]] &&
5767 error "md5sum differ: $oldmd5, $newmd5"
5771 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5773 eval $cmd || error "$cmd failed"
5775 for j in $(seq $NUMFILES); do
5776 check_stripe_count $dir/dir1/file$j $expected
5779 # lfs_migrate works with lfs find
5780 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5781 $LFS_MIGRATE -y -c $expected"
5783 eval $cmd || error "$cmd failed"
5785 for i in $(seq 2 $NUMFILES); do
5786 check_stripe_count $dir/file$i $expected
5788 for i in $(seq 2 $NUMDIRS); do
5789 for j in $(seq $NUMFILES); do
5790 check_stripe_count $dir/dir$i/file$j $expected
5794 run_test 56w "check lfs_migrate -c stripe_count works"
5797 local file1=$DIR/$tdir/file1
5798 local create_pool=false
5799 local initial_pool=$($LFS getstripe -p $DIR)
5803 echo -n "Creating test dir..."
5804 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5807 echo -n "Creating test file..."
5808 touch $file1 || error "cannot create file"
5811 echo -n "Detecting existing pools..."
5812 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5814 if [ ${#pool_list[@]} -gt 0 ]; then
5815 echo "${pool_list[@]}"
5816 for thispool in "${pool_list[@]}"; do
5817 if [[ -z "$initial_pool" ||
5818 "$initial_pool" != "$thispool" ]]; then
5820 echo "Using existing pool '$pool'"
5825 echo "none detected."
5827 if [ -z "$pool" ]; then
5828 pool=${POOL:-testpool}
5829 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5830 echo -n "Creating pool '$pool'..."
5832 pool_add $pool &> /dev/null ||
5833 error "pool_add failed"
5836 echo -n "Adding target to pool..."
5837 pool_add_targets $pool 0 0 1 &> /dev/null ||
5838 error "pool_add_targets failed"
5842 echo -n "Setting pool using -p option..."
5843 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5844 error "migrate failed rc = $?"
5847 echo -n "Verifying test file is in pool after migrating..."
5848 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5849 error "file was not migrated to pool $pool"
5852 echo -n "Removing test file from pool '$pool'..."
5853 # "lfs migrate $file" won't remove the file from the pool
5854 # until some striping information is changed.
5855 $LFS migrate -c 1 $file1 &> /dev/null ||
5856 error "cannot remove from pool"
5857 [ "$($LFS getstripe -p $file1)" ] &&
5858 error "pool still set"
5861 echo -n "Setting pool using --pool option..."
5862 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5863 error "migrate failed rc = $?"
5868 if $create_pool; then
5869 destroy_test_pools 2> /dev/null ||
5870 error "destroy test pools failed"
5873 run_test 56wb "check lfs_migrate pool support"
5876 local file1="$DIR/$tdir/file1"
5883 echo -n "Creating test dir..."
5884 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5885 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5886 error "cannot set stripe by '-S 1M -c 1'"
5889 echo -n "Setting initial stripe for test file..."
5890 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5891 error "cannot set stripe"
5892 cur_ssize=$($LFS getstripe -S "$file1")
5893 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
5896 # File currently set to -S 512K -c 1
5898 # Ensure -c and -S options are rejected when -R is set
5899 echo -n "Verifying incompatible options are detected..."
5900 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5901 error "incompatible -c and -R options not detected"
5902 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5903 error "incompatible -S and -R options not detected"
5906 # Ensure unrecognized options are passed through to 'lfs migrate'
5907 echo -n "Verifying -S option is passed through to lfs migrate..."
5908 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5909 error "migration failed"
5910 cur_ssize=$($LFS getstripe -S "$file1")
5911 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
5914 # File currently set to -S 1M -c 1
5916 # Ensure long options are supported
5917 echo -n "Verifying long options supported..."
5918 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5919 error "long option without argument not supported"
5920 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5921 error "long option with argument not supported"
5922 cur_ssize=$($LFS getstripe -S "$file1")
5923 [ $cur_ssize -eq 524288 ] ||
5924 error "migrate --stripe-size $cur_ssize != 524288"
5927 # File currently set to -S 512K -c 1
5929 if [ "$OSTCOUNT" -gt 1 ]; then
5930 echo -n "Verifying explicit stripe count can be set..."
5931 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5932 error "migrate failed"
5933 cur_scount=$($LFS getstripe -c "$file1")
5934 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
5938 # File currently set to -S 512K -c 1 or -S 512K -c 2
5940 # Ensure parent striping is used if -R is set, and no stripe
5941 # count or size is specified
5942 echo -n "Setting stripe for parent directory..."
5943 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5944 error "cannot set stripe '-S 2M -c 1'"
5947 echo -n "Verifying restripe option uses parent stripe settings..."
5948 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5949 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
5950 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5951 error "migrate failed"
5952 cur_ssize=$($LFS getstripe -S "$file1")
5953 [ $cur_ssize -eq $parent_ssize ] ||
5954 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
5955 cur_scount=$($LFS getstripe -c "$file1")
5956 [ $cur_scount -eq $parent_scount ] ||
5957 error "migrate -R stripe_count $cur_scount != $parent_scount"
5960 # File currently set to -S 1M -c 1
5962 # Ensure striping is preserved if -R is not set, and no stripe
5963 # count or size is specified
5964 echo -n "Verifying striping size preserved when not specified..."
5965 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
5966 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5967 error "cannot set stripe on parent directory"
5968 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5969 error "migrate failed"
5970 cur_ssize=$($LFS getstripe -S "$file1")
5971 [ $cur_ssize -eq $orig_ssize ] ||
5972 error "migrate by default $cur_ssize != $orig_ssize"
5975 # Ensure file name properly detected when final option has no argument
5976 echo -n "Verifying file name properly detected..."
5977 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5978 error "file name interpreted as option argument"
5984 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5987 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5989 local file1=$DIR/$tdir/file1
5991 echo -n "Creating test dir..."
5992 test_mkdir $DIR/$tdir || error "cannot create dir"
5995 echo -n "Creating test file..."
5999 # Ensure 'lfs migrate' will fail by using a non-existent option,
6000 # and make sure rsync is not called to recover
6001 echo -n "Make sure --no-rsync option works..."
6002 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
6003 grep -q 'refusing to fall back to rsync' ||
6004 error "rsync was called with --no-rsync set"
6007 # Ensure rsync is called without trying 'lfs migrate' first
6008 echo -n "Make sure --rsync option works..."
6009 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
6010 grep -q 'falling back to rsync' &&
6011 error "lfs migrate was called with --rsync set"
6014 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6015 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6016 grep -q 'at the same time' ||
6017 error "--rsync and --no-rsync accepted concurrently"
6023 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6026 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6027 check_swap_layouts_support
6029 local dir=$DIR/$tdir
6030 local ref1=/etc/passwd
6031 local file1=$dir/file1
6033 test_mkdir $dir || error "creating dir $dir"
6034 $LFS setstripe -c 2 $file1
6036 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6037 stripe=$($LFS getstripe -c $file1)
6038 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6039 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6044 run_test 56x "lfs migration support"
6047 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6048 check_swap_layouts_support
6050 local dir=$DIR/$tdir/$testnum
6054 local ref1=/etc/passwd
6055 local file1=$dir/file1
6057 $LFS setstripe -c 2 $file1
6059 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6061 local stripe=$($LFS getstripe -c $file1)
6063 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6064 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6069 run_test 56xa "lfs migration --block support"
6071 check_migrate_links() {
6073 local file1="$dir/file1"
6076 local total_count=$(($begin + $count - 1))
6077 local symlink_count=10
6080 if [ ! -f "$file1" ]; then
6081 echo -n "creating initial file..."
6082 $LFS setstripe -c 1 -S "512k" "$file1" ||
6083 error "cannot setstripe initial file"
6086 echo -n "creating symlinks..."
6087 for s in $(seq 1 $symlink_count); do
6088 ln -s "$file1" "$dir/slink$s" ||
6089 error "cannot create symlinks"
6093 echo -n "creating nonlinked files..."
6094 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6095 error "cannot create nonlinked files"
6100 if [ ! -f "$dir/file$total_count" ]; then
6101 echo -n "creating hard links $begin:$total_count..."
6102 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6103 /dev/null || error "cannot create hard links"
6107 echo -n "checking number of hard links listed in xattrs..."
6108 local fid=$($LFS getstripe -F "$file1")
6109 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6112 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6113 skip "hard link list has unexpected size, skipping test"
6115 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6116 error "link names should exceed xattrs size"
6119 echo -n "migrating files..."
6120 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
6122 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6125 # make sure all links have been properly migrated
6126 echo -n "verifying files..."
6127 fid=$($LFS getstripe -F "$file1") ||
6128 error "cannot get fid for file $file1"
6129 for i in $(seq 2 $total_count); do
6130 local fid2=$($LFS getstripe -F $dir/file$i)
6132 [ "$fid2" == "$fid" ] ||
6133 error "migrated hard link has mismatched FID"
6136 # make sure hard links were properly detected, and migration was
6137 # performed only once for the entire link set; nonlinked files should
6139 local actual=$(grep -c 'done' <<< "$migrate_out")
6140 local expected=$(($uniq_count + 1))
6142 [ "$actual" -eq "$expected" ] ||
6143 error "hard links individually migrated ($actual != $expected)"
6145 # make sure the correct number of hard links are present
6146 local hardlinks=$(stat -c '%h' "$file1")
6148 [ $hardlinks -eq $total_count ] ||
6149 error "num hard links $hardlinks != $total_count"
6156 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6157 skip "Need MDS version at least 2.10.55"
6159 local dir="$DIR/$tdir"
6161 test_mkdir "$dir" || error "cannot create dir $dir"
6163 echo "testing lfs migrate mode when all links fit within xattrs"
6164 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6166 echo "testing rsync mode when all links fit within xattrs"
6167 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6169 echo "testing lfs migrate mode when all links do not fit within xattrs"
6170 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6172 echo "testing rsync mode when all links do not fit within xattrs"
6173 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6179 run_test 56xb "lfs migration hard link support"
6182 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6184 local dir="$DIR/$tdir"
6186 test_mkdir "$dir" || error "cannot create dir $dir"
6188 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6189 echo -n "Setting initial stripe for 20MB test file..."
6190 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6191 error "cannot setstripe 20MB file"
6193 echo -n "Sizing 20MB test file..."
6194 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6196 echo -n "Verifying small file autostripe count is 1..."
6197 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6198 error "cannot migrate 20MB file"
6199 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6200 error "cannot get stripe for $dir/20mb"
6201 [ $stripe_count -eq 1 ] ||
6202 error "unexpected stripe count $stripe_count for 20MB file"
6206 # Test 2: File is small enough to fit within the available space on
6207 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6208 # have at least an additional 1KB for each desired stripe for test 3
6209 echo -n "Setting stripe for 1GB test file..."
6210 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
6212 echo -n "Sizing 1GB test file..."
6213 # File size is 1GB + 3KB
6214 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
6217 # need at least 512MB per OST for 1GB file to fit in 2 stripes
6218 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
6219 if (( avail > 524288 * OSTCOUNT )); then
6220 echo -n "Migrating 1GB file..."
6221 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
6222 error "cannot migrate 1GB file"
6224 echo -n "Verifying autostripe count is sqrt(n) + 1..."
6225 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
6226 error "cannot getstripe for 1GB file"
6227 [ $stripe_count -eq 2 ] ||
6228 error "unexpected stripe count $stripe_count != 2"
6232 # Test 3: File is too large to fit within the available space on
6233 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
6234 if [ $OSTCOUNT -ge 3 ]; then
6235 # The required available space is calculated as
6236 # file size (1GB + 3KB) / OST count (3).
6237 local kb_per_ost=349526
6239 echo -n "Migrating 1GB file with limit..."
6240 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
6241 error "cannot migrate 1GB file with limit"
6244 stripe_count=$($LFS getstripe -c "$dir/1gb")
6245 echo -n "Verifying 1GB autostripe count with limited space..."
6246 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
6247 error "unexpected stripe count $stripe_count (min 3)"
6254 run_test 56xc "lfs migration autostripe"
6257 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6259 local dir=$DIR/$tdir
6260 local f_mgrt=$dir/$tfile.mgrt
6261 local f_yaml=$dir/$tfile.yaml
6262 local f_copy=$dir/$tfile.copy
6263 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6264 local layout_copy="-c 2 -S 2M -i 1"
6265 local yamlfile=$dir/yamlfile
6266 local layout_before;
6269 test_mkdir "$dir" || error "cannot create dir $dir"
6270 $LFS setstripe $layout_yaml $f_yaml ||
6271 error "cannot setstripe $f_yaml with layout $layout_yaml"
6272 $LFS getstripe --yaml $f_yaml > $yamlfile
6273 $LFS setstripe $layout_copy $f_copy ||
6274 error "cannot setstripe $f_copy with layout $layout_copy"
6276 dd if=/dev/zero of=$f_mgrt bs=1M count=4
6278 # 1. test option --yaml
6279 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
6280 error "cannot migrate $f_mgrt with --yaml $yamlfile"
6281 layout_before=$(get_layout_param $f_yaml)
6282 layout_after=$(get_layout_param $f_mgrt)
6283 [ "$layout_after" == "$layout_before" ] ||
6284 error "lfs_migrate --yaml: $layout_after != $layout_before"
6286 # 2. test option --copy
6287 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
6288 error "cannot migrate $f_mgrt with --copy $f_copy"
6289 layout_before=$(get_layout_param $f_copy)
6290 layout_after=$(get_layout_param $f_mgrt)
6291 [ "$layout_after" == "$layout_before" ] ||
6292 error "lfs_migrate --copy: $layout_after != $layout_before"
6294 run_test 56xd "check lfs_migrate --yaml and --copy support"
6297 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6299 local dir=$DIR/$tdir
6300 local f_comp=$dir/$tfile
6301 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6302 local layout_before=""
6303 local layout_after=""
6305 test_mkdir "$dir" || error "cannot create dir $dir"
6306 $LFS setstripe $layout $f_comp ||
6307 error "cannot setstripe $f_comp with layout $layout"
6308 layout_before=$(get_layout_param $f_comp)
6309 dd if=/dev/zero of=$f_comp bs=1M count=4
6311 # 1. migrate a comp layout file by lfs_migrate
6312 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
6313 layout_after=$(get_layout_param $f_comp)
6314 [ "$layout_before" == "$layout_after" ] ||
6315 error "lfs_migrate: $layout_before != $layout_after"
6317 # 2. migrate a comp layout file by lfs migrate
6318 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
6319 layout_after=$(get_layout_param $f_comp)
6320 [ "$layout_before" == "$layout_after" ] ||
6321 error "lfs migrate: $layout_before != $layout_after"
6323 run_test 56xe "migrate a composite layout file"
6326 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
6327 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
6330 local dir=$DIR/$tdir
6334 test_mkdir -p $dir || error "creating dir $dir"
6335 touch $f1 || error "creating std file $f1"
6336 $MULTIOP $f2 H2c || error "creating released file $f2"
6338 # a directory can be raid0, so ask only for files
6339 res=$($LFS find $dir -L raid0 -type f | wc -l)
6340 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
6342 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
6343 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
6345 # only files can be released, so no need to force file search
6346 res=$($LFS find $dir -L released)
6347 [[ $res == $f2 ]] || error "search released: found $res != $f2"
6349 res=$($LFS find $dir -type f \! -L released)
6350 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
6352 run_test 56y "lfs find -L raid0|released"
6354 test_56z() { # LU-4824
6355 # This checks to make sure 'lfs find' continues after errors
6356 # There are two classes of errors that should be caught:
6357 # - If multiple paths are provided, all should be searched even if one
6359 # - If errors are encountered during the search, it should not terminate
6361 local dir=$DIR/$tdir
6365 for i in d{0..9}; do
6367 touch $dir/$i/$tfile
6369 $LFS find $DIR/non_existent_dir $dir &&
6370 error "$LFS find did not return an error"
6371 # Make a directory unsearchable. This should NOT be the last entry in
6372 # directory order. Arbitrarily pick the 6th entry
6373 chmod 700 $($LFS find $dir -type d | sed '6!d')
6375 $RUNAS $LFS find $DIR/non_existent $dir
6376 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
6378 # The user should be able to see 10 directories and 9 files
6379 (( count == 19 )) ||
6380 error "$LFS find found $count != 19 entries after error"
6382 run_test 56z "lfs find should continue after an error"
6384 test_56aa() { # LU-5937
6385 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
6387 local dir=$DIR/$tdir
6390 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
6392 createmany -o $dir/striped_dir/${tfile}- 1024
6393 local dirs=$($LFS find --size +8k $dir/)
6395 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
6397 run_test 56aa "lfs find --size under striped dir"
6399 test_56ab() { # LU-10705
6400 test_mkdir $DIR/$tdir
6401 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
6402 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
6403 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
6404 # Flush writes to ensure valid blocks. Need to be more thorough for
6405 # ZFS, since blocks are not allocated/returned to client immediately.
6407 wait_zfs_commit ost1 2
6408 cancel_lru_locks osc
6411 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
6413 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
6415 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
6416 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
6418 rm -f $DIR/$tdir/$tfile.[123]
6420 run_test 56ab "lfs find --blocks"
6423 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
6424 skip "Need MDS version at least 2.10.50"
6426 # Create composite files with one component
6427 local dir=$DIR/$tdir
6429 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
6430 # Create composite files with three components
6431 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
6432 # Create non-composite files
6433 createmany -o $dir/${tfile}- 10
6435 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
6437 [[ $nfiles == 10 ]] ||
6438 error "lfs find -E 1M found $nfiles != 10 files"
6440 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
6441 [[ $nfiles == 25 ]] ||
6442 error "lfs find ! -E 1M found $nfiles != 25 files"
6444 # All files have a component that starts at 0
6445 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
6446 [[ $nfiles == 35 ]] ||
6447 error "lfs find --component-start 0 - $nfiles != 35 files"
6449 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
6450 [[ $nfiles == 15 ]] ||
6451 error "lfs find --component-start 2M - $nfiles != 15 files"
6453 # All files created here have a componenet that does not starts at 2M
6454 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
6455 [[ $nfiles == 35 ]] ||
6456 error "lfs find ! --component-start 2M - $nfiles != 35 files"
6458 # Find files with a specified number of components
6459 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
6460 [[ $nfiles == 15 ]] ||
6461 error "lfs find --component-count 3 - $nfiles != 15 files"
6463 # Remember non-composite files have a component count of zero
6464 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
6465 [[ $nfiles == 10 ]] ||
6466 error "lfs find --component-count 0 - $nfiles != 10 files"
6468 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
6469 [[ $nfiles == 20 ]] ||
6470 error "lfs find ! --component-count 3 - $nfiles != 20 files"
6472 # All files have a flag called "init"
6473 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
6474 [[ $nfiles == 35 ]] ||
6475 error "lfs find --component-flags init - $nfiles != 35 files"
6477 # Multi-component files will have a component not initialized
6478 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
6479 [[ $nfiles == 15 ]] ||
6480 error "lfs find !--component-flags init - $nfiles != 15 files"
6485 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
6488 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
6489 skip "Need MDS version at least 2.10.57"
6499 # create mirrored directories and mirrored files
6500 mkdir $td || error "mkdir $td failed"
6501 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
6502 createmany -o $tf- 10 || error "create $tf- failed"
6504 for i in $(seq 2); do
6506 mkdir $dir || error "mkdir $dir failed"
6507 $LFS mirror create -N$((3 + i)) $dir ||
6508 error "create mirrored dir $dir failed"
6509 createmany -o $dir/$tfile- 10 ||
6510 error "create $dir/$tfile- failed"
6513 # change the states of some mirrored files
6515 for i in $(seq 2); do
6517 for j in $(seq 4 9); do
6518 echo foo > $dir/$tfile-$j
6522 # find mirrored files with specific mirror count
6523 cmd="$LFS find --mirror-count 3 --type f $td"
6524 nfiles=$($cmd | wc -l)
6525 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
6527 cmd="$LFS find ! --mirror-count 3 --type f $td"
6528 nfiles=$($cmd | wc -l)
6529 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
6531 cmd="$LFS find --mirror-count +2 --type f $td"
6532 nfiles=$($cmd | wc -l)
6533 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6535 cmd="$LFS find --mirror-count -6 --type f $td"
6536 nfiles=$($cmd | wc -l)
6537 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6539 # find mirrored files with specific file state
6540 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
6541 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
6543 cmd="$LFS find --mirror-state=ro --type f $td"
6544 nfiles=$($cmd | wc -l)
6545 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6547 cmd="$LFS find ! --mirror-state=ro --type f $td"
6548 nfiles=$($cmd | wc -l)
6549 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6551 cmd="$LFS find --mirror-state=wp --type f $td"
6552 nfiles=$($cmd | wc -l)
6553 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6555 cmd="$LFS find ! --mirror-state=sp --type f $td"
6556 nfiles=$($cmd | wc -l)
6557 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6559 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6563 # note test will not do anything if MDS is not local
6564 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6565 skip_env "ldiskfs only test"
6567 remote_mds_nodsh && skip "remote MDS with nodsh"
6569 local MNTDEV="osd*.*MDT*.mntdev"
6570 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6571 [ -z "$DEV" ] && error "can't access $MNTDEV"
6572 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6573 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6574 error "can't access $DEV"
6575 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6576 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6580 run_test 57a "verify MDS filesystem created with large inodes =="
6583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6584 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6585 skip_env "ldiskfs only test"
6587 remote_mds_nodsh && skip "remote MDS with nodsh"
6589 local dir=$DIR/$tdir
6592 local fileN=$dir/f$filecount
6594 rm -rf $dir || error "removing $dir"
6596 local mdtidx=$($LFS getstripe -m $dir)
6597 local mdtname=MDT$(printf %04x $mdtidx)
6598 local facet=mds$((mdtidx + 1))
6600 echo "mcreating $filecount files"
6601 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6603 # verify that files do not have EAs yet
6604 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6605 error "$file1 has an EA"
6606 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6607 error "$fileN has an EA"
6611 df $dir #make sure we get new statfs data
6612 local mdsfree=$(do_facet $facet \
6613 lctl get_param -n osd*.*$mdtname.kbytesfree)
6614 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6617 echo "opening files to create objects/EAs"
6618 for file in $(seq -f $dir/f%g 1 $filecount); do
6619 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6620 error "opening $file"
6623 # verify that files have EAs now
6624 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6625 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6627 sleep 1 #make sure we get new statfs data
6629 local mdsfree2=$(do_facet $facet \
6630 lctl get_param -n osd*.*$mdtname.kbytesfree)
6631 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6633 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6634 if [ "$mdsfree" != "$mdsfree2" ]; then
6635 error "MDC before $mdcfree != after $mdcfree2"
6637 echo "MDC before $mdcfree != after $mdcfree2"
6638 echo "unable to confirm if MDS has large inodes"
6643 run_test 57b "default LOV EAs are stored inside large inodes ==="
6646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6647 [ -z "$(which wiretest 2>/dev/null)" ] &&
6648 skip_env "could not find wiretest"
6652 run_test 58 "verify cross-platform wire constants =============="
6655 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6657 echo "touch 130 files"
6658 createmany -o $DIR/f59- 130
6660 unlinkmany $DIR/f59- 130
6662 # wait for commitment of removal
6663 wait_delete_completed
6665 run_test 59 "verify cancellation of llog records async ========="
6667 TEST60_HEAD="test_60 run $RANDOM"
6669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6670 remote_mgs_nodsh && skip "remote MGS with nodsh"
6671 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6672 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6673 skip_env "missing subtest run-llog.sh"
6675 log "$TEST60_HEAD - from kernel mode"
6676 do_facet mgs "$LCTL dk > /dev/null"
6677 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6678 do_facet mgs $LCTL dk > $TMP/$tfile
6680 # LU-6388: test llog_reader
6681 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6682 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6683 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6684 skip_env "missing llog_reader"
6685 local fstype=$(facet_fstype mgs)
6686 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6687 skip_env "Only for ldiskfs or zfs type mgs"
6689 local mntpt=$(facet_mntpt mgs)
6690 local mgsdev=$(mgsdevname 1)
6702 #get fid and record list
6703 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6705 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6707 #remount mgs as ldiskfs or zfs type
6708 stop mgs || error "stop mgs failed"
6709 mount_fstype mgs || error "remount mgs failed"
6710 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6713 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6714 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6719 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6721 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6723 echo "obj_file is $obj_file"
6724 do_facet mgs $llog_reader $obj_file
6726 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6727 awk '{ print $3 }' | sed -e "s/^type=//g")
6728 if [ $rec_type != $rec ]; then
6729 echo "FAILED test_60a wrong record type $rec_type," \
6735 #check obj path if record type is LLOG_LOGID_MAGIC
6736 if [ "$rec" == "1064553b" ]; then
6737 path=$(do_facet mgs $llog_reader $obj_file |
6738 grep "path=" | awk '{ print $NF }' |
6739 sed -e "s/^path=//g")
6740 if [ $obj_file != $mntpt/$path ]; then
6741 echo "FAILED test_60a wrong obj path" \
6742 "$montpt/$path, should be $obj_file"
6749 #restart mgs before "error", otherwise it will block the next test
6750 stop mgs || error "stop mgs failed"
6751 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6752 $pass || error "test failed, see FAILED test_60a messages for specifics"
6754 run_test 60a "llog_test run from kernel module and test llog_reader"
6756 test_60b() { # bug 6411
6757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6760 LLOG_COUNT=$(do_facet mgs dmesg |
6761 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6762 /llog_[a-z]*.c:[0-9]/ {
6774 [[ $LLOG_COUNT -gt 120 ]] &&
6775 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6777 run_test 60b "limit repeated messages from CERROR/CWARN"
6780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6782 echo "create 5000 files"
6783 createmany -o $DIR/f60c- 5000
6784 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6785 lctl set_param fail_loc=0x80000137
6786 unlinkmany $DIR/f60c- 5000
6787 lctl set_param fail_loc=0
6789 run_test 60c "unlink file when mds full"
6792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6794 SAVEPRINTK=$(lctl get_param -n printk)
6795 # verify "lctl mark" is even working"
6796 MESSAGE="test message ID $RANDOM $$"
6797 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6798 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6800 lctl set_param printk=0 || error "set lnet.printk failed"
6801 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6802 MESSAGE="new test message ID $RANDOM $$"
6803 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6804 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6805 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6807 lctl set_param -n printk="$SAVEPRINTK"
6809 run_test 60d "test printk console message masking"
6812 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6813 remote_mds_nodsh && skip "remote MDS with nodsh"
6816 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6817 do_facet mds1 lctl set_param fail_loc=0x15b
6820 run_test 60e "no space while new llog is being created"
6825 test_mkdir -c $MDSCOUNT $DIR/$tdir
6826 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir
6831 mkdir $DIR/$tdir/subdir$index 2>/dev/null
6832 rmdir $DIR/$tdir/subdir$index 2>/dev/null
6833 index=$((index + 1))
6839 for i in $(seq 100); do
6840 # define OBD_FAIL_OSD_TXN_START 0x19a
6841 do_facet mds1 lctl set_param fail_loc=0x8000019a
6847 mkdir $DIR/$tdir/new || error "mkdir failed"
6848 rmdir $DIR/$tdir/new || error "rmdir failed"
6850 run_test 60g "transaction abort won't cause MDT hung"
6853 [ $MDS1_VERSION -le $(version_code 2.12.52) ] ||
6854 skip "Need MDS version at least 2.12.52"
6855 [ $MDSCOUNT -le 2 ] && skip "Need >= 2 MDTs"
6859 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
6860 #define OBD_FAIL_MDS_STRIPE_FID 0x189
6861 for fail_loc in 0x80000188 0x80000189; do
6862 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
6863 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
6864 error "mkdir $dir-$fail_loc failed"
6865 for i in {0..10}; do
6866 # create may fail on missing stripe
6867 echo $i > $DIR/$tdir-$fail_loc/$i
6869 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6870 error "getdirstripe $tdir-$fail_loc failed"
6871 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
6872 error "migrate $tdir-$fail_loc failed"
6873 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6874 error "getdirstripe $tdir-$fail_loc failed"
6875 pushd $DIR/$tdir-$fail_loc
6877 echo $f | cmp $f - || error "$f data mismatch"
6880 rm -rf $DIR/$tdir-$fail_loc
6883 run_test 60h "striped directory with missing stripes can be accessed"
6886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6889 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
6890 cancel_lru_locks osc
6891 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6894 run_test 61a "mmap() writes don't make sync hang ================"
6897 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
6899 run_test 61b "mmap() of unstriped file is successful"
6901 # bug 2330 - insufficient obd_match error checking causes LBUG
6903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6907 cancel_lru_locks osc
6908 lctl set_param fail_loc=0x405
6909 cat $f && error "cat succeeded, expect -EIO"
6910 lctl set_param fail_loc=0
6912 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6913 # match every page all of the time.
6914 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6916 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6917 # Though this test is irrelevant anymore, it helped to reveal some
6918 # other grant bugs (LU-4482), let's keep it.
6919 test_63a() { # was test_63
6920 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6922 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6924 for i in `seq 10` ; do
6925 dd if=/dev/zero of=$DIR/f63 bs=8k &
6931 rm -f $DIR/f63 || true
6933 run_test 63a "Verify oig_wait interruption does not crash ======="
6935 # bug 2248 - async write errors didn't return to application on sync
6936 # bug 3677 - async write errors left page locked
6938 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6941 lctl set_param debug=-1
6943 # ensure we have a grant to do async writes
6944 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6947 sync # sync lest earlier test intercept the fail_loc
6949 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6950 lctl set_param fail_loc=0x80000406
6951 $MULTIOP $DIR/$tfile Owy && \
6952 error "sync didn't return ENOMEM"
6953 sync; sleep 2; sync # do a real sync this time to flush page
6954 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6955 error "locked page left in cache after async error" || true
6958 run_test 63b "async write errors should be returned to fsync ==="
6961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6964 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6966 run_test 64a "verify filter grant calculations (in kernel) ====="
6969 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6971 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6973 run_test 64b "check out-of-space detection on client"
6976 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6978 run_test 64c "verify grant shrink"
6984 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
6987 # this does exactly what osc_request.c:osc_announce_cached() does in
6988 # order to calculate max amount of grants to ask from server
6992 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
6993 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
6995 ((rpc_in_flight++));
6996 nrpages=$((nrpages * rpc_in_flight))
6998 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
7000 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
7002 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
7003 local undirty=$((nrpages * PAGE_SIZE))
7005 local max_extent_pages
7006 max_extent_pages=$(import_param $tgt grant_max_extent_size)
7007 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
7008 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
7009 local grant_extent_tax
7010 grant_extent_tax=$(import_param $tgt grant_extent_tax)
7012 undirty=$((undirty + nrextents * grant_extent_tax))
7017 # this is size of unit for grant allocation. It should be equal to
7018 # what tgt_grant.c:tgt_grant_chunk() calculates
7022 local grant_extent_tax
7024 max_brw_size=$(import_param $tgt max_brw_size)
7026 grant_extent_tax=$(import_param $tgt grant_extent_tax)
7028 echo $(((max_brw_size + grant_extent_tax) * 2))
7032 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
7033 skip "OST < 2.10.55 doesn't limit grants enough"
7035 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7037 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
7038 skip "no grant_param connect flag"
7040 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
7042 $LCTL set_param -n -n debug="$OLDDEBUG" || true
7043 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
7046 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7047 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
7049 $LFS setstripe $DIR/$tfile -i 0 -c 1
7050 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
7053 while kill -0 $ddpid; do
7054 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
7056 if [[ $cur_grant -gt $max_cur_granted ]]; then
7058 error "cur_grant $cur_grant > $max_cur_granted"
7064 run_test 64d "check grant limit exceed"
7070 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
7072 ((cur_grants == expected)) ||
7073 error "$msg: grants mismatch: $cur_grants, expected $expected"
7077 echo $((($1 + $2 - 1) & ~($2 - 1)))
7081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7082 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
7083 skip "Need OSS version at least 2.11.56"
7085 # Remount client to reset grant
7086 remount_client $MOUNT || error "failed to remount client"
7087 local osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7088 local init_grants=$(import_param $osc_tgt initial_grant)
7090 check_grants $osc_tgt $init_grants "init grants"
7092 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
7093 local max_brw_size=$(import_param $osc_tgt max_brw_size)
7094 local gbs=$(import_param $osc_tgt grant_block_size)
7096 # write random number of bytes from max_brw_size / 4 to max_brw_size
7097 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
7098 # align for direct io
7099 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
7100 # round to grant consumption unit
7101 local wb_round_up=$(round_up_p2 $write_bytes gbs)
7103 local grants=$((wb_round_up + extent_tax))
7105 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7107 # define OBD_FAIL_TGT_NO_GRANT 0x725
7108 # make the server not grant more back
7109 do_facet ost1 $LCTL set_param fail_loc=0x725
7110 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
7112 do_facet ost1 $LCTL set_param fail_loc=0
7114 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
7116 rm -f $DIR/$tfile || error "rm failed"
7118 # Remount client to reset grant
7119 remount_client $MOUNT || error "failed to remount client"
7120 osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7122 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7124 # define OBD_FAIL_TGT_NO_GRANT 0x725
7125 # make the server not grant more back
7126 do_facet ost1 $LCTL set_param fail_loc=0x725
7127 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
7128 do_facet ost1 $LCTL set_param fail_loc=0
7130 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
7132 run_test 64e "check grant consumption (no grant allocation)"
7135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7137 # Remount client to reset grant
7138 remount_client $MOUNT || error "failed to remount client"
7139 local osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7141 local init_grants=$(import_param $osc_tgt initial_grant)
7142 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
7143 local max_brw_size=$(import_param $osc_tgt max_brw_size)
7144 local gbs=$(import_param $osc_tgt grant_block_size)
7145 local chunk=$(grant_chunk $osc_tgt)
7147 # write random number of bytes from max_brw_size / 4 to max_brw_size
7148 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
7149 # align for direct io
7150 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
7151 # round to grant consumption unit
7152 local wb_round_up=$(round_up_p2 $write_bytes gbs)
7154 local grants=$((wb_round_up + extent_tax))
7156 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7157 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
7158 error "error writing to $DIR/$tfile"
7160 check_grants $osc_tgt $((init_grants - grants + chunk)) \
7161 "direct io with grant allocation"
7163 rm -f $DIR/$tfile || error "rm failed"
7165 # Remount client to reset grant
7166 remount_client $MOUNT || error "failed to remount client"
7167 osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7169 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7171 local cmd="oO_WRONLY:w${write_bytes}_yc"
7173 $MULTIOP $DIR/$tfile $cmd &
7177 check_grants $osc_tgt $((init_grants - grants)) \
7178 "buffered io, not write rpc"
7180 kill -USR1 $MULTIPID
7183 check_grants $osc_tgt $((init_grants - grants + chunk)) \
7184 "buffered io, one RPC"
7186 run_test 64f "check grant consumption (with grant allocation)"
7189 local cli=$($LFS getname $DIR); cli=${cli%% *}; cli=${cli#*-}
7190 local osc_tgt="$FSNAME-OST0000-osc-$cli"
7191 local num_exps=$(do_facet ost1 \
7192 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
7193 local max_brw_size=$(import_param $osc_tgt max_brw_size)
7194 local avail=$($LCTL get_param -n osc.*OST0000-osc-$cli.kbytesavail)
7195 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7197 # 10MiB is for file to be written, max_brw_size * 16 *
7198 # num_exps is space reserve so that tgt_grant_shrink() decided
7200 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
7201 (( avail * 1024 < expect )) &&
7202 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
7204 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
7205 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
7206 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
7207 $LCTL set_param osc.*OST0000*.grant_shrink=1
7208 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
7210 $LFS setstripe -c 1 -i 0 $DIR/$tfile
7211 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
7213 # drop cache so that coming read would do rpc
7214 cancel_lru_locks osc
7216 # shrink interval is set to 10, pause for 7 seconds so that
7217 # grant thread did not wake up yet but coming read entered
7218 # shrink mode for rpc (osc_should_shrink_grant())
7221 declare -a cur_grant_bytes
7222 declare -a tot_granted
7223 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
7224 tot_granted[0]=$(do_facet ost1 \
7225 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
7227 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
7229 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
7230 tot_granted[1]=$(do_facet ost1 \
7231 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
7233 # grant change should be equal on both sides
7234 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
7235 tot_granted[0] - tot_granted[1])) ||
7236 error "grant change mismatch, " \
7237 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
7238 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
7240 run_test 64h "grant shrink on read"
7242 # bug 1414 - set/get directories' stripe info
7244 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7246 test_mkdir $DIR/$tdir
7248 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7250 run_test 65a "directory with no stripe info"
7253 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7255 test_mkdir $DIR/$tdir
7256 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7258 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7261 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7263 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7266 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7267 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7269 test_mkdir $DIR/$tdir
7270 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
7272 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7273 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7275 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7277 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7282 test_mkdir $DIR/$tdir
7283 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
7284 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7286 if [[ $STRIPECOUNT -le 0 ]]; then
7288 elif [[ $STRIPECOUNT -gt 2000 ]]; then
7289 #LOV_MAX_STRIPE_COUNT is 2000
7290 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
7292 sc=$(($STRIPECOUNT - 1))
7294 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7295 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7296 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7297 error "lverify failed"
7299 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7302 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7304 test_mkdir $DIR/$tdir
7306 $SETSTRIPE $DIR/$tdir || error "setstripe"
7307 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
7308 error "no stripe info failed"
7310 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
7312 run_test 65e "directory setstripe defaults"
7315 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7317 test_mkdir $DIR/${tdir}f
7318 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
7320 run_test 65f "dir setstripe permission (should return error) ==="
7323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7325 test_mkdir $DIR/$tdir
7326 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7328 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7329 error "setstripe -S failed"
7330 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7331 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7332 error "delete default stripe failed"
7334 run_test 65g "directory setstripe -d"
7337 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7339 test_mkdir $DIR/$tdir
7340 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7342 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7343 error "setstripe -S failed"
7344 test_mkdir $DIR/$tdir/dd1
7345 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
7346 error "stripe info inherit failed"
7348 run_test 65h "directory stripe info inherit ===================="
7351 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7353 save_layout_restore_at_exit $MOUNT
7355 # bug6367: set non-default striping on root directory
7356 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7358 # bug12836: getstripe on -1 default directory striping
7359 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7361 # bug12836: getstripe -v on -1 default directory striping
7362 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7364 # bug12836: new find on -1 default directory striping
7365 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7367 run_test 65i "various tests to set root directory striping"
7369 test_65j() { # bug6367
7370 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7374 # if we aren't already remounting for each test, do so for this test
7375 if [ "$I_MOUNTED" = "yes" ]; then
7376 cleanup || error "failed to unmount"
7380 save_layout_restore_at_exit $MOUNT
7382 $SETSTRIPE -d $MOUNT || error "setstripe failed"
7384 run_test 65j "set default striping on root directory (bug 6367)="
7388 wait_delete_completed
7389 do_facet $SINGLEMDS "lctl set_param -n \
7390 osp.$ost*MDT0000.max_create_count=$max_count"
7391 do_facet $SINGLEMDS "lctl set_param -n \
7392 osp.$ost*MDT0000.create_count=$count"
7393 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7394 echo $INACTIVE_OSC "is Activate"
7396 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7399 test_65k() { # bug11679
7400 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7401 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7402 remote_mds_nodsh && skip "remote MDS with nodsh"
7404 local disable_precreate=true
7405 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7406 disable_precreate=false
7408 echo "Check OST status: "
7409 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7410 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7412 for OSC in $MDS_OSCS; do
7413 echo $OSC "is active"
7414 do_facet $SINGLEMDS lctl --device %$OSC activate
7417 for INACTIVE_OSC in $MDS_OSCS; do
7418 local ost=$(osc_to_ost $INACTIVE_OSC)
7419 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7420 lov.*md*.target_obd |
7421 awk -F: /$ost/'{ print $1 }' | head -n 1)
7424 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
7425 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7427 echo "Deactivate: " $INACTIVE_OSC
7428 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7430 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7431 osp.$ost*MDT0000.create_count")
7432 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7433 osp.$ost*MDT0000.max_create_count")
7434 $disable_precreate &&
7435 do_facet $SINGLEMDS "lctl set_param -n \
7436 osp.$ost*MDT0000.max_create_count=0"
7438 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7439 [ -f $DIR/$tdir/$idx ] && continue
7440 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
7441 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
7443 error "setstripe $idx should succeed"; }
7444 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7446 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7449 do_facet $SINGLEMDS "lctl set_param -n \
7450 osp.$ost*MDT0000.max_create_count=$max_count"
7451 do_facet $SINGLEMDS "lctl set_param -n \
7452 osp.$ost*MDT0000.create_count=$count"
7453 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7454 echo $INACTIVE_OSC "is Activate"
7456 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7459 run_test 65k "validate manual striping works properly with deactivated OSCs"
7461 test_65l() { # bug 12836
7462 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7464 test_mkdir -p $DIR/$tdir/test_dir
7465 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
7466 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7468 run_test 65l "lfs find on -1 stripe dir ========================"
7471 local layout=$(save_layout $MOUNT)
7472 $RUNAS $SETSTRIPE -c 2 $MOUNT && {
7473 restore_layout $MOUNT $layout
7474 error "setstripe should fail by non-root users"
7478 run_test 65m "normal user can't set filesystem default stripe"
7481 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.0) ]] ||
7482 skip "Need MDS version at least 2.12.0"
7483 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7485 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7486 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7487 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7489 save_layout_restore_at_exit $MOUNT
7491 # new subdirectory under root directory should not inherit
7492 # the default layout from root
7493 local dir1=$MOUNT/$tdir-1
7494 mkdir $dir1 || error "mkdir $dir1 failed"
7495 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7496 error "$dir1 shouldn't have LOV EA"
7498 # delete the default layout on root directory
7499 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7501 local dir2=$MOUNT/$tdir-2
7502 mkdir $dir2 || error "mkdir $dir2 failed"
7503 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7504 error "$dir2 shouldn't have LOV EA"
7506 # set a new striping pattern on root directory
7507 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7508 local new_def_stripe_size=$((def_stripe_size * 2))
7509 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7510 error "set stripe size on $MOUNT failed"
7512 # new file created in $dir2 should inherit the new stripe size from
7513 # the filesystem default
7514 local file2=$dir2/$tfile-2
7515 touch $file2 || error "touch $file2 failed"
7517 local file2_stripe_size=$($LFS getstripe -S $file2)
7518 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
7519 error "$file2 didn't inherit stripe size $new_def_stripe_size"
7521 local dir3=$MOUNT/$tdir-3
7522 mkdir $dir3 || error "mkdir $dir3 failed"
7523 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
7524 # the root layout, which is the actual default layout that will be used
7525 # when new files are created in $dir3.
7526 local dir3_layout=$(get_layout_param $dir3)
7527 local root_dir_layout=$(get_layout_param $MOUNT)
7528 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
7529 error "$dir3 should show the default layout from $MOUNT"
7531 # set OST pool on root directory
7532 local pool=$TESTNAME
7533 pool_add $pool || error "add $pool failed"
7534 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
7535 error "add targets to $pool failed"
7537 $LFS setstripe -p $pool $MOUNT ||
7538 error "set OST pool on $MOUNT failed"
7540 # new file created in $dir3 should inherit the pool from
7541 # the filesystem default
7542 local file3=$dir3/$tfile-3
7543 touch $file3 || error "touch $file3 failed"
7545 local file3_pool=$($LFS getstripe -p $file3)
7546 [[ "$file3_pool" = "$pool" ]] ||
7547 error "$file3 didn't inherit OST pool $pool"
7549 local dir4=$MOUNT/$tdir-4
7550 mkdir $dir4 || error "mkdir $dir4 failed"
7551 local dir4_layout=$(get_layout_param $dir4)
7552 root_dir_layout=$(get_layout_param $MOUNT)
7553 echo "$LFS getstripe -d $dir4"
7554 $LFS getstripe -d $dir4
7555 echo "$LFS getstripe -d $MOUNT"
7556 $LFS getstripe -d $MOUNT
7557 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
7558 error "$dir4 should show the default layout from $MOUNT"
7560 # new file created in $dir4 should inherit the pool from
7561 # the filesystem default
7562 local file4=$dir4/$tfile-4
7563 touch $file4 || error "touch $file4 failed"
7565 local file4_pool=$($LFS getstripe -p $file4)
7566 [[ "$file4_pool" = "$pool" ]] ||
7567 error "$file4 didn't inherit OST pool $pool"
7569 # new subdirectory under non-root directory should inherit
7570 # the default layout from its parent directory
7571 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
7572 error "set directory layout on $dir4 failed"
7574 local dir5=$dir4/$tdir-5
7575 mkdir $dir5 || error "mkdir $dir5 failed"
7577 dir4_layout=$(get_layout_param $dir4)
7578 local dir5_layout=$(get_layout_param $dir5)
7579 [[ "$dir4_layout" = "$dir5_layout" ]] ||
7580 error "$dir5 should inherit the default layout from $dir4"
7582 # though subdir under ROOT doesn't inherit default layout, but
7583 # its sub dir/file should be created with default layout.
7584 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
7585 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
7586 [[ $MDS1_VERSION -ge $(version_code 2.12.3) &&
7587 $MDS1_VERSION -lt $(version_code 2.12.50) ]] ||
7588 skip "Need MDS version at least 2.12.3 or 2.12.59"
7590 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
7591 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
7592 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
7594 if [ $default_lmv_hash == "none" ]; then
7595 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
7597 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
7598 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
7601 $LFS setdirstripe -D -c 2 $MOUNT ||
7602 error "setdirstripe -D -c 2 failed"
7603 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
7604 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
7605 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
7607 run_test 65n "don't inherit default layout from root for new subdirectories"
7609 # bug 2543 - update blocks count on client
7611 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7614 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
7615 sync; sync_all_data; sync; sync_all_data
7616 cancel_lru_locks osc
7617 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
7618 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
7620 run_test 66 "update inode blocks count on client ==============="
7623 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
7627 swapon -s | awk '($1 == "'$1'") { print $4 }'
7630 # bug5265, obdfilter oa2dentry return -ENOENT
7631 # #define OBD_FAIL_SRV_ENOENT 0x217
7633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7634 remote_ost_nodsh && skip "remote OST with nodsh"
7637 $SETSTRIPE -c 1 -i 0 $f
7639 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
7641 do_facet ost1 lctl set_param fail_loc=0x217
7642 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
7643 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
7645 do_facet ost1 lctl set_param fail_loc=0
7646 $DIRECTIO write $f 0 2 || error "write error"
7648 cancel_lru_locks osc
7649 $DIRECTIO read $f 0 1 || error "read error"
7651 do_facet ost1 lctl set_param fail_loc=0x217
7652 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
7654 do_facet ost1 lctl set_param fail_loc=0
7657 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
7660 test_mkdir $DIR/$tdir
7661 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
7662 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
7664 run_test 71 "Running dbench on lustre (don't segment fault) ===="
7666 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
7667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7668 [ "$RUNAS_ID" = "$UID" ] &&
7669 skip_env "RUNAS_ID = UID = $UID -- skipping"
7670 # Check that testing environment is properly set up. Skip if not
7671 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
7672 skip_env "User $RUNAS_ID does not exist - skipping"
7675 chmod 777 $DIR/$tfile
7676 chmod ug+s $DIR/$tfile
7677 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
7678 error "$RUNAS dd $DIR/$tfile failed"
7679 # See if we are still setuid/sgid
7680 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7681 error "S/gid is not dropped on write"
7682 # Now test that MDS is updated too
7683 cancel_lru_locks mdc
7684 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7685 error "S/gid is not dropped on MDS"
7688 run_test 72a "Test that remove suid works properly (bug5695) ===="
7690 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7693 [ "$RUNAS_ID" = "$UID" ] &&
7694 skip_env "RUNAS_ID = UID = $UID -- skipping"
7695 [ "$RUNAS_ID" -eq 0 ] &&
7696 skip_env "RUNAS_ID = 0 -- skipping"
7697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7698 # Check that testing environment is properly set up. Skip if not
7699 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7700 skip_env "User $RUNAS_ID does not exist - skipping"
7702 touch $DIR/${tfile}-f{g,u}
7703 test_mkdir $DIR/${tfile}-dg
7704 test_mkdir $DIR/${tfile}-du
7705 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7706 chmod g+s $DIR/${tfile}-{f,d}g
7707 chmod u+s $DIR/${tfile}-{f,d}u
7708 for perm in 777 2777 4777; do
7709 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7710 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7711 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7712 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7716 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7718 # bug 3462 - multiple simultaneous MDC requests
7720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7722 test_mkdir $DIR/d73-1
7723 test_mkdir $DIR/d73-2
7724 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7727 lctl set_param fail_loc=0x80000129
7728 $MULTIOP $DIR/d73-1/f73-2 Oc &
7730 lctl set_param fail_loc=0
7732 $MULTIOP $DIR/d73-2/f73-3 Oc &
7736 wait $pid1 || return 1
7740 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
7741 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
7742 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
7746 run_test 73 "multiple MDC requests (should not deadlock)"
7748 test_74a() { # bug 6149, 6184
7749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7752 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7754 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7755 # will spin in a tight reconnection loop
7756 $LCTL set_param fail_loc=0x8000030e
7757 # get any lock that won't be difficult - lookup works.
7759 $LCTL set_param fail_loc=0
7763 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
7765 test_74b() { # bug 13310
7766 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7768 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7770 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7771 # will spin in a tight reconnection loop
7772 $LCTL set_param fail_loc=0x8000030e
7773 # get a "difficult" lock
7775 $LCTL set_param fail_loc=0
7779 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
7782 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7784 #define OBD_FAIL_LDLM_NEW_LOCK
7785 $LCTL set_param fail_loc=0x319
7786 touch $DIR/$tfile && error "touch successful"
7787 $LCTL set_param fail_loc=0
7790 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
7793 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
7796 test_76() { # Now for bug 20433, added originally in bug 1443
7797 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7799 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
7801 cancel_lru_locks osc
7802 BEFORE_INODES=$(num_inodes)
7803 echo "before inodes: $BEFORE_INODES"
7805 [ "$SLOW" = "no" ] && COUNT=100
7806 for i in $(seq $COUNT); do
7810 cancel_lru_locks osc
7811 AFTER_INODES=$(num_inodes)
7812 echo "after inodes: $AFTER_INODES"
7814 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
7816 AFTER_INODES=$(num_inodes)
7818 echo "wait $wait seconds inodes: $AFTER_INODES"
7819 if [ $wait -gt 30 ]; then
7820 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
7824 run_test 76 "confirm clients recycle inodes properly ===="
7830 # Note: in sptlrpc modes which enable its own bulk checksum, the
7831 # original crc32_le bulk checksum will be automatically disabled,
7832 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
7833 # will be checked by sptlrpc code against sptlrpc bulk checksum.
7834 # In this case set_checksums() will not be no-op, because sptlrpc
7835 # bulk checksum will be enabled all through the test.
7837 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
7838 lctl set_param -n osc.*.checksums $1
7842 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7843 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
7844 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7845 tr -d [] | head -n1)}
7848 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
7849 log "set checksum type to $1"
7852 F77_TMP=$TMP/f77-temp
7855 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
7856 error "error writing to $F77_TMP"
7859 test_77a() { # bug 10889
7860 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7861 $GSS && skip_env "could not run with gss"
7863 [ ! -f $F77_TMP ] && setup_f77
7865 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
7869 run_test 77a "normal checksum read/write operation"
7871 test_77b() { # bug 10889
7872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7873 $GSS && skip_env "could not run with gss"
7875 [ ! -f $F77_TMP ] && setup_f77
7876 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7877 $LCTL set_param fail_loc=0x80000409
7880 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7881 error "dd error: $?"
7882 $LCTL set_param fail_loc=0
7884 for algo in $CKSUM_TYPES; do
7885 cancel_lru_locks osc
7886 set_checksum_type $algo
7887 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7888 $LCTL set_param fail_loc=0x80000408
7889 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7890 $LCTL set_param fail_loc=0
7893 set_checksum_type $ORIG_CSUM_TYPE
7896 run_test 77b "checksum error on client write, read"
7901 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7903 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7904 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7905 $check_ost && [ -n "$ost_file_prefix" ] &&
7906 do_facet ost1 rm -f ${ost_file_prefix}\*
7910 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7911 $GSS && skip_env "could not run with gss"
7912 remote_ost_nodsh && skip "remote OST with nodsh"
7915 local osc_file_prefix
7917 local check_ost=false
7918 local ost_file_prefix
7924 # ensure corruption will occur on first OSS/OST
7925 $LFS setstripe -i 0 $DIR/$tfile
7927 [ ! -f $F77_TMP ] && setup_f77
7928 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7929 error "dd write error: $?"
7930 fid=$($LFS path2fid $DIR/$tfile)
7932 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
7935 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7936 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7938 echo "OSS do not support bulk pages dump upon error"
7941 osc_file_prefix=$($LCTL get_param -n debug_path)
7942 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7944 trap cleanup_77c EXIT
7947 # enable bulk pages dump upon error on Client
7948 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7949 # enable bulk pages dump upon error on OSS
7951 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7953 # flush Client cache to allow next read to reach OSS
7954 cancel_lru_locks osc
7956 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7957 $LCTL set_param fail_loc=0x80000408
7958 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7959 $LCTL set_param fail_loc=0
7963 # check cksum dump on Client
7964 osc_file=$(ls ${osc_file_prefix}*)
7965 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7966 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7967 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7968 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7969 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7971 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7972 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7973 error "dump content does not match on Client"
7975 $check_ost || skip "No need to check cksum dump on OSS"
7977 # check cksum dump on OSS
7978 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7979 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7980 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7981 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7982 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7983 error "dump content does not match on OSS"
7987 run_test 77c "checksum error on client read with debug"
7989 test_77d() { # bug 10889
7990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7991 $GSS && skip_env "could not run with gss"
7993 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7994 $LCTL set_param fail_loc=0x80000409
7996 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7997 error "direct write: rc=$?"
7998 $LCTL set_param fail_loc=0
8001 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8002 $LCTL set_param fail_loc=0x80000408
8004 cancel_lru_locks osc
8005 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8006 error "direct read: rc=$?"
8007 $LCTL set_param fail_loc=0
8010 run_test 77d "checksum error on OST direct write, read"
8012 test_77f() { # bug 10889
8013 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8014 $GSS && skip_env "could not run with gss"
8017 for algo in $CKSUM_TYPES; do
8018 cancel_lru_locks osc
8019 set_checksum_type $algo
8020 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8021 $LCTL set_param fail_loc=0x409
8022 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
8023 error "direct write succeeded"
8024 $LCTL set_param fail_loc=0
8026 set_checksum_type $ORIG_CSUM_TYPE
8029 run_test 77f "repeat checksum error on write (expect error)"
8031 test_77g() { # bug 10889
8032 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8033 $GSS && skip_env "could not run with gss"
8034 remote_ost_nodsh && skip "remote OST with nodsh"
8036 [ ! -f $F77_TMP ] && setup_f77
8038 local file=$DIR/$tfile
8039 stack_trap "rm -f $file" EXIT
8041 $SETSTRIPE -c 1 -i 0 $file
8042 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
8043 do_facet ost1 lctl set_param fail_loc=0x8000021a
8045 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
8046 error "write error: rc=$?"
8047 do_facet ost1 lctl set_param fail_loc=0
8050 cancel_lru_locks osc
8051 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
8052 do_facet ost1 lctl set_param fail_loc=0x8000021b
8054 cmp $F77_TMP $file || error "file compare failed"
8055 do_facet ost1 lctl set_param fail_loc=0
8058 run_test 77g "checksum error on OST write, read"
8060 test_77k() { # LU-10906
8061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8062 $GSS && skip_env "could not run with gss"
8064 local cksum_param="osc.$FSNAME*.checksums"
8065 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
8069 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
8070 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
8071 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
8075 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
8076 error "failed to set checksum=$i on MGS"
8077 wait_update $HOSTNAME "$get_checksum" $i
8079 echo "remount client, checksum should be $i"
8080 remount_client $MOUNT || "failed to remount client"
8081 checksum=$(eval $get_checksum)
8082 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8085 for opt in "checksum" "nochecksum"; do
8086 #remount with mount option
8087 echo "remount client with option $opt, checksum should be $i"
8088 umount_client $MOUNT || "failed to umount client"
8089 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8090 "failed to mount client with option '$opt'"
8091 checksum=$(eval $get_checksum)
8092 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8096 remount_client $MOUNT || "failed to remount client"
8098 run_test 77k "enable/disable checksum correctly"
8100 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8109 test_78() { # bug 10901
8110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8111 remote_ost || skip_env "local OST"
8114 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8115 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8116 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8117 echo "MemTotal: $MEMTOTAL"
8119 # reserve 256MB of memory for the kernel and other running processes,
8120 # and then take 1/2 of the remaining memory for the read/write buffers.
8121 if [ $MEMTOTAL -gt 512 ] ;then
8122 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8124 # for those poor memory-starved high-end clusters...
8125 MEMTOTAL=$((MEMTOTAL / 2))
8127 echo "Mem to use for directio: $MEMTOTAL"
8129 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8130 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8131 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8132 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8134 echo "Smallest OST: $SMALLESTOST"
8135 [[ $SMALLESTOST -lt 10240 ]] &&
8136 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8138 trap cleanup_test_78 EXIT
8140 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8141 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8143 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8144 echo "File size: $F78SIZE"
8145 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8146 for i in $(seq 1 $NSEQ); do
8147 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8148 echo directIO rdwr round $i of $NSEQ
8149 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8154 run_test 78 "handle large O_DIRECT writes correctly ============"
8156 test_79() { # bug 12743
8157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8159 wait_delete_completed
8161 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8162 BKFREE=$(calc_osc_kbytes kbytesfree)
8163 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8165 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8166 DFTOTAL=`echo $STRING | cut -d, -f1`
8167 DFUSED=`echo $STRING | cut -d, -f2`
8168 DFAVAIL=`echo $STRING | cut -d, -f3`
8169 DFFREE=$(($DFTOTAL - $DFUSED))
8171 ALLOWANCE=$((64 * $OSTCOUNT))
8173 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8174 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8175 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8177 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8178 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8179 error "df free($DFFREE) mismatch OST free($BKFREE)"
8181 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8182 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8183 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8186 run_test 79 "df report consistency check ======================="
8188 test_80() { # bug 10718
8189 remote_ost_nodsh && skip "remote OST with nodsh"
8190 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8192 # relax strong synchronous semantics for slow backends like ZFS
8193 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8194 local soc="obdfilter.*.sync_lock_cancel"
8195 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8197 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
8198 if [ -z "$save" ]; then
8199 soc="obdfilter.*.sync_on_lock_cancel"
8200 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8203 if [ "$save" != "never" ]; then
8204 local hosts=$(comma_list $(osts_nodes))
8206 do_nodes $hosts $LCTL set_param $soc=never
8207 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
8211 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
8213 local before=$(date +%s)
8214 cancel_lru_locks osc
8215 local after=$(date +%s)
8216 local diff=$((after - before))
8217 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
8221 run_test 80 "Page eviction is equally fast at high offsets too"
8223 test_81a() { # LU-456
8224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8225 remote_ost_nodsh && skip "remote OST with nodsh"
8227 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8228 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8229 do_facet ost1 lctl set_param fail_loc=0x80000228
8231 # write should trigger a retry and success
8232 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
8233 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8235 if [ $RC -ne 0 ] ; then
8236 error "write should success, but failed for $RC"
8239 run_test 81a "OST should retry write when get -ENOSPC ==============="
8241 test_81b() { # LU-456
8242 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8243 remote_ost_nodsh && skip "remote OST with nodsh"
8245 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8246 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8247 do_facet ost1 lctl set_param fail_loc=0x228
8249 # write should retry several times and return -ENOSPC finally
8250 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
8251 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8254 if [ $RC -ne $ENOSPC ] ; then
8255 error "dd should fail for -ENOSPC, but succeed."
8258 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8260 test_82() { # LU-1031
8261 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
8265 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
8267 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
8269 kill -USR1 $MULTIPID2
8271 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
8272 error "First grouplock does not block second one"
8274 echo "Second grouplock blocks first one"
8276 kill -USR1 $MULTIPID1
8280 run_test 82 "Basic grouplock test"
8283 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
8285 test_mkdir $DIR/$tdir.cvsroot
8286 chown $RUNAS_ID $DIR/$tdir.cvsroot
8289 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
8292 # some versions of cvs import exit(1) when asked to import links or
8293 # files they can't read. ignore those files.
8294 local toignore=$(find . -type l -printf '-I %f\n' -o \
8295 ! -perm /4 -printf '-I %f\n')
8296 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
8297 $tdir.reposname vtag rtag
8300 test_mkdir $DIR/$tdir.reposname
8301 chown $RUNAS_ID $DIR/$tdir.reposname
8302 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
8304 cd $DIR/$tdir.reposname
8306 $RUNAS cvs add -m 'addmsg' foo99
8308 $RUNAS cvs commit -m 'nomsg' foo99
8309 rm -fr $DIR/$tdir.cvsroot
8311 run_test 99 "cvs strange file/directory operations"
8314 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8315 [[ "$NETTYPE" =~ tcp ]] ||
8316 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
8317 remote_ost_nodsh && skip "remote OST with nodsh"
8318 remote_mds_nodsh && skip "remote MDS with nodsh"
8320 skip "useless for local single node setup"
8322 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
8323 [ "$PROT" != "tcp" ] && continue
8324 RPORT=$(echo $REMOTE | cut -d: -f2)
8325 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
8328 LPORT=`echo $LOCAL | cut -d: -f2`
8329 if [ $LPORT -ge 1024 ]; then
8330 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
8332 error_exit "local: $LPORT > 1024, remote: $RPORT"
8335 [ "$rc" = 0 ] || error_exit "privileged port not found" )
8337 run_test 100 "check local port using privileged port ==========="
8339 function get_named_value()
8348 echo $line | sed "s/^$tag[ ]*//"
8355 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
8356 awk '/^max_cached_mb/ { print $2 }')
8359 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
8364 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8365 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
8370 local cache_limit=32
8372 $LCTL set_param -n osc.*-osc*.rpc_stats 0
8373 trap cleanup_101a EXIT
8374 $LCTL set_param -n llite.*.read_ahead_stats 0
8375 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
8378 # randomly read 10000 of 64K chunks from file 3x 32MB in size
8380 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
8381 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
8384 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
8385 get_named_value 'read but discarded' | cut -d" " -f1); do
8386 discard=$(($discard + $s))
8390 if [[ $(($discard * 10)) -gt $nreads ]]; then
8391 $LCTL get_param osc.*-osc*.rpc_stats
8392 $LCTL get_param llite.*.read_ahead_stats
8393 error "too many ($discard) discarded pages"
8395 rm -f $DIR/$tfile || true
8397 run_test 101a "check read-ahead for random reads"
8400 test_mkdir $DIR/$tdir
8401 local STRIPE_SIZE=$1
8402 local FILE_LENGTH=$2
8405 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
8407 local list=$(comma_list $(osts_nodes))
8408 set_osd_param $list '' read_cache_enable 0
8409 set_osd_param $list '' writethrough_cache_enable 0
8411 trap cleanup_test101bc EXIT
8412 # prepare the read-ahead file
8413 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8415 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
8416 count=$FILE_SIZE_MB 2> /dev/null
8420 cleanup_test101bc() {
8425 local list=$(comma_list $(osts_nodes))
8426 set_osd_param $list '' read_cache_enable 1
8427 set_osd_param $list '' writethrough_cache_enable 1
8431 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8436 local STRIPE_SIZE=$2
8437 local FILE_LENGTH=$3
8438 local RA_INC=1048576
8439 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8440 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8441 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8442 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8443 get_named_value 'read but discarded' |
8444 cut -d" " -f1 | calc_total)
8445 if [[ $DISCARD -gt $discard_limit ]]; then
8446 $LCTL get_param llite.*.read_ahead_stats
8447 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8449 echo "Read-ahead success for size ${READ_SIZE}"
8454 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8455 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8457 local STRIPE_SIZE=1048576
8458 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8460 if [ $SLOW == "yes" ]; then
8461 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8463 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8466 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8468 # prepare the read-ahead file
8469 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8470 cancel_lru_locks osc
8471 for BIDX in 2 4 8 16 32 64 128 256
8473 local BSIZE=$((BIDX*4096))
8474 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
8475 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
8476 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
8477 $LCTL set_param -n llite.*.read_ahead_stats 0
8478 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
8479 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
8480 cancel_lru_locks osc
8481 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
8486 run_test 101b "check stride-io mode read-ahead ================="
8489 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8491 local STRIPE_SIZE=1048576
8492 local FILE_LENGTH=$((STRIPE_SIZE*100))
8497 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8499 cancel_lru_locks osc
8500 $LCTL set_param osc.*.rpc_stats 0
8501 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
8502 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
8503 local stats=$($LCTL get_param -n $osc_rpc_stats)
8504 local lines=$(echo "$stats" | awk 'END {print NR;}')
8507 if [ $lines -le 20 ]; then
8510 for size in 1 2 4 8; do
8511 local rpc=$(echo "$stats" |
8512 awk '($1 == "'$size':") {print $2; exit; }')
8513 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
8514 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
8516 echo "$osc_rpc_stats check passed!"
8521 run_test 101c "check stripe_size aligned read-ahead ================="
8524 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
8525 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
8529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8531 local file=$DIR/$tfile
8532 local sz_MB=${FILESIZE_101d:-500}
8533 local ra_MB=${READAHEAD_MB:-40}
8535 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
8536 [ $free_MB -lt $sz_MB ] &&
8537 skip "Need free space ${sz_MB}M, have ${free_MB}M"
8539 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
8540 $SETSTRIPE -c -1 $file || error "setstripe failed"
8542 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
8543 echo Cancel LRU locks on lustre client to flush the client cache
8544 cancel_lru_locks osc
8546 echo Disable read-ahead
8547 local old_READAHEAD=$(set_read_ahead 0)
8549 echo Reading the test file $file with read-ahead disabled
8550 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8552 echo Cancel LRU locks on lustre client to flush the client cache
8553 cancel_lru_locks osc
8554 echo Enable read-ahead with ${ra_MB}MB
8555 set_read_ahead $ra_MB
8557 echo Reading the test file $file with read-ahead enabled
8558 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8560 echo "read-ahead disabled time read $raOFF"
8561 echo "read-ahead enabled time read $raON"
8563 set_read_ahead $old_READAHEAD
8565 wait_delete_completed
8567 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
8568 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
8570 run_test 101d "file read with and without read-ahead enabled"
8573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8575 local file=$DIR/$tfile
8576 local size_KB=500 #KB
8580 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
8581 local need_KB=$((count * size_KB))
8582 [[ $free_KB -le $need_KB ]] &&
8583 skip_env "Need free space $need_KB, have $free_KB"
8585 echo "Creating $count ${size_KB}K test files"
8586 for ((i = 0; i < $count; i++)); do
8587 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
8590 echo "Cancel LRU locks on lustre client to flush the client cache"
8591 cancel_lru_locks $OSC
8593 echo "Reset readahead stats"
8594 $LCTL set_param -n llite.*.read_ahead_stats 0
8596 for ((i = 0; i < $count; i++)); do
8597 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
8600 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8601 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8603 for ((i = 0; i < $count; i++)); do
8604 rm -rf $file.$i 2>/dev/null
8607 #10000 means 20% reads are missing in readahead
8608 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
8610 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
8613 which iozone || skip_env "no iozone installed"
8615 local old_debug=$($LCTL get_param debug)
8616 old_debug=${old_debug#*=}
8617 $LCTL set_param debug="reada mmap"
8619 # create a test file
8620 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
8622 echo Cancel LRU locks on lustre client to flush the client cache
8623 cancel_lru_locks osc
8625 echo Reset readahead stats
8626 $LCTL set_param -n llite.*.read_ahead_stats 0
8628 echo mmap read the file with small block size
8629 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
8632 echo checking missing pages
8633 $LCTL get_param llite.*.read_ahead_stats
8634 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8635 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8637 $LCTL set_param debug="$old_debug"
8638 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
8641 run_test 101f "check mmap read performance"
8643 test_101g_brw_size_test() {
8645 local pages=$((mb * 1048576 / PAGE_SIZE))
8646 local file=$DIR/$tfile
8648 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
8649 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
8650 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
8651 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
8655 stack_trap "rm -f $file" EXIT
8656 $LCTL set_param -n osc.*.rpc_stats=0
8658 # 10 RPCs should be enough for the test
8660 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
8661 { error "dd write ${mb} MB blocks failed"; return 3; }
8662 cancel_lru_locks osc
8663 dd of=/dev/null if=$file bs=${mb}M count=$count ||
8664 { error "dd write ${mb} MB blocks failed"; return 4; }
8666 # calculate number of full-sized read and write RPCs
8667 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
8668 sed -n '/pages per rpc/,/^$/p' |
8669 awk '/'$pages':/ { reads += $2; writes += $6 }; \
8670 END { print reads,writes }'))
8671 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
8673 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
8680 remote_ost_nodsh && skip "remote OST with nodsh"
8683 local osts=$(get_facets OST)
8684 local list=$(comma_list $(osts_nodes))
8685 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8686 local brw_size="obdfilter.*.brw_size"
8688 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8690 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
8691 if [ $OST1_VERSION -ge $(version_code 2.8.52) -o \
8692 \( $OST1_VERSION -ge $(version_code 2.7.17) -a \
8693 $OST1_VERSION -lt $(version_code 2.7.50) \) ] &&
8694 [ $CLIENT_VERSION -ge $(version_code 2.8.52) -o \
8695 \( $CLIENT_VERSION -ge $(version_code 2.7.17) -a \
8696 $CLIENT_VERSION -lt $(version_code 2.7.50) \) ]; then
8697 [ $OST1_VERSION -ge $(version_code 2.9.52) ] && suffix="M"
8698 if [[ $orig_mb -lt 16 ]]; then
8699 save_lustre_params $osts "$brw_size" > $p
8700 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
8701 error "set 16MB RPC size failed"
8703 echo "remount client to enable new RPC size"
8704 remount_client $MOUNT || error "remount_client failed"
8707 test_101g_brw_size_test 16 || error "16MB RPC test failed"
8708 # should be able to set brw_size=12, but no rpc_stats for that
8709 test_101g_brw_size_test 8 || error "8MB RPC test failed"
8712 test_101g_brw_size_test 4 || error "4MB RPC test failed"
8714 if [[ $orig_mb -lt 16 ]]; then
8715 restore_lustre_params < $p
8716 remount_client $MOUNT || error "remount_client restore failed"
8719 rm -f $p $DIR/$tfile
8721 run_test 101g "Big bulk(4/16 MiB) readahead"
8724 test_mkdir $DIR/$tdir
8725 chown $RUNAS_ID $DIR/$tdir
8728 STRIPE_COUNT=$OSTCOUNT
8729 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
8731 trap cleanup_test102 EXIT
8733 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
8735 for num in 1 2 3 4; do
8736 for count in $(seq 1 $STRIPE_COUNT); do
8737 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
8738 local size=`expr $STRIPE_SIZE \* $num`
8739 local file=file"$num-$idx-$count"
8740 $1 $SETSTRIPE -S $size -i $idx -c $count $file
8746 $1 tar cf $TMP/f102.tar $tdir --xattrs
8752 rm -rf $DIR/d0.sanity/d102
8756 [ "$UID" != 0 ] && skip "must run as root"
8757 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
8758 skip_env "must have user_xattr"
8760 [ -z "$(which setfattr 2>/dev/null)" ] &&
8761 skip_env "could not find setfattr"
8763 local testfile=$DIR/$tfile
8766 echo "set/get xattr..."
8767 setfattr -n trusted.name1 -v value1 $testfile ||
8768 error "setfattr -n trusted.name1=value1 $testfile failed"
8769 getfattr -n trusted.name1 $testfile 2> /dev/null |
8770 grep "trusted.name1=.value1" ||
8771 error "$testfile missing trusted.name1=value1"
8773 setfattr -n user.author1 -v author1 $testfile ||
8774 error "setfattr -n user.author1=author1 $testfile failed"
8775 getfattr -n user.author1 $testfile 2> /dev/null |
8776 grep "user.author1=.author1" ||
8777 error "$testfile missing trusted.author1=author1"
8780 setfattr -n trusted.name2 -v value2 $testfile ||
8781 error "$testfile unable to set trusted.name2"
8782 setfattr -n trusted.name3 -v value3 $testfile ||
8783 error "$testfile unable to set trusted.name3"
8784 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
8785 grep "trusted.name" | wc -l) -eq 3 ] ||
8786 error "$testfile missing 3 trusted.name xattrs"
8788 setfattr -n user.author2 -v author2 $testfile ||
8789 error "$testfile unable to set user.author2"
8790 setfattr -n user.author3 -v author3 $testfile ||
8791 error "$testfile unable to set user.author3"
8792 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
8793 grep "user.author" | wc -l) -eq 3 ] ||
8794 error "$testfile missing 3 user.author xattrs"
8796 echo "remove xattr..."
8797 setfattr -x trusted.name1 $testfile ||
8798 error "$testfile error deleting trusted.name1"
8799 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
8800 error "$testfile did not delete trusted.name1 xattr"
8802 setfattr -x user.author1 $testfile ||
8803 error "$testfile error deleting user.author1"
8804 echo "set lustre special xattr ..."
8805 $LFS setstripe -c1 $testfile
8806 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
8807 awk -F "=" '/trusted.lov/ { print $2 }' )
8808 setfattr -n "trusted.lov" -v $lovea $testfile ||
8809 error "$testfile doesn't ignore setting trusted.lov again"
8810 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
8811 error "$testfile allow setting invalid trusted.lov"
8814 run_test 102a "user xattr test =================================="
8816 check_102b_layout() {
8818 local testfile=$DIR/$tfile
8820 echo "test layout '$layout'"
8821 $LFS setstripe $layout $testfile || error "setstripe failed"
8822 $LFS getstripe -y $testfile
8824 echo "get/set/list trusted.lov xattr ..." # b=10930
8825 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
8826 [[ "$value" =~ "trusted.lov" ]] ||
8827 error "can't get trusted.lov from $testfile"
8828 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
8829 error "getstripe failed"
8831 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
8833 value=$(cut -d= -f2 <<<$value)
8834 # LU-13168: truncated xattr should fail if short lov_user_md header
8835 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
8836 lens="${#value}" || lens="$(seq 4 2 ${#value})"
8837 for len in $lens; do
8838 echo "setfattr $len $testfile.2"
8839 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
8840 [ $len -lt 66 ] && error "short xattr len=$len worked"
8842 local stripe_size=$($LFS getstripe -S $testfile.2)
8843 local stripe_count=$($LFS getstripe -c $testfile.2)
8844 [[ $stripe_size -eq 65536 ]] ||
8845 error "stripe size $stripe_size != 65536"
8846 [[ $stripe_count -eq $stripe_count_orig ]] ||
8847 error "stripe count $stripe_count != $stripe_count_orig"
8848 rm $testfile $testfile.2
8852 [ -z "$(which setfattr 2>/dev/null)" ] &&
8853 skip_env "could not find setfattr"
8854 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8856 # check plain layout
8857 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
8859 # and also check composite layout
8860 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
8863 run_test 102b "getfattr/setfattr for trusted.lov EAs"
8866 [ -z "$(which setfattr 2>/dev/null)" ] &&
8867 skip_env "could not find setfattr"
8868 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8870 # b10930: get/set/list lustre.lov xattr
8871 echo "get/set/list lustre.lov xattr ..."
8872 test_mkdir $DIR/$tdir
8873 chown $RUNAS_ID $DIR/$tdir
8874 local testfile=$DIR/$tdir/$tfile
8875 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8876 error "setstripe failed"
8877 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
8878 error "getstripe failed"
8879 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
8880 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8882 local testfile2=${testfile}2
8883 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8884 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8886 $RUNAS $MCREATE $testfile2
8887 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8888 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
8889 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
8890 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8891 [ $stripe_count -eq $STRIPECOUNT ] ||
8892 error "stripe count $stripe_count != $STRIPECOUNT"
8894 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8896 compare_stripe_info1() {
8897 local stripe_index_all_zero=true
8899 for num in 1 2 3 4; do
8900 for count in $(seq 1 $STRIPE_COUNT); do
8901 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8902 local size=$((STRIPE_SIZE * num))
8903 local file=file"$num-$offset-$count"
8904 stripe_size=$($LFS getstripe -S $PWD/$file)
8905 [[ $stripe_size -ne $size ]] &&
8906 error "$file: size $stripe_size != $size"
8907 stripe_count=$($LFS getstripe -c $PWD/$file)
8908 # allow fewer stripes to be created, ORI-601
8909 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8910 error "$file: count $stripe_count != $count"
8911 stripe_index=$($LFS getstripe -i $PWD/$file)
8912 [[ $stripe_index -ne 0 ]] &&
8913 stripe_index_all_zero=false
8917 $stripe_index_all_zero &&
8918 error "all files are being extracted starting from OST index 0"
8922 have_xattrs_include() {
8923 tar --help | grep -q xattrs-include &&
8924 echo --xattrs-include="lustre.*"
8928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8929 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8931 XINC=$(have_xattrs_include)
8933 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8935 compare_stripe_info1
8937 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8941 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8943 XINC=$(have_xattrs_include)
8945 test_mkdir $DIR/$tdir.restore
8947 tar cf - --xattrs $tdir | tar xf - \
8948 -C $DIR/$tdir.restore --xattrs $XINC
8949 cd $DIR/$tdir.restore/$tdir
8950 compare_stripe_info1
8952 run_test 102f "tar copy files, not keep osts"
8955 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8956 skip "must have user_xattr"
8957 [ -z "$(which setfattr 2>/dev/null)" ] &&
8958 skip_env "could not find setfattr"
8959 [ -z "$(which getfattr 2>/dev/null)" ] &&
8960 skip_env "could not find getfattr"
8962 local xsize=${1:-1024} # in bytes
8963 local file=$DIR/$tfile
8964 local value="$(generate_string $xsize)"
8965 local xbig=trusted.big
8968 log "save $xbig on $file"
8969 setfattr -n $xbig -v $value $file ||
8970 error "saving $xbig on $file failed"
8972 local orig=$(get_xattr_value $xbig $file)
8973 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8975 local xsml=trusted.sml
8976 log "save $xsml on $file"
8977 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8979 local new=$(get_xattr_value $xbig $file)
8980 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8982 log "grow $xsml on $file"
8983 setfattr -n $xsml -v "$value" $file ||
8984 error "growing $xsml on $file failed"
8986 new=$(get_xattr_value $xbig $file)
8987 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8988 log "$xbig still valid after growing $xsml"
8993 test_102h() { # bug 15777
8996 run_test 102h "grow xattr from inside inode to external block"
8999 large_xattr_enabled || skip_env "ea_inode feature disabled"
9001 grow_xattr $(max_xattr_size)
9003 run_test 102ha "grow xattr from inside inode to external inode"
9005 test_102i() { # bug 17038
9006 [ -z "$(which getfattr 2>/dev/null)" ] &&
9007 skip "could not find getfattr"
9010 ln -s $DIR/$tfile $DIR/${tfile}link
9011 getfattr -n trusted.lov $DIR/$tfile ||
9012 error "lgetxattr on $DIR/$tfile failed"
9013 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
9014 grep -i "no such attr" ||
9015 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
9016 rm -f $DIR/$tfile $DIR/${tfile}link
9018 run_test 102i "lgetxattr test on symbolic link ============"
9021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9022 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9024 XINC=$(have_xattrs_include)
9025 setup_test102 "$RUNAS"
9026 chown $RUNAS_ID $DIR/$tdir
9027 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9029 compare_stripe_info1 "$RUNAS"
9031 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
9034 [ -z "$(which setfattr 2>/dev/null)" ] &&
9035 skip "could not find setfattr"
9038 # b22187 just check that does not crash for regular file.
9039 setfattr -n trusted.lov $DIR/$tfile
9040 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9041 local test_kdir=$DIR/$tdir
9042 test_mkdir $test_kdir
9043 local default_size=$($LFS getstripe -S $test_kdir)
9044 local default_count=$($LFS getstripe -c $test_kdir)
9045 local default_offset=$($LFS getstripe -i $test_kdir)
9046 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9047 error 'dir setstripe failed'
9048 setfattr -n trusted.lov $test_kdir
9049 local stripe_size=$($LFS getstripe -S $test_kdir)
9050 local stripe_count=$($LFS getstripe -c $test_kdir)
9051 local stripe_offset=$($LFS getstripe -i $test_kdir)
9052 [ $stripe_size -eq $default_size ] ||
9053 error "stripe size $stripe_size != $default_size"
9054 [ $stripe_count -eq $default_count ] ||
9055 error "stripe count $stripe_count != $default_count"
9056 [ $stripe_offset -eq $default_offset ] ||
9057 error "stripe offset $stripe_offset != $default_offset"
9058 rm -rf $DIR/$tfile $test_kdir
9060 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9063 [ -z "$(which getfattr 2>/dev/null)" ] &&
9064 skip "could not find getfattr"
9066 # LU-532 trusted. xattr is invisible to non-root
9067 local testfile=$DIR/$tfile
9071 echo "listxattr as user..."
9072 chown $RUNAS_ID $testfile
9073 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9074 grep -q "trusted" &&
9075 error "$testfile trusted xattrs are user visible"
9079 run_test 102l "listxattr size test =================================="
9081 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9082 local path=$DIR/$tfile
9085 listxattr_size_check $path || error "listattr_size_check $path failed"
9087 run_test 102m "Ensure listxattr fails on small bufffer ========"
9091 getxattr() { # getxattr path name
9092 # Return the base64 encoding of the value of xattr name on path.
9096 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9098 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9100 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9102 getfattr --absolute-names --encoding=base64 --name=$name $path |
9103 awk -F= -v name=$name '$1 == name {
9104 print substr($0, index($0, "=") + 1);
9108 test_102n() { # LU-4101 mdt: protect internal xattrs
9109 [ -z "$(which setfattr 2>/dev/null)" ] &&
9110 skip "could not find setfattr"
9111 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9113 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
9116 local file0=$DIR/$tfile.0
9117 local file1=$DIR/$tfile.1
9118 local xattr0=$TMP/$tfile.0
9119 local xattr1=$TMP/$tfile.1
9120 local namelist="lov lma lmv link fid version som hsm"
9124 rm -rf $file0 $file1 $xattr0 $xattr1
9127 # Get 'before' xattrs of $file1.
9128 getfattr --absolute-names --dump --match=- $file1 > $xattr0
9130 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
9131 namelist+=" lfsck_namespace"
9132 for name in $namelist; do
9133 # Try to copy xattr from $file0 to $file1.
9134 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9136 setfattr --name=trusted.$name --value="$value" $file1 ||
9137 error "setxattr 'trusted.$name' failed"
9139 # Try to set a garbage xattr.
9140 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9142 if [[ x$name == "xlov" ]]; then
9143 setfattr --name=trusted.lov --value="$value" $file1 &&
9144 error "setxattr invalid 'trusted.lov' success"
9146 setfattr --name=trusted.$name --value="$value" $file1 ||
9147 error "setxattr invalid 'trusted.$name' failed"
9150 # Try to remove the xattr from $file1. We don't care if this
9151 # appears to succeed or fail, we just don't want there to be
9152 # any changes or crashes.
9153 setfattr --remove=$trusted.$name $file1 2> /dev/null
9156 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
9159 # Try to copy xattr from $file0 to $file1.
9160 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9162 setfattr --name=trusted.$name --value="$value" $file1 ||
9163 error "setxattr 'trusted.$name' failed"
9165 # Try to set a garbage xattr.
9166 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9168 setfattr --name=trusted.$name --value="$value" $file1 ||
9169 error "setxattr 'trusted.$name' failed"
9171 # Try to remove the xattr from $file1. We don't care if this
9172 # appears to succeed or fail, we just don't want there to be
9173 # any changes or crashes.
9174 setfattr --remove=$trusted.$name $file1 2> /dev/null
9177 # Get 'after' xattrs of file1.
9178 getfattr --absolute-names --dump --match=- $file1 > $xattr1
9180 if ! diff $xattr0 $xattr1; then
9181 error "before and after xattrs of '$file1' differ"
9184 rm -rf $file0 $file1 $xattr0 $xattr1
9188 run_test 102n "silently ignore setxattr on internal trusted xattrs"
9190 test_102p() { # LU-4703 setxattr did not check ownership
9191 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
9192 skip "MDS needs to be at least 2.5.56"
9194 local testfile=$DIR/$tfile
9198 echo "setfacl as user..."
9199 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
9200 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
9202 echo "setfattr as user..."
9203 setfacl -m "u:$RUNAS_ID:---" $testfile
9204 $RUNAS setfattr -x system.posix_acl_access $testfile
9205 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
9207 run_test 102p "check setxattr(2) correctly fails without permission"
9210 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
9211 skip "MDS needs to be at least 2.6.92"
9213 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
9215 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
9218 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
9219 skip "MDS needs to be at least 2.6.93"
9221 touch $DIR/$tfile || error "touch"
9222 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
9223 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
9224 rm $DIR/$tfile || error "rm"
9227 mkdir -p $DIR/$tdir || error "mkdir"
9228 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9229 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9230 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9231 error "$testfile error deleting user.author1"
9232 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9233 grep "user.$(basename $tdir)" &&
9234 error "$tdir did not delete user.$(basename $tdir)"
9235 rmdir $DIR/$tdir || error "rmdir"
9238 test_mkdir $DIR/$tdir
9239 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9240 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9241 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9242 error "$testfile error deleting user.author1"
9243 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9244 grep "user.$(basename $tdir)" &&
9245 error "$tdir did not delete user.$(basename $tdir)"
9246 rmdir $DIR/$tdir || error "rm striped dir"
9248 run_test 102r "set EAs with empty values"
9251 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9252 skip "MDS needs to be at least 2.11.52"
9254 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9256 save_lustre_params client "llite.*.xattr_cache" > $save
9258 for cache in 0 1; do
9259 lctl set_param llite.*.xattr_cache=$cache
9262 touch $DIR/$tfile || error "touch"
9263 for prefix in lustre security system trusted user; do
9264 # Note getxattr() may fail with 'Operation not
9265 # supported' or 'No such attribute' depending
9266 # on prefix and cache.
9267 getfattr -n $prefix.n102s $DIR/$tfile &&
9268 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
9272 restore_lustre_params < $save
9274 run_test 102s "getting nonexistent xattrs should fail"
9277 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9278 skip "MDS needs to be at least 2.11.52"
9280 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9282 save_lustre_params client "llite.*.xattr_cache" > $save
9284 for cache in 0 1; do
9285 lctl set_param llite.*.xattr_cache=$cache
9287 for buf_size in 0 256; do
9289 touch $DIR/$tfile || error "touch"
9290 setfattr -n user.multiop $DIR/$tfile
9291 $MULTIOP $DIR/$tfile oa$buf_size ||
9292 error "cannot get zero length xattr value (buf_size = $buf_size)"
9296 restore_lustre_params < $save
9298 run_test 102t "zero length xattr values handled correctly"
9302 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
9307 [ "$UID" != 0 ] && skip "must run as root"
9308 $GSS && skip_env "could not run under gss"
9309 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
9310 skip_env "must have acl enabled"
9311 [ -z "$(which setfacl 2>/dev/null)" ] &&
9312 skip_env "could not find setfacl"
9313 remote_mds_nodsh && skip "remote MDS with nodsh"
9315 gpasswd -a daemon bin # LU-5641
9316 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
9318 declare -a identity_old
9320 for num in $(seq $MDSCOUNT); do
9321 switch_identity $num true || identity_old[$num]=$?
9329 echo "performing cp ..."
9330 run_acl_subtest cp || error "run_acl_subtest cp failed"
9331 echo "performing getfacl-noacl..."
9332 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
9333 echo "performing misc..."
9334 run_acl_subtest misc || error "misc test failed"
9335 echo "performing permissions..."
9336 run_acl_subtest permissions || error "permissions failed"
9337 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
9338 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
9339 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
9340 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
9342 echo "performing permissions xattr..."
9343 run_acl_subtest permissions_xattr ||
9344 error "permissions_xattr failed"
9346 echo "performing setfacl..."
9347 run_acl_subtest setfacl || error "setfacl test failed"
9349 # inheritance test got from HP
9350 echo "performing inheritance..."
9351 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
9352 chmod +x make-tree || error "chmod +x failed"
9353 run_acl_subtest inheritance || error "inheritance test failed"
9356 echo "LU-974 ignore umask when acl is enabled..."
9357 run_acl_subtest 974 || error "LU-974 umask test failed"
9358 if [ $MDSCOUNT -ge 2 ]; then
9359 run_acl_subtest 974_remote ||
9360 error "LU-974 umask test failed under remote dir"
9363 echo "LU-2561 newly created file is same size as directory..."
9364 if [ "$mds1_FSTYPE" != "zfs" ]; then
9365 run_acl_subtest 2561 || error "LU-2561 test failed"
9367 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
9370 run_acl_subtest 4924 || error "LU-4924 test failed"
9375 for num in $(seq $MDSCOUNT); do
9376 if [ "${identity_old[$num]}" = 1 ]; then
9377 switch_identity $num false || identity_old[$num]=$?
9381 run_test 103a "acl test"
9387 for U in {0..511}; do
9389 local O=$(printf "%04o" $U)
9391 umask $(printf "%04o" $((511 ^ $O)))
9392 $LFS setstripe -c 1 $DIR/$tfile.s$O
9393 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9395 (( $S == ($O & 0666) )) ||
9396 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9398 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9399 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9400 (( $S == ($O & 0666) )) ||
9401 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9403 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9404 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9405 (( $S == ($O & 0666) )) ||
9406 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9407 rm -f $DIR/$tfile.[smp]$0
9411 # limit the concurrently running threads to 64. LU-11878
9412 local idx=$((U % 64))
9413 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9418 run_test 103b "umask lfs setstripe"
9422 cp -rp $DIR/$tdir $DIR/$tdir.bak
9424 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9425 error "$DIR/$tdir shouldn't contain default ACL"
9426 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9427 error "$DIR/$tdir.bak shouldn't contain default ACL"
9430 run_test 103c "'cp -rp' won't set empty acl"
9433 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9436 lfs df || error "lfs df failed"
9437 lfs df -ih || error "lfs df -ih failed"
9438 lfs df -h $DIR || error "lfs df -h $DIR failed"
9439 lfs df -i $DIR || error "lfs df -i $DIR failed"
9440 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9441 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9443 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9444 lctl --device %$OSC deactivate
9445 lfs df || error "lfs df with deactivated OSC failed"
9446 lctl --device %$OSC activate
9447 # wait the osc back to normal
9448 wait_osc_import_ready client ost
9450 lfs df || error "lfs df with reactivated OSC failed"
9453 run_test 104a "lfs df [-ih] [path] test ========================="
9456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9457 [ $RUNAS_ID -eq $UID ] &&
9458 skip_env "RUNAS_ID = UID = $UID -- skipping"
9460 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
9461 grep "Permission denied" | wc -l)))
9462 if [ $denied_cnt -ne 0 ]; then
9463 error "lfs check servers test failed"
9466 run_test 104b "$RUNAS lfs check servers test ===================="
9469 # Verify $1 is within range of $2.
9470 # Success when $1 is within range. That is, when $1 is >= 2% of $2 and
9471 # $1 is <= 2% of $2. Else Fail.
9474 # Strip all units (M, G, T)
9475 actual=$(echo $1 | tr -d A-Z)
9476 expect=$(echo $2 | tr -d A-Z)
9478 expect_lo=$(($expect * 98 / 100)) # 2% below
9479 expect_hi=$(($expect * 102 / 100)) # 2% above
9481 # permit 2% drift above and below
9482 (( $actual >= $expect_lo && $actual <= $expect_hi ))
9486 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9487 [ "$ost1_FSTYPE" == "zfs" ] || skip "zfs only test"
9489 local ost_param="osd-zfs.$FSNAME-OST0000."
9490 local mdt_param="osd-zfs.$FSNAME-MDT0000."
9491 local ofacets=$(get_facets OST)
9492 local mfacets=$(get_facets MDS)
9493 local saved_ost_blocks=
9494 local saved_mdt_blocks=
9496 echo "Before recordsize change"
9497 lfs_df=($($LFS df -h | grep "filesystem_summary:"))
9498 df=($(df -h | grep "/mnt/lustre"$))
9501 echo "lfs output : ${lfs_df[*]}"
9502 echo "df output : ${df[*]}"
9504 for facet in ${ofacets//,/ }; do
9505 if [ -z $saved_ost_blocks ]; then
9506 saved_ost_blocks=$(do_facet $facet \
9507 lctl get_param -n $ost_param.blocksize)
9508 echo "OST Blocksize: $saved_ost_blocks"
9510 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
9511 do_facet $facet zfs set recordsize=32768 $ost
9514 # BS too small. Sufficient for functional testing.
9515 for facet in ${mfacets//,/ }; do
9516 if [ -z $saved_mdt_blocks ]; then
9517 saved_mdt_blocks=$(do_facet $facet \
9518 lctl get_param -n $mdt_param.blocksize)
9519 echo "MDT Blocksize: $saved_mdt_blocks"
9521 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
9522 do_facet $facet zfs set recordsize=32768 $mdt
9525 # Give new values chance to reflect change
9528 echo "After recordsize change"
9529 lfs_df_after=($($LFS df -h | grep "filesystem_summary:"))
9530 df_after=($(df -h | grep "/mnt/lustre"$))
9533 echo "lfs output : ${lfs_df_after[*]}"
9534 echo "df output : ${df_after[*]}"
9537 value_in_range ${lfs_df_after[1]%.*} ${lfs_df[1]%.*} ||
9538 error "lfs_df bytes: ${lfs_df_after[1]%.*} != ${lfs_df[1]%.*}"
9539 value_in_range ${lfs_df_after[2]%.*} ${lfs_df[2]%.*} ||
9540 error "lfs_df used: ${lfs_df_after[2]%.*} != ${lfs_df[2]%.*}"
9541 value_in_range ${lfs_df_after[3]%.*} ${lfs_df[3]%.*} ||
9542 error "lfs_df avail: ${lfs_df_after[3]%.*} != ${lfs_df[3]%.*}"
9545 value_in_range ${df_after[1]%.*} ${df[1]%.*} ||
9546 error "df bytes: ${df_after[1]%.*} != ${df[1]%.*}"
9547 value_in_range ${df_after[2]%.*} ${df[2]%.*} ||
9548 error "df used: ${df_after[2]%.*} != ${df[2]%.*}"
9549 value_in_range ${df_after[3]%.*} ${df[3]%.*} ||
9550 error "df avail: ${df_after[3]%.*} != ${df[3]%.*}"
9552 # Restore MDT recordize back to original
9553 for facet in ${mfacets//,/ }; do
9554 mdt=$(do_facet $facet lctl get_param -n $mdt_param.mntdev)
9555 do_facet $facet zfs set recordsize=$saved_mdt_blocks $mdt
9558 # Restore OST recordize back to original
9559 for facet in ${ofacets//,/ }; do
9560 ost=$(do_facet $facet lctl get_param -n $ost_param.mntdev)
9561 do_facet $facet zfs set recordsize=$saved_ost_blocks $ost
9566 run_test 104c "Verify df vs lfs_df stays same after recordsize change"
9569 # doesn't work on 2.4 kernels
9571 if $(flock_is_enabled); then
9572 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
9574 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
9578 run_test 105a "flock when mounted without -o flock test ========"
9582 if $(flock_is_enabled); then
9583 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
9585 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
9589 run_test 105b "fcntl when mounted without -o flock test ========"
9593 if $(flock_is_enabled); then
9594 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
9596 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
9600 run_test 105c "lockf when mounted without -o flock test"
9602 test_105d() { # bug 15924
9603 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9605 test_mkdir $DIR/$tdir
9606 flock_is_enabled || skip_env "mount w/o flock enabled"
9607 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
9608 $LCTL set_param fail_loc=0x80000315
9609 flocks_test 2 $DIR/$tdir
9611 run_test 105d "flock race (should not freeze) ========"
9613 test_105e() { # bug 22660 && 22040
9614 flock_is_enabled || skip_env "mount w/o flock enabled"
9617 flocks_test 3 $DIR/$tfile
9619 run_test 105e "Two conflicting flocks from same process"
9621 test_106() { #bug 10921
9622 test_mkdir $DIR/$tdir
9623 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
9624 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
9626 run_test 106 "attempt exec of dir followed by chown of that dir"
9629 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9637 local save_pattern=$(sysctl -n kernel.core_pattern)
9638 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
9639 sysctl -w kernel.core_pattern=$file
9640 sysctl -w kernel.core_uses_pid=0
9648 kill -s 11 $SLEEPPID
9650 if [ -e $file ]; then
9651 size=`stat -c%s $file`
9652 [ $size -eq 0 ] && error "Fail to create core file $file"
9654 error "Fail to create core file $file"
9657 sysctl -w kernel.core_pattern=$save_pattern
9658 sysctl -w kernel.core_uses_pid=$save_uses_pid
9661 run_test 107 "Coredump on SIG"
9664 test_mkdir $DIR/$tdir
9665 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
9666 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
9667 error "mkdir with 256 char should fail, but did not"
9668 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
9669 error "create with 255 char failed"
9670 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
9671 error "create with 256 char should fail, but did not"
9676 run_test 110 "filename length checking"
9679 # Purpose: To verify dynamic thread (OSS) creation.
9682 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9683 remote_ost_nodsh && skip "remote OST with nodsh"
9685 # Lustre does not stop service threads once they are started.
9686 # Reset number of running threads to default.
9691 local save_params="$TMP/sanity-$TESTNAME.parameters"
9693 # Get ll_ost_io count before I/O
9694 OSTIO_pre=$(do_facet ost1 \
9695 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9696 # Exit if lustre is not running (ll_ost_io not running).
9697 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9699 echo "Starting with $OSTIO_pre threads"
9700 local thread_max=$((OSTIO_pre * 2))
9701 local rpc_in_flight=$((thread_max * 2))
9702 # Number of I/O Process proposed to be started.
9704 local facets=$(get_facets OST)
9706 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9707 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9709 # Set in_flight to $rpc_in_flight
9710 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9711 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9712 nfiles=${rpc_in_flight}
9713 # Set ost thread_max to $thread_max
9714 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
9716 # 5 Minutes should be sufficient for max number of OSS
9717 # threads(thread_max) to be created.
9721 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
9722 test_mkdir $DIR/$tdir
9723 for i in $(seq $nfiles); do
9724 local file=$DIR/$tdir/${tfile}-$i
9725 $LFS setstripe -c -1 -i 0 $file
9726 ($WTL $file $timeout)&
9729 # I/O Started - Wait for thread_started to reach thread_max or report
9730 # error if thread_started is more than thread_max.
9731 echo "Waiting for thread_started to reach thread_max"
9732 local thread_started=0
9733 local end_time=$((SECONDS + timeout))
9735 while [ $SECONDS -le $end_time ] ; do
9737 # Get ost i/o thread_started count.
9738 thread_started=$(do_facet ost1 \
9740 ost.OSS.ost_io.threads_started | cut -d= -f2")
9741 # Break out if thread_started is equal/greater than thread_max
9742 if [[ $thread_started -ge $thread_max ]]; then
9743 echo ll_ost_io thread_started $thread_started, \
9744 equal/greater than thread_max $thread_max
9750 # Cleanup - We have the numbers, Kill i/o jobs if running.
9751 jobcount=($(jobs -p))
9752 for i in $(seq 0 $((${#jobcount[@]}-1)))
9754 kill -9 ${jobcount[$i]}
9755 if [ $? -ne 0 ] ; then
9757 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
9761 # Cleanup files left by WTL binary.
9762 for i in $(seq $nfiles); do
9763 local file=$DIR/$tdir/${tfile}-$i
9765 if [ $? -ne 0 ] ; then
9766 echo "Warning: Failed to delete file $file"
9770 restore_lustre_params <$save_params
9771 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
9773 # Error out if no new thread has started or Thread started is greater
9775 if [[ $thread_started -le $OSTIO_pre ||
9776 $thread_started -gt $thread_max ]]; then
9777 error "ll_ost_io: thread_started $thread_started" \
9778 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
9779 "No new thread started or thread started greater " \
9783 run_test 115 "verify dynamic thread creation===================="
9786 wait_delete_completed
9787 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
9788 echo "OST kbytes available: ${AVAIL[@]}"
9793 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
9794 #echo OST $i: ${AVAIL[i]}kb
9795 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
9799 if [[ ${AVAIL[i]} -lt $MINV ]]; then
9804 echo "Min free space: OST $MINI: $MINV"
9805 echo "Max free space: OST $MAXI: $MAXV"
9808 test_116a() { # was previously test_116()
9809 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9810 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9811 remote_mds_nodsh && skip "remote MDS with nodsh"
9813 echo -n "Free space priority "
9814 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
9819 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
9820 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
9821 trap simple_cleanup_common EXIT
9823 # Check if we need to generate uneven OSTs
9824 test_mkdir -p $DIR/$tdir/OST${MINI}
9825 local FILL=$((MINV / 4))
9826 local DIFF=$((MAXV - MINV))
9827 local DIFF2=$((DIFF * 100 / MINV))
9829 local threshold=$(do_facet $SINGLEMDS \
9830 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
9831 threshold=${threshold%%%}
9832 echo -n "Check for uneven OSTs: "
9833 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
9835 if [[ $DIFF2 -gt $threshold ]]; then
9837 echo "Don't need to fill OST$MINI"
9839 # generate uneven OSTs. Write 2% over the QOS threshold value
9841 DIFF=$((threshold - DIFF2 + 2))
9842 DIFF2=$((MINV * DIFF / 100))
9843 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
9844 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
9845 error "setstripe failed"
9846 DIFF=$((DIFF2 / 2048))
9848 while [ $i -lt $DIFF ]; do
9850 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
9851 bs=2M count=1 2>/dev/null
9860 DIFF=$((MAXV - MINV))
9861 DIFF2=$((DIFF * 100 / MINV))
9862 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
9863 if [ $DIFF2 -gt $threshold ]; then
9866 echo "failed - QOS mode won't be used"
9867 simple_cleanup_common
9868 skip "QOS imbalance criteria not met"
9876 # now fill using QOS
9877 $SETSTRIPE -c 1 $DIR/$tdir
9878 FILL=$((FILL / 200))
9879 if [ $FILL -gt 600 ]; then
9882 echo "writing $FILL files to QOS-assigned OSTs"
9884 while [ $i -lt $FILL ]; do
9886 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
9890 echo "wrote $i 200k files"
9894 echo "Note: free space may not be updated, so measurements might be off"
9896 DIFF2=$((MAXV - MINV))
9897 echo "free space delta: orig $DIFF final $DIFF2"
9898 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
9899 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
9900 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
9901 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
9902 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
9903 if [[ $DIFF -gt 0 ]]; then
9904 FILL=$((DIFF2 * 100 / DIFF - 100))
9905 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
9908 # Figure out which files were written where
9909 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9910 awk '/'$MINI1': / {print $2; exit}')
9912 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9913 echo "$MINC files created on smaller OST $MINI1"
9914 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9915 awk '/'$MAXI1': / {print $2; exit}')
9917 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9918 echo "$MAXC files created on larger OST $MAXI1"
9919 if [[ $MINC -gt 0 ]]; then
9920 FILL=$((MAXC * 100 / MINC - 100))
9921 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
9923 [[ $MAXC -gt $MINC ]] ||
9924 error_ignore LU-9 "stripe QOS didn't balance free space"
9925 simple_cleanup_common
9927 run_test 116a "stripe QOS: free space balance ==================="
9929 test_116b() { # LU-2093
9930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9931 remote_mds_nodsh && skip "remote MDS with nodsh"
9933 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
9934 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
9935 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
9936 [ -z "$old_rr" ] && skip "no QOS"
9937 do_facet $SINGLEMDS lctl set_param \
9938 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
9940 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
9941 createmany -o $DIR/$tdir/f- 20 || error "can't create"
9942 do_facet $SINGLEMDS lctl set_param fail_loc=0
9944 do_facet $SINGLEMDS lctl set_param \
9945 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
9947 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
9949 test_117() # bug 10891
9951 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9953 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
9954 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
9955 lctl set_param fail_loc=0x21e
9956 > $DIR/$tfile || error "truncate failed"
9957 lctl set_param fail_loc=0
9958 echo "Truncate succeeded."
9961 run_test 117 "verify osd extend =========="
9963 NO_SLOW_RESENDCOUNT=4
9964 export OLD_RESENDCOUNT=""
9965 set_resend_count () {
9966 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
9967 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
9968 lctl set_param -n $PROC_RESENDCOUNT $1
9969 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
9972 # for reduce test_118* time (b=14842)
9973 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9975 # Reset async IO behavior after error case
9977 FILE=$DIR/reset_async
9979 # Ensure all OSCs are cleared
9980 $SETSTRIPE -c -1 $FILE
9981 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
9986 test_118a() #bug 11710
9988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9992 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9993 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9994 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9996 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9997 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10002 run_test 118a "verify O_SYNC works =========="
10006 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10007 remote_ost_nodsh && skip "remote OST with nodsh"
10011 #define OBD_FAIL_SRV_ENOENT 0x217
10012 set_nodes_failloc "$(osts_nodes)" 0x217
10013 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10015 set_nodes_failloc "$(osts_nodes)" 0
10016 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10017 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10020 if [[ $RC -eq 0 ]]; then
10021 error "Must return error due to dropped pages, rc=$RC"
10025 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10026 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10030 echo "Dirty pages not leaked on ENOENT"
10032 # Due to the above error the OSC will issue all RPCs syncronously
10033 # until a subsequent RPC completes successfully without error.
10034 $MULTIOP $DIR/$tfile Ow4096yc
10039 run_test 118b "Reclaim dirty pages on fatal error =========="
10043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10045 # for 118c, restore the original resend count, LU-1940
10046 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
10047 set_resend_count $OLD_RESENDCOUNT
10048 remote_ost_nodsh && skip "remote OST with nodsh"
10052 #define OBD_FAIL_OST_EROFS 0x216
10053 set_nodes_failloc "$(osts_nodes)" 0x216
10055 # multiop should block due to fsync until pages are written
10056 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10060 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10061 error "Multiop failed to block on fsync, pid=$MULTIPID"
10064 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10066 if [[ $WRITEBACK -eq 0 ]]; then
10067 error "No page in writeback, writeback=$WRITEBACK"
10070 set_nodes_failloc "$(osts_nodes)" 0
10073 if [[ $RC -ne 0 ]]; then
10074 error "Multiop fsync failed, rc=$RC"
10077 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10078 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10080 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10081 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10085 echo "Dirty pages flushed via fsync on EROFS"
10088 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
10090 # continue to use small resend count to reduce test_118* time (b=14842)
10091 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10095 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10096 remote_ost_nodsh && skip "remote OST with nodsh"
10100 #define OBD_FAIL_OST_BRW_PAUSE_BULK
10101 set_nodes_failloc "$(osts_nodes)" 0x214
10102 # multiop should block due to fsync until pages are written
10103 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10107 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10108 error "Multiop failed to block on fsync, pid=$MULTIPID"
10111 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10113 if [[ $WRITEBACK -eq 0 ]]; then
10114 error "No page in writeback, writeback=$WRITEBACK"
10117 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
10118 set_nodes_failloc "$(osts_nodes)" 0
10120 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10121 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10123 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10124 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10128 echo "Dirty pages gaurenteed flushed via fsync"
10131 run_test 118d "Fsync validation inject a delay of the bulk =========="
10134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10138 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10139 lctl set_param fail_loc=0x8000040a
10141 # Should simulate EINVAL error which is fatal
10142 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10144 if [[ $RC -eq 0 ]]; then
10145 error "Must return error due to dropped pages, rc=$RC"
10148 lctl set_param fail_loc=0x0
10150 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10151 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10152 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10154 if [[ $LOCKED -ne 0 ]]; then
10155 error "Locked pages remain in cache, locked=$LOCKED"
10158 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10159 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10163 echo "No pages locked after fsync"
10168 run_test 118f "Simulate unrecoverable OSC side error =========="
10171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10175 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10176 lctl set_param fail_loc=0x406
10178 # simulate local -ENOMEM
10179 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10182 lctl set_param fail_loc=0
10183 if [[ $RC -eq 0 ]]; then
10184 error "Must return error due to dropped pages, rc=$RC"
10187 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10188 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10189 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10191 if [[ $LOCKED -ne 0 ]]; then
10192 error "Locked pages remain in cache, locked=$LOCKED"
10195 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10196 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10200 echo "No pages locked after fsync"
10205 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10208 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10209 remote_ost_nodsh && skip "remote OST with nodsh"
10213 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10214 set_nodes_failloc "$(osts_nodes)" 0x20e
10215 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10216 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10219 set_nodes_failloc "$(osts_nodes)" 0
10220 if [[ $RC -eq 0 ]]; then
10221 error "Must return error due to dropped pages, rc=$RC"
10224 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10225 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10226 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10228 if [[ $LOCKED -ne 0 ]]; then
10229 error "Locked pages remain in cache, locked=$LOCKED"
10232 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10233 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10237 echo "No pages locked after fsync"
10241 run_test 118h "Verify timeout in handling recoverables errors =========="
10243 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10246 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10247 remote_ost_nodsh && skip "remote OST with nodsh"
10251 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10252 set_nodes_failloc "$(osts_nodes)" 0x20e
10254 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10255 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10258 set_nodes_failloc "$(osts_nodes)" 0
10262 if [[ $RC -ne 0 ]]; then
10263 error "got error, but should be not, rc=$RC"
10266 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10267 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10268 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10269 if [[ $LOCKED -ne 0 ]]; then
10270 error "Locked pages remain in cache, locked=$LOCKED"
10273 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10274 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10278 echo "No pages locked after fsync"
10282 run_test 118i "Fix error before timeout in recoverable error =========="
10284 [ "$SLOW" = "no" ] && set_resend_count 4
10287 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10288 remote_ost_nodsh && skip "remote OST with nodsh"
10292 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
10293 set_nodes_failloc "$(osts_nodes)" 0x220
10295 # return -EIO from OST
10296 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10298 set_nodes_failloc "$(osts_nodes)" 0x0
10299 if [[ $RC -eq 0 ]]; then
10300 error "Must return error due to dropped pages, rc=$RC"
10303 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10304 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10305 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10306 if [[ $LOCKED -ne 0 ]]; then
10307 error "Locked pages remain in cache, locked=$LOCKED"
10310 # in recoverable error on OST we want resend and stay until it finished
10311 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10312 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10316 echo "No pages locked after fsync"
10320 run_test 118j "Simulate unrecoverable OST side error =========="
10324 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10325 remote_ost_nodsh && skip "remote OSTs with nodsh"
10327 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10328 set_nodes_failloc "$(osts_nodes)" 0x20e
10329 test_mkdir $DIR/$tdir
10331 for ((i=0;i<10;i++)); do
10332 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
10333 error "dd to $DIR/$tdir/$tfile-$i failed" )&
10340 set_nodes_failloc "$(osts_nodes)" 0
10343 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
10345 test_118l() # LU-646
10347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10349 test_mkdir $DIR/$tdir
10350 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
10353 run_test 118l "fsync dir"
10355 test_118m() # LU-3066
10357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10359 test_mkdir $DIR/$tdir
10360 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
10363 run_test 118m "fdatasync dir ========="
10365 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10372 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10373 remote_ost_nodsh && skip "remote OSTs with nodsh"
10375 # Sleep to avoid a cached response.
10376 #define OBD_STATFS_CACHE_SECONDS 1
10379 # Inject a 10 second delay in the OST_STATFS handler.
10380 #define OBD_FAIL_OST_STATFS_DELAY 0x242
10381 set_nodes_failloc "$(osts_nodes)" 0x242
10384 stat --file-system $MOUNT > /dev/null
10387 set_nodes_failloc "$(osts_nodes)" 0
10389 if ((end - begin > 20)); then
10390 error "statfs took $((end - begin)) seconds, expected 10"
10393 run_test 118n "statfs() sends OST_STATFS requests in parallel"
10395 test_119a() # bug 11737
10397 BSIZE=$((512 * 1024))
10398 directio write $DIR/$tfile 0 1 $BSIZE
10399 # We ask to read two blocks, which is more than a file size.
10400 # directio will indicate an error when requested and actual
10401 # sizes aren't equeal (a normal situation in this case) and
10402 # print actual read amount.
10403 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
10404 if [ "$NOB" != "$BSIZE" ]; then
10405 error "read $NOB bytes instead of $BSIZE"
10409 run_test 119a "Short directIO read must return actual read amount"
10411 test_119b() # bug 11737
10413 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10415 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
10416 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
10418 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
10419 error "direct read failed"
10422 run_test 119b "Sparse directIO read must return actual read amount"
10424 test_119c() # bug 13099
10427 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
10428 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
10431 run_test 119c "Testing for direct read hitting hole"
10433 test_119d() # bug 15950
10435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10437 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
10438 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
10440 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
10441 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
10442 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
10443 lctl set_param fail_loc=0x40d
10444 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
10447 cat $DIR/$tfile > /dev/null &
10448 lctl set_param fail_loc=0
10451 log "the DIO writes have completed, now wait for the reads (should not block very long)"
10453 [ -n "`ps h -p $pid_reads -o comm`" ] && \
10454 error "the read rpcs have not completed in 2s"
10456 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
10458 run_test 119d "The DIO path should try to send a new rpc once one is completed"
10461 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10462 remote_mds_nodsh && skip "remote MDS with nodsh"
10463 test_mkdir $DIR/$tdir
10464 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10465 skip_env "no early lock cancel on server"
10467 lru_resize_disable mdc
10468 lru_resize_disable osc
10469 cancel_lru_locks mdc
10470 # asynchronous object destroy at MDT could cause bl ast to client
10471 cancel_lru_locks osc
10473 stat $DIR/$tdir > /dev/null
10474 can1=$(do_facet $SINGLEMDS \
10475 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10476 awk '/ldlm_cancel/ {print $2}')
10477 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10478 awk '/ldlm_bl_callback/ {print $2}')
10479 test_mkdir -c1 $DIR/$tdir/d1
10480 can2=$(do_facet $SINGLEMDS \
10481 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10482 awk '/ldlm_cancel/ {print $2}')
10483 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10484 awk '/ldlm_bl_callback/ {print $2}')
10485 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10486 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10487 lru_resize_enable mdc
10488 lru_resize_enable osc
10490 run_test 120a "Early Lock Cancel: mkdir test"
10493 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10494 remote_mds_nodsh && skip "remote MDS with nodsh"
10495 test_mkdir $DIR/$tdir
10496 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10497 skip_env "no early lock cancel on server"
10499 lru_resize_disable mdc
10500 lru_resize_disable osc
10501 cancel_lru_locks mdc
10502 stat $DIR/$tdir > /dev/null
10503 can1=$(do_facet $SINGLEMDS \
10504 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10505 awk '/ldlm_cancel/ {print $2}')
10506 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10507 awk '/ldlm_bl_callback/ {print $2}')
10508 touch $DIR/$tdir/f1
10509 can2=$(do_facet $SINGLEMDS \
10510 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10511 awk '/ldlm_cancel/ {print $2}')
10512 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10513 awk '/ldlm_bl_callback/ {print $2}')
10514 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10515 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10516 lru_resize_enable mdc
10517 lru_resize_enable osc
10519 run_test 120b "Early Lock Cancel: create test"
10522 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10523 remote_mds_nodsh && skip "remote MDS with nodsh"
10524 test_mkdir -c1 $DIR/$tdir
10525 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10526 skip "no early lock cancel on server"
10528 lru_resize_disable mdc
10529 lru_resize_disable osc
10530 test_mkdir -c1 $DIR/$tdir/d1
10531 test_mkdir -c1 $DIR/$tdir/d2
10532 touch $DIR/$tdir/d1/f1
10533 cancel_lru_locks mdc
10534 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10535 can1=$(do_facet $SINGLEMDS \
10536 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10537 awk '/ldlm_cancel/ {print $2}')
10538 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10539 awk '/ldlm_bl_callback/ {print $2}')
10540 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10541 can2=$(do_facet $SINGLEMDS \
10542 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10543 awk '/ldlm_cancel/ {print $2}')
10544 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10545 awk '/ldlm_bl_callback/ {print $2}')
10546 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10547 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10548 lru_resize_enable mdc
10549 lru_resize_enable osc
10551 run_test 120c "Early Lock Cancel: link test"
10554 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10555 remote_mds_nodsh && skip "remote MDS with nodsh"
10556 test_mkdir -c1 $DIR/$tdir
10557 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10558 skip_env "no early lock cancel on server"
10560 lru_resize_disable mdc
10561 lru_resize_disable osc
10563 cancel_lru_locks mdc
10564 stat $DIR/$tdir > /dev/null
10565 can1=$(do_facet $SINGLEMDS \
10566 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10567 awk '/ldlm_cancel/ {print $2}')
10568 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10569 awk '/ldlm_bl_callback/ {print $2}')
10570 chmod a+x $DIR/$tdir
10571 can2=$(do_facet $SINGLEMDS \
10572 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10573 awk '/ldlm_cancel/ {print $2}')
10574 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10575 awk '/ldlm_bl_callback/ {print $2}')
10576 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10577 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10578 lru_resize_enable mdc
10579 lru_resize_enable osc
10581 run_test 120d "Early Lock Cancel: setattr test"
10584 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10585 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10586 skip_env "no early lock cancel on server"
10587 remote_mds_nodsh && skip "remote MDS with nodsh"
10589 local dlmtrace_set=false
10591 test_mkdir -c1 $DIR/$tdir
10592 lru_resize_disable mdc
10593 lru_resize_disable osc
10594 ! $LCTL get_param debug | grep -q dlmtrace &&
10595 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
10596 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
10597 cancel_lru_locks mdc
10598 cancel_lru_locks osc
10599 dd if=$DIR/$tdir/f1 of=/dev/null
10600 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
10601 # XXX client can not do early lock cancel of OST lock
10602 # during unlink (LU-4206), so cancel osc lock now.
10604 cancel_lru_locks osc
10605 can1=$(do_facet $SINGLEMDS \
10606 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10607 awk '/ldlm_cancel/ {print $2}')
10608 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10609 awk '/ldlm_bl_callback/ {print $2}')
10610 unlink $DIR/$tdir/f1
10612 can2=$(do_facet $SINGLEMDS \
10613 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10614 awk '/ldlm_cancel/ {print $2}')
10615 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10616 awk '/ldlm_bl_callback/ {print $2}')
10617 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
10618 $LCTL dk $TMP/cancel.debug.txt
10619 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
10620 $LCTL dk $TMP/blocking.debug.txt
10621 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
10622 lru_resize_enable mdc
10623 lru_resize_enable osc
10625 run_test 120e "Early Lock Cancel: unlink test"
10628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10629 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10630 skip_env "no early lock cancel on server"
10631 remote_mds_nodsh && skip "remote MDS with nodsh"
10633 test_mkdir -c1 $DIR/$tdir
10634 lru_resize_disable mdc
10635 lru_resize_disable osc
10636 test_mkdir -c1 $DIR/$tdir/d1
10637 test_mkdir -c1 $DIR/$tdir/d2
10638 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
10639 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
10640 cancel_lru_locks mdc
10641 cancel_lru_locks osc
10642 dd if=$DIR/$tdir/d1/f1 of=/dev/null
10643 dd if=$DIR/$tdir/d2/f2 of=/dev/null
10644 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
10645 # XXX client can not do early lock cancel of OST lock
10646 # during rename (LU-4206), so cancel osc lock now.
10648 cancel_lru_locks osc
10649 can1=$(do_facet $SINGLEMDS \
10650 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10651 awk '/ldlm_cancel/ {print $2}')
10652 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10653 awk '/ldlm_bl_callback/ {print $2}')
10654 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10656 can2=$(do_facet $SINGLEMDS \
10657 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10658 awk '/ldlm_cancel/ {print $2}')
10659 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10660 awk '/ldlm_bl_callback/ {print $2}')
10661 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10662 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10663 lru_resize_enable mdc
10664 lru_resize_enable osc
10666 run_test 120f "Early Lock Cancel: rename test"
10669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10670 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10671 skip_env "no early lock cancel on server"
10672 remote_mds_nodsh && skip "remote MDS with nodsh"
10674 lru_resize_disable mdc
10675 lru_resize_disable osc
10677 echo create $count files
10678 test_mkdir $DIR/$tdir
10679 cancel_lru_locks mdc
10680 cancel_lru_locks osc
10683 can0=$(do_facet $SINGLEMDS \
10684 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10685 awk '/ldlm_cancel/ {print $2}')
10686 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10687 awk '/ldlm_bl_callback/ {print $2}')
10688 createmany -o $DIR/$tdir/f $count
10690 can1=$(do_facet $SINGLEMDS \
10691 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10692 awk '/ldlm_cancel/ {print $2}')
10693 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10694 awk '/ldlm_bl_callback/ {print $2}')
10696 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
10697 echo rm $count files
10700 can2=$(do_facet $SINGLEMDS \
10701 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10702 awk '/ldlm_cancel/ {print $2}')
10703 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10704 awk '/ldlm_bl_callback/ {print $2}')
10706 echo total: $count removes in $((t2-t1))
10707 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
10709 # wait for commitment of removal
10710 lru_resize_enable mdc
10711 lru_resize_enable osc
10713 run_test 120g "Early Lock Cancel: performance test"
10715 test_121() { #bug #10589
10716 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10719 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
10720 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
10721 lctl set_param fail_loc=0x310
10722 cancel_lru_locks osc > /dev/null
10723 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
10724 lctl set_param fail_loc=0
10725 [[ $reads -eq $writes ]] ||
10726 error "read $reads blocks, must be $writes blocks"
10728 run_test 121 "read cancel race ========="
10730 test_123a() { # was test 123, statahead(bug 11401)
10731 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10734 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
10735 log "testing UP system. Performance may be lower than expected."
10740 test_mkdir $DIR/$tdir
10741 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
10742 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
10744 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
10745 createmany -o $DIR/$tdir/$tfile $j $((i - j))
10747 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10748 lctl set_param -n llite.*.statahead_max 0
10749 lctl get_param llite.*.statahead_max
10750 cancel_lru_locks mdc
10751 cancel_lru_locks osc
10753 time ls -l $DIR/$tdir | wc -l
10755 delta=$((etime - stime))
10756 log "ls $i files without statahead: $delta sec"
10757 lctl set_param llite.*.statahead_max=$max
10759 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10760 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
10761 cancel_lru_locks mdc
10762 cancel_lru_locks osc
10764 time ls -l $DIR/$tdir | wc -l
10766 delta_sa=$((etime - stime))
10767 log "ls $i files with statahead: $delta_sa sec"
10768 lctl get_param -n llite.*.statahead_stats
10769 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10771 [[ $swrong -lt $ewrong ]] &&
10772 log "statahead was stopped, maybe too many locks held!"
10773 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
10775 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10776 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10777 lctl set_param -n llite.*.statahead_max 0
10778 lctl get_param llite.*.statahead_max
10779 cancel_lru_locks mdc
10780 cancel_lru_locks osc
10782 time ls -l $DIR/$tdir | wc -l
10784 delta=$((etime - stime))
10785 log "ls $i files again without statahead: $delta sec"
10786 lctl set_param llite.*.statahead_max=$max
10787 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10788 if [ $SLOWOK -eq 0 ]; then
10789 error "ls $i files is slower with statahead!"
10791 log "ls $i files is slower with statahead!"
10797 [ $delta -gt 20 ] && break
10798 [ $delta -gt 8 ] && MULT=$((50 / delta))
10799 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
10807 delta=$((etime - stime))
10808 log "rm -r $DIR/$tdir/: $delta seconds"
10810 lctl get_param -n llite.*.statahead_stats
10812 run_test 123a "verify statahead work"
10814 test_123b () { # statahead(bug 15027)
10815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10817 test_mkdir $DIR/$tdir
10818 createmany -o $DIR/$tdir/$tfile-%d 1000
10820 cancel_lru_locks mdc
10821 cancel_lru_locks osc
10823 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
10824 lctl set_param fail_loc=0x80000803
10825 ls -lR $DIR/$tdir > /dev/null
10827 lctl set_param fail_loc=0x0
10828 lctl get_param -n llite.*.statahead_stats
10833 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
10836 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
10838 test_mkdir -i 0 -c 1 $DIR/$tdir.0
10839 test_mkdir -i 1 -c 1 $DIR/$tdir.1
10840 touch $DIR/$tdir.1/{1..3}
10841 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
10843 remount_client $MOUNT
10845 $MULTIOP $DIR/$tdir.0 Q
10847 # let statahead to complete
10848 ls -l $DIR/$tdir.0 > /dev/null
10850 testid=$(echo $TESTNAME | tr '_' ' ')
10851 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
10852 error "statahead warning" || true
10854 run_test 123c "Can not initialize inode warning on DNE statahead"
10857 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10858 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10859 skip_env "no lru resize on server"
10863 test_mkdir $DIR/$tdir
10865 log "create $NR files at $DIR/$tdir"
10866 createmany -o $DIR/$tdir/f $NR ||
10867 error "failed to create $NR files in $DIR/$tdir"
10869 cancel_lru_locks mdc
10870 ls -l $DIR/$tdir > /dev/null
10874 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
10875 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
10876 LRU_SIZE=$($LCTL get_param -n $PARAM)
10877 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
10878 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
10880 log "NS=$(basename $NSDIR)"
10885 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
10886 skip "Not enough cached locks created!"
10888 log "LRU=$LRU_SIZE"
10892 # We know that lru resize allows one client to hold $LIMIT locks
10893 # for 10h. After that locks begin to be killed by client.
10895 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
10897 if [ $LIMIT -lt $LRU_SIZE ]; then
10898 skip "Limit is too small $LIMIT"
10901 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
10902 # killing locks. Some time was spent for creating locks. This means
10903 # that up to the moment of sleep finish we must have killed some of
10904 # them (10-100 locks). This depends on how fast ther were created.
10905 # Many of them were touched in almost the same moment and thus will
10906 # be killed in groups.
10907 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
10909 # Use $LRU_SIZE_B here to take into account real number of locks
10910 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
10911 local LRU_SIZE_B=$LRU_SIZE
10913 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
10914 log "OLD_LVF=$OLD_LVF"
10915 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
10917 # Let's make sure that we really have some margin. Client checks
10918 # cached locks every 10 sec.
10919 SLEEP=$((SLEEP+20))
10920 log "Sleep ${SLEEP} sec"
10922 while ((SEC<$SLEEP)); do
10926 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
10927 echo -n "$LRU_SIZE"
10930 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
10931 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
10933 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
10934 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
10935 unlinkmany $DIR/$tdir/f $NR
10939 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
10940 log "unlink $NR files at $DIR/$tdir"
10941 unlinkmany $DIR/$tdir/f $NR
10943 run_test 124a "lru resize ======================================="
10945 get_max_pool_limit()
10947 local limit=$($LCTL get_param \
10948 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
10950 for l in $limit; do
10951 if [[ $l -gt $max ]]; then
10959 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10960 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10961 skip_env "no lru resize on server"
10963 LIMIT=$(get_max_pool_limit)
10965 NR=$(($(default_lru_size)*20))
10966 if [[ $NR -gt $LIMIT ]]; then
10967 log "Limit lock number by $LIMIT locks"
10971 IFree=$(mdsrate_inodes_available)
10972 if [ $IFree -lt $NR ]; then
10973 log "Limit lock number by $IFree inodes"
10977 lru_resize_disable mdc
10978 test_mkdir -p $DIR/$tdir/disable_lru_resize
10980 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
10981 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
10982 cancel_lru_locks mdc
10985 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10988 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10991 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10995 nolruresize_delta=$((etime-stime))
10996 log "ls -la time: $nolruresize_delta seconds"
10997 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10998 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
11000 lru_resize_enable mdc
11001 test_mkdir -p $DIR/$tdir/enable_lru_resize
11003 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
11004 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
11005 cancel_lru_locks mdc
11008 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11011 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11014 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11018 lruresize_delta=$((etime-stime))
11019 log "ls -la time: $lruresize_delta seconds"
11020 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11022 if [ $lruresize_delta -gt $nolruresize_delta ]; then
11023 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
11024 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
11025 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
11027 log "lru resize performs the same with no lru resize"
11029 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
11031 run_test 124b "lru resize (performance test) ======================="
11034 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11035 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11036 skip_env "no lru resize on server"
11038 # cache ununsed locks on client
11040 cancel_lru_locks mdc
11041 test_mkdir $DIR/$tdir
11042 createmany -o $DIR/$tdir/f $nr ||
11043 error "failed to create $nr files in $DIR/$tdir"
11044 ls -l $DIR/$tdir > /dev/null
11046 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11047 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11048 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11049 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11050 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11052 # set lru_max_age to 1 sec
11053 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11054 echo "sleep $((recalc_p * 2)) seconds..."
11055 sleep $((recalc_p * 2))
11057 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11058 # restore lru_max_age
11059 $LCTL set_param -n $nsdir.lru_max_age $max_age
11060 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11061 unlinkmany $DIR/$tdir/f $nr
11063 run_test 124c "LRUR cancel very aged locks"
11066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11067 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11068 skip_env "no lru resize on server"
11070 # cache ununsed locks on client
11073 lru_resize_disable mdc
11074 stack_trap "lru_resize_enable mdc" EXIT
11076 cancel_lru_locks mdc
11078 # asynchronous object destroy at MDT could cause bl ast to client
11079 test_mkdir $DIR/$tdir
11080 createmany -o $DIR/$tdir/f $nr ||
11081 error "failed to create $nr files in $DIR/$tdir"
11082 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
11084 ls -l $DIR/$tdir > /dev/null
11086 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11087 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11088 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11089 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11091 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11093 # set lru_max_age to 1 sec
11094 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11095 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
11097 echo "sleep $((recalc_p * 2)) seconds..."
11098 sleep $((recalc_p * 2))
11100 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11102 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11104 run_test 124d "cancel very aged locks if lru-resize diasbaled"
11106 test_125() { # 13358
11107 $LCTL get_param -n llite.*.client_type | grep -q local ||
11108 skip "must run as local client"
11109 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
11110 skip_env "must have acl enabled"
11111 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11113 test_mkdir $DIR/$tdir
11114 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
11115 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
11116 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
11118 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
11120 test_126() { # bug 12829/13455
11121 $GSS && skip_env "must run as gss disabled"
11122 $LCTL get_param -n llite.*.client_type | grep -q local ||
11123 skip "must run as local client"
11124 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
11126 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
11127 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
11129 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
11131 run_test 126 "check that the fsgid provided by the client is taken into account"
11133 test_127a() { # bug 15521
11134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11136 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
11137 $LCTL set_param osc.*.stats=0
11138 FSIZE=$((2048 * 1024))
11139 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
11140 cancel_lru_locks osc
11141 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
11143 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
11144 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
11145 echo "got $COUNT $NAME"
11146 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
11147 eval $NAME=$COUNT || error "Wrong proc format"
11150 read_bytes|write_bytes)
11151 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
11152 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
11153 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
11154 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
11155 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
11156 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
11157 error "sumsquare is too small: $SUMSQ"
11158 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
11159 error "sumsquare is too big: $SUMSQ"
11163 done < $DIR/${tfile}.tmp
11165 #check that we actually got some stats
11166 [ "$read_bytes" ] || error "Missing read_bytes stats"
11167 [ "$write_bytes" ] || error "Missing write_bytes stats"
11168 [ "$read_bytes" != 0 ] || error "no read done"
11169 [ "$write_bytes" != 0 ] || error "no write done"
11171 run_test 127a "verify the client stats are sane"
11173 test_127b() { # bug LU-333
11174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11175 local name count samp unit min max sum sumsq
11177 $LCTL set_param llite.*.stats=0
11179 # perform 2 reads and writes so MAX is different from SUM.
11180 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11181 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11182 cancel_lru_locks osc
11183 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11184 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11186 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11187 while read name count samp unit min max sum sumsq; do
11188 echo "got $count $name"
11189 eval $name=$count || error "Wrong proc format"
11193 [ $count -ne 2 ] && error "count is not 2: $count"
11194 [ $min -ne $PAGE_SIZE ] &&
11195 error "min is not $PAGE_SIZE: $min"
11196 [ $max -ne $PAGE_SIZE ] &&
11197 error "max is incorrect: $max"
11198 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11199 error "sum is wrong: $sum"
11202 [ $count -ne 2 ] && error "count is not 2: $count"
11203 [ $min -ne $PAGE_SIZE ] &&
11204 error "min is not $PAGE_SIZE: $min"
11205 [ $max -ne $PAGE_SIZE ] &&
11206 error "max is incorrect: $max"
11207 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11208 error "sum is wrong: $sum"
11212 done < $TMP/$tfile.tmp
11214 #check that we actually got some stats
11215 [ "$read_bytes" ] || error "Missing read_bytes stats"
11216 [ "$write_bytes" ] || error "Missing write_bytes stats"
11217 [ "$read_bytes" != 0 ] || error "no read done"
11218 [ "$write_bytes" != 0 ] || error "no write done"
11220 rm -f $TMP/${tfile}.tmp
11222 run_test 127b "verify the llite client stats are sane"
11224 test_127c() { # LU-12394
11225 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11232 $LCTL set_param llite.*.extents_stats=1
11233 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
11235 # Use two stripes so there is enough space in default config
11236 $LFS setstripe -c 2 $DIR/$tfile
11238 # Extent stats start at 0-4K and go in power of two buckets
11239 # LL_HIST_START = 12 --> 2^12 = 4K
11240 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
11241 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
11243 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
11245 # Write and read, 2x each, second time at a non-zero offset
11246 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
11247 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
11248 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
11249 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
11253 $LCTL get_param llite.*.extents_stats
11256 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
11258 local bucket=$($LCTL get_param -n llite.*.extents_stats |
11260 reads=$(echo $bucket | awk '{print $5}')
11261 writes=$(echo $bucket | awk '{print $9}')
11262 [ "$reads" -eq $count ] ||
11263 error "$reads reads in < $bsize bucket, expect $count"
11264 [ "$writes" -eq $count ] ||
11265 error "$writes writes in < $bsize bucket, expect $count"
11268 # Test mmap write and read
11269 $LCTL set_param llite.*.extents_stats=c
11271 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
11272 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
11273 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
11275 $LCTL get_param llite.*.extents_stats
11277 count=$(((size*1024) / PAGE_SIZE))
11279 bsize=$((2 * PAGE_SIZE / 1024))K
11281 bucket=$($LCTL get_param -n llite.*.extents_stats |
11283 reads=$(echo $bucket | awk '{print $5}')
11284 writes=$(echo $bucket | awk '{print $9}')
11285 # mmap writes fault in the page first, creating an additonal read
11286 [ "$reads" -eq $((2 * count)) ] ||
11287 error "$reads reads in < $bsize bucket, expect $count"
11288 [ "$writes" -eq $count ] ||
11289 error "$writes writes in < $bsize bucket, expect $count"
11291 run_test 127c "test llite extent stats with regular & mmap i/o"
11293 test_128() { # bug 15212
11295 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
11300 result=$(grep error $TMP/$tfile.log)
11301 rm -f $DIR/$tfile $TMP/$tfile.log
11302 [ -z "$result" ] ||
11303 error "consecutive find's under interactive lfs failed"
11305 run_test 128 "interactive lfs for 2 consecutive find's"
11307 set_dir_limits () {
11312 local ldproc=/proc/fs/ldiskfs
11313 local facets=$(get_facets MDS)
11315 for facet in ${facets//,/ }; do
11316 canondev=$(ldiskfs_canon \
11317 *.$(convert_facet2label $facet).mntdev $facet)
11318 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
11319 ldproc=/sys/fs/ldiskfs
11320 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
11321 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
11325 check_mds_dmesg() {
11326 local facets=$(get_facets MDS)
11327 for facet in ${facets//,/ }; do
11328 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
11334 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11335 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
11336 skip "Need MDS version with at least 2.5.56"
11337 if [ "$mds1_FSTYPE" != ldiskfs ]; then
11338 skip_env "ldiskfs only test"
11340 remote_mds_nodsh && skip "remote MDS with nodsh"
11344 local has_warning=false
11347 mkdir -p $DIR/$tdir
11349 # block size of mds1
11350 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
11351 set_dir_limits $maxsize $maxsize
11352 local dirsize=$(stat -c%s "$DIR/$tdir")
11354 while [[ $dirsize -le $maxsize ]]; do
11355 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
11357 if ! $has_warning; then
11358 check_mds_dmesg '"is approaching"' && has_warning=true
11360 # check two errors:
11361 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
11362 # EFBIG for previous versions included in ldiskfs series
11363 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
11365 echo "return code $rc received as expected"
11367 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
11368 error_exit "create failed w/o dir size limit"
11370 check_mds_dmesg '"has reached"' ||
11371 error_exit "reached message should be output"
11373 [ $has_warning = "false" ] &&
11374 error_exit "warning message should be output"
11376 dirsize=$(stat -c%s "$DIR/$tdir")
11378 [[ $dirsize -ge $maxsize ]] && return 0
11379 error_exit "current dir size $dirsize, " \
11380 "previous limit $maxsize"
11381 elif [ $rc -ne 0 ]; then
11383 error_exit "return $rc received instead of expected " \
11384 "$EFBIG or $ENOSPC, files in dir $dirsize"
11386 nfiles=$((nfiles + 1))
11387 dirsize=$(stat -c%s "$DIR/$tdir")
11391 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
11393 run_test 129 "test directory size limit ========================"
11402 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11403 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11405 trap cleanup_130 EXIT RETURN
11407 local fm_file=$DIR/$tfile
11408 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
11409 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
11410 error "dd failed for $fm_file"
11412 # LU-1795: test filefrag/FIEMAP once, even if unsupported
11413 filefrag -ves $fm_file
11415 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11416 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11417 [ $RC != 0 ] && error "filefrag $fm_file failed"
11419 filefrag_op=$(filefrag -ve -k $fm_file |
11420 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11421 lun=$($GETSTRIPE -i $fm_file)
11423 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
11426 for line in $filefrag_op
11428 frag_lun=`echo $line | cut -d: -f5`
11429 ext_len=`echo $line | cut -d: -f4`
11430 if (( $frag_lun != $lun )); then
11432 error "FIEMAP on 1-stripe file($fm_file) failed"
11435 (( tot_len += ext_len ))
11438 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
11440 error "FIEMAP on 1-stripe file($fm_file) failed;"
11446 echo "FIEMAP on single striped file succeeded"
11448 run_test 130a "FIEMAP (1-stripe file)"
11451 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11453 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11454 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11456 trap cleanup_130 EXIT RETURN
11458 local fm_file=$DIR/$tfile
11459 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
11460 error "setstripe on $fm_file"
11461 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11462 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11464 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
11465 error "dd failed on $fm_file"
11467 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11468 filefrag_op=$(filefrag -ve -k $fm_file |
11469 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11471 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11472 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11477 for line in $filefrag_op
11479 frag_lun=$(echo $line | cut -d: -f5 |
11480 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11481 ext_len=$(echo $line | cut -d: -f4)
11482 if (( $frag_lun != $last_lun )); then
11483 if (( tot_len != 1024 )); then
11485 error "FIEMAP on $fm_file failed; returned " \
11486 "len $tot_len for OST $last_lun instead of 1024"
11489 (( num_luns += 1 ))
11493 (( tot_len += ext_len ))
11496 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
11498 error "FIEMAP on $fm_file failed; returned wrong number of " \
11499 "luns or wrong len for OST $last_lun"
11505 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
11507 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
11510 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11512 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11513 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11515 trap cleanup_130 EXIT RETURN
11517 local fm_file=$DIR/$tfile
11518 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
11519 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11520 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11522 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
11523 error "dd failed on $fm_file"
11525 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11526 filefrag_op=$(filefrag -ve -k $fm_file |
11527 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11529 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11530 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11535 for line in $filefrag_op
11537 frag_lun=$(echo $line | cut -d: -f5 |
11538 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11539 ext_len=$(echo $line | cut -d: -f4)
11540 if (( $frag_lun != $last_lun )); then
11541 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
11542 if (( logical != 512 )); then
11544 error "FIEMAP on $fm_file failed; returned " \
11545 "logical start for lun $logical instead of 512"
11548 if (( tot_len != 512 )); then
11550 error "FIEMAP on $fm_file failed; returned " \
11551 "len $tot_len for OST $last_lun instead of 1024"
11554 (( num_luns += 1 ))
11558 (( tot_len += ext_len ))
11561 if (( num_luns != 2 || tot_len != 512 )); then
11563 error "FIEMAP on $fm_file failed; returned wrong number of " \
11564 "luns or wrong len for OST $last_lun"
11570 echo "FIEMAP on 2-stripe file with hole succeeded"
11572 run_test 130c "FIEMAP (2-stripe file with hole)"
11575 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
11577 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11578 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11580 trap cleanup_130 EXIT RETURN
11582 local fm_file=$DIR/$tfile
11583 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
11584 error "setstripe on $fm_file"
11585 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11586 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11588 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
11589 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
11590 error "dd failed on $fm_file"
11592 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11593 filefrag_op=$(filefrag -ve -k $fm_file |
11594 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11596 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11597 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11602 for line in $filefrag_op
11604 frag_lun=$(echo $line | cut -d: -f5 |
11605 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11606 ext_len=$(echo $line | cut -d: -f4)
11607 if (( $frag_lun != $last_lun )); then
11608 if (( tot_len != 1024 )); then
11610 error "FIEMAP on $fm_file failed; returned " \
11611 "len $tot_len for OST $last_lun instead of 1024"
11614 (( num_luns += 1 ))
11618 (( tot_len += ext_len ))
11621 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
11623 error "FIEMAP on $fm_file failed; returned wrong number of " \
11624 "luns or wrong len for OST $last_lun"
11630 echo "FIEMAP on N-stripe file succeeded"
11632 run_test 130d "FIEMAP (N-stripe file)"
11635 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11637 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11638 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11640 trap cleanup_130 EXIT RETURN
11642 local fm_file=$DIR/$tfile
11643 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
11644 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11645 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11648 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
11649 for ((i = 0; i < $NUM_BLKS; i++))
11651 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
11654 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11655 filefrag_op=$(filefrag -ve -k $fm_file |
11656 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11658 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11659 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11664 for line in $filefrag_op
11666 frag_lun=$(echo $line | cut -d: -f5 |
11667 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11668 ext_len=$(echo $line | cut -d: -f4)
11669 if (( $frag_lun != $last_lun )); then
11670 if (( tot_len != $EXPECTED_LEN )); then
11672 error "FIEMAP on $fm_file failed; returned " \
11673 "len $tot_len for OST $last_lun instead " \
11677 (( num_luns += 1 ))
11681 (( tot_len += ext_len ))
11684 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
11686 error "FIEMAP on $fm_file failed; returned wrong number " \
11687 "of luns or wrong len for OST $last_lun"
11693 echo "FIEMAP with continuation calls succeeded"
11695 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
11698 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11699 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11701 local fm_file=$DIR/$tfile
11702 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
11703 error "multiop create with lov_delay_create on $fm_file"
11705 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11706 filefrag_extents=$(filefrag -vek $fm_file |
11707 awk '/extents? found/ { print $2 }')
11708 if [[ "$filefrag_extents" != "0" ]]; then
11709 error "FIEMAP on $fm_file failed; " \
11710 "returned $filefrag_extents expected 0"
11715 run_test 130f "FIEMAP (unstriped file)"
11717 # Test for writev/readv
11719 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
11720 error "writev test failed"
11721 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
11722 error "readv failed"
11725 run_test 131a "test iov's crossing stripe boundary for writev/readv"
11728 local fsize=$((524288 + 1048576 + 1572864))
11729 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
11730 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11731 error "append writev test failed"
11733 ((fsize += 1572864 + 1048576))
11734 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
11735 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11736 error "append writev test failed"
11739 run_test 131b "test append writev"
11742 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
11745 run_test 131c "test read/write on file w/o objects"
11748 rwv -f $DIR/$tfile -w -n 1 1572864
11749 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
11750 if [ "$NOB" != 1572864 ]; then
11751 error "Short read filed: read $NOB bytes instead of 1572864"
11755 run_test 131d "test short read"
11758 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
11759 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
11760 error "read hitting hole failed"
11763 run_test 131e "test read hitting hole"
11772 mds*) res=$(do_facet $facet \
11773 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
11775 ost*) res=$(do_facet $facet \
11776 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
11778 *) error "Wrong facet '$facet'" ;;
11780 [ "$res" ] || error "The counter for $op on $facet was not incremented"
11781 # if the argument $3 is zero, it means any stat increment is ok.
11782 if [[ $want -gt 0 ]]; then
11783 local count=$(echo $res | awk '{ print $2 }')
11784 [[ $count -ne $want ]] &&
11785 error "The $op counter on $facet is $count, not $want"
11790 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11791 remote_ost_nodsh && skip "remote OST with nodsh"
11792 remote_mds_nodsh && skip "remote MDS with nodsh"
11793 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11794 skip_env "MDS doesn't support rename stats"
11796 local testdir=$DIR/${tdir}/stats_testdir
11798 mkdir -p $DIR/${tdir}
11801 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11802 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11804 # verify mdt stats first.
11805 mkdir ${testdir} || error "mkdir failed"
11806 check_stats $SINGLEMDS "mkdir" 1
11807 touch ${testdir}/${tfile} || error "touch failed"
11808 check_stats $SINGLEMDS "open" 1
11809 check_stats $SINGLEMDS "close" 1
11810 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
11811 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
11812 check_stats $SINGLEMDS "mknod" 2
11814 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
11815 check_stats $SINGLEMDS "unlink" 1
11816 rm -f ${testdir}/${tfile} || error "file remove failed"
11817 check_stats $SINGLEMDS "unlink" 2
11819 # remove working dir and check mdt stats again.
11820 rmdir ${testdir} || error "rmdir failed"
11821 check_stats $SINGLEMDS "rmdir" 1
11823 local testdir1=$DIR/${tdir}/stats_testdir1
11824 mkdir -p ${testdir}
11825 mkdir -p ${testdir1}
11826 touch ${testdir1}/test1
11827 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
11828 check_stats $SINGLEMDS "crossdir_rename" 1
11830 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
11831 check_stats $SINGLEMDS "samedir_rename" 1
11833 rm -rf $DIR/${tdir}
11835 run_test 133a "Verifying MDT stats ========================================"
11840 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11841 remote_ost_nodsh && skip "remote OST with nodsh"
11842 remote_mds_nodsh && skip "remote MDS with nodsh"
11844 local testdir=$DIR/${tdir}/stats_testdir
11846 mkdir -p ${testdir} || error "mkdir failed"
11847 touch ${testdir}/${tfile} || error "touch failed"
11848 cancel_lru_locks mdc
11851 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11852 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11854 # extra mdt stats verification.
11855 chmod 444 ${testdir}/${tfile} || error "chmod failed"
11856 check_stats $SINGLEMDS "setattr" 1
11857 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11858 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
11860 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
11861 check_stats $SINGLEMDS "getattr" 1
11863 rm -rf $DIR/${tdir}
11865 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
11866 # so the check below is not reliable
11867 [ $MDSCOUNT -eq 1 ] || return 0
11869 # Sleep to avoid a cached response.
11870 #define OBD_STATFS_CACHE_SECONDS 1
11872 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11873 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11874 $LFS df || error "lfs failed"
11875 check_stats $SINGLEMDS "statfs" 1
11877 # check aggregated statfs (LU-10018)
11878 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
11880 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
11883 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11884 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11886 check_stats $SINGLEMDS "statfs" 1
11888 # We want to check that the client didn't send OST_STATFS to
11889 # ost1 but the MDT also uses OST_STATFS for precreate. So some
11890 # extra care is needed here.
11891 if remote_mds; then
11892 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
11893 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
11895 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
11896 [ "$res" ] && error "OST got STATFS"
11901 run_test 133b "Verifying extra MDT stats =================================="
11904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11905 remote_ost_nodsh && skip "remote OST with nodsh"
11906 remote_mds_nodsh && skip "remote MDS with nodsh"
11908 local testdir=$DIR/$tdir/stats_testdir
11910 test_mkdir -p $testdir
11912 # verify obdfilter stats.
11913 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
11915 cancel_lru_locks osc
11916 wait_delete_completed
11919 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11920 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11922 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
11925 cancel_lru_locks osc
11926 check_stats ost1 "write" 1
11928 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
11929 check_stats ost1 "read" 1
11931 > $testdir/$tfile || error "truncate failed"
11932 check_stats ost1 "punch" 1
11934 rm -f $testdir/$tfile || error "file remove failed"
11935 wait_delete_completed
11936 check_stats ost1 "destroy" 1
11940 run_test 133c "Verifying OST stats ========================================"
11947 while [ $value -ge 2 ]; do
11952 if [ $orig -gt $order ]; then
11960 local size=('K' 'M' 'G' 'T');
11962 local size_string=$value
11964 while [ $value -ge 1024 ]; do
11965 if [ $i -gt 3 ]; then
11966 #T is the biggest unit we get here, if that is bigger,
11968 size_string=${value}T
11971 value=$((value >> 10))
11972 if [ $value -lt 1024 ]; then
11973 size_string=${value}${size[$i]}
11982 get_rename_size() {
11984 local context=${2:-.}
11985 local sample=$(do_facet $SINGLEMDS $LCTL \
11986 get_param mdt.$FSNAME-MDT0000.rename_stats |
11987 grep -A1 $context |
11988 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
11993 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11994 remote_ost_nodsh && skip "remote OST with nodsh"
11995 remote_mds_nodsh && skip "remote MDS with nodsh"
11996 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11997 skip_env "MDS doesn't support rename stats"
11999 local testdir1=$DIR/${tdir}/stats_testdir1
12000 local testdir2=$DIR/${tdir}/stats_testdir2
12001 mkdir -p $DIR/${tdir}
12003 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12005 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
12006 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
12008 createmany -o $testdir1/test 512 || error "createmany failed"
12010 # check samedir rename size
12011 mv ${testdir1}/test0 ${testdir1}/test_0
12013 local testdir1_size=$(ls -l $DIR/${tdir} |
12014 awk '/stats_testdir1/ {print $5}')
12015 local testdir2_size=$(ls -l $DIR/${tdir} |
12016 awk '/stats_testdir2/ {print $5}')
12018 testdir1_size=$(order_2 $testdir1_size)
12019 testdir2_size=$(order_2 $testdir2_size)
12021 testdir1_size=$(size_in_KMGT $testdir1_size)
12022 testdir2_size=$(size_in_KMGT $testdir2_size)
12024 echo "source rename dir size: ${testdir1_size}"
12025 echo "target rename dir size: ${testdir2_size}"
12027 local cmd="do_facet $SINGLEMDS $LCTL "
12028 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
12030 eval $cmd || error "$cmd failed"
12031 local samedir=$($cmd | grep 'same_dir')
12032 local same_sample=$(get_rename_size $testdir1_size)
12033 [ -z "$samedir" ] && error "samedir_rename_size count error"
12034 [[ $same_sample -eq 1 ]] ||
12035 error "samedir_rename_size error $same_sample"
12036 echo "Check same dir rename stats success"
12038 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12040 # check crossdir rename size
12041 mv ${testdir1}/test_0 ${testdir2}/test_0
12043 testdir1_size=$(ls -l $DIR/${tdir} |
12044 awk '/stats_testdir1/ {print $5}')
12045 testdir2_size=$(ls -l $DIR/${tdir} |
12046 awk '/stats_testdir2/ {print $5}')
12048 testdir1_size=$(order_2 $testdir1_size)
12049 testdir2_size=$(order_2 $testdir2_size)
12051 testdir1_size=$(size_in_KMGT $testdir1_size)
12052 testdir2_size=$(size_in_KMGT $testdir2_size)
12054 echo "source rename dir size: ${testdir1_size}"
12055 echo "target rename dir size: ${testdir2_size}"
12057 eval $cmd || error "$cmd failed"
12058 local crossdir=$($cmd | grep 'crossdir')
12059 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
12060 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
12061 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
12062 [[ $src_sample -eq 1 ]] ||
12063 error "crossdir_rename_size error $src_sample"
12064 [[ $tgt_sample -eq 1 ]] ||
12065 error "crossdir_rename_size error $tgt_sample"
12066 echo "Check cross dir rename stats success"
12067 rm -rf $DIR/${tdir}
12069 run_test 133d "Verifying rename_stats ========================================"
12072 remote_mds_nodsh && skip "remote MDS with nodsh"
12073 remote_ost_nodsh && skip "remote OST with nodsh"
12074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12076 local testdir=$DIR/${tdir}/stats_testdir
12077 local ctr f0 f1 bs=32768 count=42 sum
12079 mkdir -p ${testdir} || error "mkdir failed"
12081 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
12083 for ctr in {write,read}_bytes; do
12085 cancel_lru_locks osc
12087 do_facet ost1 $LCTL set_param -n \
12088 "obdfilter.*.exports.clear=clear"
12090 if [ $ctr = write_bytes ]; then
12092 f1=${testdir}/${tfile}
12094 f0=${testdir}/${tfile}
12098 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
12101 cancel_lru_locks osc
12103 sum=$(do_facet ost1 $LCTL get_param \
12104 "obdfilter.*.exports.*.stats" |
12105 awk -v ctr=$ctr 'BEGIN { sum = 0 }
12106 $1 == ctr { sum += $7 }
12107 END { printf("%0.0f", sum) }')
12109 if ((sum != bs * count)); then
12110 error "Bad $ctr sum, expected $((bs * count)), got $sum"
12114 rm -rf $DIR/${tdir}
12116 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
12118 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
12120 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
12121 # not honor the -ignore_readdir_race option correctly. So we call
12122 # error_ignore() rather than error() in these cases. See LU-11152.
12124 if (find --version; do_facet mds1 find --version) |
12125 grep -q '\b4\.5\.1[1-4]\b'; then
12126 error_ignore LU-11152 "$@"
12133 # First without trusting modes.
12134 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
12135 echo "proc_dirs='$proc_dirs'"
12136 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
12137 find $proc_dirs -exec cat '{}' \; &> /dev/null
12139 # Second verifying readability.
12140 $LCTL get_param -R '*' &> /dev/null
12142 # Verifing writability with badarea_io.
12144 -ignore_readdir_race \
12146 -not -name force_lbug \
12147 -not -name changelog_mask \
12148 -exec badarea_io '{}' \; ||
12149 error_133 "find $proc_dirs failed"
12151 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
12154 remote_mds_nodsh && skip "remote MDS with nodsh"
12155 remote_ost_nodsh && skip "remote OST with nodsh"
12157 # eventually, this can also be replaced with "lctl get_param -R",
12158 # but not until that option is always available on the server
12160 for facet in mds1 ost1; do
12161 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
12162 skip_noexit "Too old lustre on $facet"
12163 local facet_proc_dirs=$(do_facet $facet \
12164 \\\ls -d $proc_regexp 2>/dev/null)
12165 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12166 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12167 do_facet $facet find $facet_proc_dirs \
12168 ! -name req_history \
12169 -exec cat '{}' \\\; &> /dev/null
12171 do_facet $facet find $facet_proc_dirs \
12172 ! -name req_history \
12174 -exec cat '{}' \\\; &> /dev/null ||
12175 error "proc file read failed"
12177 do_facet $facet find $facet_proc_dirs \
12178 -ignore_readdir_race \
12180 -not -name force_lbug \
12181 -not -name changelog_mask \
12182 -exec badarea_io '{}' \\\; ||
12183 error_133 "$facet find $facet_proc_dirs failed"
12186 # remount the FS in case writes/reads /proc break the FS
12187 cleanup || error "failed to unmount"
12188 setup || error "failed to setup"
12191 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12194 remote_mds_nodsh && skip "remote MDS with nodsh"
12195 remote_ost_nodsh && skip "remote OST with nodsh"
12196 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12197 skip "Need MDS version at least 2.9.54"
12201 for facet in client mds1 ost1; do
12202 local facet_proc_dirs=$(do_facet $facet \
12203 \\\ls -d $proc_regexp 2> /dev/null)
12204 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12205 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12206 # Get the list of files that are missing the terminating newline
12207 local missing=($(do_facet $facet \
12208 find ${facet_proc_dirs} -type f \| \
12209 while read F\; do \
12210 awk -v FS='\v' -v RS='\v\v' \
12211 "'END { if(NR>0 && \
12212 \\\$NF !~ /.*\\\n\$/) \
12213 print FILENAME}'" \
12216 [ ${#missing[*]} -eq 0 ] ||
12217 error "files do not end with newline: ${missing[*]}"
12220 run_test 133h "Proc files should end with newlines"
12223 remote_mds_nodsh && skip "remote MDS with nodsh"
12224 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12225 skip "Need MDS version at least 2.7.54"
12227 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12228 cancel_lru_locks mdc
12230 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12231 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12232 [ $unused -eq 0 ] || error "$unused locks are not cleared"
12235 createmany -o $DIR/$tdir/f $nr ||
12236 error "failed to create $nr files in $DIR/$tdir"
12237 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12239 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
12240 do_facet mds1 $LCTL set_param fail_loc=0x327
12241 do_facet mds1 $LCTL set_param fail_val=500
12244 echo "sleep 10 seconds ..."
12246 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
12248 do_facet mds1 $LCTL set_param fail_loc=0
12249 do_facet mds1 $LCTL set_param fail_val=0
12250 [ $lck_cnt -lt $unused ] ||
12251 error "No locks reclaimed, before:$unused, after:$lck_cnt"
12254 unlinkmany $DIR/$tdir/f $nr
12256 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
12259 remote_mds_nodsh && skip "remote MDS with nodsh"
12260 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12261 skip "Need MDS version at least 2.7.54"
12263 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12264 cancel_lru_locks mdc
12266 local low_wm=$(do_facet mds1 $LCTL get_param -n \
12267 ldlm.lock_reclaim_threshold_mb)
12268 # disable reclaim temporarily
12269 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
12271 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
12272 do_facet mds1 $LCTL set_param fail_loc=0x328
12273 do_facet mds1 $LCTL set_param fail_val=500
12275 $LCTL set_param debug=+trace
12278 createmany -o $DIR/$tdir/f $nr &
12279 local create_pid=$!
12281 echo "Sleep $TIMEOUT seconds ..."
12283 if ! ps -p $create_pid > /dev/null 2>&1; then
12284 do_facet mds1 $LCTL set_param fail_loc=0
12285 do_facet mds1 $LCTL set_param fail_val=0
12286 do_facet mds1 $LCTL set_param \
12287 ldlm.lock_reclaim_threshold_mb=${low_wm}m
12288 error "createmany finished incorrectly!"
12290 do_facet mds1 $LCTL set_param fail_loc=0
12291 do_facet mds1 $LCTL set_param fail_val=0
12292 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
12293 wait $create_pid || return 1
12295 unlinkmany $DIR/$tdir/f $nr
12297 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
12299 test_140() { #bug-17379
12300 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12302 test_mkdir $DIR/$tdir
12303 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
12304 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
12306 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
12307 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
12309 while i=$((i + 1)); do
12311 cd $i || error "Changing to $i"
12312 ln -s ../stat stat || error "Creating stat symlink"
12313 # Read the symlink until ELOOP present,
12314 # not LBUGing the system is considered success,
12315 # we didn't overrun the stack.
12316 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
12317 if [ $ret -ne 0 ]; then
12318 if [ $ret -eq 40 ]; then
12321 error "Open stat symlink"
12327 echo "The symlink depth = $i"
12328 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
12329 error "Invalid symlink depth"
12331 # Test recursive symlink
12332 ln -s symlink_self symlink_self
12333 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
12334 echo "open symlink_self returns $ret"
12335 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
12337 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
12340 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12342 local TF="$TMP/$tfile"
12344 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12346 cancel_lru_locks $OSC
12347 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
12348 remount_client $MOUNT
12350 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
12353 $TRUNCATE $DIR/$tfile 6000
12354 cancel_lru_locks $OSC
12355 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
12358 echo "12345" >>$DIR/$tfile
12359 cancel_lru_locks $OSC
12360 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
12363 echo "12345" >>$DIR/$tfile
12364 cancel_lru_locks $OSC
12365 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
12370 run_test 150 "truncate/append tests"
12372 #LU-2902 roc_hit was not able to read all values from lproc
12373 function roc_hit_init() {
12374 local list=$(comma_list $(osts_nodes))
12375 local dir=$DIR/$tdir-check
12376 local file=$dir/$tfile
12382 #use setstripe to do a write to every ost
12383 for i in $(seq 0 $((OSTCOUNT-1))); do
12384 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
12385 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
12386 idx=$(printf %04x $i)
12387 BEFORE=$(get_osd_param $list *OST*$idx stats |
12388 awk '$1 == "cache_access" {sum += $7}
12389 END { printf("%0.0f", sum) }')
12391 cancel_lru_locks osc
12392 cat $file >/dev/null
12394 AFTER=$(get_osd_param $list *OST*$idx stats |
12395 awk '$1 == "cache_access" {sum += $7}
12396 END { printf("%0.0f", sum) }')
12398 echo BEFORE:$BEFORE AFTER:$AFTER
12399 if ! let "AFTER - BEFORE == 4"; then
12401 error "roc_hit is not safe to use"
12409 function roc_hit() {
12410 local list=$(comma_list $(osts_nodes))
12411 echo $(get_osd_param $list '' stats |
12412 awk '$1 == "cache_hit" {sum += $7}
12413 END { printf("%0.0f", sum) }')
12416 function set_cache() {
12419 if [ "$2" == "off" ]; then
12422 local list=$(comma_list $(osts_nodes))
12423 set_osd_param $list '' $1_cache_enable $on
12425 cancel_lru_locks osc
12429 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12430 remote_ost_nodsh && skip "remote OST with nodsh"
12433 local list=$(comma_list $(osts_nodes))
12435 # check whether obdfilter is cache capable at all
12436 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
12437 skip "not cache-capable obdfilter"
12440 # check cache is enabled on all obdfilters
12441 if get_osd_param $list '' read_cache_enable | grep 0; then
12442 skip "oss cache is disabled"
12445 set_osd_param $list '' writethrough_cache_enable 1
12447 # check write cache is enabled on all obdfilters
12448 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
12449 skip "oss write cache is NOT enabled"
12454 #define OBD_FAIL_OBD_NO_LRU 0x609
12455 do_nodes $list $LCTL set_param fail_loc=0x609
12457 # pages should be in the case right after write
12458 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
12461 local BEFORE=$(roc_hit)
12462 cancel_lru_locks osc
12463 cat $DIR/$tfile >/dev/null
12464 local AFTER=$(roc_hit)
12466 do_nodes $list $LCTL set_param fail_loc=0
12468 if ! let "AFTER - BEFORE == CPAGES"; then
12469 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12472 # the following read invalidates the cache
12473 cancel_lru_locks osc
12474 set_osd_param $list '' read_cache_enable 0
12475 cat $DIR/$tfile >/dev/null
12477 # now data shouldn't be found in the cache
12479 cancel_lru_locks osc
12480 cat $DIR/$tfile >/dev/null
12482 if let "AFTER - BEFORE != 0"; then
12483 error "IN CACHE: before: $BEFORE, after: $AFTER"
12486 set_osd_param $list '' read_cache_enable 1
12489 run_test 151 "test cache on oss and controls ==============================="
12492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12494 local TF="$TMP/$tfile"
12496 # simulate ENOMEM during write
12497 #define OBD_FAIL_OST_NOMEM 0x226
12498 lctl set_param fail_loc=0x80000226
12499 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12501 sync || error "sync failed"
12502 lctl set_param fail_loc=0
12504 # discard client's cache
12505 cancel_lru_locks osc
12507 # simulate ENOMEM during read
12508 lctl set_param fail_loc=0x80000226
12509 cmp $TF $DIR/$tfile || error "cmp failed"
12510 lctl set_param fail_loc=0
12514 run_test 152 "test read/write with enomem ============================"
12517 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
12519 run_test 153 "test if fdatasync does not crash ======================="
12521 dot_lustre_fid_permission_check() {
12523 local ffid=$MOUNT/.lustre/fid/$fid
12526 echo "stat fid $fid"
12527 stat $ffid > /dev/null || error "stat $ffid failed."
12528 echo "touch fid $fid"
12529 touch $ffid || error "touch $ffid failed."
12530 echo "write to fid $fid"
12531 cat /etc/hosts > $ffid || error "write $ffid failed."
12532 echo "read fid $fid"
12533 diff /etc/hosts $ffid || error "read $ffid failed."
12534 echo "append write to fid $fid"
12535 cat /etc/hosts >> $ffid || error "append write $ffid failed."
12536 echo "rename fid $fid"
12537 mv $ffid $test_dir/$tfile.1 &&
12538 error "rename $ffid to $tfile.1 should fail."
12539 touch $test_dir/$tfile.1
12540 mv $test_dir/$tfile.1 $ffid &&
12541 error "rename $tfile.1 to $ffid should fail."
12542 rm -f $test_dir/$tfile.1
12543 echo "truncate fid $fid"
12544 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
12545 echo "link fid $fid"
12546 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
12547 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
12548 echo "setfacl fid $fid"
12549 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
12550 echo "getfacl fid $fid"
12551 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
12553 echo "unlink fid $fid"
12554 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
12555 echo "mknod fid $fid"
12556 mknod $ffid c 1 3 && error "mknod $ffid should fail."
12558 fid=[0xf00000400:0x1:0x0]
12559 ffid=$MOUNT/.lustre/fid/$fid
12561 echo "stat non-exist fid $fid"
12562 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
12563 echo "write to non-exist fid $fid"
12564 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
12565 echo "link new fid $fid"
12566 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
12568 mkdir -p $test_dir/$tdir
12569 touch $test_dir/$tdir/$tfile
12570 fid=$($LFS path2fid $test_dir/$tdir)
12573 error "error: could not get fid for $test_dir/$dir/$tfile."
12575 ffid=$MOUNT/.lustre/fid/$fid
12578 ls $ffid > /dev/null || error "ls $ffid failed."
12579 echo "touch $fid/$tfile.1"
12580 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
12582 echo "touch $MOUNT/.lustre/fid/$tfile"
12583 touch $MOUNT/.lustre/fid/$tfile && \
12584 error "touch $MOUNT/.lustre/fid/$tfile should fail."
12586 echo "setxattr to $MOUNT/.lustre/fid"
12587 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
12589 echo "listxattr for $MOUNT/.lustre/fid"
12590 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
12592 echo "delxattr from $MOUNT/.lustre/fid"
12593 setfattr -x trusted.name1 $MOUNT/.lustre/fid
12595 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
12596 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
12597 error "touch invalid fid should fail."
12599 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
12600 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
12601 error "touch non-normal fid should fail."
12603 echo "rename $tdir to $MOUNT/.lustre/fid"
12604 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
12605 error "rename to $MOUNT/.lustre/fid should fail."
12607 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
12609 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
12610 local new_obf_mode=777
12612 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
12613 chmod $new_obf_mode $DIR/.lustre/fid ||
12614 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
12616 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
12617 [ $obf_mode -eq $new_obf_mode ] ||
12618 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
12620 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
12621 chmod $old_obf_mode $DIR/.lustre/fid ||
12622 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
12625 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
12626 fid=$($LFS path2fid $test_dir/$tfile-2)
12628 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
12630 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
12631 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
12632 error "create lov data thru .lustre failed"
12634 echo "cp /etc/passwd $test_dir/$tfile-2"
12635 cp /etc/passwd $test_dir/$tfile-2 ||
12636 error "copy to $test_dir/$tfile-2 failed."
12637 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
12638 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
12639 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
12641 rm -rf $test_dir/tfile.lnk
12642 rm -rf $test_dir/$tfile-2
12646 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12647 skip "Need MDS version at least 2.4.1"
12649 local tf=$DIR/$tfile
12652 local fid=$($LFS path2fid $tf)
12653 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
12655 # check that we get the same pathname back
12656 local found=$($LFS fid2path $MOUNT "$fid")
12657 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
12658 [ "$found" == "$tf" ] ||
12659 error "fid2path($fid=path2fid($tf)) = $found != $tf"
12661 run_test 154A "lfs path2fid and fid2path basic checks"
12664 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12665 skip "Need MDS version at least 2.4.1"
12667 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
12668 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
12669 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
12670 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
12672 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
12673 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
12675 # check that we get the same pathname
12676 echo "PFID: $PFID, name: $name"
12677 local FOUND=$($LFS fid2path $MOUNT "$PFID")
12678 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
12679 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
12680 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
12682 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
12684 run_test 154B "verify the ll_decode_linkea tool"
12687 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12688 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12689 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12690 skip "Need MDS version at least 2.2.51"
12691 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12693 cp /etc/hosts $DIR/$tfile
12695 fid=$($LFS path2fid $DIR/$tfile)
12697 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
12699 dot_lustre_fid_permission_check "$fid" $DIR ||
12700 error "dot lustre permission check $fid failed"
12702 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
12704 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
12706 touch $MOUNT/.lustre/file &&
12707 error "creation is not allowed under .lustre"
12709 mkdir $MOUNT/.lustre/dir &&
12710 error "mkdir is not allowed under .lustre"
12714 run_test 154a "Open-by-FID"
12717 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12718 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12719 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12720 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12721 skip "Need MDS version at least 2.2.51"
12723 local remote_dir=$DIR/$tdir/remote_dir
12727 mkdir -p $DIR/$tdir
12728 $LFS mkdir -i $MDTIDX $remote_dir ||
12729 error "create remote directory failed"
12731 cp /etc/hosts $remote_dir/$tfile
12733 fid=$($LFS path2fid $remote_dir/$tfile)
12735 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
12737 dot_lustre_fid_permission_check "$fid" $remote_dir ||
12738 error "dot lustre permission check $fid failed"
12741 run_test 154b "Open-by-FID for remote directory"
12744 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12745 skip "Need MDS version at least 2.4.1"
12747 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
12748 local FID1=$($LFS path2fid $DIR/$tfile.1)
12749 local FID2=$($LFS path2fid $DIR/$tfile.2)
12750 local FID3=$($LFS path2fid $DIR/$tfile.3)
12753 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
12754 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
12755 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
12757 [ "$FID" = "${!want}" ] ||
12758 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
12762 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
12764 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
12765 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
12769 run_test 154c "lfs path2fid and fid2path multiple arguments"
12772 remote_mds_nodsh && skip "remote MDS with nodsh"
12773 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
12774 skip "Need MDS version at least 2.5.53"
12776 if remote_mds; then
12777 nid=$($LCTL list_nids | sed "s/\./\\\./g")
12781 local proc_ofile="mdt.*.exports.'$nid'.open_files"
12788 local fid=$($LFS path2fid $DIR/$tfile)
12791 cmd="exec $fd<$DIR/$tfile"
12793 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
12794 echo "$fid_list" | grep "$fid"
12797 cmd="exec $fd>/dev/null"
12799 if [ $rc -ne 0 ]; then
12800 error "FID $fid not found in open files list $fid_list"
12803 run_test 154d "Verify open file fid"
12807 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
12808 skip "Need MDS version at least 2.6.50"
12810 if ls -a $MOUNT | grep -q '^\.lustre$'; then
12811 error ".lustre returned by readdir"
12814 run_test 154e ".lustre is not returned by readdir"
12817 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12819 # create parent directory on a single MDT to avoid cross-MDT hardlinks
12820 test_mkdir -p -c1 $DIR/$tdir/d
12821 # test dirs inherit from its stripe
12822 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
12823 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
12824 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
12825 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
12828 # get fid of parents
12829 local FID0=$($LFS path2fid $DIR/$tdir/d)
12830 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
12831 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
12832 local FID3=$($LFS path2fid $DIR)
12834 # check that path2fid --parents returns expected <parent_fid>/name
12835 # 1) test for a directory (single parent)
12836 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
12837 [ "$parent" == "$FID0/foo1" ] ||
12838 error "expected parent: $FID0/foo1, got: $parent"
12840 # 2) test for a file with nlink > 1 (multiple parents)
12841 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
12842 echo "$parent" | grep -F "$FID1/$tfile" ||
12843 error "$FID1/$tfile not returned in parent list"
12844 echo "$parent" | grep -F "$FID2/link" ||
12845 error "$FID2/link not returned in parent list"
12847 # 3) get parent by fid
12848 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
12849 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12850 echo "$parent" | grep -F "$FID1/$tfile" ||
12851 error "$FID1/$tfile not returned in parent list (by fid)"
12852 echo "$parent" | grep -F "$FID2/link" ||
12853 error "$FID2/link not returned in parent list (by fid)"
12855 # 4) test for entry in root directory
12856 parent=$($LFS path2fid --parents $DIR/f)
12857 echo "$parent" | grep -F "$FID3/f" ||
12858 error "$FID3/f not returned in parent list"
12860 # 5) test it on root directory
12861 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
12862 error "$MOUNT should not have parents"
12864 # enable xattr caching and check that linkea is correctly updated
12865 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12866 save_lustre_params client "llite.*.xattr_cache" > $save
12867 lctl set_param llite.*.xattr_cache 1
12869 # 6.1) linkea update on rename
12870 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
12872 # get parents by fid
12873 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12874 # foo1 should no longer be returned in parent list
12875 echo "$parent" | grep -F "$FID1" &&
12876 error "$FID1 should no longer be in parent list"
12877 # the new path should appear
12878 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
12879 error "$FID2/$tfile.moved is not in parent list"
12881 # 6.2) linkea update on unlink
12882 rm -f $DIR/$tdir/d/foo2/link
12883 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12884 # foo2/link should no longer be returned in parent list
12885 echo "$parent" | grep -F "$FID2/link" &&
12886 error "$FID2/link should no longer be in parent list"
12890 restore_lustre_params < $save
12893 run_test 154f "get parent fids by reading link ea"
12897 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12898 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
12899 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
12900 skip "Need MDS version at least 2.6.92"
12902 mkdir -p $DIR/$tdir
12903 llapi_fid_test -d $DIR/$tdir
12905 run_test 154g "various llapi FID tests"
12907 test_155_small_load() {
12908 local temp=$TMP/$tfile
12909 local file=$DIR/$tfile
12911 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
12912 error "dd of=$temp bs=6096 count=1 failed"
12914 cancel_lru_locks $OSC
12915 cmp $temp $file || error "$temp $file differ"
12917 $TRUNCATE $temp 6000
12918 $TRUNCATE $file 6000
12919 cmp $temp $file || error "$temp $file differ (truncate1)"
12921 echo "12345" >>$temp
12922 echo "12345" >>$file
12923 cmp $temp $file || error "$temp $file differ (append1)"
12925 echo "12345" >>$temp
12926 echo "12345" >>$file
12927 cmp $temp $file || error "$temp $file differ (append2)"
12933 test_155_big_load() {
12934 remote_ost_nodsh && skip "remote OST with nodsh"
12936 local temp=$TMP/$tfile
12937 local file=$DIR/$tfile
12940 local cache_size=$(do_facet ost$((MAXI+1)) \
12941 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
12942 local large_file_size=$((cache_size * 2))
12944 echo "OSS cache size: $cache_size KB"
12945 echo "Large file size: $large_file_size KB"
12947 [ $MAXV -le $large_file_size ] &&
12948 skip_env "max available OST size needs > $large_file_size KB"
12950 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
12952 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
12953 error "dd of=$temp bs=$large_file_size count=1k failed"
12956 cancel_lru_locks osc
12957 cmp $temp $file || error "$temp $file differ"
12963 save_writethrough() {
12964 local facets=$(get_facets OST)
12966 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
12970 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12972 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12974 save_writethrough $p
12977 set_cache writethrough on
12978 test_155_small_load
12979 restore_lustre_params < $p
12982 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
12985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12987 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12989 save_writethrough $p
12992 set_cache writethrough off
12993 test_155_small_load
12994 restore_lustre_params < $p
12997 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
13000 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13002 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13004 save_writethrough $p
13007 set_cache writethrough on
13008 test_155_small_load
13009 restore_lustre_params < $p
13012 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
13015 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13017 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13019 save_writethrough $p
13022 set_cache writethrough off
13023 test_155_small_load
13024 restore_lustre_params < $p
13027 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
13030 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13032 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13034 save_writethrough $p
13037 set_cache writethrough on
13039 restore_lustre_params < $p
13042 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
13045 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13047 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13049 save_writethrough $p
13052 set_cache writethrough off
13054 restore_lustre_params < $p
13057 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
13060 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13062 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13064 save_writethrough $p
13067 set_cache writethrough on
13069 restore_lustre_params < $p
13072 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
13075 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13077 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13079 save_writethrough $p
13082 set_cache writethrough off
13084 restore_lustre_params < $p
13087 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
13090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13091 remote_ost_nodsh && skip "remote OST with nodsh"
13092 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
13093 skip "stats not implemented on old servers"
13094 [ "$ost1_FSTYPE" = "zfs" ] &&
13095 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
13100 local file="$DIR/$tfile"
13101 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13103 save_writethrough $p
13106 log "Turn on read and write cache"
13108 set_cache writethrough on
13110 log "Write data and read it back."
13111 log "Read should be satisfied from the cache."
13112 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13114 cancel_lru_locks osc
13115 cat $file >/dev/null
13117 if ! let "AFTER - BEFORE == CPAGES"; then
13118 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13120 log "cache hits:: before: $BEFORE, after: $AFTER"
13123 log "Read again; it should be satisfied from the cache."
13125 cancel_lru_locks osc
13126 cat $file >/dev/null
13128 if ! let "AFTER - BEFORE == CPAGES"; then
13129 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13131 log "cache hits:: before: $BEFORE, after: $AFTER"
13134 log "Turn off the read cache and turn on the write cache"
13136 set_cache writethrough on
13138 log "Read again; it should be satisfied from the cache."
13140 cancel_lru_locks osc
13141 cat $file >/dev/null
13143 if ! let "AFTER - BEFORE == CPAGES"; then
13144 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13146 log "cache hits:: before: $BEFORE, after: $AFTER"
13149 log "Read again; it should not be satisfied from the cache."
13151 cancel_lru_locks osc
13152 cat $file >/dev/null
13154 if ! let "AFTER - BEFORE == 0"; then
13155 error "IN CACHE: before: $BEFORE, after: $AFTER"
13157 log "cache hits:: before: $BEFORE, after: $AFTER"
13160 log "Write data and read it back."
13161 log "Read should be satisfied from the cache."
13162 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13164 cancel_lru_locks osc
13165 cat $file >/dev/null
13167 if ! let "AFTER - BEFORE == CPAGES"; then
13168 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13170 log "cache hits:: before: $BEFORE, after: $AFTER"
13173 log "Read again; it should not be satisfied from the cache."
13175 cancel_lru_locks osc
13176 cat $file >/dev/null
13178 if ! let "AFTER - BEFORE == 0"; then
13179 error "IN CACHE: before: $BEFORE, after: $AFTER"
13181 log "cache hits:: before: $BEFORE, after: $AFTER"
13184 log "Turn off read and write cache"
13186 set_cache writethrough off
13188 log "Write data and read it back"
13189 log "It should not be satisfied from the cache."
13191 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13192 cancel_lru_locks osc
13194 cat $file >/dev/null
13196 if ! let "AFTER - BEFORE == 0"; then
13197 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13199 log "cache hits:: before: $BEFORE, after: $AFTER"
13202 log "Turn on the read cache and turn off the write cache"
13204 set_cache writethrough off
13206 log "Write data and read it back"
13207 log "It should not be satisfied from the cache."
13209 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13211 cancel_lru_locks osc
13212 cat $file >/dev/null
13214 if ! let "AFTER - BEFORE == 0"; then
13215 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13217 log "cache hits:: before: $BEFORE, after: $AFTER"
13220 log "Read again; it should be satisfied from the cache."
13222 cancel_lru_locks osc
13223 cat $file >/dev/null
13225 if ! let "AFTER - BEFORE == CPAGES"; then
13226 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13228 log "cache hits:: before: $BEFORE, after: $AFTER"
13231 restore_lustre_params < $p
13234 run_test 156 "Verification of tunables"
13237 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13238 remote_mds_nodsh && skip "remote MDS with nodsh"
13239 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13240 skip "Need MDS version at least 2.2.0"
13242 changelog_register || error "changelog_register failed"
13243 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13244 changelog_users $SINGLEMDS | grep -q $cl_user ||
13245 error "User $cl_user not found in changelog_users"
13248 test_mkdir -p $DIR/$tdir/pics/2008/zachy
13249 changelog_clear 0 || error "changelog_clear failed"
13250 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
13251 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
13252 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
13253 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
13254 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
13255 rm $DIR/$tdir/pics/desktop.jpg
13257 changelog_dump | tail -10
13259 echo "verifying changelog mask"
13260 changelog_chmask "-MKDIR"
13261 changelog_chmask "-CLOSE"
13263 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
13264 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
13266 changelog_chmask "+MKDIR"
13267 changelog_chmask "+CLOSE"
13269 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
13270 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
13272 changelog_dump | tail -10
13273 MKDIRS=$(changelog_dump | grep -c "MKDIR")
13274 CLOSES=$(changelog_dump | grep -c "CLOSE")
13275 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
13276 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
13279 echo "verifying target fid"
13280 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
13281 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
13282 [ "$fidc" == "$fidf" ] ||
13283 error "changelog '$tfile' fid $fidc != file fid $fidf"
13284 echo "verifying parent fid"
13285 # The FID returned from the Changelog may be the directory shard on
13286 # a different MDT, and not the FID returned by path2fid on the parent.
13287 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
13288 # since this is what will matter when recreating this file in the tree.
13289 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
13290 local pathp=$($LFS fid2path $MOUNT "$fidp")
13291 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
13292 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
13294 echo "getting records for $cl_user"
13295 changelog_users $SINGLEMDS
13296 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
13298 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
13299 error "changelog_clear failed"
13300 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
13301 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
13302 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
13303 error "user index expect $user_rec1 + $nclr != $user_rec2"
13305 local min0_rec=$(changelog_users $SINGLEMDS |
13306 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
13307 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
13308 awk '{ print $1; exit; }')
13310 changelog_dump | tail -n 5
13311 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
13312 [ $first_rec == $((min0_rec + 1)) ] ||
13313 error "first index should be $min0_rec + 1 not $first_rec"
13315 # LU-3446 changelog index reset on MDT restart
13316 local cur_rec1=$(changelog_users $SINGLEMDS |
13317 awk '/^current.index:/ { print $NF }')
13318 changelog_clear 0 ||
13319 error "clear all changelog records for $cl_user failed"
13320 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
13321 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
13322 error "Fail to start $SINGLEMDS"
13323 local cur_rec2=$(changelog_users $SINGLEMDS |
13324 awk '/^current.index:/ { print $NF }')
13325 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
13326 [ $cur_rec1 == $cur_rec2 ] ||
13327 error "current index should be $cur_rec1 not $cur_rec2"
13329 echo "verifying users from this test are deregistered"
13330 changelog_deregister || error "changelog_deregister failed"
13331 changelog_users $SINGLEMDS | grep -q $cl_user &&
13332 error "User '$cl_user' still in changelog_users"
13334 # lctl get_param -n mdd.*.changelog_users
13335 # current index: 144
13336 # ID index (idle seconds)
13338 if ! changelog_users $SINGLEMDS | grep "^cl"; then
13339 # this is the normal case where all users were deregistered
13340 # make sure no new records are added when no users are present
13341 local last_rec1=$(changelog_users $SINGLEMDS |
13342 awk '/^current.index:/ { print $NF }')
13343 touch $DIR/$tdir/chloe
13344 local last_rec2=$(changelog_users $SINGLEMDS |
13345 awk '/^current.index:/ { print $NF }')
13346 echo "verify changelogs are off: $last_rec1 == $last_rec2"
13347 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
13349 # any changelog users must be leftovers from a previous test
13350 changelog_users $SINGLEMDS
13351 echo "other changelog users; can't verify off"
13354 run_test 160a "changelog sanity"
13356 test_160b() { # LU-3587
13357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13358 remote_mds_nodsh && skip "remote MDS with nodsh"
13359 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13360 skip "Need MDS version at least 2.2.0"
13362 changelog_register || error "changelog_register failed"
13363 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13364 changelog_users $SINGLEMDS | grep -q $cl_user ||
13365 error "User '$cl_user' not found in changelog_users"
13367 local longname1=$(str_repeat a 255)
13368 local longname2=$(str_repeat b 255)
13371 echo "creating very long named file"
13372 touch $longname1 || error "create of '$longname1' failed"
13373 echo "renaming very long named file"
13374 mv $longname1 $longname2
13376 changelog_dump | grep RENME | tail -n 5
13379 run_test 160b "Verify that very long rename doesn't crash in changelog"
13382 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13383 remote_mds_nodsh && skip "remote MDS with nodsh"
13385 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
13386 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
13387 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
13388 skip "Need MDS version at least 2.5.58 or 2.5.2+"
13392 # Registration step
13393 changelog_register || error "changelog_register failed"
13396 mkdir -p $DIR/$tdir
13397 $MCREATE $DIR/$tdir/foo_160c
13398 changelog_chmask "-TRUNC"
13399 $TRUNCATE $DIR/$tdir/foo_160c 200
13400 changelog_chmask "+TRUNC"
13401 $TRUNCATE $DIR/$tdir/foo_160c 199
13402 changelog_dump | tail -n 5
13403 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
13404 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
13406 run_test 160c "verify that changelog log catch the truncate event"
13409 remote_mds_nodsh && skip "remote MDS with nodsh"
13410 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13411 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13412 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
13413 skip "Need MDS version at least 2.7.60"
13415 # Registration step
13416 changelog_register || error "changelog_register failed"
13418 mkdir -p $DIR/$tdir/migrate_dir
13419 changelog_clear 0 || error "changelog_clear failed"
13421 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
13422 changelog_dump | tail -n 5
13423 local migrates=$(changelog_dump | grep -c "MIGRT")
13424 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
13426 run_test 160d "verify that changelog log catch the migrate event"
13429 remote_mds_nodsh && skip "remote MDS with nodsh"
13432 changelog_register || error "changelog_register failed"
13434 # Delete a future user (expect fail)
13435 local MDT0=$(facet_svc $SINGLEMDS)
13436 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
13439 if [ $rc -eq 0 ]; then
13440 error "Deleted non-existant user cl77"
13441 elif [ $rc -ne 2 ]; then
13442 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
13445 # Clear to a bad index (1 billion should be safe)
13446 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
13449 if [ $rc -eq 0 ]; then
13450 error "Successfully cleared to invalid CL index"
13451 elif [ $rc -ne 22 ]; then
13452 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
13455 run_test 160e "changelog negative testing (should return errors)"
13458 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13459 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13460 skip "Need MDS version at least 2.10.56"
13462 local mdts=$(comma_list $(mdts_nodes))
13465 changelog_register || error "first changelog_register failed"
13466 changelog_register || error "second changelog_register failed"
13468 declare -A cl_user1
13469 declare -A cl_user2
13474 # generate some changelog records to accumulate on each MDT
13475 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13476 log "$(date +%s): creating first files"
13477 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13478 error "create $DIR/$tdir/$tfile failed"
13480 # check changelogs have been generated
13481 local start=$SECONDS
13482 local idle_time=$((MDSCOUNT * 5 + 5))
13483 local nbcl=$(changelog_dump | wc -l)
13484 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13486 for param in "changelog_max_idle_time=$idle_time" \
13488 "changelog_min_gc_interval=2" \
13489 "changelog_min_free_cat_entries=3"; do
13490 local MDT0=$(facet_svc $SINGLEMDS)
13491 local var="${param%=*}"
13492 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13494 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13495 do_nodes $mdts $LCTL set_param mdd.*.$param
13498 # force cl_user2 to be idle (1st part), but also cancel the
13499 # cl_user1 records so that it is not evicted later in the test.
13500 local sleep1=$((idle_time / 2))
13501 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
13504 # simulate changelog catalog almost full
13505 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13506 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13508 for i in $(seq $MDSCOUNT); do
13509 cl_users=(${CL_USERS[mds$i]})
13510 cl_user1[mds$i]="${cl_users[0]}"
13511 cl_user2[mds$i]="${cl_users[1]}"
13513 [ -n "${cl_user1[mds$i]}" ] ||
13514 error "mds$i: no user registered"
13515 [ -n "${cl_user2[mds$i]}" ] ||
13516 error "mds$i: only ${cl_user2[mds$i]} is registered"
13518 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13519 [ -n "$user_rec1" ] ||
13520 error "mds$i: User ${cl_user1[mds$i]} not registered"
13521 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13522 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13523 [ -n "$user_rec2" ] ||
13524 error "mds$i: User ${cl_user1[mds$i]} not registered"
13525 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13526 "$user_rec1 + 2 == $user_rec2"
13527 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13528 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13529 "$user_rec1 + 2, but is $user_rec2"
13530 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13531 [ -n "$user_rec2" ] ||
13532 error "mds$i: User ${cl_user2[mds$i]} not registered"
13533 [ $user_rec1 == $user_rec2 ] ||
13534 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13535 "$user_rec1, but is $user_rec2"
13538 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
13539 local sleep2=$((idle_time - (SECONDS - start) + 1))
13540 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
13543 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
13544 # cl_user1 should be OK because it recently processed records.
13545 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
13546 createmany -m $DIR/$tdir/${tfile}b $((MDSCOUNT * 2)) ||
13547 error "create $DIR/$tdir/${tfile}b failed"
13549 # ensure gc thread is done
13550 for i in $(mdts_nodes); do
13552 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13553 error "$i: GC-thread not done"
13557 for i in $(seq $MDSCOUNT); do
13558 # check cl_user1 still registered
13559 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13560 error "mds$i: User ${cl_user1[mds$i]} not registered"
13561 # check cl_user2 unregistered
13562 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13563 error "mds$i: User ${cl_user2[mds$i]} still registered"
13565 # check changelogs are present and starting at $user_rec1 + 1
13566 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13567 [ -n "$user_rec1" ] ||
13568 error "mds$i: User ${cl_user1[mds$i]} not registered"
13569 first_rec=$($LFS changelog $(facet_svc mds$i) |
13570 awk '{ print $1; exit; }')
13572 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13573 [ $((user_rec1 + 1)) == $first_rec ] ||
13574 error "mds$i: first index should be $user_rec1 + 1, " \
13575 "but is $first_rec"
13578 run_test 160f "changelog garbage collect (timestamped users)"
13581 remote_mds_nodsh && skip "remote MDS with nodsh"
13582 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13583 skip "Need MDS version at least 2.10.56"
13585 local mdts=$(comma_list $(mdts_nodes))
13587 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
13588 do_nodes $mdts $LCTL set_param fail_loc=0x1314
13591 changelog_register || error "first changelog_register failed"
13592 changelog_register || error "second changelog_register failed"
13594 declare -A cl_user1
13595 declare -A cl_user2
13600 # generate some changelog records to accumulate on each MDT
13601 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13602 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13603 error "create $DIR/$tdir/$tfile failed"
13605 # check changelogs have been generated
13606 local nbcl=$(changelog_dump | wc -l)
13607 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13609 # reduce the max_idle_indexes value to make sure we exceed it
13610 max_ndx=$((nbcl / 2 - 1))
13612 for param in "changelog_max_idle_indexes=$max_ndx" \
13614 "changelog_min_gc_interval=2" \
13615 "changelog_min_free_cat_entries=3"; do
13616 local MDT0=$(facet_svc $SINGLEMDS)
13617 local var="${param%=*}"
13618 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13620 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13621 do_nodes $mdts $LCTL set_param mdd.*.$param ||
13622 error "unable to set mdd.*.$param"
13625 # simulate changelog catalog almost full
13626 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13627 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13629 for i in $(seq $MDSCOUNT); do
13630 cl_users=(${CL_USERS[mds$i]})
13631 cl_user1[mds$i]="${cl_users[0]}"
13632 cl_user2[mds$i]="${cl_users[1]}"
13634 [ -n "${cl_user1[mds$i]}" ] ||
13635 error "mds$i: no user registered"
13636 [ -n "${cl_user2[mds$i]}" ] ||
13637 error "mds$i: only ${cl_user1[mds$i]} is registered"
13639 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13640 [ -n "$user_rec1" ] ||
13641 error "mds$i: User ${cl_user1[mds$i]} not registered"
13642 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13643 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13644 [ -n "$user_rec2" ] ||
13645 error "mds$i: User ${cl_user1[mds$i]} not registered"
13646 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13647 "$user_rec1 + 2 == $user_rec2"
13648 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13649 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13650 "$user_rec1 + 2, but is $user_rec2"
13651 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13652 [ -n "$user_rec2" ] ||
13653 error "mds$i: User ${cl_user2[mds$i]} not registered"
13654 [ $user_rec1 == $user_rec2 ] ||
13655 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13656 "$user_rec1, but is $user_rec2"
13659 # ensure we are past the previous changelog_min_gc_interval set above
13662 # generate one more changelog to trigger fail_loc
13663 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13664 error "create $DIR/$tdir/${tfile}bis failed"
13666 # ensure gc thread is done
13667 for i in $(mdts_nodes); do
13669 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13670 error "$i: GC-thread not done"
13674 for i in $(seq $MDSCOUNT); do
13675 # check cl_user1 still registered
13676 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13677 error "mds$i: User ${cl_user1[mds$i]} not registered"
13678 # check cl_user2 unregistered
13679 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13680 error "mds$i: User ${cl_user2[mds$i]} still registered"
13682 # check changelogs are present and starting at $user_rec1 + 1
13683 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13684 [ -n "$user_rec1" ] ||
13685 error "mds$i: User ${cl_user1[mds$i]} not registered"
13686 first_rec=$($LFS changelog $(facet_svc mds$i) |
13687 awk '{ print $1; exit; }')
13689 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13690 [ $((user_rec1 + 1)) == $first_rec ] ||
13691 error "mds$i: first index should be $user_rec1 + 1, " \
13692 "but is $first_rec"
13695 run_test 160g "changelog garbage collect (old users)"
13698 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13699 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13700 skip "Need MDS version at least 2.10.56"
13702 local mdts=$(comma_list $(mdts_nodes))
13705 changelog_register || error "first changelog_register failed"
13706 changelog_register || error "second changelog_register failed"
13708 declare -A cl_user1
13709 declare -A cl_user2
13714 # generate some changelog records to accumulate on each MDT
13715 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13716 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13717 error "create $DIR/$tdir/$tfile failed"
13719 # check changelogs have been generated
13720 local nbcl=$(changelog_dump | wc -l)
13721 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13723 for param in "changelog_max_idle_time=10" \
13725 "changelog_min_gc_interval=2"; do
13726 local MDT0=$(facet_svc $SINGLEMDS)
13727 local var="${param%=*}"
13728 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13730 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13731 do_nodes $mdts $LCTL set_param mdd.*.$param
13734 # force cl_user2 to be idle (1st part)
13737 for i in $(seq $MDSCOUNT); do
13738 cl_users=(${CL_USERS[mds$i]})
13739 cl_user1[mds$i]="${cl_users[0]}"
13740 cl_user2[mds$i]="${cl_users[1]}"
13742 [ -n "${cl_user1[mds$i]}" ] ||
13743 error "mds$i: no user registered"
13744 [ -n "${cl_user2[mds$i]}" ] ||
13745 error "mds$i: only ${cl_user2[mds$i]} is registered"
13747 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13748 [ -n "$user_rec1" ] ||
13749 error "mds$i: User ${cl_user1[mds$i]} not registered"
13750 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13751 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13752 [ -n "$user_rec2" ] ||
13753 error "mds$i: User ${cl_user1[mds$i]} not registered"
13754 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13755 "$user_rec1 + 2 == $user_rec2"
13756 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13757 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13758 "$user_rec1 + 2, but is $user_rec2"
13759 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13760 [ -n "$user_rec2" ] ||
13761 error "mds$i: User ${cl_user2[mds$i]} not registered"
13762 [ $user_rec1 == $user_rec2 ] ||
13763 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13764 "$user_rec1, but is $user_rec2"
13767 # force cl_user2 to be idle (2nd part) and to reach
13768 # changelog_max_idle_time
13771 # force each GC-thread start and block then
13772 # one per MDT/MDD, set fail_val accordingly
13773 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
13774 do_nodes $mdts $LCTL set_param fail_loc=0x1316
13776 # generate more changelogs to trigger fail_loc
13777 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13778 error "create $DIR/$tdir/${tfile}bis failed"
13780 # stop MDT to stop GC-thread, should be done in back-ground as it will
13781 # block waiting for the thread to be released and exit
13782 declare -A stop_pids
13783 for i in $(seq $MDSCOUNT); do
13785 stop_pids[mds$i]=$!
13788 for i in $(mdts_nodes); do
13791 local facets=$(facets_up_on_host $i)
13793 for facet in ${facets//,/ }; do
13794 if [[ $facet == mds* ]]; then
13798 # ensure each MDS's gc threads are still present and all in "R"
13799 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
13800 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
13801 error "$i: expected $nb GC-thread"
13803 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
13805 error "$i: GC-thread not found in R-state"
13806 # check umounts of each MDT on MDS have reached kthread_stop()
13807 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
13808 error "$i: expected $nb umount"
13810 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
13811 error "$i: umount not found in D-state"
13814 # release all GC-threads
13815 do_nodes $mdts $LCTL set_param fail_loc=0
13817 # wait for MDT stop to complete
13818 for i in $(seq $MDSCOUNT); do
13819 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
13823 # may try to check if any orphan changelog records are present
13824 # via ldiskfs/zfs and llog_reader...
13826 # re-start/mount MDTs
13827 for i in $(seq $MDSCOUNT); do
13828 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
13829 error "Fail to start mds$i"
13833 for i in $(seq $MDSCOUNT); do
13834 # check cl_user1 still registered
13835 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13836 error "mds$i: User ${cl_user1[mds$i]} not registered"
13837 # check cl_user2 unregistered
13838 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13839 error "mds$i: User ${cl_user2[mds$i]} still registered"
13841 # check changelogs are present and starting at $user_rec1 + 1
13842 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13843 [ -n "$user_rec1" ] ||
13844 error "mds$i: User ${cl_user1[mds$i]} not registered"
13845 first_rec=$($LFS changelog $(facet_svc mds$i) |
13846 awk '{ print $1; exit; }')
13848 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13849 [ $((user_rec1 + 1)) == $first_rec ] ||
13850 error "mds$i: first index should be $user_rec1 + 1, " \
13851 "but is $first_rec"
13854 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
13859 local mdts=$(comma_list $(mdts_nodes))
13861 changelog_register || error "first changelog_register failed"
13863 # generate some changelog records to accumulate on each MDT
13864 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13865 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13866 error "create $DIR/$tdir/$tfile failed"
13868 # check changelogs have been generated
13869 local nbcl=$(changelog_dump | wc -l)
13870 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13872 # simulate race between register and unregister
13873 # XXX as fail_loc is set per-MDS, with DNE configs the race
13874 # simulation will only occur for one MDT per MDS and for the
13875 # others the normal race scenario will take place
13876 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
13877 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
13878 do_nodes $mdts $LCTL set_param fail_val=1
13880 # unregister 1st user
13881 changelog_deregister &
13883 # wait some time for deregister work to reach race rdv
13885 # register 2nd user
13886 changelog_register || error "2nd user register failed"
13888 wait $pid1 || error "1st user deregister failed"
13892 declare -A LAST_REC
13893 for i in $(seq $MDSCOUNT); do
13894 if changelog_users mds$i | grep "^cl"; then
13895 # make sure new records are added with one user present
13896 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
13897 awk '/^current.index:/ { print $NF }')
13899 error "mds$i has no user registered"
13903 # generate more changelog records to accumulate on each MDT
13904 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13905 error "create $DIR/$tdir/${tfile}bis failed"
13907 for i in $(seq $MDSCOUNT); do
13908 last_rec=$(changelog_users $SINGLEMDS |
13909 awk '/^current.index:/ { print $NF }')
13910 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
13911 [ $last_rec != ${LAST_REC[mds$i]} ] ||
13912 error "changelogs are off on mds$i"
13915 run_test 160i "changelog user register/unregister race"
13918 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13919 remote_mds_nodsh && skip "remote MDS with nodsh"
13921 mkdir -p $DIR/$tdir/1/1
13923 changelog_register || error "changelog_register failed"
13924 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13926 changelog_users $SINGLEMDS | grep -q $cl_user ||
13927 error "User '$cl_user' not found in changelog_users"
13928 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
13929 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
13930 rmdir $DIR/$tdir/1/1 & sleep 1
13932 touch $DIR/$tdir/2/2
13933 rm -rf $DIR/$tdir/2
13938 changelog_dump | grep rmdir || error "rmdir not recorded"
13941 changelog_deregister
13943 run_test 160k "Verify that changelog records are not lost"
13946 remote_mds_nodsh && skip "remote MDS with nodsh"
13947 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
13948 skip "Need MDS version at least 2.12.56"
13950 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
13952 changelog_register || error "first changelog_register failed"
13954 # generate some changelog
13955 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13956 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13957 error "create $DIR/$tdir/${tfile}bis failed"
13959 # open the changelog device
13960 exec 3>/dev/changelog-$FSNAME-MDT0000
13961 exec 4</dev/changelog-$FSNAME-MDT0000
13963 # umount the first lustre mount
13967 cat <&4 >/dev/null || error "read changelog failed"
13970 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13971 changelog_users $SINGLEMDS | grep -q $cl_user ||
13972 error "User $cl_user not found in changelog_users"
13974 printf 'clear:'$cl_user':0' >&3
13981 changelog_deregister || error "changelog_deregister failed"
13984 mount_client $MOUNT || error "mount_client on $MOUNT failed"
13986 run_test 160j "client can be umounted while its chanangelog is being used"
13989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13991 test_mkdir -c1 $DIR/$tdir
13992 cp /etc/hosts $DIR/$tdir/$tfile
13993 test_mkdir -c1 $DIR/$tdir/foo1
13994 test_mkdir -c1 $DIR/$tdir/foo2
13995 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
13996 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
13997 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
13998 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
13999 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
14000 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14001 $LFS fid2path $DIR $FID
14002 error "bad link ea"
14005 rm $DIR/$tdir/foo2/zachary
14007 rm $DIR/$tdir/foo2/thor
14009 rm $DIR/$tdir/$tfile
14011 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
14012 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
14013 { $LFS fid2path $DIR $FID; error "bad link rename"; }
14014 rm $DIR/$tdir/foo2/maggie
14017 local longname=$tfile.avg_len_is_thirty_two_
14018 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
14019 error_noexit 'failed to unlink many hardlinks'" EXIT
14020 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
14021 error "failed to hardlink many files"
14022 links=$($LFS fid2path $DIR $FID | wc -l)
14023 echo -n "${links}/1000 links in link EA"
14024 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
14026 run_test 161a "link ea sanity"
14029 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14030 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
14033 local remote_dir=$DIR/$tdir/remote_dir
14035 mkdir -p $DIR/$tdir
14036 $LFS mkdir -i $MDTIDX $remote_dir ||
14037 error "create remote directory failed"
14039 cp /etc/hosts $remote_dir/$tfile
14040 mkdir -p $remote_dir/foo1
14041 mkdir -p $remote_dir/foo2
14042 ln $remote_dir/$tfile $remote_dir/foo1/sofia
14043 ln $remote_dir/$tfile $remote_dir/foo2/zachary
14044 ln $remote_dir/$tfile $remote_dir/foo1/luna
14045 ln $remote_dir/$tfile $remote_dir/foo2/thor
14047 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
14049 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14050 $LFS fid2path $DIR $FID
14051 error "bad link ea"
14054 rm $remote_dir/foo2/zachary
14056 rm $remote_dir/foo2/thor
14058 rm $remote_dir/$tfile
14060 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
14061 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
14062 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
14063 $LFS fid2path $DIR $FID
14064 error "bad link rename"
14066 rm $remote_dir/foo2/maggie
14069 local longname=filename_avg_len_is_thirty_two_
14070 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
14071 error "failed to hardlink many files"
14072 links=$($LFS fid2path $DIR $FID | wc -l)
14073 echo -n "${links}/1000 links in link EA"
14074 [[ ${links} -gt 60 ]] ||
14075 error "expected at least 60 links in link EA"
14076 unlinkmany $remote_dir/foo2/$longname 1000 ||
14077 error "failed to unlink many hardlinks"
14079 run_test 161b "link ea sanity under remote directory"
14082 remote_mds_nodsh && skip "remote MDS with nodsh"
14083 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14084 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
14085 skip "Need MDS version at least 2.1.5"
14087 # define CLF_RENAME_LAST 0x0001
14088 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
14089 changelog_register || error "changelog_register failed"
14092 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
14093 touch $DIR/$tdir/foo_161c
14094 touch $DIR/$tdir/bar_161c
14095 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14096 changelog_dump | grep RENME | tail -n 5
14097 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14098 changelog_clear 0 || error "changelog_clear failed"
14099 if [ x$flags != "x0x1" ]; then
14100 error "flag $flags is not 0x1"
14103 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
14104 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
14105 touch $DIR/$tdir/foo_161c
14106 touch $DIR/$tdir/bar_161c
14107 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14108 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14109 changelog_dump | grep RENME | tail -n 5
14110 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14111 changelog_clear 0 || error "changelog_clear failed"
14112 if [ x$flags != "x0x0" ]; then
14113 error "flag $flags is not 0x0"
14115 echo "rename overwrite a target having nlink > 1," \
14116 "changelog record has flags of $flags"
14118 # rename doesn't overwrite a target (changelog flag 0x0)
14119 touch $DIR/$tdir/foo_161c
14120 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
14121 changelog_dump | grep RENME | tail -n 5
14122 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
14123 changelog_clear 0 || error "changelog_clear failed"
14124 if [ x$flags != "x0x0" ]; then
14125 error "flag $flags is not 0x0"
14127 echo "rename doesn't overwrite a target," \
14128 "changelog record has flags of $flags"
14130 # define CLF_UNLINK_LAST 0x0001
14131 # unlink a file having nlink = 1 (changelog flag 0x1)
14132 rm -f $DIR/$tdir/foo2_161c
14133 changelog_dump | grep UNLNK | tail -n 5
14134 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14135 changelog_clear 0 || error "changelog_clear failed"
14136 if [ x$flags != "x0x1" ]; then
14137 error "flag $flags is not 0x1"
14139 echo "unlink a file having nlink = 1," \
14140 "changelog record has flags of $flags"
14142 # unlink a file having nlink > 1 (changelog flag 0x0)
14143 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14144 rm -f $DIR/$tdir/foobar_161c
14145 changelog_dump | grep UNLNK | tail -n 5
14146 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14147 changelog_clear 0 || error "changelog_clear failed"
14148 if [ x$flags != "x0x0" ]; then
14149 error "flag $flags is not 0x0"
14151 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
14153 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
14156 remote_mds_nodsh && skip "remote MDS with nodsh"
14161 changelog_register || error "changelog_register failed"
14163 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
14164 # interfer with $MOUNT/.lustre/fid/ access
14166 [[ $? -eq 0 ]] || error "mkdir failed"
14168 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
14169 $LCTL set_param fail_loc=0x8000140c
14171 $LCTL set_param fail_val=5
14174 echo foofoo > $DIR/$tdir/$tfile &
14177 # wait for create to be delayed
14181 [[ $? -eq 0 ]] || error "create should be blocked"
14183 local tempfile=$(mktemp)
14184 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
14185 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
14186 # some delay may occur during ChangeLog publishing and file read just
14187 # above, that could allow file write to happen finally
14188 [[ -s $tempfile ]] && echo "file should be empty"
14190 $LCTL set_param fail_loc=0
14193 [[ $? -eq 0 ]] || error "create failed"
14195 run_test 161d "create with concurrent .lustre/fid access"
14198 local expected="$1"
14203 path=$($LFS fid2path "$@")
14206 if [ $rc -ne 0 ]; then
14207 error "path looked up of '$expected' failed: rc=$rc"
14208 elif [ "$path" != "$expected" ]; then
14209 error "path looked up '$path' instead of '$expected'"
14211 echo "FID '$fid' resolves to path '$path' as expected"
14215 test_162a() { # was test_162
14216 test_mkdir -p -c1 $DIR/$tdir/d2
14217 touch $DIR/$tdir/d2/$tfile
14218 touch $DIR/$tdir/d2/x1
14219 touch $DIR/$tdir/d2/x2
14220 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
14221 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
14223 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
14224 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
14227 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
14228 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
14229 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
14231 # softlink to wrong file
14232 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
14233 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
14234 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
14237 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
14238 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
14239 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
14240 # fid2path dir/fsname should both work
14241 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
14242 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
14244 # hardlink count: check that there are 2 links
14245 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
14246 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
14248 # hardlink indexing: remove the first link
14249 rm $DIR/$tdir/d2/p/q/r/hlink
14250 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
14252 run_test 162a "path lookup sanity"
14255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14256 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14259 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
14260 error "create striped dir failed"
14262 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
14263 tail -n 1 | awk '{print $2}')
14264 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
14266 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
14267 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
14270 for ((i=0;i<5;i++)); do
14271 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
14272 error "get fid for f$i failed"
14273 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
14275 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
14276 error "get fid for d$i failed"
14277 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
14282 run_test 162b "striped directory path lookup sanity"
14284 # LU-4239: Verify fid2path works with paths 100 or more directories deep
14286 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
14287 skip "Need MDS version at least 2.7.51"
14289 local lpath=$tdir.local
14290 local rpath=$tdir.remote
14292 test_mkdir $DIR/$lpath
14293 test_mkdir $DIR/$rpath
14295 for ((i = 0; i <= 101; i++)); do
14298 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
14299 error "get fid for local directory $DIR/$lpath failed"
14300 check_path "$DIR/$lpath" $MOUNT $FID --link 0
14303 test_mkdir $DIR/$rpath
14304 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
14305 error "get fid for remote directory $DIR/$rpath failed"
14306 check_path "$DIR/$rpath" $MOUNT $FID --link 0
14311 run_test 162c "fid2path works with paths 100 or more directories deep"
14314 # do directio so as not to populate the page cache
14315 log "creating a 10 Mb file"
14316 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14317 log "starting reads"
14318 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14319 log "truncating the file"
14320 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14322 kill %+ || true # reads might have finished
14323 echo "wait until dd is finished"
14325 log "removing the temporary file"
14326 rm -rf $DIR/$tfile || error "tmp file removal failed"
14328 run_test 169 "parallel read and truncate should not deadlock"
14331 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14333 $LCTL clear # bug 18514
14334 $LCTL debug_daemon start $TMP/${tfile}_log_good
14336 $LCTL debug_daemon stop
14337 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
14338 error "sed failed to read log_good"
14340 $LCTL debug_daemon start $TMP/${tfile}_log_good
14342 $LCTL debug_daemon stop
14344 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
14345 error "lctl df log_bad failed"
14347 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14348 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14350 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
14351 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
14353 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
14354 error "bad_line good_line1 good_line2 are empty"
14356 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14357 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
14358 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14360 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
14361 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14362 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14364 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
14365 error "bad_line_new good_line_new are empty"
14367 local expected_good=$((good_line1 + good_line2*2))
14369 rm -f $TMP/${tfile}*
14370 # LU-231, short malformed line may not be counted into bad lines
14371 if [ $bad_line -ne $bad_line_new ] &&
14372 [ $bad_line -ne $((bad_line_new - 1)) ]; then
14373 error "expected $bad_line bad lines, but got $bad_line_new"
14377 if [ $expected_good -ne $good_line_new ]; then
14378 error "expected $expected_good good lines, but got $good_line_new"
14383 run_test 170 "test lctl df to handle corrupted log ====================="
14385 test_171() { # bug20592
14386 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14388 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
14389 $LCTL set_param fail_loc=0x50e
14390 $LCTL set_param fail_val=3000
14391 multiop_bg_pause $DIR/$tfile O_s || true
14393 kill -USR1 $MULTIPID
14397 if dmesg | grep "recursive fault"; then
14398 error "caught a recursive fault"
14400 $LCTL set_param fail_loc=0
14403 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
14405 # it would be good to share it with obdfilter-survey/iokit-libecho code
14406 setup_obdecho_osc () {
14409 local obdfilter_name=$2
14410 echo "Creating new osc for $obdfilter_name on $ost_nid"
14411 # make sure we can find loopback nid
14412 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
14414 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
14415 ${obdfilter_name}_osc_UUID || rc=2; }
14416 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
14417 ${obdfilter_name}_UUID $ost_nid || rc=3; }
14421 cleanup_obdecho_osc () {
14422 local obdfilter_name=$1
14423 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
14424 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
14431 local pages=${3:-64}
14436 local obd_size=$(get_obd_size $node $OBD)
14437 local page_size=$(get_page_size $node)
14438 if [[ -n "$obd_size" ]]; then
14439 local new_count=$((obd_size / (pages * page_size / 1024)))
14440 [[ $new_count -ge $count ]] || count=$new_count
14443 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
14444 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
14446 if [ $rc -eq 0 ]; then
14447 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
14448 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
14450 echo "New object id is $id"
14451 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
14453 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
14454 "test_brw $count w v $pages $id" || rc=4; }
14455 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
14457 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
14458 "cleanup" || rc=5; }
14459 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
14460 "detach" || rc=6; }
14461 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
14466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14468 if ! module_loaded obdecho; then
14469 load_module obdecho/obdecho &&
14470 stack_trap "rmmod obdecho" EXIT ||
14471 error "unable to load obdecho on client"
14474 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
14475 local host=$($LCTL get_param -n osc.$osc.import |
14476 awk '/current_connection:/ { print $2 }' )
14477 local target=$($LCTL get_param -n osc.$osc.import |
14478 awk '/target:/ { print $2 }' )
14479 target=${target%_UUID}
14481 if [ -n "$target" ]; then
14482 setup_obdecho_osc $host $target &&
14483 stack_trap "cleanup_obdecho_osc $target" EXIT ||
14484 { error "obdecho setup failed with $?"; return; }
14486 obdecho_test ${target}_osc client ||
14487 error "obdecho_test failed on ${target}_osc"
14489 $LCTL get_param osc.$osc.import
14490 error "there is no osc.$osc.import target"
14493 run_test 180a "test obdecho on osc"
14496 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14497 remote_ost_nodsh && skip "remote OST with nodsh"
14499 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14500 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14501 error "failed to load module obdecho"
14503 local target=$(do_facet ost1 $LCTL dl |
14504 awk '/obdfilter/ { print $4; exit; }')
14506 if [ -n "$target" ]; then
14507 obdecho_test $target ost1 || error "obdecho_test failed with $?"
14509 do_facet ost1 $LCTL dl
14510 error "there is no obdfilter target on ost1"
14513 run_test 180b "test obdecho directly on obdfilter"
14515 test_180c() { # LU-2598
14516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14517 remote_ost_nodsh && skip "remote OST with nodsh"
14518 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
14519 skip "Need MDS version at least 2.4.0"
14521 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14522 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14523 error "failed to load module obdecho"
14525 local target=$(do_facet ost1 $LCTL dl |
14526 awk '/obdfilter/ { print $4; exit; }')
14528 if [ -n "$target" ]; then
14529 local pages=16384 # 64MB bulk I/O RPC size
14531 obdecho_test "$target" ost1 "$pages" ||
14532 error "obdecho_test with pages=$pages failed with $?"
14534 do_facet ost1 $LCTL dl
14535 error "there is no obdfilter target on ost1"
14538 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
14540 test_181() { # bug 22177
14541 test_mkdir $DIR/$tdir
14542 # create enough files to index the directory
14543 createmany -o $DIR/$tdir/foobar 4000
14544 # print attributes for debug purpose
14547 multiop_bg_pause $DIR/$tdir D_Sc || return 1
14549 # remove the files & current working dir
14550 unlinkmany $DIR/$tdir/foobar 4000
14552 kill -USR1 $MULTIPID
14554 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
14557 run_test 181 "Test open-unlinked dir ========================"
14563 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14565 $LCTL set_param mdc.*.rpc_stats=clear
14567 for (( i = 0; i < $tcount; i++ )) ; do
14568 mkdir $DIR/$tdir/$i
14571 for (( i = 0; i < $tcount; i++ )) ; do
14572 createmany -o $DIR/$tdir/$i/f- $fcount &
14576 for (( i = 0; i < $tcount; i++ )) ; do
14577 unlinkmany $DIR/$tdir/$i/f- $fcount &
14581 $LCTL get_param mdc.*.rpc_stats
14585 run_test 182 "Test parallel modify metadata operations ================"
14587 test_183() { # LU-2275
14588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14589 remote_mds_nodsh && skip "remote MDS with nodsh"
14590 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
14591 skip "Need MDS version at least 2.3.56"
14593 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14594 echo aaa > $DIR/$tdir/$tfile
14596 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
14597 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
14599 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
14600 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
14602 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14604 # Flush negative dentry cache
14605 touch $DIR/$tdir/$tfile
14607 # We are not checking for any leaked references here, they'll
14608 # become evident next time we do cleanup with module unload.
14611 run_test 183 "No crash or request leak in case of strange dispositions ========"
14613 # test suite 184 is for LU-2016, LU-2017
14615 check_swap_layouts_support
14617 dir0=$DIR/$tdir/$testnum
14618 test_mkdir -p -c1 $dir0
14623 $SETSTRIPE -c1 $file1
14625 $SETSTRIPE -c2 $file2
14627 gen1=$($GETSTRIPE -g $file1)
14628 gen2=$($GETSTRIPE -g $file2)
14630 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
14631 gen=$($GETSTRIPE -g $file1)
14632 [[ $gen1 != $gen ]] ||
14633 "Layout generation on $file1 does not change"
14634 gen=$($GETSTRIPE -g $file2)
14635 [[ $gen2 != $gen ]] ||
14636 "Layout generation on $file2 does not change"
14638 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
14639 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14641 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
14643 run_test 184a "Basic layout swap"
14646 check_swap_layouts_support
14648 dir0=$DIR/$tdir/$testnum
14649 mkdir -p $dir0 || error "creating dir $dir0"
14656 $SETSTRIPE -c1 $file1
14657 $SETSTRIPE -c2 $file2
14658 $SETSTRIPE -c1 $file3
14659 chown $RUNAS_ID $file3
14660 gen1=$($GETSTRIPE -g $file1)
14661 gen2=$($GETSTRIPE -g $file2)
14663 $LFS swap_layouts $dir1 $dir2 &&
14664 error "swap of directories layouts should fail"
14665 $LFS swap_layouts $dir1 $file1 &&
14666 error "swap of directory and file layouts should fail"
14667 $RUNAS $LFS swap_layouts $file1 $file2 &&
14668 error "swap of file we cannot write should fail"
14669 $LFS swap_layouts $file1 $file3 &&
14670 error "swap of file with different owner should fail"
14671 /bin/true # to clear error code
14673 run_test 184b "Forbidden layout swap (will generate errors)"
14676 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
14677 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
14678 check_swap_layouts_support
14680 local dir0=$DIR/$tdir/$testnum
14681 mkdir -p $dir0 || error "creating dir $dir0"
14683 local ref1=$dir0/ref1
14684 local ref2=$dir0/ref2
14685 local file1=$dir0/file1
14686 local file2=$dir0/file2
14687 # create a file large enough for the concurrent test
14688 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
14689 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
14690 echo "ref file size: ref1($(stat -c %s $ref1))," \
14691 "ref2($(stat -c %s $ref2))"
14694 dd if=$ref1 of=$file1 bs=16k &
14697 # Make sure dd starts to copy file
14698 while [ ! -f $file1 ]; do sleep 0.1; done
14700 $LFS swap_layouts $file1 $file2
14703 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
14704 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
14706 # how many bytes copied before swapping layout
14707 local copied=$(stat -c %s $file2)
14708 local remaining=$(stat -c %s $ref1)
14709 remaining=$((remaining - copied))
14710 echo "Copied $copied bytes before swapping layout..."
14712 cmp -n $copied $file1 $ref2 | grep differ &&
14713 error "Content mismatch [0, $copied) of ref2 and file1"
14714 cmp -n $copied $file2 $ref1 ||
14715 error "Content mismatch [0, $copied) of ref1 and file2"
14716 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
14717 error "Content mismatch [$copied, EOF) of ref1 and file1"
14720 rm -f $ref1 $ref2 $file1 $file2
14722 run_test 184c "Concurrent write and layout swap"
14725 check_swap_layouts_support
14726 [ -z "$(which getfattr 2>/dev/null)" ] &&
14727 skip_env "no getfattr command"
14729 local file1=$DIR/$tdir/$tfile-1
14730 local file2=$DIR/$tdir/$tfile-2
14731 local file3=$DIR/$tdir/$tfile-3
14735 mkdir -p $DIR/$tdir
14736 touch $file1 || error "create $file1 failed"
14737 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14738 error "create $file2 failed"
14739 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14740 error "create $file3 failed"
14741 lovea1=$(get_layout_param $file1)
14743 $LFS swap_layouts $file2 $file3 ||
14744 error "swap $file2 $file3 layouts failed"
14745 $LFS swap_layouts $file1 $file2 ||
14746 error "swap $file1 $file2 layouts failed"
14748 lovea2=$(get_layout_param $file2)
14751 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
14753 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14754 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
14756 run_test 184d "allow stripeless layouts swap"
14759 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
14760 skip "Need MDS version at least 2.6.94"
14761 check_swap_layouts_support
14762 [ -z "$(which getfattr 2>/dev/null)" ] &&
14763 skip_env "no getfattr command"
14765 local file1=$DIR/$tdir/$tfile-1
14766 local file2=$DIR/$tdir/$tfile-2
14767 local file3=$DIR/$tdir/$tfile-3
14770 mkdir -p $DIR/$tdir
14771 touch $file1 || error "create $file1 failed"
14772 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14773 error "create $file2 failed"
14774 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14775 error "create $file3 failed"
14777 $LFS swap_layouts $file1 $file2 ||
14778 error "swap $file1 $file2 layouts failed"
14780 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14781 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
14783 echo 123 > $file1 || error "Should be able to write into $file1"
14785 $LFS swap_layouts $file1 $file3 ||
14786 error "swap $file1 $file3 layouts failed"
14788 echo 123 > $file1 || error "Should be able to write into $file1"
14790 rm -rf $file1 $file2 $file3
14792 run_test 184e "Recreate layout after stripeless layout swaps"
14795 # Create a file with name longer than sizeof(struct stat) ==
14796 # 144 to see if we can get chars from the file name to appear
14797 # in the returned striping. Note that 'f' == 0x66.
14798 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
14800 mkdir -p $DIR/$tdir
14801 mcreate $DIR/$tdir/$file
14802 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
14803 error "IOC_MDC_GETFILEINFO returned garbage striping"
14806 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
14808 test_185() { # LU-2441
14809 # LU-3553 - no volatile file support in old servers
14810 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
14811 skip "Need MDS version at least 2.3.60"
14813 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14814 touch $DIR/$tdir/spoo
14815 local mtime1=$(stat -c "%Y" $DIR/$tdir)
14816 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
14817 error "cannot create/write a volatile file"
14818 [ "$FILESET" == "" ] &&
14819 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
14820 error "FID is still valid after close"
14822 multiop_bg_pause $DIR/$tdir vVw4096_c
14829 # assume that the next FID for this client is sequential, since stdout
14830 # is unfortunately eaten by multiop_bg_pause
14831 local n=$((${fidv[1]} + 1))
14832 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
14833 if [ "$FILESET" == "" ]; then
14834 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
14835 error "FID is missing before close"
14837 kill -USR1 $multi_pid
14838 # 1 second delay, so if mtime change we will see it
14840 local mtime2=$(stat -c "%Y" $DIR/$tdir)
14841 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
14843 run_test 185 "Volatile file support"
14845 function create_check_volatile() {
14849 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
14852 local FID=$(cat /tmp/${tfile}.fid)
14853 [ "$FID" == "" ] && error "can't get FID for volatile"
14854 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
14855 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
14856 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
14860 cancel_lru_locks mdc # flush opencache
14861 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
14866 # LU-12516 - volatile creation via .lustre
14867 [[ $MDS1_VERSION -ge $(version_code 2.12.2) ]] ||
14868 skip "Need MDS version at least 2.12.2"
14870 create_check_volatile 0
14871 [ $MDSCOUNT -lt 2 ] && return 0
14874 create_check_volatile 1
14878 run_test 185a "Volatile file creation in .lustre/fid/"
14881 remote_mds_nodsh && skip "remote MDS with nodsh"
14882 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14883 skip "Need MDS version at least 2.3.0"
14885 local dir0=$DIR/$tdir/$testnum
14886 mkdir -p $dir0 || error "creating dir $dir0"
14888 local file=$dir0/file1
14889 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
14890 local dv1=$($LFS data_version $file)
14891 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
14892 local dv2=$($LFS data_version $file)
14893 [[ $dv1 != $dv2 ]] ||
14894 error "data version did not change on write $dv1 == $dv2"
14899 run_test 187a "Test data version change"
14902 remote_mds_nodsh && skip "remote MDS with nodsh"
14903 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14904 skip "Need MDS version at least 2.3.0"
14906 local dir0=$DIR/$tdir/$testnum
14907 mkdir -p $dir0 || error "creating dir $dir0"
14909 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
14910 [[ ${DV[0]} != ${DV[1]} ]] ||
14911 error "data version did not change on write"\
14912 " ${DV[0]} == ${DV[1]}"
14917 run_test 187b "Test data version change on volatile file"
14920 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14921 remote_mgs_nodsh && skip "remote MGS with nodsh"
14922 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14924 local POOL=${POOL:-cea1}
14925 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
14926 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
14929 local last_ost=$(($OSTCOUNT - 1))
14931 local ost_list=$(seq $first_ost $ost_step $last_ost)
14932 local ost_range="$first_ost $last_ost $ost_step"
14933 local test_path=$POOL_ROOT/$POOL_DIR_NAME
14934 local file_dir=$POOL_ROOT/file_tst
14935 local subdir=$test_path/subdir
14939 # former test_200a test_200b
14940 pool_add $POOL || { rc=$? ; break; }
14941 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
14942 # former test_200c test_200d
14943 mkdir -p $test_path
14944 pool_set_dir $POOL $test_path || { rc=$? ; break; }
14945 pool_check_dir $POOL $test_path || { rc=$? ; break; }
14947 pool_check_dir $POOL $subdir || { rc=$? ; break; }
14948 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
14949 || { rc=$? ; break; }
14950 # former test_200e test_200f
14951 local files=$((OSTCOUNT*3))
14952 pool_alloc_files $POOL $test_path $files "$ost_list" \
14953 || { rc=$? ; break; }
14954 pool_create_files $POOL $file_dir $files "$ost_list" \
14955 || { rc=$? ; break; }
14956 # former test_200g test_200h
14957 pool_lfs_df $POOL || { rc=$? ; break; }
14958 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
14960 # former test_201a test_201b test_201c
14961 pool_remove_first_target $POOL || { rc=$? ; break; }
14963 local f=$test_path/$tfile
14964 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
14965 pool_remove $POOL $f || { rc=$? ; break; }
14973 run_test 200 "OST pools"
14975 # usage: default_attr <count | size | offset>
14977 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
14980 # usage: check_default_stripe_attr
14981 check_default_stripe_attr() {
14982 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
14985 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
14987 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
14991 error "unknown getstripe attr '$1'"
14994 [ $ACTUAL == $EXPECTED ] ||
14995 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
14999 test_mkdir $DIR/$tdir
15000 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
15002 check_default_stripe_attr --stripe-count
15003 check_default_stripe_attr --stripe-size
15004 check_default_stripe_attr --stripe-index
15006 run_test 204a "Print default stripe attributes"
15009 test_mkdir $DIR/$tdir
15010 $SETSTRIPE --stripe-count 1 $DIR/$tdir
15012 check_default_stripe_attr --stripe-size
15013 check_default_stripe_attr --stripe-index
15015 run_test 204b "Print default stripe size and offset"
15018 test_mkdir $DIR/$tdir
15019 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
15021 check_default_stripe_attr --stripe-count
15022 check_default_stripe_attr --stripe-index
15024 run_test 204c "Print default stripe count and offset"
15027 test_mkdir $DIR/$tdir
15028 $SETSTRIPE --stripe-index 0 $DIR/$tdir
15030 check_default_stripe_attr --stripe-count
15031 check_default_stripe_attr --stripe-size
15033 run_test 204d "Print default stripe count and size"
15036 test_mkdir $DIR/$tdir
15037 $SETSTRIPE -d $DIR/$tdir
15039 check_default_stripe_attr --stripe-count --raw
15040 check_default_stripe_attr --stripe-size --raw
15041 check_default_stripe_attr --stripe-index --raw
15043 run_test 204e "Print raw stripe attributes"
15046 test_mkdir $DIR/$tdir
15047 $SETSTRIPE --stripe-count 1 $DIR/$tdir
15049 check_default_stripe_attr --stripe-size --raw
15050 check_default_stripe_attr --stripe-index --raw
15052 run_test 204f "Print raw stripe size and offset"
15055 test_mkdir $DIR/$tdir
15056 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
15058 check_default_stripe_attr --stripe-count --raw
15059 check_default_stripe_attr --stripe-index --raw
15061 run_test 204g "Print raw stripe count and offset"
15064 test_mkdir $DIR/$tdir
15065 $SETSTRIPE --stripe-index 0 $DIR/$tdir
15067 check_default_stripe_attr --stripe-count --raw
15068 check_default_stripe_attr --stripe-size --raw
15070 run_test 204h "Print raw stripe count and size"
15072 # Figure out which job scheduler is being used, if any,
15073 # or use a fake one
15074 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
15075 JOBENV=SLURM_JOB_ID
15076 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
15078 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
15080 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
15081 JOBENV=LOADL_STEP_ID
15082 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
15085 $LCTL list_param jobid_name > /dev/null 2>&1
15086 if [ $? -eq 0 ]; then
15092 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
15094 verify_jobstats() {
15099 # we don't really need to clear the stats for this test to work, since each
15100 # command has a unique jobid, but it makes debugging easier if needed.
15101 # for facet in $facets; do
15102 # local dev=$(convert_facet2label $facet)
15103 # # clear old jobstats
15104 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
15107 # use a new JobID for each test, or we might see an old one
15108 [ "$JOBENV" = "FAKE_JOBID" ] &&
15109 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
15111 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
15113 [ "$JOBENV" = "nodelocal" ] && {
15114 FAKE_JOBID=id.$testnum.%e.$RANDOM
15115 $LCTL set_param jobid_name=$FAKE_JOBID
15116 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
15119 log "Test: ${cmd[*]}"
15120 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
15122 if [ $JOBENV = "FAKE_JOBID" ]; then
15123 FAKE_JOBID=$JOBVAL ${cmd[*]}
15128 # all files are created on OST0000
15129 for facet in $facets; do
15130 local stats="*.$(convert_facet2label $facet).job_stats"
15132 # strip out libtool wrappers for in-tree executables
15133 if [ $(do_facet $facet lctl get_param $stats |
15134 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
15135 do_facet $facet lctl get_param $stats
15136 error "No jobstats for $JOBVAL found on $facet::$stats"
15142 local new_jobenv=$1
15144 set_persistent_param_and_check client "jobid_var" \
15145 "$FSNAME.sys.jobid_var" $new_jobenv
15148 test_205a() { # Job stats
15149 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15150 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
15151 skip "Need MDS version with at least 2.7.1"
15152 remote_mgs_nodsh && skip "remote MGS with nodsh"
15153 remote_mds_nodsh && skip "remote MDS with nodsh"
15154 remote_ost_nodsh && skip "remote OST with nodsh"
15155 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
15156 skip "Server doesn't support jobstats"
15157 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
15159 local old_jobenv=$($LCTL get_param -n jobid_var)
15160 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
15162 if [[ $PERM_CMD = *"set_param -P"* ]]; then
15163 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
15165 stack_trap "do_facet mgs $PERM_CMD \
15166 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
15170 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
15171 mdt.*.job_cleanup_interval | head -n 1)
15172 local new_interval=5
15173 do_facet $SINGLEMDS \
15174 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
15175 stack_trap "do_facet $SINGLEMDS \
15176 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
15177 local start=$SECONDS
15181 cmd="mkdir $DIR/$tdir"
15182 verify_jobstats "$cmd" "$SINGLEMDS"
15184 cmd="rmdir $DIR/$tdir"
15185 verify_jobstats "$cmd" "$SINGLEMDS"
15186 # mkdir on secondary MDT
15187 if [ $MDSCOUNT -gt 1 ]; then
15188 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
15189 verify_jobstats "$cmd" "mds2"
15192 cmd="mknod $DIR/$tfile c 1 3"
15193 verify_jobstats "$cmd" "$SINGLEMDS"
15195 cmd="rm -f $DIR/$tfile"
15196 verify_jobstats "$cmd" "$SINGLEMDS"
15197 # create all files on OST0000 so verify_jobstats can find OST stats
15199 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
15200 verify_jobstats "$cmd" "$SINGLEMDS"
15202 cmd="touch $DIR/$tfile"
15203 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15205 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
15206 verify_jobstats "$cmd" "ost1"
15208 cancel_lru_locks osc
15209 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
15210 verify_jobstats "$cmd" "ost1"
15212 cmd="$TRUNCATE $DIR/$tfile 0"
15213 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15215 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
15216 verify_jobstats "$cmd" "$SINGLEMDS"
15217 # jobstats expiry - sleep until old stats should be expired
15218 local left=$((new_interval + 5 - (SECONDS - start)))
15219 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
15220 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
15222 cmd="mkdir $DIR/$tdir.expire"
15223 verify_jobstats "$cmd" "$SINGLEMDS"
15224 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
15225 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
15227 # Ensure that jobid are present in changelog (if supported by MDS)
15228 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
15229 changelog_dump | tail -10
15230 jobids=$(changelog_dump | tail -9 | grep -c "j=")
15231 [ $jobids -eq 9 ] ||
15232 error "Wrong changelog jobid count $jobids != 9"
15236 jobstats_set $JOBENV
15238 changelog_dump | grep $tfile
15239 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
15240 [ $jobids -eq 0 ] ||
15241 error "Unexpected jobids when jobid_var=$JOBENV"
15244 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
15245 JOBENV="JOBCOMPLEX"
15246 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
15248 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
15250 run_test 205a "Verify job stats"
15254 $LCTL set_param jobid_var=USER jobid_name="%e.%u"
15255 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
15256 do_facet $SINGLEMDS $LCTL get_param mdt.*.job_stats |
15257 grep job_id: | grep foolish &&
15258 error "Unexpected jobid found"
15261 run_test 205b "Verify job stats jobid parsing"
15263 # LU-1480, LU-1773 and LU-1657
15265 mkdir -p $DIR/$tdir
15266 $SETSTRIPE -c -1 $DIR/$tdir
15267 #define OBD_FAIL_LOV_INIT 0x1403
15268 $LCTL set_param fail_loc=0xa0001403
15269 $LCTL set_param fail_val=1
15270 touch $DIR/$tdir/$tfile || true
15272 run_test 206 "fail lov_init_raid0() doesn't lbug"
15275 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15276 local fsz=`stat -c %s $DIR/$tfile`
15277 cancel_lru_locks mdc
15279 # do not return layout in getattr intent
15280 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
15281 $LCTL set_param fail_loc=0x170
15282 local sz=`stat -c %s $DIR/$tfile`
15284 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
15288 run_test 207a "can refresh layout at glimpse"
15291 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15292 local cksum=`md5sum $DIR/$tfile`
15293 local fsz=`stat -c %s $DIR/$tfile`
15294 cancel_lru_locks mdc
15295 cancel_lru_locks osc
15297 # do not return layout in getattr intent
15298 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
15299 $LCTL set_param fail_loc=0x171
15301 # it will refresh layout after the file is opened but before read issues
15302 echo checksum is "$cksum"
15303 echo "$cksum" |md5sum -c --quiet || error "file differs"
15307 run_test 207b "can refresh layout at open"
15310 # FIXME: in this test suite, only RD lease is used. This is okay
15311 # for now as only exclusive open is supported. After generic lease
15312 # is done, this test suite should be revised. - Jinshan
15314 remote_mds_nodsh && skip "remote MDS with nodsh"
15315 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
15316 skip "Need MDS version at least 2.4.52"
15318 echo "==== test 1: verify get lease work"
15319 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
15321 echo "==== test 2: verify lease can be broken by upcoming open"
15322 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15326 $MULTIOP $DIR/$tfile oO_RDONLY:c
15327 kill -USR1 $PID && wait $PID || error "break lease error"
15329 echo "==== test 3: verify lease can't be granted if an open already exists"
15330 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
15334 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
15335 kill -USR1 $PID && wait $PID || error "open file error"
15337 echo "==== test 4: lease can sustain over recovery"
15338 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
15344 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
15346 echo "==== test 5: lease broken can't be regained by replay"
15347 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15351 # open file to break lease and then recovery
15352 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
15355 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
15359 run_test 208 "Exclusive open"
15362 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
15363 skip_env "must have disp_stripe"
15366 sync; sleep 5; sync;
15368 echo 3 > /proc/sys/vm/drop_caches
15369 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15371 # open/close 500 times
15372 for i in $(seq 500); do
15376 echo 3 > /proc/sys/vm/drop_caches
15377 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15379 echo "before: $req_before, after: $req_after"
15380 [ $((req_after - req_before)) -ge 300 ] &&
15381 error "open/close requests are not freed"
15384 run_test 209 "read-only open/close requests should be freed promptly"
15388 size=$((size % 8192 + 1))
15389 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
15390 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
15391 rm -f $DIR/f212 $DIR/f212.xyz
15393 run_test 212 "Sendfile test ============================================"
15396 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
15397 cancel_lru_locks osc
15398 lctl set_param fail_loc=0x8000040f
15399 # generate a read lock
15400 cat $DIR/$tfile > /dev/null
15401 # write to the file, it will try to cancel the above read lock.
15402 cat /etc/hosts >> $DIR/$tfile
15404 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
15406 test_214() { # for bug 20133
15407 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
15408 for (( i=0; i < 340; i++ )) ; do
15409 touch $DIR/$tdir/d214c/a$i
15412 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
15413 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
15414 ls $DIR/d214c || error "ls $DIR/d214c failed"
15415 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
15416 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
15418 run_test 214 "hash-indexed directory test - bug 20133"
15420 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
15421 create_lnet_proc_files() {
15422 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
15425 # counterpart of create_lnet_proc_files
15426 remove_lnet_proc_files() {
15427 rm -f $TMP/lnet_$1.sys
15430 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15431 # 3rd arg as regexp for body
15432 check_lnet_proc_stats() {
15433 local l=$(cat "$TMP/lnet_$1" |wc -l)
15434 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
15436 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
15439 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15440 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
15441 # optional and can be regexp for 2nd line (lnet.routes case)
15442 check_lnet_proc_entry() {
15443 local blp=2 # blp stands for 'position of 1st line of body'
15444 [ -z "$5" ] || blp=3 # lnet.routes case
15446 local l=$(cat "$TMP/lnet_$1" |wc -l)
15447 # subtracting one from $blp because the body can be empty
15448 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
15450 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
15451 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
15453 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
15454 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
15456 # bail out if any unexpected line happened
15457 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
15458 [ "$?" != 0 ] || error "$2 misformatted"
15461 test_215() { # for bugs 18102, 21079, 21517
15462 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15464 local N='(0|[1-9][0-9]*)' # non-negative numeric
15465 local P='[1-9][0-9]*' # positive numeric
15466 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
15467 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
15468 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
15469 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
15471 local L1 # regexp for 1st line
15472 local L2 # regexp for 2nd line (optional)
15473 local BR # regexp for the rest (body)
15475 # lnet.stats should look as 11 space-separated non-negative numerics
15476 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
15477 create_lnet_proc_files "stats"
15478 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
15479 remove_lnet_proc_files "stats"
15481 # lnet.routes should look like this:
15482 # Routing disabled/enabled
15483 # net hops priority state router
15484 # where net is a string like tcp0, hops > 0, priority >= 0,
15485 # state is up/down,
15486 # router is a string like 192.168.1.1@tcp2
15487 L1="^Routing (disabled|enabled)$"
15488 L2="^net +hops +priority +state +router$"
15489 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
15490 create_lnet_proc_files "routes"
15491 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
15492 remove_lnet_proc_files "routes"
15494 # lnet.routers should look like this:
15495 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
15496 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
15497 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
15498 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
15499 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
15500 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
15501 create_lnet_proc_files "routers"
15502 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
15503 remove_lnet_proc_files "routers"
15505 # lnet.peers should look like this:
15506 # nid refs state last max rtr min tx min queue
15507 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
15508 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
15509 # numeric (0 or >0 or <0), queue >= 0.
15510 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
15511 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
15512 create_lnet_proc_files "peers"
15513 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
15514 remove_lnet_proc_files "peers"
15516 # lnet.buffers should look like this:
15517 # pages count credits min
15518 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
15519 L1="^pages +count +credits +min$"
15520 BR="^ +$N +$N +$I +$I$"
15521 create_lnet_proc_files "buffers"
15522 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
15523 remove_lnet_proc_files "buffers"
15525 # lnet.nis should look like this:
15526 # nid status alive refs peer rtr max tx min
15527 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
15528 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
15529 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
15530 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
15531 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
15532 create_lnet_proc_files "nis"
15533 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
15534 remove_lnet_proc_files "nis"
15536 # can we successfully write to lnet.stats?
15537 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
15539 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
15541 test_216() { # bug 20317
15542 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15543 remote_ost_nodsh && skip "remote OST with nodsh"
15546 local facets=$(get_facets OST)
15547 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15549 save_lustre_params client "osc.*.contention_seconds" > $p
15550 save_lustre_params $facets \
15551 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
15552 save_lustre_params $facets \
15553 "ldlm.namespaces.filter-*.contended_locks" >> $p
15554 save_lustre_params $facets \
15555 "ldlm.namespaces.filter-*.contention_seconds" >> $p
15556 clear_stats osc.*.osc_stats
15558 # agressive lockless i/o settings
15559 do_nodes $(comma_list $(osts_nodes)) \
15560 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
15561 ldlm.namespaces.filter-*.contended_locks=0 \
15562 ldlm.namespaces.filter-*.contention_seconds=60"
15563 lctl set_param -n osc.*.contention_seconds=60
15565 $DIRECTIO write $DIR/$tfile 0 10 4096
15566 $CHECKSTAT -s 40960 $DIR/$tfile
15568 # disable lockless i/o
15569 do_nodes $(comma_list $(osts_nodes)) \
15570 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
15571 ldlm.namespaces.filter-*.contended_locks=32 \
15572 ldlm.namespaces.filter-*.contention_seconds=0"
15573 lctl set_param -n osc.*.contention_seconds=0
15574 clear_stats osc.*.osc_stats
15576 dd if=/dev/zero of=$DIR/$tfile count=0
15577 $CHECKSTAT -s 0 $DIR/$tfile
15579 restore_lustre_params <$p
15583 run_test 216 "check lockless direct write updates file size and kms correctly"
15585 test_217() { # bug 22430
15586 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15591 for node in $(nodes_list); do
15592 nid=$(host_nids_address $node $NETTYPE)
15593 if [[ $nid = *-* ]] ; then
15594 echo "lctl ping $(h2nettype $nid)"
15595 lctl ping $(h2nettype $nid)
15597 echo "skipping $node (no hyphen detected)"
15601 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
15604 # do directio so as not to populate the page cache
15605 log "creating a 10 Mb file"
15606 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
15607 log "starting reads"
15608 dd if=$DIR/$tfile of=/dev/null bs=4096 &
15609 log "truncating the file"
15610 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
15612 kill %+ || true # reads might have finished
15613 echo "wait until dd is finished"
15615 log "removing the temporary file"
15616 rm -rf $DIR/$tfile || error "tmp file removal failed"
15618 run_test 218 "parallel read and truncate should not deadlock"
15621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15623 # write one partial page
15624 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
15625 # set no grant so vvp_io_commit_write will do sync write
15626 $LCTL set_param fail_loc=0x411
15627 # write a full page at the end of file
15628 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
15630 $LCTL set_param fail_loc=0
15631 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
15632 $LCTL set_param fail_loc=0x411
15633 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
15636 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
15637 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
15639 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
15641 test_220() { #LU-325
15642 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15643 remote_ost_nodsh && skip "remote OST with nodsh"
15644 remote_mds_nodsh && skip "remote MDS with nodsh"
15645 remote_mgs_nodsh && skip "remote MGS with nodsh"
15649 # create on MDT0000 so the last_id and next_id are correct
15651 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
15655 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
15656 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
15657 osp.$mdtosc_proc1.prealloc_last_id)
15658 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
15659 osp.$mdtosc_proc1.prealloc_next_id)
15663 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
15664 #define OBD_FAIL_OST_ENOINO 0x229
15665 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
15666 create_pool $FSNAME.$TESTNAME || return 1
15667 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
15669 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
15671 MDSOBJS=$((last_id - next_id))
15672 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
15674 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
15675 echo "OST still has $count kbytes free"
15677 echo "create $MDSOBJS files @next_id..."
15678 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
15680 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15681 osp.$mdtosc_proc1.prealloc_last_id)
15682 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15683 osp.$mdtosc_proc1.prealloc_next_id)
15685 echo "after creation, last_id=$last_id2, next_id=$next_id2"
15690 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
15691 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
15693 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
15694 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
15695 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15696 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
15697 echo "unlink $MDSOBJS files @$next_id..."
15698 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
15700 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
15703 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15705 dd if=`which date` of=$MOUNT/date oflag=sync
15706 chmod +x $MOUNT/date
15708 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
15709 $LCTL set_param fail_loc=0x80001401
15711 $MOUNT/date > /dev/null
15714 run_test 221 "make sure fault and truncate race to not cause OOM"
15717 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15720 test_mkdir $DIR/$tdir
15721 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15722 createmany -o $DIR/$tdir/$tfile 10
15723 cancel_lru_locks mdc
15724 cancel_lru_locks osc
15725 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15726 $LCTL set_param fail_loc=0x31a
15727 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
15728 $LCTL set_param fail_loc=0
15731 run_test 222a "AGL for ls should not trigger CLIO lock failure"
15734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15737 test_mkdir $DIR/$tdir
15738 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15739 createmany -o $DIR/$tdir/$tfile 10
15740 cancel_lru_locks mdc
15741 cancel_lru_locks osc
15742 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15743 $LCTL set_param fail_loc=0x31a
15744 rm -r $DIR/$tdir || error "AGL for rmdir failed"
15745 $LCTL set_param fail_loc=0
15747 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
15750 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15753 test_mkdir $DIR/$tdir
15754 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15755 createmany -o $DIR/$tdir/$tfile 10
15756 cancel_lru_locks mdc
15757 cancel_lru_locks osc
15758 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
15759 $LCTL set_param fail_loc=0x31b
15760 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
15761 $LCTL set_param fail_loc=0
15764 run_test 223 "osc reenqueue if without AGL lock granted ======================="
15766 test_224a() { # LU-1039, MRP-303
15767 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15769 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
15770 $LCTL set_param fail_loc=0x508
15771 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
15772 $LCTL set_param fail_loc=0
15775 run_test 224a "Don't panic on bulk IO failure"
15777 test_224b() { # LU-1039, MRP-303
15778 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15780 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
15781 cancel_lru_locks osc
15782 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
15783 $LCTL set_param fail_loc=0x515
15784 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
15785 $LCTL set_param fail_loc=0
15788 run_test 224b "Don't panic on bulk IO failure"
15790 test_224c() { # LU-6441
15791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15792 remote_mds_nodsh && skip "remote MDS with nodsh"
15794 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15795 save_writethrough $p
15796 set_cache writethrough on
15798 local pages_per_rpc=$($LCTL get_param \
15799 osc.*.max_pages_per_rpc)
15800 local at_max=$($LCTL get_param -n at_max)
15801 local timeout=$($LCTL get_param -n timeout)
15802 local test_at="at_max"
15803 local param_at="$FSNAME.sys.at_max"
15804 local test_timeout="timeout"
15805 local param_timeout="$FSNAME.sys.timeout"
15807 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
15809 set_persistent_param_and_check client "$test_at" "$param_at" 0
15810 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
15812 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
15813 do_facet ost1 $LCTL set_param fail_loc=0x520
15814 $LFS setstripe -c 1 -i 0 $DIR/$tfile
15815 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
15817 do_facet ost1 $LCTL set_param fail_loc=0
15819 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
15820 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
15823 $LCTL set_param -n $pages_per_rpc
15824 restore_lustre_params < $p
15827 run_test 224c "Don't hang if one of md lost during large bulk RPC"
15829 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
15831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15832 if [ -z ${MDSSURVEY} ]; then
15833 skip_env "mds-survey not found"
15835 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15836 skip "Need MDS version at least 2.2.51"
15838 local mds=$(facet_host $SINGLEMDS)
15839 local target=$(do_nodes $mds 'lctl dl' |
15840 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15842 local cmd1="file_count=1000 thrhi=4"
15843 local cmd2="dir_count=2 layer=mdd stripe_count=0"
15844 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15845 local cmd="$cmd1 $cmd2 $cmd3"
15847 rm -f ${TMP}/mds_survey*
15849 eval $cmd || error "mds-survey with zero-stripe failed"
15850 cat ${TMP}/mds_survey*
15851 rm -f ${TMP}/mds_survey*
15853 run_test 225a "Metadata survey sanity with zero-stripe"
15856 if [ -z ${MDSSURVEY} ]; then
15857 skip_env "mds-survey not found"
15859 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15860 skip "Need MDS version at least 2.2.51"
15861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15862 remote_mds_nodsh && skip "remote MDS with nodsh"
15863 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
15864 skip_env "Need to mount OST to test"
15867 local mds=$(facet_host $SINGLEMDS)
15868 local target=$(do_nodes $mds 'lctl dl' |
15869 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15871 local cmd1="file_count=1000 thrhi=4"
15872 local cmd2="dir_count=2 layer=mdd stripe_count=1"
15873 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15874 local cmd="$cmd1 $cmd2 $cmd3"
15876 rm -f ${TMP}/mds_survey*
15878 eval $cmd || error "mds-survey with stripe_count failed"
15879 cat ${TMP}/mds_survey*
15880 rm -f ${TMP}/mds_survey*
15882 run_test 225b "Metadata survey sanity with stripe_count = 1"
15884 mcreate_path2fid () {
15890 local path=$DIR/$tdir/$name
15895 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
15896 error "cannot create $desc"
15898 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
15900 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
15902 fid_path=$($LFS fid2path $MOUNT $fid)
15904 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
15906 [ "$path" == "$fid_path" ] ||
15907 error "fid2path returned $fid_path, expected $path"
15909 echo "pass with $path and $fid"
15914 mkdir -p $DIR/$tdir
15916 mcreate_path2fid 0010666 0 0 fifo "FIFO"
15917 mcreate_path2fid 0020666 1 3 null "character special file (null)"
15918 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
15919 mcreate_path2fid 0040666 0 0 dir "directory"
15920 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
15921 mcreate_path2fid 0100666 0 0 file "regular file"
15922 mcreate_path2fid 0120666 0 0 link "symbolic link"
15923 mcreate_path2fid 0140666 0 0 sock "socket"
15925 run_test 226a "call path2fid and fid2path on files of all type"
15928 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15933 mkdir -p $DIR/$tdir
15934 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
15935 error "create remote directory failed"
15936 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
15937 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
15938 "character special file (null)"
15939 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
15940 "character special file (no device)"
15941 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
15942 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
15943 "block special file (loop)"
15944 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
15945 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
15946 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
15948 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
15950 # LU-1299 Executing or running ldd on a truncated executable does not
15951 # cause an out-of-memory condition.
15953 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15954 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
15956 dd if=$(which date) of=$MOUNT/date bs=1k count=1
15957 chmod +x $MOUNT/date
15959 $MOUNT/date > /dev/null
15960 ldd $MOUNT/date > /dev/null
15963 run_test 227 "running truncated executable does not cause OOM"
15965 # LU-1512 try to reuse idle OI blocks
15967 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15968 remote_mds_nodsh && skip "remote MDS with nodsh"
15969 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15971 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15972 local myDIR=$DIR/$tdir
15975 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15976 $LCTL set_param fail_loc=0x80001002
15977 createmany -o $myDIR/t- 10000
15978 $LCTL set_param fail_loc=0
15979 # The guard is current the largest FID holder
15981 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15983 local IDX=$(($SEQ % 64))
15985 do_facet $SINGLEMDS sync
15986 # Make sure journal flushed.
15988 local blk1=$(do_facet $SINGLEMDS \
15989 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15990 grep Blockcount | awk '{print $4}')
15992 # Remove old files, some OI blocks will become idle.
15993 unlinkmany $myDIR/t- 10000
15994 # Create new files, idle OI blocks should be reused.
15995 createmany -o $myDIR/t- 2000
15996 do_facet $SINGLEMDS sync
15997 # Make sure journal flushed.
15999 local blk2=$(do_facet $SINGLEMDS \
16000 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16001 grep Blockcount | awk '{print $4}')
16003 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16005 run_test 228a "try to reuse idle OI blocks"
16008 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16009 remote_mds_nodsh && skip "remote MDS with nodsh"
16010 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16012 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16013 local myDIR=$DIR/$tdir
16016 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16017 $LCTL set_param fail_loc=0x80001002
16018 createmany -o $myDIR/t- 10000
16019 $LCTL set_param fail_loc=0
16020 # The guard is current the largest FID holder
16022 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16024 local IDX=$(($SEQ % 64))
16026 do_facet $SINGLEMDS sync
16027 # Make sure journal flushed.
16029 local blk1=$(do_facet $SINGLEMDS \
16030 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16031 grep Blockcount | awk '{print $4}')
16033 # Remove old files, some OI blocks will become idle.
16034 unlinkmany $myDIR/t- 10000
16037 stop $SINGLEMDS || error "Fail to stop MDT."
16039 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
16041 df $MOUNT || error "Fail to df."
16042 # Create new files, idle OI blocks should be reused.
16043 createmany -o $myDIR/t- 2000
16044 do_facet $SINGLEMDS sync
16045 # Make sure journal flushed.
16047 local blk2=$(do_facet $SINGLEMDS \
16048 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16049 grep Blockcount | awk '{print $4}')
16051 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16053 run_test 228b "idle OI blocks can be reused after MDT restart"
16057 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16058 remote_mds_nodsh && skip "remote MDS with nodsh"
16059 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16061 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16062 local myDIR=$DIR/$tdir
16065 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16066 $LCTL set_param fail_loc=0x80001002
16067 # 20000 files can guarantee there are index nodes in the OI file
16068 createmany -o $myDIR/t- 20000
16069 $LCTL set_param fail_loc=0
16070 # The guard is current the largest FID holder
16072 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16074 local IDX=$(($SEQ % 64))
16076 do_facet $SINGLEMDS sync
16077 # Make sure journal flushed.
16079 local blk1=$(do_facet $SINGLEMDS \
16080 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16081 grep Blockcount | awk '{print $4}')
16083 # Remove old files, some OI blocks will become idle.
16084 unlinkmany $myDIR/t- 20000
16086 # The OI file should become empty now
16088 # Create new files, idle OI blocks should be reused.
16089 createmany -o $myDIR/t- 2000
16090 do_facet $SINGLEMDS sync
16091 # Make sure journal flushed.
16093 local blk2=$(do_facet $SINGLEMDS \
16094 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16095 grep Blockcount | awk '{print $4}')
16097 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16099 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
16101 test_229() { # LU-2482, LU-3448
16102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16103 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
16104 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
16105 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
16109 # Create a file with a released layout and stripe count 2.
16110 $MULTIOP $DIR/$tfile H2c ||
16111 error "failed to create file with released layout"
16113 $GETSTRIPE -v $DIR/$tfile
16115 local pattern=$($GETSTRIPE -L $DIR/$tfile)
16116 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
16118 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
16119 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
16120 stat $DIR/$tfile || error "failed to stat released file"
16122 chown $RUNAS_ID $DIR/$tfile ||
16123 error "chown $RUNAS_ID $DIR/$tfile failed"
16125 chgrp $RUNAS_ID $DIR/$tfile ||
16126 error "chgrp $RUNAS_ID $DIR/$tfile failed"
16128 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
16129 rm $DIR/$tfile || error "failed to remove released file"
16131 run_test 229 "getstripe/stat/rm/attr changes work on released files"
16134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16135 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16136 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16137 skip "Need MDS version at least 2.11.52"
16141 test_mkdir $DIR/$tdir
16142 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
16143 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
16144 [ $mdt_idx -ne 0 ] &&
16145 error "create local directory on wrong MDT $mdt_idx"
16147 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
16148 error "create remote directory failed"
16149 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
16150 [ $mdt_idx -ne $MDTIDX ] &&
16151 error "create remote directory on wrong MDT $mdt_idx"
16153 createmany -o $DIR/$tdir/test_230/t- 10 ||
16154 error "create files on remote directory failed"
16155 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
16156 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
16157 rm -r $DIR/$tdir || error "unlink remote directory failed"
16159 run_test 230a "Create remote directory and files under the remote directory"
16162 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16163 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16164 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16165 skip "Need MDS version at least 2.11.52"
16173 local migrate_dir=$DIR/$tdir/migrate_dir
16174 local other_dir=$DIR/$tdir/other_dir
16176 test_mkdir $DIR/$tdir
16177 test_mkdir -i0 -c1 $migrate_dir
16178 test_mkdir -i0 -c1 $other_dir
16179 for ((i=0; i<10; i++)); do
16180 mkdir -p $migrate_dir/dir_${i}
16181 createmany -o $migrate_dir/dir_${i}/f 10 ||
16182 error "create files under remote dir failed $i"
16185 cp /etc/passwd $migrate_dir/$tfile
16186 cp /etc/passwd $other_dir/$tfile
16187 chattr +SAD $migrate_dir
16188 chattr +SAD $migrate_dir/$tfile
16190 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16191 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16192 local old_dir_mode=$(stat -c%f $migrate_dir)
16193 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
16195 mkdir -p $migrate_dir/dir_default_stripe2
16196 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
16197 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
16199 mkdir -p $other_dir
16200 ln $migrate_dir/$tfile $other_dir/luna
16201 ln $migrate_dir/$tfile $migrate_dir/sofia
16202 ln $other_dir/$tfile $migrate_dir/david
16203 ln -s $migrate_dir/$tfile $other_dir/zachary
16204 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
16205 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
16211 for len in 58 59 60; do
16212 lnktgt=$(str_repeat 'l' $len)
16213 touch $migrate_dir/$lnktgt
16214 ln -s $lnktgt $migrate_dir/${len}char_ln
16218 for len in 4094 4095; do
16219 lnktgt=$(str_repeat 'l' $len)
16220 ln -s $lnktgt $migrate_dir/${len}char_ln
16224 for len in 254 255; do
16225 touch $migrate_dir/$(str_repeat 'l' $len)
16228 $LFS migrate -m $MDTIDX $migrate_dir ||
16229 error "fails on migrating remote dir to MDT1"
16231 echo "migratate to MDT1, then checking.."
16232 for ((i = 0; i < 10; i++)); do
16233 for file in $(find $migrate_dir/dir_${i}); do
16234 mdt_index=$($LFS getstripe -m $file)
16235 # broken symlink getstripe will fail
16236 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
16237 error "$file is not on MDT${MDTIDX}"
16241 # the multiple link file should still in MDT0
16242 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
16243 [ $mdt_index == 0 ] ||
16244 error "$file is not on MDT${MDTIDX}"
16246 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16247 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16248 error " expect $old_dir_flag get $new_dir_flag"
16250 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16251 [ "$old_file_flag" = "$new_file_flag" ] ||
16252 error " expect $old_file_flag get $new_file_flag"
16254 local new_dir_mode=$(stat -c%f $migrate_dir)
16255 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16256 error "expect mode $old_dir_mode get $new_dir_mode"
16258 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16259 [ "$old_file_mode" = "$new_file_mode" ] ||
16260 error "expect mode $old_file_mode get $new_file_mode"
16262 diff /etc/passwd $migrate_dir/$tfile ||
16263 error "$tfile different after migration"
16265 diff /etc/passwd $other_dir/luna ||
16266 error "luna different after migration"
16268 diff /etc/passwd $migrate_dir/sofia ||
16269 error "sofia different after migration"
16271 diff /etc/passwd $migrate_dir/david ||
16272 error "david different after migration"
16274 diff /etc/passwd $other_dir/zachary ||
16275 error "zachary different after migration"
16277 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16278 error "${tfile}_ln different after migration"
16280 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16281 error "${tfile}_ln_other different after migration"
16283 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
16284 [ $stripe_count = 2 ] ||
16285 error "dir strpe_count $d != 2 after migration."
16287 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
16288 [ $stripe_count = 2 ] ||
16289 error "file strpe_count $d != 2 after migration."
16291 #migrate back to MDT0
16294 $LFS migrate -m $MDTIDX $migrate_dir ||
16295 error "fails on migrating remote dir to MDT0"
16297 echo "migrate back to MDT0, checking.."
16298 for file in $(find $migrate_dir); do
16299 mdt_index=$($LFS getstripe -m $file)
16300 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
16301 error "$file is not on MDT${MDTIDX}"
16304 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16305 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16306 error " expect $old_dir_flag get $new_dir_flag"
16308 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16309 [ "$old_file_flag" = "$new_file_flag" ] ||
16310 error " expect $old_file_flag get $new_file_flag"
16312 local new_dir_mode=$(stat -c%f $migrate_dir)
16313 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16314 error "expect mode $old_dir_mode get $new_dir_mode"
16316 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16317 [ "$old_file_mode" = "$new_file_mode" ] ||
16318 error "expect mode $old_file_mode get $new_file_mode"
16320 diff /etc/passwd ${migrate_dir}/$tfile ||
16321 error "$tfile different after migration"
16323 diff /etc/passwd ${other_dir}/luna ||
16324 error "luna different after migration"
16326 diff /etc/passwd ${migrate_dir}/sofia ||
16327 error "sofia different after migration"
16329 diff /etc/passwd ${other_dir}/zachary ||
16330 error "zachary different after migration"
16332 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16333 error "${tfile}_ln different after migration"
16335 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16336 error "${tfile}_ln_other different after migration"
16338 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
16339 [ $stripe_count = 2 ] ||
16340 error "dir strpe_count $d != 2 after migration."
16342 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
16343 [ $stripe_count = 2 ] ||
16344 error "file strpe_count $d != 2 after migration."
16346 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16348 run_test 230b "migrate directory"
16351 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16352 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16353 remote_mds_nodsh && skip "remote MDS with nodsh"
16354 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16355 skip "Need MDS version at least 2.11.52"
16361 local migrate_dir=$DIR/$tdir/migrate_dir
16363 #If migrating directory fails in the middle, all entries of
16364 #the directory is still accessiable.
16365 test_mkdir $DIR/$tdir
16366 test_mkdir -i0 -c1 $migrate_dir
16367 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
16369 createmany -o $migrate_dir/f $total ||
16370 error "create files under ${migrate_dir} failed"
16372 # fail after migrating top dir, and this will fail only once, so the
16373 # first sub file migration will fail (currently f3), others succeed.
16374 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
16375 do_facet mds1 lctl set_param fail_loc=0x1801
16376 local t=$(ls $migrate_dir | wc -l)
16377 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
16378 error "migrate should fail"
16379 local u=$(ls $migrate_dir | wc -l)
16380 [ "$u" == "$t" ] || error "$u != $t during migration"
16382 # add new dir/file should succeed
16383 mkdir $migrate_dir/dir ||
16384 error "mkdir failed under migrating directory"
16385 touch $migrate_dir/file ||
16386 error "create file failed under migrating directory"
16388 # add file with existing name should fail
16389 for file in $migrate_dir/f*; do
16390 stat $file > /dev/null || error "stat $file failed"
16391 $OPENFILE -f O_CREAT:O_EXCL $file &&
16392 error "open(O_CREAT|O_EXCL) $file should fail"
16393 $MULTIOP $file m && error "create $file should fail"
16394 touch $DIR/$tdir/remote_dir/$tfile ||
16395 error "touch $tfile failed"
16396 ln $DIR/$tdir/remote_dir/$tfile $file &&
16397 error "link $file should fail"
16398 mdt_index=$($LFS getstripe -m $file)
16399 if [ $mdt_index == 0 ]; then
16400 # file failed to migrate is not allowed to rename to
16401 mv $DIR/$tdir/remote_dir/$tfile $file &&
16402 error "rename to $file should fail"
16404 mv $DIR/$tdir/remote_dir/$tfile $file ||
16405 error "rename to $file failed"
16407 echo hello >> $file || error "write $file failed"
16410 # resume migration with different options should fail
16411 $LFS migrate -m 0 $migrate_dir &&
16412 error "migrate -m 0 $migrate_dir should fail"
16414 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
16415 error "migrate -c 2 $migrate_dir should fail"
16417 # resume migration should succeed
16418 $LFS migrate -m $MDTIDX $migrate_dir ||
16419 error "migrate $migrate_dir failed"
16421 echo "Finish migration, then checking.."
16422 for file in $(find $migrate_dir); do
16423 mdt_index=$($LFS getstripe -m $file)
16424 [ $mdt_index == $MDTIDX ] ||
16425 error "$file is not on MDT${MDTIDX}"
16428 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16430 run_test 230c "check directory accessiblity if migration failed"
16433 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16434 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16435 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16436 skip "Need MDS version at least 2.11.52"
16438 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
16440 local migrate_dir=$DIR/$tdir/migrate_dir
16450 old_index=$((RANDOM % MDSCOUNT))
16451 old_count=$((MDSCOUNT - old_index))
16452 new_index=$((RANDOM % MDSCOUNT))
16453 new_count=$((MDSCOUNT - new_index))
16454 new_hash="all_char"
16456 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
16457 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
16459 test_mkdir $DIR/$tdir
16460 test_mkdir -i $old_index -c $old_count $migrate_dir
16462 for ((i=0; i<100; i++)); do
16463 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
16464 createmany -o $migrate_dir/dir_${i}/f 100 ||
16465 error "create files under remote dir failed $i"
16468 echo -n "Migrate from MDT$old_index "
16469 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
16470 echo -n "to MDT$new_index"
16471 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
16474 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
16475 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
16476 error "migrate remote dir error"
16478 echo "Finish migration, then checking.."
16479 for file in $(find $migrate_dir); do
16480 mdt_index=$($LFS getstripe -m $file)
16481 if [ $mdt_index -lt $new_index ] ||
16482 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
16483 error "$file is on MDT$mdt_index"
16487 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16489 run_test 230d "check migrate big directory"
16492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16493 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16494 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16495 skip "Need MDS version at least 2.11.52"
16502 mkdir -p $DIR/$tdir
16503 mkdir $DIR/$tdir/migrate_dir
16504 mkdir $DIR/$tdir/other_dir
16505 touch $DIR/$tdir/migrate_dir/a
16506 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
16507 ls $DIR/$tdir/other_dir
16509 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16510 error "migrate dir fails"
16512 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16513 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16515 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16516 [ $mdt_index == 0 ] || error "a is not on MDT0"
16518 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
16519 error "migrate dir fails"
16521 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
16522 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
16524 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16525 [ $mdt_index == 1 ] || error "a is not on MDT1"
16527 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
16528 [ $mdt_index == 1 ] || error "b is not on MDT1"
16530 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16531 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
16533 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
16535 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16537 run_test 230e "migrate mulitple local link files"
16540 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16541 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16542 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16543 skip "Need MDS version at least 2.11.52"
16548 mkdir -p $DIR/$tdir
16549 mkdir $DIR/$tdir/migrate_dir
16550 $LFS mkdir -i1 $DIR/$tdir/other_dir
16551 touch $DIR/$tdir/migrate_dir/a
16552 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
16553 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
16554 ls $DIR/$tdir/other_dir
16556 # a should be migrated to MDT1, since no other links on MDT0
16557 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16558 error "#1 migrate dir fails"
16559 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16560 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16561 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16562 [ $mdt_index == 1 ] || error "a is not on MDT1"
16564 # a should stay on MDT1, because it is a mulitple link file
16565 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16566 error "#2 migrate dir fails"
16567 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16568 [ $mdt_index == 1 ] || error "a is not on MDT1"
16570 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16571 error "#3 migrate dir fails"
16573 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16574 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
16575 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
16577 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
16578 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
16580 # a should be migrated to MDT0, since no other links on MDT1
16581 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16582 error "#4 migrate dir fails"
16583 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16584 [ $mdt_index == 0 ] || error "a is not on MDT0"
16586 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16588 run_test 230f "migrate mulitple remote link files"
16591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16592 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16593 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16594 skip "Need MDS version at least 2.11.52"
16596 mkdir -p $DIR/$tdir/migrate_dir
16598 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
16599 error "migrating dir to non-exist MDT succeeds"
16602 run_test 230g "migrate dir to non-exist MDT"
16605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16606 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16607 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16608 skip "Need MDS version at least 2.11.52"
16612 mkdir -p $DIR/$tdir/migrate_dir
16614 $LFS migrate -m1 $DIR &&
16615 error "migrating mountpoint1 should fail"
16617 $LFS migrate -m1 $DIR/$tdir/.. &&
16618 error "migrating mountpoint2 should fail"
16621 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
16622 error "migrating $tdir/migrate_dir/.. should fail"
16626 run_test 230h "migrate .. and root"
16629 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16630 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16631 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16632 skip "Need MDS version at least 2.11.52"
16634 mkdir -p $DIR/$tdir/migrate_dir
16636 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
16637 error "migration fails with a tailing slash"
16639 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
16640 error "migration fails with two tailing slashes"
16642 run_test 230i "lfs migrate -m tolerates trailing slashes"
16645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16646 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16647 skip "Need MDS version at least 2.11.52"
16649 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
16650 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
16651 error "create $tfile failed"
16652 cat /etc/passwd > $DIR/$tdir/$tfile
16654 $LFS migrate -m 1 $DIR/$tdir
16656 cmp /etc/passwd $DIR/$tdir/$tfile ||
16657 error "DoM file mismatch after migration"
16659 run_test 230j "DoM file data not changed after dir migration"
16662 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
16663 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16664 skip "Need MDS version at least 2.11.56"
16667 local files_on_starting_mdt=0
16669 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
16670 $LFS getdirstripe $DIR/$tdir
16671 for i in $(seq $total); do
16672 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
16673 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16674 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16677 echo "$files_on_starting_mdt files on MDT0"
16679 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
16680 $LFS getdirstripe $DIR/$tdir
16682 files_on_starting_mdt=0
16683 for i in $(seq $total); do
16684 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16685 error "file $tfile.$i mismatch after migration"
16686 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
16687 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16690 echo "$files_on_starting_mdt files on MDT1 after migration"
16691 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
16693 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
16694 $LFS getdirstripe $DIR/$tdir
16696 files_on_starting_mdt=0
16697 for i in $(seq $total); do
16698 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16699 error "file $tfile.$i mismatch after 2nd migration"
16700 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16701 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16704 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
16705 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
16709 run_test 230k "file data not changed after dir migration"
16712 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16713 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16714 skip "Need MDS version at least 2.11.56"
16716 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
16717 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
16718 error "create files under remote dir failed $i"
16719 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
16721 run_test 230l "readdir between MDTs won't crash"
16724 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16725 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16726 skip "Need MDS version at least 2.11.56"
16729 local mig_dir=$DIR/$tdir/migrate_dir
16730 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
16734 echo "Creating files and dirs with xattrs"
16735 test_mkdir $DIR/$tdir
16736 test_mkdir -i0 -c1 $mig_dir
16738 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
16739 error "cannot set xattr attr1 on dir"
16740 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
16741 error "cannot set xattr attr2 on dir"
16742 touch $mig_dir/dir/f0
16743 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
16744 error "cannot set xattr attr1 on file"
16745 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
16746 error "cannot set xattr attr2 on file"
16747 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
16748 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
16749 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
16750 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
16751 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
16752 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
16753 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
16754 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
16755 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
16757 echo "Migrating to MDT1"
16758 $LFS migrate -m $MDTIDX $mig_dir ||
16759 error "fails on migrating dir to MDT1"
16761 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
16762 echo "Checking xattrs"
16763 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
16764 [ "$val" = $longstr ] ||
16765 error "expecting xattr1 $longstr on dir, found $val"
16766 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
16767 [ "$val" = $shortstr ] ||
16768 error "expecting xattr2 $shortstr on dir, found $val"
16769 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
16770 [ "$val" = $longstr ] ||
16771 error "expecting xattr1 $longstr on file, found $val"
16772 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
16773 [ "$val" = $shortstr ] ||
16774 error "expecting xattr2 $shortstr on file, found $val"
16776 run_test 230m "xattrs not changed after dir migration"
16779 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16780 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
16781 [[ $MDS1_VERSION -ge $(version_code 2.12.5) ]] ||
16782 skip "Need MDS version at least 2.12.5"
16784 # maximum amount of local locks:
16785 # parent striped dir - 2 locks
16786 # new stripe in parent to migrate to - 1 lock
16787 # source and target - 2 locks
16788 # Total 5 locks for regular file
16789 mkdir -p $DIR/$tdir
16790 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
16791 touch $DIR/$tdir/dir1/eee
16793 # create 4 hardlink for 4 more locks
16794 # Total: 9 locks > RS_MAX_LOCKS (8)
16795 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
16796 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
16797 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
16798 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
16799 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
16800 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
16801 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
16802 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
16804 cancel_lru_locks mdc
16806 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
16807 error "migrate dir fails"
16809 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16811 run_test 230r "migrate with too many local locks"
16815 # For simplicity this test assumes that max_pages_per_rpc
16816 # is the same across all OSCs
16817 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
16818 local bulk_size=$((max_pages * PAGE_SIZE))
16819 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
16822 mkdir -p $DIR/$tdir
16823 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
16824 error "failed to set stripe with -S ${brw_size}M option"
16826 # clear the OSC stats
16827 $LCTL set_param osc.*.stats=0 &>/dev/null
16830 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
16831 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
16832 oflag=direct &>/dev/null || error "dd failed"
16834 sync; sleep 1; sync # just to be safe
16835 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
16836 if [ x$nrpcs != "x1" ]; then
16837 $LCTL get_param osc.*.stats
16838 error "found $nrpcs ost_write RPCs, not 1 as expected"
16842 # Drop the OSC cache, otherwise we will read from it
16843 cancel_lru_locks osc
16845 # clear the OSC stats
16846 $LCTL set_param osc.*.stats=0 &>/dev/null
16848 # Client reads $bulk_size.
16849 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
16850 iflag=direct &>/dev/null || error "dd failed"
16852 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
16853 if [ x$nrpcs != "x1" ]; then
16854 $LCTL get_param osc.*.stats
16855 error "found $nrpcs ost_read RPCs, not 1 as expected"
16858 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
16861 mkdir -p $DIR/$tdir
16863 for i in {0..1023}; do
16864 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
16865 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
16866 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
16870 run_test 231b "must not assert on fully utilized OST request buffer"
16873 mkdir -p $DIR/$tdir
16874 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16876 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16877 do_facet ost1 $LCTL set_param fail_loc=0x31c
16879 # ignore dd failure
16880 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
16882 do_facet ost1 $LCTL set_param fail_loc=0
16883 umount_client $MOUNT || error "umount failed"
16884 mount_client $MOUNT || error "mount failed"
16885 stop ost1 || error "cannot stop ost1"
16886 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16888 run_test 232a "failed lock should not block umount"
16891 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
16892 skip "Need MDS version at least 2.10.58"
16894 mkdir -p $DIR/$tdir
16895 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16896 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
16898 cancel_lru_locks osc
16900 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16901 do_facet ost1 $LCTL set_param fail_loc=0x31c
16904 $LFS data_version $DIR/$tdir/$tfile || true
16906 do_facet ost1 $LCTL set_param fail_loc=0
16907 umount_client $MOUNT || error "umount failed"
16908 mount_client $MOUNT || error "mount failed"
16909 stop ost1 || error "cannot stop ost1"
16910 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16912 run_test 232b "failed data version lock should not block umount"
16915 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
16916 skip "Need MDS version at least 2.3.64"
16917 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16919 local fid=$($LFS path2fid $MOUNT)
16921 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16922 error "cannot access $MOUNT using its FID '$fid'"
16924 run_test 233a "checking that OBF of the FS root succeeds"
16927 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
16928 skip "Need MDS version at least 2.5.90"
16929 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16931 local fid=$($LFS path2fid $MOUNT/.lustre)
16933 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16934 error "cannot access $MOUNT/.lustre using its FID '$fid'"
16936 fid=$($LFS path2fid $MOUNT/.lustre/fid)
16937 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16938 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
16940 run_test 233b "checking that OBF of the FS .lustre succeeds"
16943 local p="$TMP/sanityN-$TESTNAME.parameters"
16944 save_lustre_params client "llite.*.xattr_cache" > $p
16945 lctl set_param llite.*.xattr_cache 1 ||
16946 skip_env "xattr cache is not supported"
16948 mkdir -p $DIR/$tdir || error "mkdir failed"
16949 touch $DIR/$tdir/$tfile || error "touch failed"
16950 # OBD_FAIL_LLITE_XATTR_ENOMEM
16951 $LCTL set_param fail_loc=0x1405
16952 getfattr -n user.attr $DIR/$tdir/$tfile &&
16953 error "getfattr should have failed with ENOMEM"
16954 $LCTL set_param fail_loc=0x0
16957 restore_lustre_params < $p
16960 run_test 234 "xattr cache should not crash on ENOMEM"
16963 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
16964 skip "Need MDS version at least 2.4.52"
16966 flock_deadlock $DIR/$tfile
16971 124) error "process hangs on a deadlock"
16973 *) error "error executing flock_deadlock $DIR/$tfile"
16977 run_test 235 "LU-1715: flock deadlock detection does not work properly"
16981 check_swap_layouts_support
16983 local ref1=/etc/passwd
16984 local ref2=/etc/group
16985 local file1=$DIR/$tdir/f1
16986 local file2=$DIR/$tdir/f2
16988 test_mkdir -c1 $DIR/$tdir
16989 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
16990 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
16991 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
16992 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
16993 local fd=$(free_fd)
16994 local cmd="exec $fd<>$file2"
16997 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
16998 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
17001 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
17006 run_test 236 "Layout swap on open unlinked file"
17008 # LU-4659 linkea consistency
17010 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
17011 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
17012 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
17013 skip "Need MDS version at least 2.5.58 or 2.5.2+"
17016 ln $DIR/$tfile $DIR/$tfile.lnk
17017 touch $DIR/$tfile.new
17018 mv $DIR/$tfile.new $DIR/$tfile
17019 local fid1=$($LFS path2fid $DIR/$tfile)
17020 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
17021 local path1=$($LFS fid2path $FSNAME "$fid1")
17022 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
17023 local path2=$($LFS fid2path $FSNAME "$fid2")
17024 [ $tfile.lnk == $path2 ] ||
17025 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
17028 run_test 238 "Verify linkea consistency"
17030 test_239A() { # was test_239
17031 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
17032 skip "Need MDS version at least 2.5.60"
17034 local list=$(comma_list $(mdts_nodes))
17036 mkdir -p $DIR/$tdir
17037 createmany -o $DIR/$tdir/f- 5000
17038 unlinkmany $DIR/$tdir/f- 5000
17039 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
17040 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
17041 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
17042 osp.*MDT*.sync_in_flight" | calc_sum)
17043 [ "$changes" -eq 0 ] || error "$changes not synced"
17045 run_test 239A "osp_sync test"
17047 test_239a() { #LU-5297
17048 remote_mds_nodsh && skip "remote MDS with nodsh"
17051 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
17052 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
17053 chgrp $RUNAS_GID $DIR/$tfile
17054 wait_delete_completed
17056 run_test 239a "process invalid osp sync record correctly"
17058 test_239b() { #LU-5297
17059 remote_mds_nodsh && skip "remote MDS with nodsh"
17062 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
17063 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
17064 chgrp $RUNAS_GID $DIR/$tfile1
17065 wait_delete_completed
17066 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17068 chgrp $RUNAS_GID $DIR/$tfile2
17069 wait_delete_completed
17071 run_test 239b "process osp sync record with ENOMEM error correctly"
17074 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17075 remote_mds_nodsh && skip "remote MDS with nodsh"
17077 mkdir -p $DIR/$tdir
17079 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
17080 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
17081 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
17082 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
17084 umount_client $MOUNT || error "umount failed"
17085 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
17086 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
17087 mount_client $MOUNT || error "failed to mount client"
17089 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
17090 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
17092 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
17098 for LOOP in $(seq $count); do
17099 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
17100 cancel_lru_locks $OSC || true
17108 for LOOP in $(seq $1); do
17109 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
17114 test_241a() { # was test_241
17115 local bsize=$PAGE_SIZE
17117 (( bsize < 40960 )) && bsize=40960
17118 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17120 cancel_lru_locks $OSC
17121 test_241_bio 1000 $bsize &
17123 test_241_dio 1000 $bsize
17126 run_test 241a "bio vs dio"
17129 local bsize=$PAGE_SIZE
17131 (( bsize < 40960 )) && bsize=40960
17132 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17134 test_241_dio 1000 $bsize &
17136 test_241_dio 1000 $bsize
17139 run_test 241b "dio vs dio"
17142 remote_mds_nodsh && skip "remote MDS with nodsh"
17144 mkdir -p $DIR/$tdir
17145 touch $DIR/$tdir/$tfile
17147 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
17148 do_facet mds1 lctl set_param fail_loc=0x105
17149 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
17151 do_facet mds1 lctl set_param fail_loc=0
17152 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
17154 run_test 242 "mdt_readpage failure should not cause directory unreadable"
17158 test_mkdir $DIR/$tdir
17159 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
17161 run_test 243 "various group lock tests"
17165 test_mkdir $DIR/$tdir
17166 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
17167 sendfile_grouplock $DIR/$tdir/$tfile || \
17168 error "sendfile+grouplock failed"
17171 run_test 244 "sendfile with group lock tests"
17174 local flagname="multi_mod_rpcs"
17175 local connect_data_name="max_mod_rpcs"
17178 # check if multiple modify RPCs flag is set
17179 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
17180 grep "connect_flags:")
17183 echo "$out" | grep -qw $flagname
17184 if [ $? -ne 0 ]; then
17185 echo "connect flag $flagname is not set"
17189 # check if multiple modify RPCs data is set
17190 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
17193 echo "$out" | grep -qw $connect_data_name ||
17194 error "import should have connect data $connect_data_name"
17196 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
17198 test_246() { # LU-7371
17199 remote_ost_nodsh && skip "remote OST with nodsh"
17200 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
17201 skip "Need OST version >= 2.7.62"
17203 do_facet ost1 $LCTL set_param fail_val=4095
17204 #define OBD_FAIL_OST_READ_SIZE 0x234
17205 do_facet ost1 $LCTL set_param fail_loc=0x234
17206 $LFS setstripe $DIR/$tfile -i 0 -c 1
17207 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
17208 cancel_lru_locks $FSNAME-OST0000
17209 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
17211 run_test 246 "Read file of size 4095 should return right length"
17217 umount_client $submount
17222 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17224 skip_env "Fileset feature is not supported"
17226 local submount=${MOUNT}_$tdir
17229 mkdir -p $submount || error "mkdir $submount failed"
17230 FILESET="$FILESET/$tdir" mount_client $submount ||
17231 error "mount $submount failed"
17232 trap "cleanup_247 $submount" EXIT
17233 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
17234 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
17235 error "read $MOUNT/$tdir/$tfile failed"
17236 cleanup_247 $submount
17238 run_test 247a "mount subdir as fileset"
17241 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17242 skip_env "Fileset feature is not supported"
17244 local submount=${MOUNT}_$tdir
17246 rm -rf $MOUNT/$tdir
17247 mkdir -p $submount || error "mkdir $submount failed"
17249 FILESET="$FILESET/$tdir" mount_client $submount &&
17250 error "mount $submount should fail"
17253 run_test 247b "mount subdir that dose not exist"
17256 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17257 skip_env "Fileset feature is not supported"
17259 local submount=${MOUNT}_$tdir
17261 mkdir -p $MOUNT/$tdir/dir1
17262 mkdir -p $submount || error "mkdir $submount failed"
17263 trap "cleanup_247 $submount" EXIT
17264 FILESET="$FILESET/$tdir" mount_client $submount ||
17265 error "mount $submount failed"
17266 local fid=$($LFS path2fid $MOUNT/)
17267 $LFS fid2path $submount $fid && error "fid2path should fail"
17268 cleanup_247 $submount
17270 run_test 247c "running fid2path outside root"
17273 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17274 skip "Fileset feature is not supported"
17276 local submount=${MOUNT}_$tdir
17278 mkdir -p $MOUNT/$tdir/dir1
17279 mkdir -p $submount || error "mkdir $submount failed"
17280 FILESET="$FILESET/$tdir" mount_client $submount ||
17281 error "mount $submount failed"
17282 trap "cleanup_247 $submount" EXIT
17283 local fid=$($LFS path2fid $submount/dir1)
17284 $LFS fid2path $submount $fid || error "fid2path should succeed"
17285 cleanup_247 $submount
17287 run_test 247d "running fid2path inside root"
17291 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17293 skip "Fileset feature is not supported"
17295 local submount=${MOUNT}_$tdir
17298 mkdir -p $submount || error "mkdir $submount failed"
17299 FILESET="$FILESET/.." mount_client $submount &&
17300 error "mount $submount should fail"
17303 run_test 247e "mount .. as fileset"
17306 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17307 [ $MDS1_VERSION -lt $(version_code 2.12.6) ] &&
17308 skip "Need at least version 2.12.6"
17309 [ $CLIENT_VERSION -lt $(version_code 2.12.6) ] &&
17310 skip "Need at least version 2.12.6"
17311 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17313 skip "Fileset feature is not supported"
17315 mkdir $DIR/$tdir || error "mkdir $tdir failed"
17316 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
17317 error "mkdir remote failed"
17318 mkdir $DIR/$tdir/remote/subdir || error "mkdir remote/subdir failed"
17319 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
17320 error "mkdir striped failed"
17321 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
17323 local submount=${MOUNT}_$tdir
17325 mkdir -p $submount || error "mkdir $submount failed"
17326 stack_trap "rmdir $submount"
17330 local fileset=$FILESET
17331 local mdts=$(comma_list $(mdts_nodes))
17333 stat=$(do_facet mds1 $LCTL get_param -n \
17334 mdt.*MDT0000.enable_remote_subdir_mount)
17335 stack_trap "do_nodes $mdts $LCTL set_param \
17336 mdt.*.enable_remote_subdir_mount=$stat"
17338 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
17339 stack_trap "umount_client $submount"
17340 FILESET="$fileset/$tdir/remote" mount_client $submount &&
17341 error "mount remote dir $dir should fail"
17343 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
17344 $tdir/striped/. ; do
17345 FILESET="$fileset/$dir" mount_client $submount ||
17346 error "mount $dir failed"
17347 umount_client $submount
17350 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
17351 FILESET="$fileset/$tdir/remote" mount_client $submount ||
17352 error "mount $tdir/remote failed"
17354 run_test 247f "mount striped or remote directory as fileset"
17357 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
17358 [ $CLIENT_VERSION -lt $(version_code 2.12.6) ] &&
17359 skip "Need at least version 2.12.6"
17361 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
17362 error "mkdir $tdir failed"
17363 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
17365 local submount=${MOUNT}_$tdir
17367 mkdir -p $submount || error "mkdir $submount failed"
17368 stack_trap "rmdir $submount"
17370 FILESET="$fileset/$tdir" mount_client $submount ||
17371 error "mount $dir failed"
17372 stack_trap "umount $submount"
17374 local mdts=$(comma_list $(mdts_nodes))
17378 stat $submount > /dev/null
17379 cancel_lru_locks $MDC
17380 stat $submount > /dev/null
17381 stat $submount/$tfile > /dev/null
17382 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
17383 stat $submount/$tfile > /dev/null
17384 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
17385 awk '/getattr/ {sum += $2} END {print sum}')
17387 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
17389 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
17392 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
17393 [ -z "$fast_read_sav" ] && skip "no fast read support"
17395 # create a large file for fast read verification
17396 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
17398 # make sure the file is created correctly
17399 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
17400 { rm -f $DIR/$tfile; skip "file creation error"; }
17402 echo "Test 1: verify that fast read is 4 times faster on cache read"
17404 # small read with fast read enabled
17405 $LCTL set_param -n llite.*.fast_read=1
17406 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17407 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17408 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17409 # small read with fast read disabled
17410 $LCTL set_param -n llite.*.fast_read=0
17411 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17412 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17413 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17415 # verify that fast read is 4 times faster for cache read
17416 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
17417 error_not_in_vm "fast read was not 4 times faster: " \
17418 "$t_fast vs $t_slow"
17420 echo "Test 2: verify the performance between big and small read"
17421 $LCTL set_param -n llite.*.fast_read=1
17423 # 1k non-cache read
17424 cancel_lru_locks osc
17425 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17426 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17427 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17429 # 1M non-cache read
17430 cancel_lru_locks osc
17431 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17432 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17433 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17435 # verify that big IO is not 4 times faster than small IO
17436 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
17437 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
17439 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
17442 run_test 248 "fast read verification"
17444 test_249() { # LU-7890
17445 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
17446 skip "Need at least version 2.8.54"
17449 $SETSTRIPE -c 1 $DIR/$tfile
17450 # Offset 2T == 4k * 512M
17451 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
17452 error "dd to 2T offset failed"
17454 run_test 249 "Write above 2T file size"
17457 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
17458 && skip "no 16TB file size limit on ZFS"
17460 $SETSTRIPE -c 1 $DIR/$tfile
17461 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
17462 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
17463 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
17464 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
17465 conv=notrunc,fsync && error "append succeeded"
17468 run_test 250 "Write above 16T limit"
17471 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
17473 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
17474 #Skip once - writing the first stripe will succeed
17475 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17476 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
17477 error "short write happened"
17479 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17480 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
17481 error "short read happened"
17485 run_test 251 "Handling short read and write correctly"
17488 remote_mds_nodsh && skip "remote MDS with nodsh"
17489 remote_ost_nodsh && skip "remote OST with nodsh"
17490 if [ "$ost1_FSTYPE" != "ldiskfs" -o "$mds1_FSTYPE" != "ldiskfs" ]; then
17491 skip_env "ldiskfs only test"
17501 # check lr_reader on OST0000
17503 dev=$(facet_device $tgt)
17504 out=$(do_facet $tgt $LR_READER $dev)
17505 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17507 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
17508 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
17509 error "Invalid uuid returned by $LR_READER on target $tgt"
17510 echo -e "uuid returned by $LR_READER is '$uuid'\n"
17512 # check lr_reader -c on MDT0000
17514 dev=$(facet_device $tgt)
17515 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
17516 skip "$LR_READER does not support additional options"
17518 out=$(do_facet $tgt $LR_READER -c $dev)
17519 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17521 num=$(echo "$out" | grep -c "mdtlov")
17522 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
17523 error "Invalid number of mdtlov clients returned by $LR_READER"
17524 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
17526 # check lr_reader -cr on MDT0000
17527 out=$(do_facet $tgt $LR_READER -cr $dev)
17528 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17530 echo "$out" | grep -q "^reply_data:$" ||
17531 error "$LR_READER should have returned 'reply_data' section"
17532 num=$(echo "$out" | grep -c "client_generation")
17533 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
17535 run_test 252 "check lr_reader tool"
17537 test_253_fill_ost() {
17538 local size_mb #how many MB should we write to pass watermark
17539 local lwm=$3 #low watermark
17540 local free_10mb #10% of free space
17542 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
17543 size_mb=$((free_kb / 1024 - lwm))
17544 free_10mb=$((free_kb / 10240))
17545 #If 10% of free space cross low watermark use it
17546 if (( free_10mb > size_mb )); then
17549 #At least we need to store 1.1 of difference between
17550 #free space and low watermark
17551 size_mb=$((size_mb + size_mb / 10))
17553 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
17554 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
17555 oflag=append conv=notrunc
17560 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
17561 echo "OST still has $((free_kb / 1024)) mbytes free"
17565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17566 remote_mds_nodsh && skip "remote MDS with nodsh"
17567 remote_mgs_nodsh && skip "remote MGS with nodsh"
17572 local ost_name=$($LFS osts |
17573 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
17575 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
17576 do_facet $SINGLEMDS $LCTL get_param -n \
17577 osp.$mdtosc_proc1.reserved_mb_high ||
17578 skip "remote MDS does not support reserved_mb_high"
17582 wait_delete_completed
17585 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
17586 osp.$mdtosc_proc1.reserved_mb_high)
17587 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
17588 osp.$mdtosc_proc1.reserved_mb_low)
17589 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
17591 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
17592 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
17593 error "Adding $ost_name to pool failed"
17595 # Wait for client to see a OST at pool
17596 wait_update $HOSTNAME "$LCTL get_param -n
17597 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
17598 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
17599 error "Client can not see the pool"
17600 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
17601 error "Setstripe failed"
17603 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
17604 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
17605 echo "OST still has $((blocks/1024)) mbytes free"
17607 local new_lwm=$((blocks/1024-10))
17608 do_facet $SINGLEMDS $LCTL set_param \
17609 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
17610 do_facet $SINGLEMDS $LCTL set_param \
17611 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
17613 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
17615 #First enospc could execute orphan deletion so repeat.
17616 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
17618 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17619 osp.$mdtosc_proc1.prealloc_status)
17620 echo "prealloc_status $oa_status"
17622 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
17623 error "File creation should fail"
17624 #object allocation was stopped, but we still able to append files
17625 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
17626 error "Append failed"
17627 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
17629 wait_delete_completed
17633 for i in $(seq 10 12); do
17634 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
17635 error "File creation failed after rm";
17638 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17639 osp.$mdtosc_proc1.prealloc_status)
17640 echo "prealloc_status $oa_status"
17642 if (( oa_status != 0 )); then
17643 error "Object allocation still disable after rm"
17645 do_facet $SINGLEMDS $LCTL set_param \
17646 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
17647 do_facet $SINGLEMDS $LCTL set_param \
17648 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
17651 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
17652 error "Remove $ost_name from pool failed"
17653 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
17654 error "Pool destroy fialed"
17656 run_test 253 "Check object allocation limit"
17659 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17660 remote_mds_nodsh && skip "remote MDS with nodsh"
17661 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
17662 skip "MDS does not support changelog_size"
17665 local MDT0=$(facet_svc $SINGLEMDS)
17667 changelog_register || error "changelog_register failed"
17669 changelog_clear 0 || error "changelog_clear failed"
17671 local size1=$(do_facet $SINGLEMDS \
17672 $LCTL get_param -n mdd.$MDT0.changelog_size)
17673 echo "Changelog size $size1"
17676 $LFS mkdir -i 0 $DIR/$tdir
17678 mkdir -p $DIR/$tdir/pics/2008/zachy
17679 touch $DIR/$tdir/pics/2008/zachy/timestamp
17680 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
17681 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
17682 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
17683 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
17684 rm $DIR/$tdir/pics/desktop.jpg
17686 local size2=$(do_facet $SINGLEMDS \
17687 $LCTL get_param -n mdd.$MDT0.changelog_size)
17688 echo "Changelog size after work $size2"
17690 (( $size2 > $size1 )) ||
17691 error "new Changelog size=$size2 less than old size=$size1"
17693 run_test 254 "Check changelog size"
17700 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
17701 awk -F: '{print $2}' | grep $type > /dev/null
17702 if [ $? -ne 0 ]; then
17712 lfs ladvise -a willread $file > /dev/null 2>&1
17713 if [ $? -eq 0 ]; then
17717 lfs ladvise -a willread $file 2>&1 |
17718 grep "Inappropriate ioctl for device" > /dev/null
17719 if [ $? -eq 0 ]; then
17726 bc <<<"scale=2; ($1 - $2) * 100 / $2"
17729 # run a random read IO workload
17730 # usage: random_read_iops <filename> <filesize> <iosize>
17731 random_read_iops() {
17734 local iosize=${3:-4096}
17736 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
17737 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
17740 drop_file_oss_cache() {
17744 $LFS ladvise -a dontneed $file 2>/dev/null ||
17745 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
17748 ladvise_willread_performance()
17751 local average_origin=0
17752 local average_cache=0
17753 local average_ladvise=0
17755 for ((i = 1; i <= $repeat; i++)); do
17756 echo "Iter $i/$repeat: reading without willread hint"
17757 cancel_lru_locks osc
17758 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17759 local speed_origin=$(random_read_iops $DIR/$tfile $size)
17760 echo "Iter $i/$repeat: uncached speed: $speed_origin"
17761 average_origin=$(bc <<<"$average_origin + $speed_origin")
17763 cancel_lru_locks osc
17764 local speed_cache=$(random_read_iops $DIR/$tfile $size)
17765 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
17766 average_cache=$(bc <<<"$average_cache + $speed_cache")
17768 cancel_lru_locks osc
17769 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17770 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
17771 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
17772 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
17773 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
17775 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
17776 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
17777 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
17779 speedup_cache=$(percent $average_cache $average_origin)
17780 speedup_ladvise=$(percent $average_ladvise $average_origin)
17782 echo "Average uncached read: $average_origin"
17783 echo "Average speedup with OSS cached read: " \
17784 "$average_cache = +$speedup_cache%"
17785 echo "Average speedup with ladvise willread: " \
17786 "$average_ladvise = +$speedup_ladvise%"
17788 local lowest_speedup=20
17789 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
17790 echo "Speedup with OSS cached read less than $lowest_speedup%," \
17791 "got $average_cache%. Skipping ladvise willread check."
17795 # the test won't work on ZFS until it supports 'ladvise dontneed', but
17796 # it is still good to run until then to exercise 'ladvise willread'
17797 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17798 [ "$ost1_FSTYPE" = "zfs" ] &&
17799 echo "osd-zfs does not support dontneed or drop_caches" &&
17802 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
17803 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
17804 error_not_in_vm "Speedup with willread is less than " \
17805 "$lowest_speedup%, got $average_ladvise%"
17809 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17810 skip "lustre < 2.8.54 does not support ladvise "
17811 remote_ost_nodsh && skip "remote OST with nodsh"
17813 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
17815 ladvise_no_type willread $DIR/$tfile &&
17816 skip "willread ladvise is not supported"
17818 ladvise_no_ioctl $DIR/$tfile &&
17819 skip "ladvise ioctl is not supported"
17822 local size=$((size_mb * 1048576))
17823 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17824 error "dd to $DIR/$tfile failed"
17826 lfs ladvise -a willread $DIR/$tfile ||
17827 error "Ladvise failed with no range argument"
17829 lfs ladvise -a willread -s 0 $DIR/$tfile ||
17830 error "Ladvise failed with no -l or -e argument"
17832 lfs ladvise -a willread -e 1 $DIR/$tfile ||
17833 error "Ladvise failed with only -e argument"
17835 lfs ladvise -a willread -l 1 $DIR/$tfile ||
17836 error "Ladvise failed with only -l argument"
17838 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
17839 error "End offset should not be smaller than start offset"
17841 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
17842 error "End offset should not be equal to start offset"
17844 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
17845 error "Ladvise failed with overflowing -s argument"
17847 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
17848 error "Ladvise failed with overflowing -e argument"
17850 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
17851 error "Ladvise failed with overflowing -l argument"
17853 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
17854 error "Ladvise succeeded with conflicting -l and -e arguments"
17856 echo "Synchronous ladvise should wait"
17858 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
17859 do_nodes $(comma_list $(osts_nodes)) \
17860 $LCTL set_param fail_val=$delay fail_loc=0x237
17862 local start_ts=$SECONDS
17863 lfs ladvise -a willread $DIR/$tfile ||
17864 error "Ladvise failed with no range argument"
17865 local end_ts=$SECONDS
17866 local inteval_ts=$((end_ts - start_ts))
17868 if [ $inteval_ts -lt $(($delay - 1)) ]; then
17869 error "Synchronous advice didn't wait reply"
17872 echo "Asynchronous ladvise shouldn't wait"
17873 local start_ts=$SECONDS
17874 lfs ladvise -a willread -b $DIR/$tfile ||
17875 error "Ladvise failed with no range argument"
17876 local end_ts=$SECONDS
17877 local inteval_ts=$((end_ts - start_ts))
17879 if [ $inteval_ts -gt $(($delay / 2)) ]; then
17880 error "Asynchronous advice blocked"
17883 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
17884 ladvise_willread_performance
17886 run_test 255a "check 'lfs ladvise -a willread'"
17892 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
17896 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17897 skip "lustre < 2.8.54 does not support ladvise "
17898 remote_ost_nodsh && skip "remote OST with nodsh"
17900 lfs setstripe -c 1 -i 0 $DIR/$tfile
17902 ladvise_no_type dontneed $DIR/$tfile &&
17903 skip "dontneed ladvise is not supported"
17905 ladvise_no_ioctl $DIR/$tfile &&
17906 skip "ladvise ioctl is not supported"
17908 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17909 [ "$ost1_FSTYPE" = "zfs" ] &&
17910 skip "zfs-osd does not support 'ladvise dontneed'"
17913 local size=$((size_mb * 1048576))
17914 # In order to prevent disturbance of other processes, only check 3/4
17915 # of the memory usage
17916 local kibibytes=$((size_mb * 1024 * 3 / 4))
17918 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17919 error "dd to $DIR/$tfile failed"
17921 #force write to complete before dropping OST cache & checking memory
17924 local total=$(facet_meminfo ost1 MemTotal)
17925 echo "Total memory: $total KiB"
17927 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
17928 local before_read=$(facet_meminfo ost1 Cached)
17929 echo "Cache used before read: $before_read KiB"
17931 lfs ladvise -a willread $DIR/$tfile ||
17932 error "Ladvise willread failed"
17933 local after_read=$(facet_meminfo ost1 Cached)
17934 echo "Cache used after read: $after_read KiB"
17936 lfs ladvise -a dontneed $DIR/$tfile ||
17937 error "Ladvise dontneed again failed"
17938 local no_read=$(facet_meminfo ost1 Cached)
17939 echo "Cache used after dontneed ladvise: $no_read KiB"
17941 if [ $total -lt $((before_read + kibibytes)) ]; then
17942 echo "Memory is too small, abort checking"
17946 if [ $((before_read + kibibytes)) -gt $after_read ]; then
17947 error "Ladvise willread should use more memory" \
17948 "than $kibibytes KiB"
17951 if [ $((no_read + kibibytes)) -gt $after_read ]; then
17952 error "Ladvise dontneed should release more memory" \
17953 "than $kibibytes KiB"
17956 run_test 255b "check 'lfs ladvise -a dontneed'"
17959 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
17960 skip "lustre < 2.10.50 does not support lockahead"
17962 local ost1_imp=$(get_osc_import_name client ost1)
17963 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
17971 test_mkdir -p $DIR/$tdir
17972 $SETSTRIPE -i 0 $DIR/$tdir
17974 #test 10 returns only success/failure
17976 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17978 if [ $rc -eq 255 ]; then
17979 error "Ladvise test${i} failed, ${rc}"
17982 #test 11 counts lock enqueue requests, all others count new locks
17984 count=$(do_facet ost1 \
17985 $LCTL get_param -n ost.OSS.ost.stats)
17986 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
17988 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17990 if [ $rc -eq 255 ]; then
17991 error "Ladvise test${i} failed, ${rc}"
17994 new_count=$(do_facet ost1 \
17995 $LCTL get_param -n ost.OSS.ost.stats)
17996 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
17997 awk '{ print $2 }')
17999 difference="$((new_count - count))"
18000 if [ $difference -ne $rc ]; then
18001 error "Ladvise test${i}, bad enqueue count, returned " \
18002 "${rc}, actual ${difference}"
18005 for i in $(seq 12 21); do
18006 # If we do not do this, we run the risk of having too many
18007 # locks and starting lock cancellation while we are checking
18009 cancel_lru_locks osc
18011 count=$($LCTL get_param -n \
18012 ldlm.namespaces.$imp_name.lock_unused_count)
18014 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18016 if [ $rc -eq 255 ]; then
18017 error "Ladvise test ${i} failed, ${rc}"
18020 new_count=$($LCTL get_param -n \
18021 ldlm.namespaces.$imp_name.lock_unused_count)
18022 difference="$((new_count - count))"
18024 # Test 15 output is divided by 100 to map down to valid return
18025 if [ $i -eq 15 ]; then
18029 if [ $difference -ne $rc ]; then
18030 error "Ladvise test ${i}, bad lock count, returned " \
18031 "${rc}, actual ${difference}"
18035 #test 22 returns only success/failure
18037 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18039 if [ $rc -eq 255 ]; then
18040 error "Ladvise test${i} failed, ${rc}"
18043 run_test 255c "suite of ladvise lockahead tests"
18046 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18047 remote_mds_nodsh && skip "remote MDS with nodsh"
18048 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18049 changelog_users $SINGLEMDS | grep "^cl" &&
18050 skip "active changelog user"
18056 mdt_dev=$(mdsdevname 1)
18059 changelog_register || error "changelog_register failed"
18062 mkdir -p $DIR/$tdir
18064 changelog_clear 0 || error "changelog_clear failed"
18067 touch $DIR/$tdir/{1..10}
18070 stop $SINGLEMDS || error "Fail to stop MDT"
18074 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
18076 #after mount new plainllog is used
18077 touch $DIR/$tdir/{11..19}
18078 local tmpfile=$(mktemp -u $tfile.XXXXXX)
18079 cat_sl=$(do_facet $SINGLEMDS "sync; \
18080 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18081 llog_reader $tmpfile | grep -c type=1064553b")
18082 do_facet $SINGLEMDS llog_reader $tmpfile
18084 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
18086 changelog_clear 0 || error "changelog_clear failed"
18088 cat_sl=$(do_facet $SINGLEMDS "sync; \
18089 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18090 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
18092 if (( cat_sl == 2 )); then
18093 error "Empty plain llog was not deleted from changelog catalog"
18094 elif (( cat_sl != 1 )); then
18095 error "Active plain llog shouldn't be deleted from catalog"
18098 run_test 256 "Check llog delete for empty and not full state"
18101 remote_mds_nodsh && skip "remote MDS with nodsh"
18102 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
18103 skip "Need MDS version at least 2.8.55"
18105 test_mkdir $DIR/$tdir
18107 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
18108 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
18111 #define OBD_FAIL_MDS_XATTR_REP 0x161
18112 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18113 local facet=mds$((mdtidx + 1))
18114 set_nodes_failloc $(facet_active_host $facet) 0x80000161
18115 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
18117 stop $facet || error "stop MDS failed"
18118 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
18119 error "start MDS fail"
18121 run_test 257 "xattr locks are not lost"
18123 # Verify we take the i_mutex when security requires it
18125 #define OBD_FAIL_IMUTEX_SEC 0x141c
18126 $LCTL set_param fail_loc=0x141c
18128 chmod u+s $DIR/$tfile
18129 chmod a+rwx $DIR/$tfile
18130 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18132 if [ $RC -ne 0 ]; then
18133 error "error, failed to take i_mutex, rc=$?"
18137 run_test 258a "verify i_mutex security behavior when suid attributes is set"
18139 # Verify we do NOT take the i_mutex in the normal case
18141 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
18142 $LCTL set_param fail_loc=0x141d
18145 chmod a+rw $DIR/$tfile
18146 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18148 if [ $RC -ne 0 ]; then
18149 error "error, took i_mutex unnecessarily, rc=$?"
18154 run_test 258b "verify i_mutex security behavior"
18157 local file=$DIR/$tfile
18161 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18163 stack_trap "rm -f $file" EXIT
18165 wait_delete_completed
18166 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18167 echo "before: $before"
18169 $LFS setstripe -i 0 -c 1 $file
18170 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
18172 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18173 echo "after write: $after"
18175 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
18176 do_facet ost1 $LCTL set_param fail_loc=0x2301
18178 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18179 echo "after truncate: $after"
18182 do_facet ost1 $LCTL set_param fail_loc=0
18183 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18185 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18186 echo "after restart: $after"
18187 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
18188 error "missing truncate?"
18192 run_test 259 "crash at delayed truncate"
18195 #define OBD_FAIL_MDC_CLOSE 0x806
18196 $LCTL set_param fail_loc=0x80000806
18200 run_test 260 "Check mdc_close fail"
18202 ### Data-on-MDT sanity tests ###
18204 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18205 skip "Need MDS version at least 2.10.55 for DoM"
18208 local dom=$DIR/$tdir/dom_file
18209 local tmp=$DIR/$tdir/tmp_file
18211 mkdir -p $DIR/$tdir
18213 # basic checks for DoM component creation
18214 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
18215 error "Can set MDT layout to non-first entry"
18217 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
18218 error "Can define multiple entries as MDT layout"
18220 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
18222 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
18223 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
18224 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
18226 local mdtidx=$($LFS getstripe -m $dom)
18227 local mdtname=MDT$(printf %04x $mdtidx)
18228 local facet=mds$((mdtidx + 1))
18229 local space_check=1
18231 # Skip free space checks with ZFS
18232 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
18236 local size_tmp=$((65536 * 3))
18237 local mdtfree1=$(do_facet $facet \
18238 lctl get_param -n osd*.*$mdtname.kbytesfree)
18240 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18241 # check also direct IO along write
18242 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
18243 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18245 cmp $tmp $dom || error "file data is different"
18246 [ $(stat -c%s $dom) == $size_tmp ] ||
18247 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18248 if [ $space_check == 1 ]; then
18249 local mdtfree2=$(do_facet $facet \
18250 lctl get_param -n osd*.*$mdtname.kbytesfree)
18252 # increase in usage from by $size_tmp
18253 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18254 error "MDT free space wrong after write: " \
18255 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18259 local size_dom=10000
18261 $TRUNCATE $dom $size_dom
18262 [ $(stat -c%s $dom) == $size_dom ] ||
18263 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
18264 if [ $space_check == 1 ]; then
18265 mdtfree1=$(do_facet $facet \
18266 lctl get_param -n osd*.*$mdtname.kbytesfree)
18267 # decrease in usage from $size_tmp to new $size_dom
18268 [ $(($mdtfree1 - $mdtfree2)) -ge \
18269 $(((size_tmp - size_dom) / 1024)) ] ||
18270 error "MDT free space is wrong after truncate: " \
18271 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
18277 size_dom=$((size_dom + size_tmp))
18278 [ $(stat -c%s $dom) == $size_dom ] ||
18279 error "bad size after append: $(stat -c%s $dom) != $size_dom"
18280 if [ $space_check == 1 ]; then
18281 mdtfree2=$(do_facet $facet \
18282 lctl get_param -n osd*.*$mdtname.kbytesfree)
18283 # increase in usage by $size_tmp from previous
18284 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18285 error "MDT free space is wrong after append: " \
18286 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18291 if [ $space_check == 1 ]; then
18292 mdtfree1=$(do_facet $facet \
18293 lctl get_param -n osd*.*$mdtname.kbytesfree)
18294 # decrease in usage by $size_dom from previous
18295 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
18296 error "MDT free space is wrong after removal: " \
18297 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
18300 # combined striping
18301 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
18302 error "Can't create DoM + OST striping"
18304 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
18305 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18306 # check also direct IO along write
18307 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18309 cmp $tmp $dom || error "file data is different"
18310 [ $(stat -c%s $dom) == $size_tmp ] ||
18311 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18316 run_test 270a "DoM: basic functionality tests"
18319 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18320 skip "Need MDS version at least 2.10.55"
18322 local dom=$DIR/$tdir/dom_file
18323 local max_size=1048576
18325 mkdir -p $DIR/$tdir
18326 $LFS setstripe -E $max_size -L mdt $dom
18328 # truncate over the limit
18329 $TRUNCATE $dom $(($max_size + 1)) &&
18330 error "successful truncate over the maximum size"
18331 # write over the limit
18332 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
18333 error "successful write over the maximum size"
18334 # append over the limit
18335 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
18336 echo "12345" >> $dom && error "successful append over the maximum size"
18341 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
18344 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18345 skip "Need MDS version at least 2.10.55"
18347 mkdir -p $DIR/$tdir
18348 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18350 # check files inherit DoM EA
18351 touch $DIR/$tdir/first
18352 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
18353 error "bad pattern"
18354 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
18355 error "bad stripe count"
18356 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
18357 error "bad stripe size"
18359 # check directory inherits DoM EA and uses it as default
18360 mkdir $DIR/$tdir/subdir
18361 touch $DIR/$tdir/subdir/second
18362 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
18363 error "bad pattern in sub-directory"
18364 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
18365 error "bad stripe count in sub-directory"
18366 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
18367 error "bad stripe size in sub-directory"
18370 run_test 270c "DoM: DoM EA inheritance tests"
18373 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18374 skip "Need MDS version at least 2.10.55"
18376 mkdir -p $DIR/$tdir
18377 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18379 # inherit default DoM striping
18380 mkdir $DIR/$tdir/subdir
18381 touch $DIR/$tdir/subdir/f1
18383 # change default directory striping
18384 $LFS setstripe -c 1 $DIR/$tdir/subdir
18385 touch $DIR/$tdir/subdir/f2
18386 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
18387 error "wrong default striping in file 2"
18388 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
18389 error "bad pattern in file 2"
18392 run_test 270d "DoM: change striping from DoM to RAID0"
18395 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18396 skip "Need MDS version at least 2.10.55"
18398 mkdir -p $DIR/$tdir/dom
18399 mkdir -p $DIR/$tdir/norm
18402 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
18403 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
18405 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
18406 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
18408 # find DoM files by layout
18409 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
18410 [ $NUM -eq $DOMFILES ] ||
18411 error "lfs find -L: found $NUM, expected $DOMFILES"
18412 echo "Test 1: lfs find 20 DOM files by layout: OK"
18414 # there should be 1 dir with default DOM striping
18415 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
18417 error "lfs find -L: found $NUM, expected 1 dir"
18418 echo "Test 2: lfs find 1 DOM dir by layout: OK"
18420 # find DoM files by stripe size
18421 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
18422 [ $NUM -eq $DOMFILES ] ||
18423 error "lfs find -S: found $NUM, expected $DOMFILES"
18424 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
18426 # find files by stripe offset except DoM files
18427 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
18428 [ $NUM -eq $NORMFILES ] ||
18429 error "lfs find -i: found $NUM, expected $NORMFILES"
18430 echo "Test 5: lfs find no DOM files by stripe index: OK"
18433 run_test 270e "DoM: lfs find with DoM files test"
18436 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18437 skip "Need MDS version at least 2.10.55"
18439 local mdtname=${FSNAME}-MDT0000-mdtlov
18440 local dom=$DIR/$tdir/dom_file
18441 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
18442 lod.$mdtname.dom_stripesize)
18443 local dom_limit=131072
18445 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
18446 local dom_current=$(do_facet mds1 $LCTL get_param -n \
18447 lod.$mdtname.dom_stripesize)
18448 [ ${dom_limit} -eq ${dom_current} ] ||
18449 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
18451 $LFS mkdir -i 0 -c 1 $DIR/$tdir
18452 $LFS setstripe -d $DIR/$tdir
18453 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
18454 error "Can't set directory default striping"
18456 # exceed maximum stripe size
18457 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18458 error "Can't create file with $((dom_limit * 2)) DoM stripe"
18459 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
18460 error "Able to create DoM component size more than LOD limit"
18462 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
18463 dom_current=$(do_facet mds1 $LCTL get_param -n \
18464 lod.$mdtname.dom_stripesize)
18465 [ 0 -eq ${dom_current} ] ||
18466 error "Can't set zero DoM stripe limit"
18469 # attempt to create DoM file on server with disabled DoM should
18470 # remove DoM entry from layout and be succeed
18471 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
18472 error "Can't create DoM file (DoM is disabled)"
18473 [ $($LFS getstripe -L $dom) == "mdt" ] &&
18474 error "File has DoM component while DoM is disabled"
18477 # attempt to create DoM file with only DoM stripe should return error
18478 $LFS setstripe -E $dom_limit -L mdt $dom &&
18479 error "Able to create DoM-only file while DoM is disabled"
18481 # too low values to be aligned with smallest stripe size 64K
18482 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
18483 dom_current=$(do_facet mds1 $LCTL get_param -n \
18484 lod.$mdtname.dom_stripesize)
18485 [ 30000 -eq ${dom_current} ] &&
18486 error "Can set too small DoM stripe limit"
18488 # 64K is a minimal stripe size in Lustre, expect limit of that size
18489 [ 65536 -eq ${dom_current} ] ||
18490 error "Limit is not set to 64K but ${dom_current}"
18492 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
18493 dom_current=$(do_facet mds1 $LCTL get_param -n \
18494 lod.$mdtname.dom_stripesize)
18496 [ 2147483648 -eq ${dom_current} ] &&
18497 error "Can set too large DoM stripe limit"
18499 do_facet mds1 $LCTL set_param -n \
18500 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
18501 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18502 error "Can't create DoM component size after limit change"
18503 do_facet mds1 $LCTL set_param -n \
18504 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
18505 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
18506 error "Can't create DoM file after limit decrease"
18507 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
18508 error "Can create big DoM component after limit decrease"
18509 touch ${dom}_def ||
18510 error "Can't create file with old default layout"
18512 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
18515 run_test 270f "DoM: maximum DoM stripe size checks"
18518 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18519 skip "Need MDS version at least 2.10.55"
18521 local dom=$DIR/$tdir/dom
18523 mkdir -p $DIR/$tdir
18525 $LFS setstripe -E 1024K -L mdt $dom
18527 lctl set_param -n mdc.*.stats=clear
18528 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18529 cat $dom > /dev/null
18530 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
18531 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
18535 run_test 271a "DoM: data is cached for read after write"
18538 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18539 skip "Need MDS version at least 2.10.55"
18541 local dom=$DIR/$tdir/dom
18543 mkdir -p $DIR/$tdir
18545 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18547 lctl set_param -n mdc.*.stats=clear
18548 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18549 cancel_lru_locks mdc
18550 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
18551 # second stat to check size is cached on client
18552 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
18553 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18554 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
18557 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
18560 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18561 skip "Need MDS version at least 2.10.55"
18563 local dom=$DIR/$tdir/dom
18565 mkdir -p $DIR/$tdir
18567 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18569 lctl set_param -n mdc.*.stats=clear
18570 lctl set_param -n osc.*.stats=clear
18571 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
18572 cancel_lru_locks mdc
18573 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18574 # second stat to check size is cached on client
18575 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18576 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18577 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
18578 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
18579 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
18582 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
18588 local mdt=MDT$(printf %04x $mdtidx)
18590 if [ -z $param ]; then
18591 lctl get_param -n mdc.*$mdt*.stats
18593 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
18598 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18599 skip "Need MDS version at least 2.10.55"
18601 local dom=$DIR/$tdir/dom
18603 mkdir -p $DIR/$tdir
18605 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18607 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18608 local facet=mds$((mdtidx + 1))
18610 cancel_lru_locks mdc
18611 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
18612 createmany -o $dom 1000
18613 lctl set_param -n mdc.*.stats=clear
18614 smalliomany -w $dom 1000 200
18615 get_mdc_stats $mdtidx
18616 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18617 # Each file has 1 open, 1 IO enqueues, total 2000
18618 # but now we have also +1 getxattr for security.capability, total 3000
18619 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
18620 unlinkmany $dom 1000
18622 cancel_lru_locks mdc
18623 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
18624 createmany -o $dom 1000
18625 lctl set_param -n mdc.*.stats=clear
18626 smalliomany -w $dom 1000 200
18627 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18628 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
18629 # for OPEN and IO lock.
18630 [ $((enq - enq_2)) -ge 1000 ] ||
18631 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
18632 unlinkmany $dom 1000
18635 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
18637 cleanup_271def_tests() {
18643 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18644 skip "Need MDS version at least 2.10.57"
18646 local dom=$DIR/$tdir/dom
18647 local tmp=$TMP/$tfile
18648 trap "cleanup_271def_tests $tmp" EXIT
18650 mkdir -p $DIR/$tdir
18652 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18654 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18656 cancel_lru_locks mdc
18657 dd if=/dev/urandom of=$tmp bs=1000 count=1
18658 dd if=$tmp of=$dom bs=1000 count=1
18659 cancel_lru_locks mdc
18661 cat /etc/hosts >> $tmp
18662 lctl set_param -n mdc.*.stats=clear
18664 # append data to the same file it should update local page
18665 echo "Append to the same page"
18666 cat /etc/hosts >> $dom
18667 local num=$(get_mdc_stats $mdtidx ost_read)
18668 local ra=$(get_mdc_stats $mdtidx req_active)
18669 local rw=$(get_mdc_stats $mdtidx req_waittime)
18671 [ -z $num ] || error "$num READ RPC occured"
18672 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18676 cmp $tmp $dom || error "file miscompare"
18678 cancel_lru_locks mdc
18679 lctl set_param -n mdc.*.stats=clear
18681 echo "Open and read file"
18682 cat $dom > /dev/null
18683 local num=$(get_mdc_stats $mdtidx ost_read)
18684 local ra=$(get_mdc_stats $mdtidx req_active)
18685 local rw=$(get_mdc_stats $mdtidx req_waittime)
18687 [ -z $num ] || error "$num READ RPC occured"
18688 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18692 cmp $tmp $dom || error "file miscompare"
18696 run_test 271d "DoM: read on open (1K file in reply buffer)"
18699 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18700 skip "Need MDS version at least 2.10.57"
18702 local dom=$DIR/$tdir/dom
18703 local tmp=$TMP/$tfile
18704 trap "cleanup_271def_tests $tmp" EXIT
18706 mkdir -p $DIR/$tdir
18708 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18710 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18712 cancel_lru_locks mdc
18713 dd if=/dev/urandom of=$tmp bs=200000 count=1
18714 dd if=$tmp of=$dom bs=200000 count=1
18715 cancel_lru_locks mdc
18716 cat /etc/hosts >> $tmp
18717 lctl set_param -n mdc.*.stats=clear
18719 echo "Append to the same page"
18720 cat /etc/hosts >> $dom
18721 local num=$(get_mdc_stats $mdtidx ost_read)
18722 local ra=$(get_mdc_stats $mdtidx req_active)
18723 local rw=$(get_mdc_stats $mdtidx req_waittime)
18725 [ -z $num ] || error "$num READ RPC occured"
18726 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18730 cmp $tmp $dom || error "file miscompare"
18732 cancel_lru_locks mdc
18733 lctl set_param -n mdc.*.stats=clear
18735 echo "Open and read file"
18736 cat $dom > /dev/null
18737 local num=$(get_mdc_stats $mdtidx ost_read)
18738 local ra=$(get_mdc_stats $mdtidx req_active)
18739 local rw=$(get_mdc_stats $mdtidx req_waittime)
18741 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
18742 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18746 cmp $tmp $dom || error "file miscompare"
18750 run_test 271f "DoM: read on open (200K file and read tail)"
18753 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
18754 skip "Skipping due to old client or server version"
18756 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
18758 $CHECKSTAT -t file $DIR1/$tfile
18760 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
18763 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
18764 $LCTL set_param fail_loc=0x80000314
18765 rm $DIR1/$tfile || error "Unlink fails"
18767 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
18768 [ $RC -eq 0 ] || error "Failed write to stale object"
18770 run_test 271g "Discard DoM data vs client flush race"
18773 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18774 skip "Need MDS version at least 2.11.50"
18776 local dom=$DIR/$tdir/dom
18777 mkdir -p $DIR/$tdir
18779 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
18780 dd if=/dev/urandom of=$dom bs=512K count=1 ||
18781 error "failed to write data into $dom"
18782 local old_md5=$(md5sum $dom)
18784 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
18785 error "failed to migrate to the same DoM component"
18787 [ $($LFS getstripe -c $dom) -eq 2 ] ||
18788 error "layout was not changed silently"
18790 local new_md5=$(md5sum $dom)
18792 [ "$old_md5" != "$new_md5" ] &&
18793 error "md5sum differ: $old_md5, $new_md5"
18796 run_test 272a "DoM migration: new layout with the same DOM component"
18799 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18800 skip "Need MDS version at least 2.11.50"
18802 local dom=$DIR/$tdir/dom
18803 mkdir -p $DIR/$tdir
18804 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18806 local mdtidx=$($LFS getstripe -m $dom)
18807 local mdtname=MDT$(printf %04x $mdtidx)
18808 local facet=mds$((mdtidx + 1))
18810 local mdtfree1=$(do_facet $facet \
18811 lctl get_param -n osd*.*$mdtname.kbytesfree)
18812 dd if=/dev/urandom of=$dom bs=2M count=1 ||
18813 error "failed to write data into $dom"
18814 local old_md5=$(md5sum $dom)
18815 cancel_lru_locks mdc
18816 local mdtfree1=$(do_facet $facet \
18817 lctl get_param -n osd*.*$mdtname.kbytesfree)
18819 $LFS migrate -c2 $dom ||
18820 error "failed to migrate to the new composite layout"
18821 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18822 error "MDT stripe was not removed"
18824 cancel_lru_locks mdc
18825 local new_md5=$(md5sum $dom)
18826 [ "$old_md5" != "$new_md5" ] &&
18827 error "$old_md5 != $new_md5"
18829 # Skip free space checks with ZFS
18830 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18831 local mdtfree2=$(do_facet $facet \
18832 lctl get_param -n osd*.*$mdtname.kbytesfree)
18833 [ $mdtfree2 -gt $mdtfree1 ] ||
18834 error "MDT space is not freed after migration"
18838 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
18841 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18842 skip "Need MDS version at least 2.11.50"
18844 local dom=$DIR/$tdir/$tfile
18845 mkdir -p $DIR/$tdir
18846 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18848 local mdtidx=$($LFS getstripe -m $dom)
18849 local mdtname=MDT$(printf %04x $mdtidx)
18850 local facet=mds$((mdtidx + 1))
18852 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
18853 error "failed to write data into $dom"
18854 local old_md5=$(md5sum $dom)
18855 cancel_lru_locks mdc
18856 local mdtfree1=$(do_facet $facet \
18857 lctl get_param -n osd*.*$mdtname.kbytesfree)
18859 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
18860 error "failed to migrate to the new composite layout"
18861 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18862 error "MDT stripe was not removed"
18864 cancel_lru_locks mdc
18865 local new_md5=$(md5sum $dom)
18866 [ "$old_md5" != "$new_md5" ] &&
18867 error "$old_md5 != $new_md5"
18869 # Skip free space checks with ZFS
18870 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18871 local mdtfree2=$(do_facet $facet \
18872 lctl get_param -n osd*.*$mdtname.kbytesfree)
18873 [ $mdtfree2 -gt $mdtfree1 ] ||
18874 error "MDS space is not freed after migration"
18878 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
18881 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18882 skip "Need MDS version at least 2.11.50"
18884 # Layout swap cannot be done if either file has DOM component,
18885 # this will never be supported, migration should be used instead
18887 local dom=$DIR/$tdir/$tfile
18888 mkdir -p $DIR/$tdir
18890 $LFS setstripe -c2 ${dom}_plain
18891 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
18892 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
18893 error "can swap layout with DoM component"
18894 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
18895 error "can swap layout with DoM component"
18897 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
18898 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
18899 error "can swap layout with DoM component"
18900 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
18901 error "can swap layout with DoM component"
18904 run_test 273a "DoM: layout swapping should fail with DOM"
18907 remote_ost_nodsh && skip "remote OST with nodsh"
18908 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
18909 skip "Need OST version >= 2.10.57"
18911 local file=$DIR/$tfile
18914 oss=$(comma_list $(osts_nodes))
18916 dd if=/dev/urandom of=$file bs=1M count=2 ||
18917 error "failed to create a file"
18918 cancel_lru_locks osc
18921 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18922 error "failed to read a file"
18924 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
18925 $LCTL set_param fail_loc=0x8000031f
18927 cancel_lru_locks osc &
18930 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
18931 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
18932 #IO takes another lock, but matches the PENDING one
18933 #and places it to the IO RPC
18934 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18935 error "failed to read a file with PENDING lock"
18937 run_test 275 "Read on a canceled duplicate lock"
18940 remote_ost_nodsh && skip "remote OST with nodsh"
18943 do_facet ost1 "(while true; do \
18944 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
18945 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
18948 for LOOP in $(seq 20); do
18950 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
18953 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
18954 rm $TMP/sanity_276_pid"
18956 run_test 276 "Race between mount and obd_statfs"
18958 cleanup_test_300() {
18962 test_striped_dir() {
18967 mkdir -p $DIR/$tdir
18969 SAVE_UMASK=$(umask)
18970 trap cleanup_test_300 RETURN EXIT
18972 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
18973 $DIR/$tdir/striped_dir ||
18974 error "set striped dir error"
18976 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
18977 [ "$mode" = "755" ] || error "expect 755 got $mode"
18979 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
18980 error "getdirstripe failed"
18981 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
18982 if [ "$stripe_count" != "2" ]; then
18983 error "1:stripe_count is $stripe_count, expect 2"
18985 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
18986 if [ "$stripe_count" != "2" ]; then
18987 error "2:stripe_count is $stripe_count, expect 2"
18990 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
18991 if [ "$stripe_index" != "$mdt_index" ]; then
18992 error "stripe_index is $stripe_index, expect $mdt_index"
18995 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18996 error "nlink error after create striped dir"
18998 mkdir $DIR/$tdir/striped_dir/a
18999 mkdir $DIR/$tdir/striped_dir/b
19001 stat $DIR/$tdir/striped_dir/a ||
19002 error "create dir under striped dir failed"
19003 stat $DIR/$tdir/striped_dir/b ||
19004 error "create dir under striped dir failed"
19006 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
19007 error "nlink error after mkdir"
19009 rmdir $DIR/$tdir/striped_dir/a
19010 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
19011 error "nlink error after rmdir"
19013 rmdir $DIR/$tdir/striped_dir/b
19014 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
19015 error "nlink error after rmdir"
19017 chattr +i $DIR/$tdir/striped_dir
19018 createmany -o $DIR/$tdir/striped_dir/f 10 &&
19019 error "immutable flags not working under striped dir!"
19020 chattr -i $DIR/$tdir/striped_dir
19022 rmdir $DIR/$tdir/striped_dir ||
19023 error "rmdir striped dir error"
19031 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19032 skip "skipped for lustre < 2.7.0"
19033 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19034 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19036 test_striped_dir 0 || error "failed on striped dir on MDT0"
19037 test_striped_dir 1 || error "failed on striped dir on MDT0"
19039 run_test 300a "basic striped dir sanity test"
19042 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19043 skip "skipped for lustre < 2.7.0"
19044 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19045 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19052 test_mkdir $DIR/$tdir || error "mkdir fail"
19053 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19054 error "set striped dir error"
19055 for i in {0..9}; do
19056 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
19058 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
19059 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
19060 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
19062 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
19063 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
19064 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
19068 run_test 300b "check ctime/mtime for striped dir"
19071 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19072 skip "skipped for lustre < 2.7.0"
19073 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19074 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19078 mkdir -p $DIR/$tdir
19079 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
19080 error "set striped dir error"
19082 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
19083 error "chown striped dir failed"
19085 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
19086 error "create 5k files failed"
19088 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
19090 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
19094 run_test 300c "chown && check ls under striped directory"
19097 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19098 skip "skipped for lustre < 2.7.0"
19099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19100 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19105 mkdir -p $DIR/$tdir
19106 $SETSTRIPE -c 2 $DIR/$tdir
19108 #local striped directory
19109 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19110 error "set striped dir error"
19111 #look at the directories for debug purposes
19113 $LFS getdirstripe $DIR/$tdir
19114 ls -l $DIR/$tdir/striped_dir
19115 $LFS getdirstripe $DIR/$tdir/striped_dir
19116 createmany -o $DIR/$tdir/striped_dir/f 10 ||
19117 error "create 10 files failed"
19119 #remote striped directory
19120 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
19121 error "set striped dir error"
19122 #look at the directories for debug purposes
19124 $LFS getdirstripe $DIR/$tdir
19125 ls -l $DIR/$tdir/remote_striped_dir
19126 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
19127 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
19128 error "create 10 files failed"
19130 for file in $(find $DIR/$tdir); do
19131 stripe_count=$($LFS getstripe -c $file)
19132 [ $stripe_count -eq 2 ] ||
19133 error "wrong stripe $stripe_count for $file"
19138 run_test 300d "check default stripe under striped directory"
19141 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19142 skip "Need MDS version at least 2.7.55"
19143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19144 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19149 mkdir -p $DIR/$tdir
19151 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19152 error "set striped dir error"
19154 touch $DIR/$tdir/striped_dir/a
19155 touch $DIR/$tdir/striped_dir/b
19156 touch $DIR/$tdir/striped_dir/c
19158 mkdir $DIR/$tdir/striped_dir/dir_a
19159 mkdir $DIR/$tdir/striped_dir/dir_b
19160 mkdir $DIR/$tdir/striped_dir/dir_c
19162 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
19163 error "set striped adir under striped dir error"
19165 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
19166 error "set striped bdir under striped dir error"
19168 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
19169 error "set striped cdir under striped dir error"
19171 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
19172 error "rename dir under striped dir fails"
19174 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
19175 error "rename dir under different stripes fails"
19177 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
19178 error "rename file under striped dir should succeed"
19180 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
19181 error "rename dir under striped dir should succeed"
19185 run_test 300e "check rename under striped directory"
19188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19189 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19190 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19191 skip "Need MDS version at least 2.7.55"
19197 mkdir -p $DIR/$tdir
19199 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19200 error "set striped dir error"
19202 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
19203 error "set striped dir error"
19205 touch $DIR/$tdir/striped_dir/a
19206 mkdir $DIR/$tdir/striped_dir/dir_a
19207 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
19208 error "create striped dir under striped dir fails"
19210 touch $DIR/$tdir/striped_dir1/b
19211 mkdir $DIR/$tdir/striped_dir1/dir_b
19212 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
19213 error "create striped dir under striped dir fails"
19215 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
19216 error "rename dir under different striped dir should fail"
19218 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
19219 error "rename striped dir under diff striped dir should fail"
19221 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
19222 error "rename file under diff striped dirs fails"
19226 run_test 300f "check rename cross striped directory"
19228 test_300_check_default_striped_dir()
19231 local default_count=$2
19232 local default_index=$3
19235 local dir_stripe_index
19238 echo "checking $dirname $default_count $default_index"
19239 $LFS setdirstripe -D -c $default_count -i $default_index \
19240 -t all_char $DIR/$tdir/$dirname ||
19241 error "set default stripe on striped dir error"
19242 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
19243 [ $stripe_count -eq $default_count ] ||
19244 error "expect $default_count get $stripe_count for $dirname"
19246 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
19247 [ $stripe_index -eq $default_index ] ||
19248 error "expect $default_index get $stripe_index for $dirname"
19250 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
19251 error "create dirs failed"
19253 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
19254 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
19255 for dir in $(find $DIR/$tdir/$dirname/*); do
19256 stripe_count=$($LFS getdirstripe -c $dir)
19257 [ $stripe_count -eq $default_count ] ||
19258 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
19259 error "stripe count $default_count != $stripe_count for $dir"
19261 stripe_index=$($LFS getdirstripe -i $dir)
19262 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
19263 error "$stripe_index != $default_index for $dir"
19265 #check default stripe
19266 stripe_count=$($LFS getdirstripe -D -c $dir)
19267 [ $stripe_count -eq $default_count ] ||
19268 error "default count $default_count != $stripe_count for $dir"
19270 stripe_index=$($LFS getdirstripe -D -i $dir)
19271 [ $stripe_index -eq $default_index ] ||
19272 error "default index $default_index != $stripe_index for $dir"
19274 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
19278 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19279 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19280 skip "Need MDS version at least 2.7.55"
19287 mkdir $DIR/$tdir/normal_dir
19289 #Checking when client cache stripe index
19290 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
19291 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
19292 error "create striped_dir failed"
19294 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
19295 error "create dir0 fails"
19296 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
19297 [ $stripe_index -eq 0 ] ||
19298 error "dir0 expect index 0 got $stripe_index"
19300 mkdir $DIR/$tdir/striped_dir/dir1 ||
19301 error "create dir1 fails"
19302 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
19303 [ $stripe_index -eq 1 ] ||
19304 error "dir1 expect index 1 got $stripe_index"
19306 #check default stripe count/stripe index
19307 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
19308 test_300_check_default_striped_dir normal_dir 1 0
19309 test_300_check_default_striped_dir normal_dir 2 1
19310 test_300_check_default_striped_dir normal_dir 2 -1
19312 #delete default stripe information
19313 echo "delete default stripeEA"
19314 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
19315 error "set default stripe on striped dir error"
19317 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
19318 for dir in $(find $DIR/$tdir/normal_dir/*); do
19319 stripe_count=$($LFS getdirstripe -c $dir)
19320 [ $stripe_count -eq 0 ] ||
19321 error "expect 1 get $stripe_count for $dir"
19322 stripe_index=$($LFS getdirstripe -i $dir)
19323 [ $stripe_index -eq 0 ] ||
19324 error "expect 0 get $stripe_index for $dir"
19327 run_test 300g "check default striped directory for normal directory"
19330 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19331 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19332 skip "Need MDS version at least 2.7.55"
19338 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19339 error "set striped dir error"
19341 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
19342 test_300_check_default_striped_dir striped_dir 1 0
19343 test_300_check_default_striped_dir striped_dir 2 1
19344 test_300_check_default_striped_dir striped_dir 2 -1
19346 #delete default stripe information
19347 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
19348 error "set default stripe on striped dir error"
19350 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
19351 for dir in $(find $DIR/$tdir/striped_dir/*); do
19352 stripe_count=$($LFS getdirstripe -c $dir)
19353 [ $stripe_count -eq 0 ] ||
19354 error "expect 1 get $stripe_count for $dir"
19357 run_test 300h "check default striped directory for striped directory"
19360 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19361 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19362 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19363 skip "Need MDS version at least 2.7.55"
19370 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19371 error "set striped dir error"
19373 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19374 error "create files under striped dir failed"
19376 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
19377 error "set striped hashdir error"
19379 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
19380 error "create dir0 under hash dir failed"
19381 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
19382 error "create dir1 under hash dir failed"
19384 # unfortunately, we need to umount to clear dir layout cache for now
19385 # once we fully implement dir layout, we can drop this
19386 umount_client $MOUNT || error "umount failed"
19387 mount_client $MOUNT || error "mount failed"
19389 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
19390 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
19391 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
19393 #set the stripe to be unknown hash type
19394 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
19395 $LCTL set_param fail_loc=0x1901
19396 for ((i = 0; i < 10; i++)); do
19397 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
19398 error "stat f-$i failed"
19399 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
19402 touch $DIR/$tdir/striped_dir/f0 &&
19403 error "create under striped dir with unknown hash should fail"
19405 $LCTL set_param fail_loc=0
19407 umount_client $MOUNT || error "umount failed"
19408 mount_client $MOUNT || error "mount failed"
19412 run_test 300i "client handle unknown hash type striped directory"
19415 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19416 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19417 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19418 skip "Need MDS version at least 2.7.55"
19425 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
19426 $LCTL set_param fail_loc=0x1702
19427 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19428 error "set striped dir error"
19430 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19431 error "create files under striped dir failed"
19433 $LCTL set_param fail_loc=0
19435 rm -rf $DIR/$tdir || error "unlink striped dir fails"
19439 run_test 300j "test large update record"
19442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19443 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19444 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19445 skip "Need MDS version at least 2.7.55"
19452 #define OBD_FAIL_LARGE_STRIPE 0x1703
19453 $LCTL set_param fail_loc=0x1703
19454 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
19455 error "set striped dir error"
19456 $LCTL set_param fail_loc=0
19458 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19459 error "getstripeddir fails"
19460 rm -rf $DIR/$tdir/striped_dir ||
19461 error "unlink striped dir fails"
19465 run_test 300k "test large striped directory"
19468 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19469 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19470 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19471 skip "Need MDS version at least 2.7.55"
19475 test_mkdir -p $DIR/$tdir/striped_dir
19476 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
19477 error "chown $RUNAS_ID failed"
19478 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
19479 error "set default striped dir failed"
19481 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
19482 $LCTL set_param fail_loc=0x80000158
19483 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
19485 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
19486 [ $stripe_index -eq 1 ] ||
19487 error "expect 1 get $stripe_index for $dir"
19489 run_test 300l "non-root user to create dir under striped dir with stale layout"
19492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19493 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
19494 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19495 skip "Need MDS version at least 2.7.55"
19497 mkdir -p $DIR/$tdir/striped_dir
19498 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
19499 error "set default stripes dir error"
19501 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
19503 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
19504 [ $stripe_count -eq 0 ] ||
19505 error "expect 0 get $stripe_count for a"
19507 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
19508 error "set default stripes dir error"
19510 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
19512 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
19513 [ $stripe_count -eq 0 ] ||
19514 error "expect 0 get $stripe_count for b"
19516 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
19517 error "set default stripes dir error"
19519 mkdir $DIR/$tdir/striped_dir/c &&
19520 error "default stripe_index is invalid, mkdir c should fails"
19522 rm -rf $DIR/$tdir || error "rmdir fails"
19524 run_test 300m "setstriped directory on single MDT FS"
19527 local list=$(comma_list $(mdts_nodes))
19530 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19535 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19536 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19537 skip "Need MDS version at least 2.7.55"
19538 remote_mds_nodsh && skip "remote MDS with nodsh"
19541 local list=$(comma_list $(mdts_nodes))
19543 trap cleanup_300n RETURN EXIT
19544 mkdir -p $DIR/$tdir
19545 chmod 777 $DIR/$tdir
19546 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
19547 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19548 error "create striped dir succeeds with gid=0"
19550 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19551 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
19552 error "create striped dir fails with gid=-1"
19554 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19555 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
19556 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19557 error "set default striped dir succeeds with gid=0"
19560 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19561 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
19562 error "set default striped dir fails with gid=-1"
19565 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19566 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
19567 error "create test_dir fails"
19568 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
19569 error "create test_dir1 fails"
19570 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
19571 error "create test_dir2 fails"
19574 run_test 300n "non-root user to create dir under striped dir with default EA"
19577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19578 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19579 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19580 skip "Need MDS version at least 2.7.55"
19585 mkdir -p $DIR/$tdir
19587 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
19588 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
19589 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
19590 skip "not enough free inodes $numfree1 $numfree2"
19593 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
19594 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
19595 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
19596 skip "not enough free space $numfree1 $numfree2"
19599 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
19600 error "setdirstripe fails"
19602 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
19603 error "create dirs fails"
19605 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
19606 ls $DIR/$tdir/striped_dir > /dev/null ||
19607 error "ls striped dir fails"
19608 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
19609 error "unlink big striped dir fails"
19611 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
19614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19615 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19616 remote_mds_nodsh && skip "remote MDS with nodsh"
19618 mkdir -p $DIR/$tdir
19620 #define OBD_FAIL_OUT_ENOSPC 0x1704
19621 do_facet mds2 lctl set_param fail_loc=0x80001704
19622 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
19623 && error "create striped directory should fail"
19625 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
19627 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
19630 run_test 300p "create striped directory without space"
19633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19634 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19636 local fd=$(free_fd)
19637 local cmd="exec $fd<$tdir"
19639 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
19642 trap "eval $cmd" EXIT
19643 cd $tdir || error "cd $tdir fails"
19644 rmdir ../$tdir || error "rmdir $tdir fails"
19645 mkdir local_dir && error "create dir succeeds"
19646 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
19650 run_test 300q "create remote directory under orphan directory"
19653 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
19654 skip "Need MDS version at least 2.7.55" && return
19655 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19659 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
19660 error "set striped dir error"
19662 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19663 error "getstripeddir fails"
19666 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
19667 awk '/lmv_stripe_count:/ { print $2 }')
19669 [ $MDSCOUNT -ne $stripe_count ] &&
19670 error "wrong stripe count $stripe_count expected $MDSCOUNT"
19672 rm -rf $DIR/$tdir/striped_dir ||
19673 error "unlink striped dir fails"
19675 run_test 300r "test -1 striped directory"
19677 test_300s_helper() {
19680 local stripe_dir=$DIR/$tdir/striped_dir.$count
19682 $LFS mkdir -c $count $stripe_dir ||
19683 error "lfs mkdir -c error"
19685 $LFS getdirstripe $stripe_dir ||
19686 error "lfs getdirstripe fails"
19689 stripe_count=$($LFS getdirstripe $stripe_dir |
19690 awk '/lmv_stripe_count:/ { print $2 }')
19692 [ $count -ne $stripe_count ] &&
19693 error_noexit "bad stripe count $stripe_count expected $count"
19696 dupe_stripes=$($LFS getdirstripe $stripe_dir |
19697 awk '/0x/ {count[$1] += 1}; END {
19698 for (idx in count) {
19699 if (count[idx]>1) {
19700 print "index " idx " count " count[idx]
19705 if [[ -n "$dupe_stripes" ]] ; then
19706 lfs getdirstripe $stripe_dir
19707 error_noexit "Dupe MDT above: $dupe_stripes "
19710 rm -rf $stripe_dir ||
19711 error_noexit "unlink $stripe_dir fails"
19715 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19716 skip "Need MDS version at least 2.7.55" && return
19717 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19720 for count in $(seq 2 $MDSCOUNT); do
19721 test_300s_helper $count
19724 run_test 300s "test lfs mkdir -c without -i"
19727 prepare_remote_file() {
19728 mkdir $DIR/$tdir/src_dir ||
19729 error "create remote source failed"
19731 cp /etc/hosts $DIR/$tdir/src_dir/a ||
19732 error "cp to remote source failed"
19733 touch $DIR/$tdir/src_dir/a
19735 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
19736 error "create remote target dir failed"
19738 touch $DIR/$tdir/tgt_dir/b
19740 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
19741 error "rename dir cross MDT failed!"
19743 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
19744 error "src_child still exists after rename"
19746 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
19747 error "missing file(a) after rename"
19749 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
19750 error "diff after rename"
19754 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19755 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19757 local remote_file=$DIR/$tdir/tgt_dir/b
19759 mkdir -p $DIR/$tdir
19761 prepare_remote_file || error "prepare remote file failed"
19764 $OPENUNLINK $remote_file $remote_file ||
19765 error "openunlink $remote_file failed"
19766 $CHECKSTAT -a $remote_file || error "$remote_file exists"
19768 run_test 310a "open unlink remote file"
19771 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19772 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19774 local remote_file=$DIR/$tdir/tgt_dir/b
19776 mkdir -p $DIR/$tdir
19778 prepare_remote_file || error "prepare remote file failed"
19780 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19781 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
19782 $CHECKSTAT -t file $remote_file || error "check file failed"
19784 run_test 310b "unlink remote file with multiple links while open"
19787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19788 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
19790 local remote_file=$DIR/$tdir/tgt_dir/b
19792 mkdir -p $DIR/$tdir
19794 prepare_remote_file || error "prepare remote file failed"
19796 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19797 multiop_bg_pause $remote_file O_uc ||
19798 error "mulitop failed for remote file"
19800 $MULTIOP $DIR/$tfile Ouc
19801 kill -USR1 $MULTIPID
19804 run_test 310c "open-unlink remote file with multiple links"
19808 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19809 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19810 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
19811 skip "lustre < 2.8.54 does not contain LU-4825 fix"
19812 remote_mds_nodsh && skip "remote MDS with nodsh"
19814 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19815 local mdts=$(comma_list $(mdts_nodes))
19817 mkdir -p $DIR/$tdir
19818 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
19819 createmany -o $DIR/$tdir/$tfile. 1000
19821 # statfs data is not real time, let's just calculate it
19822 old_iused=$((old_iused + 1000))
19824 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19825 osp.*OST0000*MDT0000.create_count")
19826 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19827 osp.*OST0000*MDT0000.max_create_count")
19828 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
19830 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
19831 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
19832 [ $index -ne 0 ] || error "$tfile stripe index is 0"
19834 unlinkmany $DIR/$tdir/$tfile. 1000
19836 do_nodes $mdts "$LCTL set_param -n \
19837 osp.*OST0000*.max_create_count=$max_count"
19838 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
19839 do_nodes $mdts "$LCTL set_param -n \
19840 osp.*OST0000*.create_count=$count"
19841 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
19842 grep "=0" && error "create_count is zero"
19845 for i in $(seq 120); do
19846 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19847 # system may be too busy to destroy all objs in time, use
19848 # a somewhat small value to not fail autotest
19849 [ $((old_iused - new_iused)) -gt 400 ] && break
19853 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
19854 [ $((old_iused - new_iused)) -gt 400 ] ||
19855 error "objs not destroyed after unlink"
19857 run_test 311 "disable OSP precreate, and unlink should destroy objs"
19864 local vdevdir=$(dirname $(facet_vdevice $ost))
19865 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
19866 local zfs_zapid=$(do_facet $ost $cmd |
19867 grep -w "/O/0/d$((objid%32))" -C 5 |
19868 awk '/Object/{getline; print $1}')
19869 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
19870 awk "/$objid = /"'{printf $3}')
19875 zfs_object_blksz() {
19879 local vdevdir=$(dirname $(facet_vdevice $ost))
19880 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
19881 local blksz=$(do_facet $ost $cmd $objid |
19882 awk '/dblk/{getline; printf $4}')
19884 case "${blksz: -1}" in
19885 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
19886 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
19893 test_312() { # LU-4856
19894 remote_ost_nodsh && skip "remote OST with nodsh"
19895 [ "$ost1_FSTYPE" = "zfs" ] ||
19896 skip_env "the test only applies to zfs"
19898 local max_blksz=$(do_facet ost1 \
19899 $ZFS get -p recordsize $(facet_device ost1) |
19900 awk '!/VALUE/{print $3}')
19902 # to make life a little bit easier
19903 $LFS mkdir -c 1 -i 0 $DIR/$tdir
19904 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19906 local tf=$DIR/$tdir/$tfile
19908 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19910 # Get ZFS object id
19911 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19912 # block size change by sequential overwrite
19915 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
19916 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
19918 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
19919 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
19923 # block size change by sequential append write
19924 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
19925 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19926 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19929 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
19930 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
19931 oflag=sync conv=notrunc
19933 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19934 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
19935 error "blksz error, actual $blksz, " \
19936 "expected: 2 * $count * $PAGE_SIZE"
19942 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19943 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19945 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
19946 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19947 [ $blksz -eq $PAGE_SIZE ] ||
19948 error "blksz error: $blksz, expected: $PAGE_SIZE"
19950 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
19951 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19952 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
19954 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
19955 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19956 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
19958 run_test 312 "make sure ZFS adjusts its block size by write pattern"
19961 remote_ost_nodsh && skip "remote OST with nodsh"
19963 local file=$DIR/$tfile
19966 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
19968 # define OBD_FAIL_TGT_RCVD_EIO 0x720
19969 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19970 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
19971 error "write should failed"
19972 do_facet ost1 "$LCTL set_param fail_loc=0"
19975 run_test 313 "io should fail after last_rcvd update fail"
19978 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19980 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
19981 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19983 wait_delete_completed
19984 do_facet ost1 "$LCTL set_param fail_loc=0"
19986 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
19988 test_315() { # LU-618
19989 local file=$DIR/$tfile
19992 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
19993 error "multiop file write failed"
19994 $MULTIOP $file oO_RDONLY:r4063232_c &
19999 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
20002 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
20005 run_test 315 "read should be accounted"
20008 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20009 large_xattr_enabled || skip_env "ea_inode feature disabled"
20011 rm -rf $DIR/$tdir/d
20012 mkdir -p $DIR/$tdir/d
20013 chown nobody $DIR/$tdir/d
20014 touch $DIR/$tdir/d/file
20016 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
20018 run_test 316 "lfs mv"
20021 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
20022 skip "Need MDS version at least 2.11.53"
20023 if [ "$ost1_FSTYPE" == "zfs" ]; then
20024 skip "LU-10370: no implementation for ZFS"
20028 local grant_blk_size
20030 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
20031 awk '/grant_block_size:/ { print $2; exit; }')
20033 # Create File of size 5M. Truncate it to below size's and verify
20036 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
20037 error "Create file $DIR/$tfile failed"
20038 stack_trap "rm -f $DIR/$tfile" EXIT
20040 for trunc_sz in 2097152 4097 4000 509 0; do
20041 $TRUNCATE $DIR/$tfile $trunc_sz ||
20042 error "truncate $tfile to $trunc_sz failed"
20043 local sz=$(stat --format=%s $DIR/$tfile)
20044 local blk=$(stat --format=%b $DIR/$tfile)
20045 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
20046 grant_blk_size) * 8))
20048 if [[ $blk -ne $trunc_blk ]]; then
20049 $(which stat) $DIR/$tfile
20050 error "Expected Block $trunc_blk got $blk for $tfile"
20053 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20054 error "Expected Size $trunc_sz got $sz for $tfile"
20059 # Create file with a hole and write actual two blocks. Block count
20062 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
20063 conv=fsync || error "Create file : $DIR/$tfile"
20065 # Calculate the final truncate size.
20066 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
20069 # truncate to size $trunc_sz bytes. Strip the last block
20070 # The block count must drop to 8
20072 $TRUNCATE $DIR/$tfile $trunc_sz ||
20073 error "truncate $tfile to $trunc_sz failed"
20075 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
20076 sz=$(stat --format=%s $DIR/$tfile)
20077 blk=$(stat --format=%b $DIR/$tfile)
20079 if [[ $blk -ne $trunc_bsz ]]; then
20080 $(which stat) $DIR/$tfile
20081 error "Expected Block $trunc_bsz got $blk for $tfile"
20084 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20085 error "Expected Size $trunc_sz got $sz for $tfile"
20087 run_test 317 "Verify blocks get correctly update after truncate"
20090 local read_write=$1
20091 if [ "$read_write" = "write" ]; then
20092 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
20093 elif [ "$read_write" = "read" ]; then
20094 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
20096 error "argument error"
20099 # turn off debug for performance testing
20100 local saved_debug=$($LCTL get_param -n debug)
20101 $LCTL set_param debug=0
20103 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
20105 # get ost1 size - lustre-OST0000
20106 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
20107 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
20108 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
20110 if [ "$read_write" = "read" ]; then
20111 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
20114 local start_time=$(date +%s.%N)
20115 $dd_cmd bs=1M count=$blocks oflag=sync ||
20116 error "real dd $read_write error"
20117 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
20119 if [ "$read_write" = "write" ]; then
20123 # define OBD_FAIL_OST_FAKE_RW 0x238
20124 do_facet ost1 $LCTL set_param fail_loc=0x238
20126 local start_time=$(date +%s.%N)
20127 $dd_cmd bs=1M count=$blocks oflag=sync ||
20128 error "fake dd $read_write error"
20129 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
20131 if [ "$read_write" = "write" ]; then
20133 cancel_lru_locks osc
20134 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
20135 error "$tfile size not $blocks MB"
20137 do_facet ost1 $LCTL set_param fail_loc=0
20139 echo "fake $read_write $duration_fake vs. normal $read_write" \
20140 "$duration in seconds"
20141 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
20142 error_not_in_vm "fake write is slower"
20144 $LCTL set_param -n debug="$saved_debug"
20147 test_399a() { # LU-7655 for OST fake write
20148 remote_ost_nodsh && skip "remote OST with nodsh"
20152 run_test 399a "fake write should not be slower than normal write"
20154 test_399b() { # LU-8726 for OST fake read
20155 remote_ost_nodsh && skip "remote OST with nodsh"
20156 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
20157 skip_env "ldiskfs only test"
20162 run_test 399b "fake read should not be slower than normal read"
20164 test_400a() { # LU-1606, was conf-sanity test_74
20165 if ! which $CC > /dev/null 2>&1; then
20166 skip_env "$CC is not installed"
20169 local extra_flags=''
20170 local out=$TMP/$tfile
20171 local prefix=/usr/include/lustre
20174 # Oleg removes c files in his test rig so test if any c files exist
20175 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
20176 skip_env "Needed c test files are missing"
20178 if ! [[ -d $prefix ]]; then
20179 # Assume we're running in tree and fixup the include path.
20180 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
20181 extra_flags+=" -L$LUSTRE/utils/.lib"
20184 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
20185 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
20186 error "client api broken"
20190 run_test 400a "Lustre client api program can compile and link"
20192 test_400b() { # LU-1606, LU-5011
20194 local out=$TMP/$tfile
20195 local prefix=/usr/include/linux/lustre
20197 # We use a hard coded prefix so that this test will not fail
20198 # when run in tree. There are headers in lustre/include/lustre/
20199 # that are not packaged (like lustre_idl.h) and have more
20200 # complicated include dependencies (like config.h and lnet/types.h).
20201 # Since this test about correct packaging we just skip them when
20202 # they don't exist (see below) rather than try to fixup cppflags.
20204 if ! which $CC > /dev/null 2>&1; then
20205 skip_env "$CC is not installed"
20208 for header in $prefix/*.h; do
20209 if ! [[ -f "$header" ]]; then
20213 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
20214 continue # lustre_ioctl.h is internal header
20217 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
20218 error "cannot compile '$header'"
20222 run_test 400b "packaged headers can be compiled"
20224 test_401a() { #LU-7437
20225 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
20226 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
20228 #count the number of parameters by "list_param -R"
20229 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
20230 #count the number of parameters by listing proc files
20231 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
20232 echo "proc_dirs='$proc_dirs'"
20233 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
20234 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
20237 [ $params -eq $procs ] ||
20238 error "found $params parameters vs. $procs proc files"
20240 # test the list_param -D option only returns directories
20241 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
20242 #count the number of parameters by listing proc directories
20243 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
20246 [ $params -eq $procs ] ||
20247 error "found $params parameters vs. $procs proc files"
20249 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
20252 local save=$($LCTL get_param -n jobid_var)
20255 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
20256 error "no error returned when setting bad parameters"
20258 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
20259 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
20261 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
20262 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
20263 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
20265 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
20268 local jobid_var_old=$($LCTL get_param -n jobid_var)
20269 local jobid_var_new
20271 $LCTL set_param jobid_var= &&
20272 error "no error returned for 'set_param a='"
20274 jobid_var_new=$($LCTL get_param -n jobid_var)
20275 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20276 error "jobid_var was changed by setting without value"
20278 $LCTL set_param jobid_var &&
20279 error "no error returned for 'set_param a'"
20281 jobid_var_new=$($LCTL get_param -n jobid_var)
20282 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20283 error "jobid_var was changed by setting without value"
20285 run_test 401c "Verify 'lctl set_param' without value fails in either format."
20288 local jobid_var_old=$($LCTL get_param -n jobid_var)
20289 local jobid_var_new
20290 local new_value="foo=bar"
20292 $LCTL set_param jobid_var=$new_value ||
20293 error "'set_param a=b' did not accept a value containing '='"
20295 jobid_var_new=$($LCTL get_param -n jobid_var)
20296 [[ "$jobid_var_new" == "$new_value" ]] ||
20297 error "'set_param a=b' failed on a value containing '='"
20299 # Reset the jobid_var to test the other format
20300 $LCTL set_param jobid_var=$jobid_var_old
20301 jobid_var_new=$($LCTL get_param -n jobid_var)
20302 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20303 error "failed to reset jobid_var"
20305 $LCTL set_param jobid_var $new_value ||
20306 error "'set_param a b' did not accept a value containing '='"
20308 jobid_var_new=$($LCTL get_param -n jobid_var)
20309 [[ "$jobid_var_new" == "$new_value" ]] ||
20310 error "'set_param a b' failed on a value containing '='"
20312 $LCTL set_param jobid_var $jobid_var_old
20313 jobid_var_new=$($LCTL get_param -n jobid_var)
20314 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20315 error "failed to reset jobid_var"
20317 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
20320 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
20321 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
20322 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
20323 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
20324 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
20325 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
20326 remote_mds_nodsh && skip "remote MDS with nodsh"
20328 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
20329 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
20330 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
20331 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
20332 echo "Touch failed - OK"
20334 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
20337 local file1=$DIR/$tfile.1
20338 local file2=$DIR/$tfile.2
20339 local tfile=$TMP/$tfile
20341 rm -f $file1 $file2 $tfile
20346 # 30 sec OBD_TIMEOUT in ll_getattr()
20347 # right before populating st_nlink
20348 $LCTL set_param fail_loc=0x80001409
20349 stat -c %h $file1 > $tfile &
20351 # create an alias, drop all locks and reclaim the dentry
20353 cancel_lru_locks mdc
20354 cancel_lru_locks osc
20355 sysctl -w vm.drop_caches=2
20359 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
20361 rm -f $tfile $file1 $file2
20363 run_test 403 "i_nlink should not drop to zero due to aliasing"
20365 test_404() { # LU-6601
20366 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
20367 skip "Need server version newer than 2.8.52"
20368 remote_mds_nodsh && skip "remote MDS with nodsh"
20370 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
20371 awk '/osp .*-osc-MDT/ { print $4}')
20374 for osp in $mosps; do
20375 echo "Deactivate: " $osp
20376 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
20377 local stat=$(do_facet $SINGLEMDS $LCTL dl |
20378 awk -vp=$osp '$4 == p { print $2 }')
20379 [ $stat = IN ] || {
20380 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
20381 error "deactivate error"
20383 echo "Activate: " $osp
20384 do_facet $SINGLEMDS $LCTL --device %$osp activate
20385 local stat=$(do_facet $SINGLEMDS $LCTL dl |
20386 awk -vp=$osp '$4 == p { print $2 }')
20387 [ $stat = UP ] || {
20388 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
20389 error "activate error"
20393 run_test 404 "validate manual {de}activated works properly for OSPs"
20396 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
20397 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
20398 skip "Layout swap lock is not supported"
20400 check_swap_layouts_support
20402 test_mkdir $DIR/$tdir
20403 swap_lock_test -d $DIR/$tdir ||
20404 error "One layout swap locked test failed"
20406 run_test 405 "Various layout swap lock tests"
20409 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20410 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
20411 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
20412 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20413 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
20414 skip "Need MDS version at least 2.8.50"
20416 local def_stripe_size=$($LFS getstripe -S $MOUNT)
20417 local test_pool=$TESTNAME
20419 pool_add $test_pool || error "pool_add failed"
20420 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
20421 error "pool_add_targets failed"
20423 save_layout_restore_at_exit $MOUNT
20425 # parent set default stripe count only, child will stripe from both
20426 # parent and fs default
20427 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
20428 error "setstripe $MOUNT failed"
20429 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
20430 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
20431 for i in $(seq 10); do
20432 local f=$DIR/$tdir/$tfile.$i
20433 touch $f || error "touch failed"
20434 local count=$($LFS getstripe -c $f)
20435 [ $count -eq $OSTCOUNT ] ||
20436 error "$f stripe count $count != $OSTCOUNT"
20437 local offset=$($LFS getstripe -i $f)
20438 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
20439 local size=$($LFS getstripe -S $f)
20440 [ $size -eq $((def_stripe_size * 2)) ] ||
20441 error "$f stripe size $size != $((def_stripe_size * 2))"
20442 local pool=$($LFS getstripe -p $f)
20443 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
20446 # change fs default striping, delete parent default striping, now child
20447 # will stripe from new fs default striping only
20448 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
20449 error "change $MOUNT default stripe failed"
20450 $LFS setstripe -c 0 $DIR/$tdir ||
20451 error "delete $tdir default stripe failed"
20452 for i in $(seq 11 20); do
20453 local f=$DIR/$tdir/$tfile.$i
20454 touch $f || error "touch $f failed"
20455 local count=$($LFS getstripe -c $f)
20456 [ $count -eq 1 ] || error "$f stripe count $count != 1"
20457 local offset=$($LFS getstripe -i $f)
20458 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
20459 local size=$($LFS getstripe -S $f)
20460 [ $size -eq $def_stripe_size ] ||
20461 error "$f stripe size $size != $def_stripe_size"
20462 local pool=$($LFS getstripe -p $f)
20463 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
20466 unlinkmany $DIR/$tdir/$tfile. 1 20
20468 local f=$DIR/$tdir/$tfile
20469 pool_remove_all_targets $test_pool $f
20470 pool_remove $test_pool $f
20472 run_test 406 "DNE support fs default striping"
20475 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20476 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
20477 skip "Need MDS version at least 2.8.55"
20478 remote_mds_nodsh && skip "remote MDS with nodsh"
20480 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
20481 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
20482 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
20483 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
20484 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
20486 #define OBD_FAIL_DT_TXN_STOP 0x2019
20487 for idx in $(seq $MDSCOUNT); do
20488 do_facet mds$idx "lctl set_param fail_loc=0x2019"
20490 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
20491 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
20492 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
20495 run_test 407 "transaction fail should cause operation fail"
20498 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
20500 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
20501 lctl set_param fail_loc=0x8000040a
20502 # let ll_prepare_partial_page() fail
20503 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
20507 # create at least 100 unused inodes so that
20508 # shrink_icache_memory(0) should not return 0
20509 touch $DIR/$tfile-{0..100}
20510 rm -f $DIR/$tfile-{0..100}
20513 echo 2 > /proc/sys/vm/drop_caches
20515 run_test 408 "drop_caches should not hang due to page leaks"
20519 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20520 check_mount_and_prep
20522 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
20523 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
20524 touch $DIR/$tdir/guard || error "(2) Fail to create"
20526 local PREFIX=$(str_repeat 'A' 128)
20527 echo "Create 1K hard links start at $(date)"
20528 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20529 error "(3) Fail to hard link"
20531 echo "Links count should be right although linkEA overflow"
20532 stat $DIR/$tdir/guard || error "(4) Fail to stat"
20533 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
20534 [ $linkcount -eq 1001 ] ||
20535 error "(5) Unexpected hard links count: $linkcount"
20537 echo "List all links start at $(date)"
20538 ls -l $DIR/$tdir/foo > /dev/null ||
20539 error "(6) Fail to list $DIR/$tdir/foo"
20541 echo "Unlink hard links start at $(date)"
20542 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20543 error "(7) Fail to unlink"
20545 run_test 409 "Large amount of cross-MDTs hard links on the same file"
20549 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
20550 skip "Need client version at least 2.9.59"
20552 # Create a file, and stat it from the kernel
20553 local testfile=$DIR/$tfile
20556 local run_id=$RANDOM
20557 local my_ino=$(stat --format "%i" $testfile)
20559 # Try to insert the module. This will always fail as the
20560 # module is designed to not be inserted.
20561 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
20564 # Anything but success is a test failure
20566 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
20567 error "no inode match"
20569 run_test 410 "Test inode number returned from kernel thread"
20571 cleanup_test411_cgroup() {
20577 local cg_basedir=/sys/fs/cgroup/memory
20579 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
20580 skip "no setup for cgroup"
20582 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
20583 error "test file creation failed"
20584 cancel_lru_locks osc
20586 # Create a very small memory cgroup to force a slab allocation error
20587 local cgdir=$cg_basedir/osc_slab_alloc
20588 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
20589 trap "cleanup_test411_cgroup $cgdir" EXIT
20590 echo 2M > $cgdir/memory.kmem.limit_in_bytes
20591 echo 1M > $cgdir/memory.limit_in_bytes
20593 # Should not LBUG, just be killed by oom-killer
20594 # dd will return 0 even allocation failure in some environment.
20595 # So don't check return value
20596 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
20597 cleanup_test411_cgroup $cgdir
20601 run_test 411 "Slab allocation error with cgroup does not LBUG"
20604 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20605 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20606 skip "Need server version at least 2.10.55"
20609 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
20610 error "mkdir failed"
20611 $LFS getdirstripe $DIR/$tdir
20612 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20613 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
20614 error "expect $((MDSCOUT - 1)) get $stripe_index"
20615 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
20616 [ $stripe_count -eq 2 ] ||
20617 error "expect 2 get $stripe_count"
20619 run_test 412 "mkdir on specific MDTs"
20622 [ $MDSCOUNT -lt 2 ] &&
20623 skip "We need at least 2 MDTs for this test"
20625 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20626 skip "Need server version at least 2.10.55"
20629 mkdir $DIR/$tdir || error "mkdir failed"
20631 # find MDT that is the most full
20632 local max=$($LFS df | grep MDT |
20641 END { split(b, c, ":")
20646 for i in $(seq $((MDSCOUNT - 1))); do
20647 $LFS mkdir -c $i $DIR/$tdir/d$i ||
20648 error "mkdir d$i failed"
20649 $LFS getdirstripe $DIR/$tdir/d$i
20650 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
20651 [ $stripe_index -ne $max ] ||
20652 error "don't expect $max"
20655 run_test 413 "mkdir on less full MDTs"
20658 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
20659 $LCTL set_param fail_loc=0x80000521
20660 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
20663 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
20666 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20667 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
20668 skip "Need server version at least 2.11.52"
20678 # this test may be slow on ZFS
20679 [ "$mds1_FSTYPE" == "zfs" ] && total=100
20681 # though this test is designed for striped directory, let's test normal
20682 # directory too since lock is always saved as CoS lock.
20683 test_mkdir $DIR/$tdir || error "mkdir $tdir"
20684 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
20693 start_time=$(date +%s)
20694 for i in $(seq $total); do
20695 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
20698 end_time=$(date +%s)
20699 duration=$((end_time - start_time))
20701 kill -9 $setattr_pid
20703 echo "rename $total files took $duration sec"
20704 [ $duration -lt 100 ] || error "rename took $duration sec"
20706 run_test 415 "lock revoke is not missing"
20709 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
20710 skip "Need server version at least 2.11.55"
20712 # define OBD_FAIL_OSD_TXN_START 0x19a
20713 do_facet mds1 lctl set_param fail_loc=0x19a
20715 lfs mkdir -c $MDSCOUNT $DIR/$tdir
20719 run_test 416 "transaction start failure won't cause system hung"
20723 do_nodes $(comma_list $(mdts_nodes)) \
20724 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
20725 do_nodes $(comma_list $(mdts_nodes)) \
20726 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
20727 do_nodes $(comma_list $(mdts_nodes)) \
20728 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
20732 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20733 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
20734 skip "Need MDS version at least 2.11.56"
20736 trap cleanup_417 RETURN EXIT
20738 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
20739 do_nodes $(comma_list $(mdts_nodes)) \
20740 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
20741 $LFS migrate -m 0 $DIR/$tdir.1 &&
20742 error "migrate dir $tdir.1 should fail"
20744 do_nodes $(comma_list $(mdts_nodes)) \
20745 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
20746 $LFS mkdir -i 1 $DIR/$tdir.2 &&
20747 error "create remote dir $tdir.2 should fail"
20749 do_nodes $(comma_list $(mdts_nodes)) \
20750 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
20751 $LFS mkdir -c 2 $DIR/$tdir.3 &&
20752 error "create striped dir $tdir.3 should fail"
20755 run_test 417 "disable remote dir, striped dir and dir migration"
20757 # Checks that the outputs of df [-i] and lfs df [-i] match
20759 # usage: check_lfs_df <blocks | inodes> <mountpoint>
20769 [ "$1" == "blocks" ] && inodes= || inodes="-i"
20771 for count in {1..100}; do
20775 # read the lines of interest
20776 df_out=($(df -P $inodes $dir | tail -n +2)) ||
20777 error "df $inodes $dir | tail -n +2 failed"
20778 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
20779 error "lfs df $inodes $dir | grep summary: failed"
20781 # skip first substrings of each output as they are different
20782 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
20783 # compare the remaining fields of the two outputs
20785 for i in {1..5}; do
20786 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
20794 lfs df $inodes $dir
20795 error "df and lfs df $1 output mismatch: " \
20796 "df ${inodes}: ${df_out[*]}, " \
20797 "lfs df ${inodes}: ${lfs_df_out[*]}"
20802 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20804 local dir=$DIR/$tdir
20805 local numfiles=$((RANDOM % 4096 + 2))
20806 local numblocks=$((RANDOM % 256 + 1))
20808 wait_delete_completed
20811 # check block output
20812 check_lfs_df blocks $dir
20813 # check inode output
20814 check_lfs_df inodes $dir
20816 # create a single file and retest
20817 echo "Creating a single file and testing"
20818 createmany -o $dir/$tfile- 1 &>/dev/null ||
20819 error "creating 1 file in $dir failed"
20820 check_lfs_df blocks $dir
20821 check_lfs_df inodes $dir
20823 # create a random number of files
20824 echo "Creating $((numfiles - 1)) files and testing"
20825 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
20826 error "creating $((numfiles - 1)) files in $dir failed"
20828 # write a random number of blocks to the first test file
20829 echo "Writing $numblocks 4K blocks and testing"
20830 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
20831 count=$numblocks &>/dev/null ||
20832 error "dd to $dir/${tfile}-0 failed"
20835 check_lfs_df blocks $dir
20836 check_lfs_df inodes $dir
20838 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
20839 error "unlinking $numfiles files in $dir failed"
20841 run_test 418 "df and lfs df outputs match"
20845 local dir=$DIR/$tdir
20850 cancel_lru_locks mdc
20852 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
20853 $LCTL set_param fail_loc=0x1410
20855 $LCTL set_param fail_loc=0
20858 run_test 419 "Verify open file by name doesn't crash kernel"
20862 [[ $MDS1_VERSION -ge $(version_code 2.12.1) ]] ||
20863 skip "Need MDS version at least 2.12.1"
20865 local SAVE_UMASK=$(umask)
20866 local dir=$DIR/$tdir
20867 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
20871 mkdir -m03777 $dir/testdir
20872 ls -dn $dir/testdir
20873 # Need to remove trailing '.' when SELinux is enabled
20874 local dirperms=$(ls -dn $dir/testdir |
20875 awk '{ sub(/\.$/, "", $1); print $1}')
20876 [ $dirperms == "drwxrwsrwt" ] ||
20877 error "incorrect perms on $dir/testdir"
20879 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
20880 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
20881 ls -n $dir/testdir/testfile
20882 local fileperms=$(ls -n $dir/testdir/testfile |
20883 awk '{ sub(/\.$/, "", $1); print $1}')
20884 [ $fileperms == "-rwxr-xr-x" ] ||
20885 error "incorrect perms on $dir/testdir/testfile"
20889 run_test 420 "clear SGID bit on non-directories for non-members"
20896 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20897 skip "Need MDS version at least 2.12.2"
20899 test_mkdir $DIR/$tdir
20900 createmany -o $DIR/$tdir/f 3
20901 cnt=$(ls -1 $DIR/$tdir | wc -l)
20902 [ $cnt != 3 ] && error "unexpected #files: $cnt"
20904 fid1=$(lfs path2fid $DIR/$tdir/f1)
20905 fid2=$(lfs path2fid $DIR/$tdir/f2)
20906 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
20908 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
20909 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
20911 cnt=$(ls -1 $DIR/$tdir | wc -l)
20912 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
20914 rm -f $DIR/$tdir/f3 || error "can't remove f3"
20915 createmany -o $DIR/$tdir/f 3
20916 cnt=$(ls -1 $DIR/$tdir | wc -l)
20917 [ $cnt != 3 ] && error "unexpected #files: $cnt"
20919 fid1=$(lfs path2fid $DIR/$tdir/f1)
20920 fid2=$(lfs path2fid $DIR/$tdir/f2)
20921 echo "remove using fsname $FSNAME"
20922 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
20924 cnt=$(ls -1 $DIR/$tdir | wc -l)
20925 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
20927 run_test 421a "simple rm by fid"
20934 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20935 skip "Need MDS version at least 2.12.2"
20937 test_mkdir $DIR/$tdir
20938 createmany -o $DIR/$tdir/f 3
20939 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
20942 FID1=$(lfs path2fid $DIR/$tdir/f1)
20943 FID2=$(lfs path2fid $DIR/$tdir/f2)
20944 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
20946 kill -USR1 $MULTIPID
20949 cnt=$(ls $DIR/$tdir | wc -l)
20950 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
20952 run_test 421b "rm by fid on open file"
20958 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20959 skip "Need MDS version at least 2.12.2"
20961 test_mkdir $DIR/$tdir
20962 createmany -o $DIR/$tdir/f 3
20963 touch $DIR/$tdir/$tfile
20964 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
20965 cnt=$(ls -1 $DIR/$tdir | wc -l)
20966 [ $cnt != 184 ] && error "unexpected #files: $cnt"
20968 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
20969 $LFS rmfid $DIR $FID1 || error "rmfid failed"
20971 cnt=$(ls $DIR/$tdir | wc -l)
20972 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
20974 run_test 421c "rm by fid against hardlinked files"
20980 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20981 skip "Need MDS version at least 2.12.2"
20983 test_mkdir $DIR/$tdir
20984 createmany -o $DIR/$tdir/f 4097
20985 cnt=$(ls -1 $DIR/$tdir | wc -l)
20986 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
20988 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
20989 $LFS rmfid $DIR $FIDS || error "rmfid failed"
20991 cnt=$(ls $DIR/$tdir | wc -l)
20993 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
20995 run_test 421d "rmfid en masse"
21001 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21002 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21003 skip "Need MDS version at least 2.12.2"
21005 mkdir -p $DIR/$tdir
21006 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
21007 createmany -o $DIR/$tdir/striped_dir/f 512
21008 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21009 [ $cnt != 512 ] && error "unexpected #files: $cnt"
21011 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
21012 sed "s/[/][^:]*://g")
21013 $LFS rmfid $DIR $FIDS || error "rmfid failed"
21015 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21017 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21019 run_test 421e "rmfid in DNE"
21025 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21026 skip "Need MDS version at least 2.12.2"
21028 test_mkdir $DIR/$tdir
21030 cnt=$(ls -1 $DIR/$tdir | wc -l)
21031 [ $cnt != 1 ] && error "unexpected #files: $cnt"
21033 FID=$(lfs path2fid $DIR/$tdir/f)
21034 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
21035 # rmfid should fail
21036 cnt=$(ls -1 $DIR/$tdir | wc -l)
21037 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
21039 chmod a+rw $DIR/$tdir
21041 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
21042 # rmfid should fail
21043 cnt=$(ls -1 $DIR/$tdir | wc -l)
21044 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
21047 $RUNAS touch $DIR/$tdir/f
21048 FID=$(lfs path2fid $DIR/$tdir/f)
21049 echo "rmfid as root"
21050 $LFS rmfid $DIR $FID || error "rmfid as root failed"
21051 cnt=$(ls -1 $DIR/$tdir | wc -l)
21052 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
21055 $RUNAS touch $DIR/$tdir/f
21056 cnt=$(ls -1 $DIR/$tdir | wc -l)
21057 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
21058 FID=$(lfs path2fid $DIR/$tdir/f)
21059 # rmfid w/o user_fid2path mount option should fail
21060 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
21061 cnt=$(ls -1 $DIR/$tdir | wc -l)
21062 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
21064 umount_client $MOUNT || "failed to umount client"
21065 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
21066 "failed to mount client'"
21068 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
21069 # rmfid should succeed
21070 cnt=$(ls -1 $DIR/$tdir | wc -l)
21071 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
21073 # rmfid shouldn't allow to remove files due to dir's permission
21074 chmod a+rwx $DIR/$tdir
21077 FID=$(lfs path2fid $DIR/$tdir/f)
21078 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
21080 umount_client $MOUNT || "failed to umount client"
21081 mount_client $MOUNT "$MOUNT_OPTS" ||
21082 "failed to mount client'"
21085 run_test 421f "rmfid checks permissions"
21091 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21092 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
21093 skip "Need MDS version at least 2.12.2"
21095 mkdir -p $DIR/$tdir
21096 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
21097 createmany -o $DIR/$tdir/striped_dir/f 512
21098 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21099 [ $cnt != 512 ] && error "unexpected #files: $cnt"
21101 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
21102 sed "s/[/][^:]*://g")
21104 rm -f $DIR/$tdir/striped_dir/f1*
21105 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21106 removed=$((512 - cnt))
21108 # few files have been just removed, so we expect
21109 # rmfid to fail on their fids
21110 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
21111 [ $removed != $errors ] && error "$errors != $removed"
21113 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21115 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21117 run_test 421g "rmfid to return errors properly"
21130 # ensure statfs cache is expired
21133 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
21134 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
21138 run_test 423 "statfs should return a right data"
21141 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21142 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
21143 skip "Need server version at least 2.9.55"
21145 start_full_debug_logging
21149 stop_full_debug_logging
21153 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
21154 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
21155 awk '/The barrier for/ { print $7 }')
21158 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
21163 barrier_expired() {
21166 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
21167 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
21168 awk '/will be expired/ { print $7 }')
21170 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
21179 echo "Start barrier_freeze at: $(date)"
21180 #define OBD_FAIL_BARRIER_DELAY 0x2202
21181 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
21182 # Do not reduce barrier time - See LU-11873
21183 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
21186 local b_status=$(barrier_stat)
21187 echo "Got barrier status at: $(date)"
21188 [ "$b_status" = "'freezing_p1'" ] ||
21189 error "(1) unexpected barrier status $b_status"
21191 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
21193 b_status=$(barrier_stat)
21194 [ "$b_status" = "'frozen'" ] ||
21195 error "(2) unexpected barrier status $b_status"
21197 local expired=$(barrier_expired)
21198 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
21199 sleep $((expired + 3))
21201 b_status=$(barrier_stat)
21202 [ "$b_status" = "'expired'" ] ||
21203 error "(3) unexpected barrier status $b_status"
21205 # Do not reduce barrier time - See LU-11873
21206 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
21207 error "(4) fail to freeze barrier"
21209 b_status=$(barrier_stat)
21210 [ "$b_status" = "'frozen'" ] ||
21211 error "(5) unexpected barrier status $b_status"
21213 echo "Start barrier_thaw at: $(date)"
21214 #define OBD_FAIL_BARRIER_DELAY 0x2202
21215 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
21216 do_facet mgs $LCTL barrier_thaw $FSNAME &
21219 b_status=$(barrier_stat)
21220 echo "Got barrier status at: $(date)"
21221 [ "$b_status" = "'thawing'" ] ||
21222 error "(6) unexpected barrier status $b_status"
21224 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
21226 b_status=$(barrier_stat)
21227 [ "$b_status" = "'thawed'" ] ||
21228 error "(7) unexpected barrier status $b_status"
21230 #define OBD_FAIL_BARRIER_FAILURE 0x2203
21231 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
21232 do_facet mgs $LCTL barrier_freeze $FSNAME
21234 b_status=$(barrier_stat)
21235 [ "$b_status" = "'failed'" ] ||
21236 error "(8) unexpected barrier status $b_status"
21238 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21239 do_facet mgs $LCTL barrier_thaw $FSNAME
21243 run_test 801a "write barrier user interfaces and stat machine"
21248 mkdir $DIR/$tdir || error "(1) fail to mkdir"
21249 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
21250 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
21251 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
21252 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
21254 cancel_lru_locks mdc
21256 # 180 seconds should be long enough
21257 do_facet mgs $LCTL barrier_freeze $FSNAME 180
21259 local b_status=$(barrier_stat)
21260 [ "$b_status" = "'frozen'" ] ||
21261 error "(6) unexpected barrier status $b_status"
21263 mkdir $DIR/$tdir/d0/d10 &
21266 touch $DIR/$tdir/d1/f13 &
21269 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
21272 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
21275 rm -f $DIR/$tdir/d4/f12 &
21278 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
21280 # To guarantee taht the 'stat' is not blocked
21281 b_status=$(barrier_stat)
21282 [ "$b_status" = "'frozen'" ] ||
21283 error "(8) unexpected barrier status $b_status"
21285 # let above commands to run at background
21288 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
21289 ps -p $touch_pid || error "(10) touch should be blocked"
21290 ps -p $ln_pid || error "(11) link should be blocked"
21291 ps -p $mv_pid || error "(12) rename should be blocked"
21292 ps -p $rm_pid || error "(13) unlink should be blocked"
21294 b_status=$(barrier_stat)
21295 [ "$b_status" = "'frozen'" ] ||
21296 error "(14) unexpected barrier status $b_status"
21298 do_facet mgs $LCTL barrier_thaw $FSNAME
21299 b_status=$(barrier_stat)
21300 [ "$b_status" = "'thawed'" ] ||
21301 error "(15) unexpected barrier status $b_status"
21303 wait $mkdir_pid || error "(16) mkdir should succeed"
21304 wait $touch_pid || error "(17) touch should succeed"
21305 wait $ln_pid || error "(18) link should succeed"
21306 wait $mv_pid || error "(19) rename should succeed"
21307 wait $rm_pid || error "(20) unlink should succeed"
21311 run_test 801b "modification will be blocked by write barrier"
21314 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21318 stop mds2 || error "(1) Fail to stop mds2"
21320 do_facet mgs $LCTL barrier_freeze $FSNAME 30
21322 local b_status=$(barrier_stat)
21323 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
21324 do_facet mgs $LCTL barrier_thaw $FSNAME
21325 error "(2) unexpected barrier status $b_status"
21328 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21329 error "(3) Fail to rescan barrier bitmap"
21331 # Do not reduce barrier time - See LU-11873
21332 do_facet mgs $LCTL barrier_freeze $FSNAME 20
21334 b_status=$(barrier_stat)
21335 [ "$b_status" = "'frozen'" ] ||
21336 error "(4) unexpected barrier status $b_status"
21338 do_facet mgs $LCTL barrier_thaw $FSNAME
21339 b_status=$(barrier_stat)
21340 [ "$b_status" = "'thawed'" ] ||
21341 error "(5) unexpected barrier status $b_status"
21343 local devname=$(mdsdevname 2)
21345 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
21347 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21348 error "(7) Fail to rescan barrier bitmap"
21352 run_test 801c "rescan barrier bitmap"
21354 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
21355 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
21356 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
21357 saved_MOUNT_OPTS=$MOUNT_OPTS
21363 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
21364 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
21365 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
21366 MOUNT_OPTS=$saved_MOUNT_OPTS
21371 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
21372 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21373 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
21374 skip "Need server version at least 2.9.55"
21376 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
21378 mkdir $DIR/$tdir || error "(1) fail to mkdir"
21380 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
21381 error "(2) Fail to copy"
21383 trap cleanup_802 EXIT
21385 # sync by force before remount as readonly
21386 sync; sync_all_data; sleep 3; sync_all_data
21390 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
21391 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
21392 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
21394 echo "Mount the server as read only"
21395 setupall server_only || error "(3) Fail to start servers"
21397 echo "Mount client without ro should fail"
21398 mount_client $MOUNT &&
21399 error "(4) Mount client without 'ro' should fail"
21401 echo "Mount client with ro should succeed"
21402 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
21403 mount_client $MOUNT ||
21404 error "(5) Mount client with 'ro' should succeed"
21406 echo "Modify should be refused"
21407 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
21409 echo "Read should be allowed"
21410 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
21411 error "(7) Read should succeed under ro mode"
21415 run_test 802 "simulate readonly device"
21418 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21419 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21420 skip "MDS needs to be newer than 2.10.54"
21422 mkdir -p $DIR/$tdir
21423 # Create some objects on all MDTs to trigger related logs objects
21424 for idx in $(seq $MDSCOUNT); do
21425 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
21426 $DIR/$tdir/dir${idx} ||
21427 error "Fail to create $DIR/$tdir/dir${idx}"
21431 wait_delete_completed # ensure old test cleanups are finished
21432 echo "before create:"
21434 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21436 for i in {1..10}; do
21437 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
21438 error "Fail to create $DIR/$tdir/foo$i"
21442 echo "after create:"
21444 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21446 # allow for an llog to be cleaned up during the test
21447 [ $after_used -ge $((before_used + 10 - 1)) ] ||
21448 error "before ($before_used) + 10 > after ($after_used)"
21450 for i in {1..10}; do
21451 rm -rf $DIR/$tdir/foo$i ||
21452 error "Fail to remove $DIR/$tdir/foo$i"
21455 sleep 3 # avoid MDT return cached statfs
21456 wait_delete_completed
21457 echo "after unlink:"
21459 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21461 # allow for an llog to be created during the test
21462 [ $after_used -le $((before_used + 1)) ] ||
21463 error "after ($after_used) > before ($before_used) + 1"
21465 run_test 803a "verify agent object for remote object"
21468 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21469 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
21470 skip "MDS needs to be newer than 2.13.56"
21471 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21473 for i in $(seq 0 $((MDSCOUNT - 1))); do
21474 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
21482 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
21483 for i in $(seq 0 $((MDSCOUNT - 1))); do
21484 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
21485 awk '/getattr/ { print $2 }')
21486 before=$((before + tmp))
21488 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
21489 for i in $(seq 0 $((MDSCOUNT - 1))); do
21490 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
21491 awk '/getattr/ { print $2 }')
21492 after=$((after + tmp))
21495 [ $before -eq $after ] || error "getattr count $before != $after"
21497 run_test 803b "remote object can getattr from cache"
21500 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21501 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21502 skip "MDS needs to be newer than 2.10.54"
21503 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21505 mkdir -p $DIR/$tdir
21506 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
21507 error "Fail to create $DIR/$tdir/dir0"
21509 local fid=$($LFS path2fid $DIR/$tdir/dir0)
21510 local dev=$(mdsdevname 2)
21512 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21513 grep ${fid} || error "NOT found agent entry for dir0"
21515 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
21516 error "Fail to create $DIR/$tdir/dir1"
21518 touch $DIR/$tdir/dir1/foo0 ||
21519 error "Fail to create $DIR/$tdir/dir1/foo0"
21520 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
21523 for idx in $(seq $MDSCOUNT); do
21524 dev=$(mdsdevname $idx)
21525 do_facet mds${idx} \
21526 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21527 grep ${fid} && rc=$idx
21530 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
21531 error "Fail to rename foo0 to foo1"
21532 if [ $rc -eq 0 ]; then
21533 for idx in $(seq $MDSCOUNT); do
21534 dev=$(mdsdevname $idx)
21535 do_facet mds${idx} \
21536 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21537 grep ${fid} && rc=$idx
21541 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
21542 error "Fail to rename foo1 to foo2"
21543 if [ $rc -eq 0 ]; then
21544 for idx in $(seq $MDSCOUNT); do
21545 dev=$(mdsdevname $idx)
21546 do_facet mds${idx} \
21547 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21548 grep ${fid} && rc=$idx
21552 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
21554 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
21555 error "Fail to link to $DIR/$tdir/dir1/foo2"
21556 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
21557 error "Fail to rename foo2 to foo0"
21558 unlink $DIR/$tdir/dir1/foo0 ||
21559 error "Fail to unlink $DIR/$tdir/dir1/foo0"
21560 rm -rf $DIR/$tdir/dir0 ||
21561 error "Fail to rm $DIR/$tdir/dir0"
21563 for idx in $(seq $MDSCOUNT); do
21564 dev=$(mdsdevname $idx)
21568 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
21570 start mds${idx} $dev $MDS_MOUNT_OPTS ||
21571 error "mount mds$idx failed"
21572 df $MOUNT > /dev/null 2>&1
21574 # e2fsck should not return error
21576 error "e2fsck detected error on MDT${idx}: rc=$rc"
21579 run_test 804 "verify agent entry for remote entry"
21582 do_facet $SINGLEMDS zfs set quota=$old $fsset
21583 unlinkmany $DIR/$tdir/f- 1000000
21588 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
21589 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
21590 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
21591 skip "netfree not implemented before 0.7"
21592 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
21593 skip "Need MDS version at least 2.10.57"
21600 local pref="osd-zfs.lustre-MDT0000."
21602 # limit available space on MDS dataset to meet nospace issue
21603 # quickly. then ZFS 0.7.2 can use reserved space if asked
21604 # properly (using netfree flag in osd_declare_destroy()
21605 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
21606 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
21608 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
21609 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
21610 let "usedkb=usedkb-freekb"
21611 let "freekb=freekb/2"
21612 if let "freekb > 5000"; then
21615 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
21616 trap cleanup_805 EXIT
21618 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
21619 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
21620 rm -rf $DIR/$tdir || error "not able to remove"
21621 do_facet $SINGLEMDS zfs set quota=$old $fsset
21624 run_test 805 "ZFS can remove from full fs"
21630 local size=$($LFS getsom -s $file)
21631 local expect=$(stat -c %s $file)
21633 [[ $size == $expect ]] ||
21634 error "$file expected size: $expect, got: $size"
21636 local blocks=$($LFS getsom -b $file)
21637 expect=$(stat -c %b $file)
21638 [[ $blocks == $expect ]] ||
21639 error "$file expected blocks: $expect, got: $blocks"
21644 local size=$($LFS getsom -s $1)
21647 [[ $size == $expect ]] ||
21648 error "$file expected size: $expect, got: $size"
21652 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21653 skip "Need MDS version at least 2.11.52"
21657 touch $DIR/$tfile || error "touch $tfile failed"
21659 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21660 save_lustre_params client "llite.*.xattr_cache" > $save
21661 lctl set_param llite.*.xattr_cache=0
21662 stack_trap "restore_lustre_params < $save" EXIT
21664 # single-threaded write
21665 echo "Test SOM for single-threaded write"
21666 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
21667 error "write $tfile failed"
21668 check_lsom_size $DIR/$tfile $bs
21671 local size=$(($num * $bs))
21675 echo "Test SOM for single client multi-threaded($num) write"
21676 $TRUNCATE $DIR/$tfile 0
21677 for ((i = 0; i < $num; i++)); do
21678 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21680 offset=$((offset + $bs))
21682 for (( i=0; i < $num; i++ )); do
21685 check_lsom_size $DIR/$tfile $size
21687 $TRUNCATE $DIR/$tfile 0
21688 for ((i = 0; i < $num; i++)); do
21689 offset=$((offset - $bs))
21690 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21693 for (( i=0; i < $num; i++ )); do
21696 check_lsom_size $DIR/$tfile $size
21698 # multi-client writes
21699 num=$(get_node_count ${CLIENTS//,/ })
21700 size=$(($num * $bs))
21704 echo "Test SOM for multi-client ($num) writes"
21705 $TRUNCATE $DIR/$tfile 0
21706 for client in ${CLIENTS//,/ }; do
21707 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21710 offset=$((offset + $bs))
21712 for (( i=0; i < $num; i++ )); do
21715 check_lsom_size $DIR/$tfile $offset
21718 $TRUNCATE $DIR/$tfile 0
21719 for client in ${CLIENTS//,/ }; do
21720 offset=$((offset - $bs))
21721 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21725 for (( i=0; i < $num; i++ )); do
21728 check_lsom_size $DIR/$tfile $size
21731 echo "Test SOM for truncate"
21732 $TRUNCATE $DIR/$tfile 1048576
21733 check_lsom_size $DIR/$tfile 1048576
21734 $TRUNCATE $DIR/$tfile 1234
21735 check_lsom_size $DIR/$tfile 1234
21737 # verify SOM blocks count
21738 echo "Verify SOM block count"
21739 $TRUNCATE $DIR/$tfile 0
21740 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
21741 error "failed to write file $tfile"
21742 check_lsom_data $DIR/$tfile
21744 run_test 806 "Verify Lazy Size on MDS"
21747 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21748 skip "Need MDS version at least 2.11.52"
21750 # Registration step
21751 changelog_register || error "changelog_register failed"
21752 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
21753 changelog_users $SINGLEMDS | grep -q $cl_user ||
21754 error "User $cl_user not found in changelog_users"
21756 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21757 save_lustre_params client "llite.*.xattr_cache" > $save
21758 lctl set_param llite.*.xattr_cache=0
21759 stack_trap "restore_lustre_params < $save" EXIT
21761 rm -rf $DIR/$tdir || error "rm $tdir failed"
21762 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
21763 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
21764 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
21765 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
21766 error "truncate $tdir/trunc failed"
21769 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
21770 error "write $tfile failed"
21772 # multi-client wirtes
21773 local num=$(get_node_count ${CLIENTS//,/ })
21777 echo "Test SOM for multi-client ($num) writes"
21778 touch $DIR/$tfile || error "touch $tfile failed"
21779 $TRUNCATE $DIR/$tfile 0
21780 for client in ${CLIENTS//,/ }; do
21781 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21784 offset=$((offset + $bs))
21786 for (( i=0; i < $num; i++ )); do
21791 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
21792 check_lsom_data $DIR/$tdir/trunc
21793 check_lsom_data $DIR/$tdir/single_dd
21794 check_lsom_data $DIR/$tfile
21797 # Deregistration step
21798 changelog_deregister || error "changelog_deregister failed"
21800 run_test 807 "verify LSOM syncing tool"
21802 check_som_nologged()
21804 local lines=$($LFS changelog $FSNAME-MDT0000 |
21805 grep 'x=trusted.som' | wc -l)
21806 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
21810 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
21811 skip "Need MDS version at least 2.11.55"
21813 # Registration step
21814 changelog_register || error "changelog_register failed"
21816 touch $DIR/$tfile || error "touch $tfile failed"
21819 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
21820 error "write $tfile failed"
21823 $TRUNCATE $DIR/$tfile 1234
21826 $TRUNCATE $DIR/$tfile 1048576
21829 # Deregistration step
21830 changelog_deregister || error "changelog_deregister failed"
21832 run_test 808 "Check trusted.som xattr not logged in Changelogs"
21837 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
21841 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
21842 skip "Need MDS version at least 2.11.56"
21844 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
21845 error "failed to create DoM-only file $DIR/$tfile"
21846 touch $DIR/$tfile || error "touch $tfile failed"
21847 check_som_nodata $DIR/$tfile
21849 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
21850 error "write $tfile failed"
21851 check_som_nodata $DIR/$tfile
21853 $TRUNCATE $DIR/$tfile 1234
21854 check_som_nodata $DIR/$tfile
21856 $TRUNCATE $DIR/$tfile 4097
21857 check_som_nodata $DIR/$file
21859 run_test 809 "Verify no SOM xattr store for DoM-only files"
21862 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21863 $GSS && skip_env "could not run with gss"
21866 stack_trap "set_checksums $ORIG_CSUM" EXIT
21867 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
21872 for csum in $CKSUM_TYPES; do
21873 #define OBD_FAIL_OSC_NO_GRANT 0x411
21874 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
21875 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
21877 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
21878 before=$(md5sum $DIR/$tfile)
21879 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
21880 after=$(md5sum $DIR/$tfile)
21881 [ "$before" == "$after" ] ||
21882 error "$csum: $before != $after bs=$1 seek=$2"
21886 run_test 810 "partial page writes on ZFS (LU-11663)"
21889 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
21890 skip "OST < 2.12.51 doesn't support this fail_loc"
21891 [ "$SHARED_KEY" = true ] &&
21892 skip "OSC connections never go IDLE with Shared-Keys enabled"
21894 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21895 # ensure ost1 is connected
21896 stat $DIR/$tfile >/dev/null || error "can't stat"
21897 wait_osc_import_state client ost1 FULL
21898 # no locks, no reqs to let the connection idle
21899 cancel_lru_locks osc
21901 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
21902 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
21903 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
21904 wait_osc_import_state client ost1 CONNECTING
21905 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
21907 stat $DIR/$tfile >/dev/null || error "can't stat file"
21909 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
21913 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
21914 echo -n y >> $DIR/$tfile
21915 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
21916 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
21918 run_test 814 "sparse cp works as expected (LU-12361)"
21922 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
21923 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
21925 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
21928 local ost1_imp=$(get_osc_import_name client ost1)
21929 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
21932 [ "$SHARED_KEY" = true ] &&
21933 skip "OSC connections never go IDLE with Shared-Keys enabled"
21935 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21936 # ensure ost1 is connected
21937 stat $DIR/$tfile >/dev/null || error "can't stat"
21938 wait_osc_import_state client ost1 FULL
21939 # no locks, no reqs to let the connection idle
21940 cancel_lru_locks osc
21941 lru_resize_disable osc
21944 before=$($LCTL get_param -n \
21945 ldlm.namespaces.$imp_name.lru_size)
21947 wait_osc_import_state client ost1 IDLE
21948 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
21949 now=$($LCTL get_param -n \
21950 ldlm.namespaces.$imp_name.lru_size)
21951 [ $before == $now ] || error "lru_size changed $before != $now"
21953 run_test 816 "do not reset lru_resize on idle reconnect"
21957 exportfs -u localhost:$DIR/nfsexp
21962 systemctl restart nfs-server.service || skip "failed to restart nfsd"
21964 mkdir -p $DIR/nfsexp
21965 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
21966 error "failed to export nfs"
21968 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
21969 stack_trap cleanup_817 EXIT
21971 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
21972 error "failed to mount nfs to $tmpdir"
21974 cp /bin/true $tmpdir
21975 $DIR/nfsexp/true || error "failed to execute 'true' command"
21977 run_test 817 "nfsd won't cache write lock for exec file"
21980 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21981 cancel_lru_locks osc
21982 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
21983 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
21984 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
21987 run_test 819a "too big niobuf in read"
21990 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
21991 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
21992 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21993 cancel_lru_locks osc
21997 run_test 819b "too big niobuf in write"
22001 $LFS setstripe -c1 -i0 $DIR/$tfile
22002 $LFS setstripe -c1 -i1 $DIR/$tfile
22004 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
22005 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
22006 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
22007 error "start $SINGLEMDS failed"
22010 run_test 818 "unlink with failed llog"
22013 # tests that do cleanup/setup should be run at the end
22017 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22020 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
22021 $LCTL set_param fail_loc=0x903
22023 cancel_lru_locks MGC
22025 FAIL_ON_ERROR=true cleanup
22026 FAIL_ON_ERROR=true setup
22028 run_test 900 "umount should not race with any mgc requeue thread"
22032 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
22033 skip "client does not have LU-13377 fix"
22034 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
22035 $LCTL set_param fail_loc=0x1415
22036 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
22037 cancel_lru_locks osc
22040 run_test 902 "test short write doesn't hang lustre"
22043 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
22044 check_and_cleanup_lustre
22045 if [ "$I_MOUNTED" != "yes" ]; then
22046 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true